1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,790806,e=>{"use strict";var t=e.i(843476),a=e.i(522016),r=e.i(574520),s=e.i(928950),n=e.i(908032),l=e.i(231319),i=e.i(224928);let o={campaign:{icon:r.MegaphoneIcon,accent:"#6366F1",bg:"rgba(99,102,241,0.08)",border:"rgba(99,102,241,0.18)",label:"Campaign",href:e=>`/dashboard/user/campaign/${e}`},creator:{icon:s.UserCircleIcon,accent:"#A855F7",bg:"rgba(168,85,247,0.08)",border:"rgba(168,85,247,0.18)",label:"Creator",href:e=>`/dashboard/user/creator/${e}`},post:{icon:n.PhotoIcon,accent:"#10B981",bg:"rgba(16,185,129,0.08)",border:"rgba(16,185,129,0.18)",label:"Post",href:e=>`/dashboard/user/post/${e}`},organization:{icon:l.BuildingOffice2Icon,accent:"#0EA5E9",bg:"rgba(14,165,233,0.08)",border:"rgba(14,165,233,0.18)",label:"Organization",href:e=>`/dashboard/user/organization/${e}`},deal:{icon:i.BriefcaseIcon,accent:"#10B981",bg:"rgba(16,185,129,0.08)",border:"rgba(16,185,129,0.18)",label:"Deal",href:e=>`/dashboard/user/sales/deal/${e}`}};e.s(["default",0,function({type:e,entity:r,size:s="md",showLabel:n=!0,nonInteractive:l=!1}){if(!r)return null;let i=o[e];if(!i)return null;let d=r?"post"===e?r.campaign?.image||null:r.image||null:null,c=(r?"post"===e?r.campaign?.name||r.platform||"Post":r.name||r.handle||null:null)||i.label,u=r._id||r,x=i.icon,p="sm"===s?{avatar:18,text:"text-[10px]",padX:"px-1.5",padY:"py-0.5",gap:"gap-1"}:{avatar:22,text:"text-[11px]",padX:"px-2",padY:"py-1",gap:"gap-1.5"},m=`inline-flex items-center ${p.gap} ${p.padX} ${p.padY} rounded-full font-semibold transition-all duration-200 ${l?"":"hover:shadow-sm hover:-translate-y-0.5"} max-w-[200px]`,h={background:i.bg,border:`1px solid ${i.border}`,color:i.accent},g=`${i.label}: ${c}`,b=(0,t.jsxs)(t.Fragment,{children:[d?(0,t.jsx)("img",{src:d,alt:c,width:p.avatar,height:p.avatar,className:"rounded-full object-cover flex-shrink-0",style:{width:p.avatar,height:p.avatar,border:`1.5px solid ${i.border}`}}):(0,t.jsx)("div",{className:"rounded-full flex items-center justify-center flex-shrink-0",style:{width:p.avatar,height:p.avatar,background:i.bg,border:`1.5px solid ${i.border}`},children:(0,t.jsx)(x,{style:{color:i.accent,width:.55*p.avatar,height:.55*p.avatar}})}),n&&(0,t.jsx)("span",{className:`${p.text} truncate`,children:c})]});return l?(0,t.jsx)("span",{className:m,style:h,title:g,children:b}):(0,t.jsx)(a.default,{href:i.href(u),onClick:e=>e.stopPropagation(),className:m,style:h,title:g,children:b})}])},700109,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(217255),s=e.i(618566),n=e.i(865654),l=e.i(846932),i=e.i(88653),o=e.i(477183),d=e.i(76590),c=e.i(807311),u=e.i(247103),x=e.i(844735),p=e.i(578517),m=e.i(460759),h=e.i(370221),g=e.i(683512),b=e.i(107657),f=e.i(782611),y=e.i(803884),v=e.i(960590),k=e.i(790806),j=e.i(171387);let w=[.25,.46,.45,.94];function N(e){return e?"string"==typeof e?e:e._id?.toString?.()||e.toString?.()||null:null}function C({kind:e,ownBoardId:r,rawIds:s=[],linkedTasks:n=[]}){let o,[d,c]=(0,a.useState)(!1),[u,x]=(0,a.useState)(null),[p,m]=(0,a.useState)(!1),h=(0,a.useRef)(null),g=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(d)return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)};function e(e){h.current&&!h.current.contains(e.target)&&c(!1)}function t(e){"Escape"===e.key&&c(!1)}},[d]);let b="linked"===e?n.filter(e=>{let t=N(e.board)||N(e.task?.board);return t&&r&&t!==r}):null,f="linked"===e?n.length:s.length,y=b?b.length:null,v=u?u.filter(e=>N(e.board?._id||e.board)!==r):null,k="blocks"===e&&null!==v&&0===v.length,S="blockedBy"===e&&null!==v&&0===v.length,z="blocks"===e&&v&&v.length>0?1===(o=[...new Set(v.map(e=>e.board?.name).filter(Boolean))]).length?o[0]:"multiple":null,_="linked"===e?y:null!==v?v.length:f,D="linked"===e?{bg:"rgba(99,102,241,0.10)",color:"#4F46E5",border:"rgba(99,102,241,0.25)"}:{bg:"rgba(239,68,68,0.10)",color:"#DC2626",border:"rgba(239,68,68,0.25)"};async function I(){if("linked"===e)return void x(b.map(e=>({_id:N(e.task?._id||e.task),title:e.task?.title||"(untitled)",status:e.task?.status,statusColor:e.task?.statusColor,board:{_id:N(e.board?._id||e.board),name:"object"==typeof e.board?e.board?.name:null}})));if(s.length){m(!0);try{let e=await Promise.all(s.slice(0,10).map(async e=>{let t=N(e);if(!t)return null;try{let e=await fetch(`/api/tasks/${t}`);if(!e.ok)return null;return(await e.json()).task||null}catch{return null}}));x(e.filter(Boolean))}catch{x([])}finally{m(!1)}}}let E=u?u.filter(e=>{let t=N(e.board?._id||e.board);return!t||!r||t!==r}):null;return 0===f||"linked"===e&&0===y||k||S?null:(0,t.jsxs)("div",{ref:h,className:"relative inline-flex",onMouseEnter:function(){g.current=setTimeout(()=>void(c(!0),null===u&&I()),150)},onMouseLeave:function(){clearTimeout(g.current),c(!1)},children:[(0,t.jsx)("span",{className:"inline-flex items-center gap-0.5 pl-1.5 pr-1 py-0.5 rounded-md text-[11px] font-semibold flex-shrink-0 select-none cursor-default",style:{background:D.bg,color:D.color,border:`1px solid ${D.border}`},title:"linked"===e?"Linked tasks on other boards":"blocks"===e?"This task blocks tasks on other boards":"This task is blocked by tasks on other boards",children:"linked"===e?`â ${_}`:"blocks"===e?v&&z?`â ${v.length} â ${z}`:`â ${_}`:"blockedBy"===e?`â blocked by ${_}`:""}),(0,t.jsx)(i.AnimatePresence,{children:d&&(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:-4,scale:.98}
1,animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.15,ease:w},className:"absolute z-50 left-0 top-full mt-1.5 w-[280px] rounded-xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",border:"1px solid var(--border-default)",boxShadow:"0 18px 42px var(--shadow-ambient-xl), 0 4px 12px var(--shadow-ambient)"},onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"h-[2px]",style:{background:"linked"===e?"linear-gradient(to right, #6366F1, #EC4899)":"linear-gradient(to right, #EF4444, #F97316)"}}),(0,t.jsxs)("div",{className:"p-2.5",children:[(0,t.jsxs)("div",{className:"text-[10px] font-bold uppercase tracking-[0.12em] mb-2",style:{color:"var(--text-label)"},children:["linked"===e&&"Linked on other boards","blocks"===e&&"Blocks on other boards","blockedBy"===e&&"Blocked by on other boards"]}),(p||!p&&null===u)&&(0,t.jsx)("div",{className:"flex items-center justify-center py-3",children:(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-indigo-300 dark:border-indigo-700 border-t-indigo-500 rounded-full animate-spin"})}),!p&&E&&0===E.length&&(0,t.jsx)("p",{className:"text-[11px] py-2 text-center",style:{color:"var(--text-tertiary)"},children:"No cross-board refs found"}),!p&&E&&E.length>0&&(0,t.jsx)("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:E.map(e=>{let a=N(e.board?._id||e.board),r=e.board?.name,s=N(e._id),n=`/dashboard/user/tasks?${a?`board=${a}&`:""}taskId=${s}`,l=function(e){let t=[{bg:"rgba(99,102,241,0.10)",color:"#4F46E5",border:"rgba(99,102,241,0.25)"},{bg:"rgba(236,72,153,0.10)",color:"#BE185D",border:"rgba(236,72,153,0.25)"},{bg:"rgba(16,185,129,0.10)",color:"#047857",border:"rgba(16,185,129,0.25)"},{bg:"rgba(245,158,11,0.10)",color:"#B45309",border:"rgba(245,158,11,0.25)"},{bg:"rgba(14,165,233,0.10)",color:"#0369A1",border:"rgba(14,165,233,0.25)"}],a=String(e||"?"),r=0;for(let e=0;e<a.length;
1e+=1)r=31*r+a.charCodeAt(e)|0;return t[Math.abs(r)%t.length]}(a);return(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("span",{className:"inline-block w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:e.statusColor||"#c4c4c4"}}),(0,t.jsx)("span",{className:"flex-1 min-w-0 text-[12px] font-medium truncate",style:{color:"var(--text-secondary)"},children:e.title||"(untitled)"}),e.status&&(0,t.jsx)("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded flex-shrink-0",style:{background:e.statusColor?`${e.statusColor}20`:"var(--surface-softer)",color:e.statusColor||"var(--text-tertiary)",border:`1px solid ${e.statusColor?`${e.statusColor}35`:"var(--border-subtle)"}`},children:e.status}),r&&(0,t.jsx)("span",{className:"text-[9px] uppercase tracking-wider px-1 py-0.5 rounded flex-shrink-0",style:{background:l.bg,color:l.color,border:`1px solid ${l.border}`},children:r}),(0,t.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),className:"flex-shrink-0 w-5 h-5 rounded flex items-center justify-center transition-colors hover:bg-gray-100 dark:hover:bg-zinc-800",title:"Jump to this task",style:{color:"var(--text-tertiary)"},children:(0,t.jsx)(j.ArrowTopRightOnSquareIcon,{className:"w-3 h-3"})})]},s||String(Math.random()))})})]})]})})]})}function S({task:e,ownBoardId:a}){let r=e.linkedTasks||[],s=e.blocks||[],n=e.blockedBy||[];return r.length||s.length||n.length?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C,{kind:"linked",ownBoardId:a,linkedTasks:r}),(0,t.jsx)(C,{kind:"blocks",ownBoardId:a,rawIds:s}),(0,t.jsx)(C,{kind:"blockedBy",ownBoardId:a,rawIds:n})]}):null}var z={};!function e(t,a,r,s){var n,l,i,o,d,c,u,x,p,m,h,g=!!(t.Worker&&t.Blob&&t.Promise&&t.OffscreenCanvas&&t.OffscreenCanvasRenderingContext2D&&t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype.transferControlToOffscreen&&t.URL&&t.URL.createObjectURL),b="function"==typeof Path2D&&"function"==typeof DOMMatrix;function f(){}function y(e){var r=a.exports.Promise,s=void 0!==r?r:t.Promise;return"function"==typeof s?new s(e):(e(f,f),null)}var v=(n=function(){if(!t.OffscreenCanvas)return!1;try{var e=new OffscreenCanvas(1,1),a=e.getContext("2d");a.fillRect(0,0,1,1);var r=e.transferToImageBitmap();a.createPattern(r,"no-repeat")}catch(e){return!1}return!0}(),l=new Map,{transform:function(e){if(n)return e;if(l.has(e))return l.get(e);var t=new OffscreenCanvas(e.width,e.height);return t.getContext("2d").drawImage(e,0,0),l.set(e,t),t},clear:function(){l.clear()}}),k=(d=Math.floor(1e3/60),c={},u=0,"function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame?(i=function(e){var t=Math.random();return c[t]=requestAnimationFrame(function a(r){u===r||u+d-1<r?(u=r,delete c[t],e()):c[t]=requestAnimationFrame(a)}),t},o=function(e){c[e]&&cancelAnimationFrame(c[e])}):(i=function(e){return setTimeout(e,d)},o=function(e){return clearTimeout(e)}),{frame:i,cancel:o}),j=(m={},function(){if(x)return x;if(!r&&g){var t=["var CONFETTI, SIZE = {}, module = {};","("+e.toString()+")(this, module, true, SIZE);","onmessage = function(msg) {\n if (msg.data.options) {\n CONFETTI(msg.data.options).then(function () {\n if (msg.data.callback) {\n postMessage({ callback: msg.data.callback });\n }\n });\n } else if (msg.data.reset) {\n CONFETTI && CONFETTI.reset();\n } else if (msg.data.resize) {\n SIZE.width = msg.data.resize.width;\n SIZE.height = msg.data.resize.height;\n } else if (msg.data.canvas) {\n SIZE.width = msg.data.canvas.width;\n SIZE.height = msg.data.canvas.height;\n CONFETTI = module.exports.create(msg.data.canvas);\n }\n}"].join("\n");try{x=new Worker(URL.createObjectURL(new Blob([t])))}catch(e){return"u">typeof console&&"function"==typeof console.warn&&console.warn("ð Could not load worker",e),null}var a=x;function s(e,t){a.postMessage({options:e||{},callback:t})}a.init=function(e){var t=e.transferControlToOffscreen();a.postMessage({canvas:t},[t])},a.fire=function(e,t,r){if(p)return s(e,null),p;var n=Math.random().toString(36).slice(2);return p=y(function(t){function l(e){e.data.callback===n&&(delete m[n],a.removeEventListener("message",l),p=null,v.clear(),r(),t())}a.addEventListener("message",l),s(e,n),m[n]=l.bind(null,{data:{callback:n}})})},a.reset=function(){for(var e in a.postMessage({reset:!0}),m)m[e](),delete m[e]}}return x}),w={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:["square","circle"],zIndex:100,colors:["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"],disableForReducedMotion:!1,scalar:1};function N(e,t,a){var r;return r=e&&null!=e[t]?e[t]:w[t],a?a(r):r}function C(e){return e<0?0:Math.floor(e)}function S(e){return parseInt(e,16)}function z(e){return e.map(_)}function _(e){var t=String(e).replace(/[^0-9a-f]/gi,"");return t.length<6&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),{r:S(t.substring(0,2)),g:S(t.substring(2,4)),b:S(t.substring(4,6))}}function D(e){e.width=document.documentElement.clientWidth,e.height=document.documentElement.clientHeight}function I(e){var t=e.getBoundingClientRect();e.width=t.width,e.height=t.height}function E(e,a){var n,l=!e,i=!!N(a||{},"resize"),o=!1,d=N(a,"disableForReducedMotion",Boolean),c=g&&N(a||{},"useWorker")?j():null,u=l?D:I,x=!!e&&!!c&&!!e.__confetti_initialized,p="function"==typeof matchMedia&&matchMedia("(prefers-reduced-motion)").matches;function m(a){var m,h=d||N(a,"disableForReducedMotion",Boolean),g=N(a,"zIndex",Number);if(h&&p)return y(function(e){e()});l&&n?e=n.canvas:l&&!e&&((m=document.createElement("canvas")).style.position="fixed",m.style.top="0px",m.style.left="0px",m.style.pointerEvents="none",m.style.zIndex=g,e=m,document.body.appendChild(e)),i&&!x&&u(e);var f={width:e.width,height:e.height};function j(){if(c){var t={getBoundingClientRect:function(){if(!l)return e.getBoundingClientRect()}};u(t),c.postMessage({resize:{width:t.width,height:t.height}});return}f.width=f.height=null}function w(){n=null,i&&(o=!1,t.removeEventListener("resize",j)),l&&e&&(document.body.contains(e)&&document.body.removeChild(e),e=null,x=!1)}return(c&&!x&&c.init(e),x=!0,c&&(e.__confetti_initialized=!0),i&&!o&&(o=!0,t.addEventListener("resize",j,!1)),c)?c.fire(a,f,w
1):function(t,a,l){for(var i,o,d,c,x,p,m,h=N(t,"particleCount",C),g=N(t,"angle",Number),f=N(t,"spread",Number),j=N(t,"startVelocity",Number),w=N(t,"decay",Number),S=N(t,"gravity",Number),_=N(t,"drift",Number),D=N(t,"colors",z),I=N(t,"ticks",Number),E=N(t,"shapes"),$=N(t,"scalar"),T=!!N(t,"flat"),F=((i=N(t,"origin",Object)).x=N(i,"x",Number),i.y=N(i,"y",Number),i),M=h,A=[],L=e.width*F.x,P=e.height*F.y;M--;)A.push(function(e){var t=e.angle*(Math.PI/180),a=e.spread*(Math.PI/180);return{x:e.x,y:e.y,wobble:10*Math.random(),wobbleSpeed:Math.min(.11,.1*Math.random()+.05),velocity:.5*e.startVelocity+Math.random()*e.startVelocity,angle2D:-t+(.5*a-Math.random()*a),tiltAngle:(.5*Math.random()+.25)*Math.PI,color:e.color,shape:e.shape,tick:0,totalTicks:e.ticks,decay:e.decay,drift:e.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:3*e.gravity,ovalScalar:.6,scalar:e.scalar,flat:e.flat}}({x:L,y:P,angle:g,spread:f,startVelocity:j,color:D[M%D.length],shape:E[Math.floor(Math.random()*(E.length-0))+0],ticks:I,decay:w,gravity:S,drift:_,scalar:$,flat:T}));return n?n.addFettis(A):(o=e,x=A.slice(),p=o.getContext("2d"),m=y(function(e){function t(){d=c=null,p.clearRect(0,0,a.width,a.height),v.clear(),l(),e()}d=k.frame(function e(){r&&(a.width!==s.width||a.height!==s.height)&&(a.width=o.width=s.width,a.height=o.height=s.height),a.width||a.height||(u(o),a.width=o.width,a.height=o.height),p.clearRect(0,0,a.width,a.height),(x=x.filter(function(e){return function(e,t){t.x+=Math.cos(t.angle2D)*t.velocity+t.drift,t.y+=Math.sin(t.angle2D)*t.velocity+t.gravity,t.velocity*=t.decay,t.flat?(t.wobble=0,t.wobbleX=t.x+10*t.scalar,t.wobbleY=t.y+10*t.scalar,t.tiltSin=0,t.tiltCos=0,t.random=1):(t.wobble+=t.wobbleSpeed,t.wobbleX=t.x+10*t.scalar*Math.cos(t.wobble),t.wobbleY=t.y+10*t.scalar*Math.sin(t.wobble),t.tiltAngle+=.1,t.tiltSin=Math.sin(t.tiltAngle),t.tiltCos=Math.cos(t.tiltAngle),t.random=Math.random()+2);var a,r,s,n,l,i,o,d,c,u,x,p,m,h,g,f,y=t.tick++/t.totalTicks,k=t.x+t.random*t.tiltCos,j=t.y+t.random*t.tiltSin,w=t.wobbleX+t.random*t.tiltCos,N=t.wobbleY+t.random*t.tiltSin;if(e.fillStyle="rgba("+t.color.r+", "+t.color.g+", "+t.color.b+", "+(1-y)+")",e.beginPath(),b&&"path"===t.shape.type&&"string"==typeof t.shape.path&&Array.isArray(t.shape.matrix)){e.fill((a=t.shape.path,r=t.shape.matrix,s=t.x,n=t.y,l=.1*Math.abs(w-k),i=.1*Math.abs(N-j),o=Math.PI/10*t.wobble,d=new Path2D(a),(c=new Path2D).addPath(d,new DOMMatrix(r)),(u=new Path2D).addPath(c,new DOMMatrix([Math.cos(o)*l,Math.sin(o)*l,-Math.sin(o)*i,Math.cos(o)*i,s,n])),u))}else if("bitmap"===t.shape.type){var C=Math.PI/10*t.wobble,S=.1*Math.abs(w-k),z=.1*Math.abs(N-j),_=t.shape.bitmap.width*t.scalar,D=t.shape.bitmap.height*t.scalar,I=new DOMMatrix([Math.cos(C)*S,Math.sin(C)*S,-Math.sin(C)*z,Math.cos(C)*z,t.x,t.y]);I.multiplySelf(new DOMMatrix(t.shape.matrix));var E=e.createPattern(v.transform(t.shape.bitmap),"no-repeat");E.setTransform(I),e.globalAlpha=1-y,e.fillStyle=E,e.fillRect(t.x-_/2,t.y-D/2,_,D),e.globalAlpha=1}else if("circle"===t.shape)e.ellipse?e.ellipse(t.x,t.y,Math.abs(w-k)*t.ovalScalar,Math.abs(N-j)*t.ovalScalar,Math.PI/10*t.wobble,0,2*Math.PI):(x=t.x,p=t.y,m=Math.abs(w-k)*t.ovalScalar,h=Math.abs(N-j)*t.ovalScalar,g=Math.PI/10*t.wobble,f=2*Math.PI,e.save(),e.translate(x,p),e.rotate(g),e.scale(m,h),e.arc(0,0,1,0,f,void 0),e.restore());else if("star"===t.shape)for(var $=Math.PI/2*3,T=4*t.scalar,F=8*t.scalar,M=t.x,A=t.y,L=5,P=Math.PI/5;L--;)M=t.x+Math.cos($)*F,A=t.y+Math.sin($)*F,e.lineTo(M,A),$+=P,M=t.x+Math.cos($)*T,A=t.y+Math.sin($)*T,e.lineTo(M,A),$+=P;else e.moveTo(Math.floor(t.x),Math.floor(t.y)),e.lineTo(Math.floor(t.wobbleX),Math.floor(j)),e.lineTo(Math.floor(w),Math.floor(N)),e.lineTo(Math.floor(k),Math.floor(t.wobbleY));return e.closePath(),e.fill(),t.tick<t.totalTicks}(p,e)})).length?d=k.frame(e):t()}),c=t}),(n={addFettis:function(e){return x=x.concat(e),m},canvas:o,promise:m,reset:function(){d&&k.cancel(d),c&&c()}}).promise)}(a,f,w)}return m.reset=function(){c&&c.reset(),n&&n.reset()},m}function $(){return h||(h=E(null,{useWorker:!0,resize:!0})),h}a.exports=function(){return $().apply(this,arguments)},a.exports.reset=function(){$().reset()},a.exports.create=E,a.exports.shapeFromPath=function(e){if(!b)throw Error("path confetti are not supported in this browser");"string"==typeof e?r=e:(r=e.path,s=e.matrix);var t=new Path2D(r),a=document.createElement("canvas").getContext("2d");if(!s){for(var r,s,n,l,i=1e3,o=1e3,d=0,c=0,u=0;u<1e3;u+=2)for(var x=0;x<1e3;x+=2)a.isPointInPath(t,u,x,"nonzero")&&(i=Math.min(i,u),o=Math.min(o,x),d=Math.max(d,u),c=Math.max(c,x));n=d-i;
1var p=Math.min(10/n,10/(l=c-o));s=[p,0,0,p,-Math.round(n/2+i)*p,-Math.round(l/2+o)*p]}return{type:"path",path:r,matrix:s}},a.exports.shapeFromText=function(e){var t,a=1,r="#000000",s='"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';"string"==typeof e?t=e:(t=e.text,a="scalar"in e?e.scalar:a,s="fontFamily"in e?e.fontFamily:s,r="color"in e?e.color:r);var n=10*a,l=""+n+"px "+s,i=new OffscreenCanvas(n,n),o=i.getContext("2d");o.font=l;var d=o.measureText(t),c=Math.ceil(d.actualBoundingBoxRight+d.actualBoundingBoxLeft),u=Math.ceil(d.actualBoundingBoxAscent+d.actualBoundingBoxDescent),x=d.actualBoundingBoxLeft+2,p=d.actualBoundingBoxAscent+2;c+=4,u+=4,(o=(i=new OffscreenCanvas(c,u)).getContext("2d")).font=l,o.fillStyle=r,o.fillText(t,x,p);var m=1/a;return{type:"bitmap",bitmap:i.transferToImageBitmap(),matrix:[m,0,0,m,-c*m/2,-u*m/2]}}}(function(){return"u">typeof window?window:"u">typeof self?self:this||{}}(),z,!1);let _=z.exports;z.exports.create;let D=["low","medium","high","critical"];function I({task:e,columns:r,onUpdate:s,onClick:n,onArchive:o,onDelete:d,onRequestDelete:c,onToggleSubItems:j,isSubItemsExpanded:w,teamMembers:N,statusOptions:C,groupColor:z="#6366F1",index:E=0,context:$="global",dueDateMode:T="single",taskColumnWidth:F=680}){var M;let A="Done"===e.status||"Complete"===e.status,L="critical"===e.priority;e.priority;let P=(0,a.useRef)(A),B=(0,a.useRef)(null),[R,O]=(0,a.useState)(!1),U="campaign"!==$&&!!e.linkedCampaign,W="creator"!==$&&!!e.linkedCreator,q="post"!==$&&!!e.linkedPost,X="organization"!==$&&!!e.organization,G="deal"!==$&&!!e.parentDeal,H=U||W||q||X||G,K=(M=e.statusHistory?.length?e.statusHistory[e.statusHistory.length-1].changedAt:e.updatedAt)?Math.floor(Math.floor((Date.now()-new Date(M).getTime())/1e3)/86400):null,J=!A&&"To Do"!==e.status&&null!==K&&K>=3,V=e.subItems?.length||0,Y=e.subItems?.filter(e=>e.completed).length||0;(0,a.useEffect)(()=>{if(A&&!P.current&&B.current){let e=B.current.getBoundingClientRect();_({particleCount:36,spread:60,startVelocity:25,ticks:70,origin:{x:(e.left+60)/window.innerWidth,y:(e.top+e.height/2)/window.innerHeight},colors:["#10B981","#34D399","#F59E0B","#EC4899"],scalar:.8})}P.current=A},[A]),(0,a.useEffect)(()=>{if(R)return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t);function t(t){let a=(t.target.tagName||"").toLowerCase();if("input"!==a&&"textarea"!==a&&!t.target.isContentEditable&&!t.metaKey&&!t.ctrlKey&&!t.altKey)if("s"===t.key||"S"===t.key){t.preventDefault();let a=C||[];if(0===a.length)return;let r=a.findIndex(t=>t.label===e.status),n=a[(r+1)%a.length];s(e._id,{status:n.label,statusColor:n.color})}else if("p"===t.key||"P"===t.key){t.preventDefault();let a=D.indexOf(e.priority),r=D[(a+1)%D.length];s(e._id,{priority:r})}else"Delete"===t.key||"Backspace"===t.key?t.shiftKey&&(t.preventDefault(),c?.(e)):("e"===t.key||"E"===t.key)&&(t.preventDefault(),o?.(e._id,!e.archived))}},[R,e,C,s,c,o]);let Z=L&&!A?{boxShadow:"inset 3px 0 0 #EF4444, 0 0 0 1px rgba(239,68,68,0.08)"}:{};return(0,t.jsxs)(l.motion.div,{ref:B,layout:!0,layoutId:`task-${e._id}`,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{layout:{type:"spring",stiffness:380,damping:32},delay:.03*E,duration:.3,ease:[.25,.46,.45,.94]},onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),className:`relative flex items-center border-b group ${A?"opacity-50":""} ${e.archived?"opacity-40 saturate-50":""}`,style:{borderColor:"var(--surface-softer)",background:"transparent",...Z},whileHover:{backgroundColor:`${z}06`},children:[!L&&(0,t.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:z}}),L&&!A&&(0,t.jsx)(l.motion.div,{className:"absolute left-0 top-0 bottom-0 w-[3px] pointer-events-none",style:{background:"#EF4444"},animate:{opacity:[.5,1,.5]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}}),(0,t.jsx)("div",{className:"flex-shrink-0",style:{width:F,minWidth:F},children:(0,t.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>n(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),n(e))},className:"w-full text-left px-5 py-3 flex flex-col gap-1.5 group/title cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-orange-300/50 rounded",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),j?.(e._id)},className:`flex-shrink-0 w-4 h-4 flex items-center justify-center rounded transition-all duration-150 hover:bg-gray-100 dark:hover:bg-zinc-900 ${0===V&&!w?"opacity-0 group-hover/title:opacity-100":""}`,title:V>0?`${Y}/${V} sub-tasks`:"Add sub-tasks",children:w?(0,t.jsx)(x.ChevronDownIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"}):(0,t.jsx)(u.ChevronRightIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"})}),(0,t.jsx)("div",{className:`w-[18px] h-[18px] rounded-full border-2 flex-shrink-0 flex items-center justify-center transition-all duration-300 ${A?"border-emerald-500 bg-emerald-500 shadow-sm":"border-gray-300/60 dark:border-zinc-700/60 group-hover/title:border-gray-400/80"}`,style:A?{boxShadow:"0 0 8px rgba(16,185,129,0.3)"}:{},children:A&&(0,t.jsx)(l.motion.svg,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:500,damping:20}
1,className:"w-2.5 h-2.5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}),(0,t.jsx)("span",{className:`text-[13px] font-medium text-gray-800 dark:text-zinc-100 truncate transition-colors duration-200 group-hover/title:text-gray-950 dark:group-hover/title:text-white ${A?"line-through text-gray-400 dark:text-zinc-500":""}`,children:e.title}),e.isPrivate&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-bold flex-shrink-0 tracking-wide",style:{background:"rgba(99,102,241,0.1)",color:"#6366F1",border:"1px solid rgba(99,102,241,0.25)"},title:"Private â visible only to you and explicit assignees",children:[(0,t.jsx)(b.LockClosedIcon,{className:"w-2.5 h-2.5"}),"Private"]}),V>0&&(0,t.jsxs)("span",{className:"text-[9px] font-bold px-2 py-0.5 rounded-full flex-shrink-0 tracking-wide",style:{background:`${z}12`,color:z,border:`1px solid ${z}20`},children:[Y,"/",V]}),e.comments?.length>0&&(0,t.jsxs)("span",{className:"flex items-center gap-0.5 flex-shrink-0 text-gray-400 dark:text-zinc-500",children:[(0,t.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),(0,t.jsx)("span",{className:"text-[10px] font-semibold",children:e.comments.length})]}),e.media?.length>0&&(0,t.jsxs)("span",{className:"flex items-center gap-0.5 flex-shrink-0 text-gray-400 dark:text-zinc-500",title:`${e.media.length} attachment${1===e.media.length?"":"s"}`,children:[(0,t.jsx)(f.PaperClipIcon,{className:"w-3 h-3"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold",children:e.media.length})]}),e.links?.length>0&&(0,t.jsxs)("span",{className:"flex items-center gap-0.5 flex-shrink-0 text-gray-400 dark:text-zinc-500",title:`${e.links.length} link${1===e.links.length?"":"s"}`,children:[(0,t.jsx)(y.LinkIcon,{className:"w-3 h-3"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold",children:e.links.length})]}),(e.collaborators?.length||0)+(e.externalCollaborators?.length||0)>0&&(0,t.jsxs)("span",{className:"flex items-center gap-0.5 flex-shrink-0 px-1.5 py-0.5 rounded-md text-[9px] font-bold tracking-wide",style:{background:"rgba(14,165,233,0.08)",color:"#0EA5E9",border:"1px solid rgba(14,165,233,0.18)"},title:`${(e.collaborators?.length||0)+(e.externalCollaborators?.length||0)} collaborator(s) watching`,children:[(0,t.jsx)(g.EyeIcon,{className:"w-2.5 h-2.5"}),(e.collaborators?.length||0)+(e.externalCollaborators?.length||0)]}),J&&(0,t.jsxs)("span",{className:"flex items-center gap-0.5 flex-shrink-0 px-1.5 py-0.5 rounded-md text-[9px] font-bold tracking-wide",style:{background:"rgba(239,68,68,0.08)",color:"#DC2626",border:"1px solid rgba(239,68,68,0.18)"},title:`No status change for ${K} days`,children:[(0,t.jsx)(h.ClockIcon,{className:"w-2.5 h-2.5"}),K,"d"]}),(0,t.jsx)(S,{task:e,ownBoardId:"object"==typeof e.board?e.board?._id?.toString?.():e.board?.toString?.()})]}),H&&(0,t.jsxs)("div",{className:"flex items-center gap-1 pl-7 flex-wrap",children:[U&&(0,t.jsx)(k.default,{type:"campaign",entity:e.linkedCampaign,size:"sm"}),W&&(0,t.jsx)(k.default,{type:"creator",entity:e.linkedCreator,size:"sm"}),X&&(0,t.jsx)(k.default,{type:"organization",entity:e.organization,size:"sm"}),q&&(0,t.jsx)(k.default,{type:"post",entity:e.linkedPost,size:"sm"}),G&&(0,t.jsx)(k.default,{type:"deal",entity:e.parentDeal,size:"sm"})]})]})}),r.map(a=>(0,t.jsx)("div",{className:"flex-shrink-0 px-1 border-l",style:{width:a.width||150,borderColor:"var(--surface-softer)"},children:(0,t.jsx)(v.default,{column:a,task:e,onUpdate:t=>s(e._id,t),teamMembers:N,statusOptions:C,dueDateMode:T})},a._id||a.key)),(0,t.jsx)(i.AnimatePresence,{children:R&&(0,t.jsxs)(l.motion.div,{initial:{opacity:0,x:4}
1,animate:{opacity:1,x:0},exit:{opacity:0,x:4},transition:{duration:.12},className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 z-10",children:[(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),o?.(e._id,!e.archived)},className:"w-7 h-7 flex items-center justify-center rounded-lg transition-all duration-150",style:{background:"var(--surface-panel)",border:"1px solid var(--border-default)",boxShadow:"0 2px 6px var(--border-subtle)"},title:e.archived?"Restore (E)":"Archive (E)",children:(0,t.jsx)(p.ArchiveBoxIcon,{className:"w-3.5 h-3.5 text-gray-500 dark:text-zinc-400 hover:text-amber-600"})}),(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),c?.(e)},className:"w-7 h-7 flex items-center justify-center rounded-lg transition-all duration-150",style:{background:"var(--surface-panel)",border:"1px solid var(--border-default)",boxShadow:"0 2px 6px var(--border-subtle)"},title:"Delete (Shift+Backspace)",children:(0,t.jsx)(m.TrashIcon,{className:"w-3.5 h-3.5 text-gray-500 dark:text-zinc-400 hover:text-red-500"})})]})})]})}var E=e.i(787906),$=e.i(913107),T=e.i(427217),F=e.i(474121),M=e.i(144452);let A=(0,e.i(475254).default)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);var L=e.i(705766),P=e.i(283564),B=e.i(825367),R=e.i(723994),O=e.i(615737),U=e.i(300058),W=e.i(597730),q=e.i(539156),X=e.i(743607),G=e.i(465509);function H({column:e,subItem:r,onUpdate:s,teamMembers:n=[],statusOptions:o=[]}){let d,[c,u]=(0,a.useState)(null),x=(0,a.useRef)(null);function p(e,t){s(e,t),u(Date.now()),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{},1200)}(0,a.useEffect)(()=>()=>{x.current&&clearTimeout(x.current)},[]);let{key:m,type:h,options:g}=e;function b(e){let t=r.customFields;return t?t instanceof Map?t.get(e)??null:t[e]??null:null}function f(e,t){switch(m){case"status":p({status:e,statusColor:t||void 0});break;case"person":p({assignees:e},{assignees:e.map(e=>e._id||e)});break;case"collaborators":p({collaborators:e},{collaborators:e.map(e=>e._id||e)});break;case"assigner":{let t=e.length>0?e[e.length-1]:null;p({assigner:t},{assigner:t?t._id||t:null})}break;case"dueDate":p({dueDate:e});break;case"priority":p({priority:e});break;default:"creator"===h&&e&&"object"==typeof e?p({customFields:{[m]:e._id,[`${m}__display`]:{_id:e._id,name:e.name,image:e.image}}}):p({customFields:{[m]:e}})}}let y=function(){switch(m){case"status":return r.status;case"person":return r.assignees;case"collaborators":return r.collaborators;case"assigner":return r.assigner?[r.assigner]:[];case"dueDate":return r.dueDate;case"priority":return r.priority;default:return b(m)}}();switch(h){case"status":d=(0,t.jsx)(P.default,{value:y,onChange:f,statusOptions:o,compact:!0});break;case"person":case"collaborators":case"assigner":d=(0,t.jsx)(B.default,{value:y,externalValue:[],onChange:f,teamMembers:n,compact:!0});break;case"date":d=(0,t.jsx)(R.default,{value:y,onChange:f,compact:!0});break;case"priority":d=(0,t.jsx)(O.default,{value:y,onChange:f,compact:!0});break;case"text":default:d=(0,t.jsx)(U.default,{value:y,onChange:f});break;case"link":d=(0,t.jsx)(W.default,{value:y,onChange:f});break;case"dropdown":d=(0,t.jsx)(q.default,{value:y,onChange:f,column:e,options:g||[]});break;case"number":d=(0,t.jsx)(X.default,{value:y,onChange:f});break;case"creator":{let e=b(`${m}__display`)||null;d=(0,t.jsx)(G.default,{value:e,onChange:f})}}return(0,t.jsxs)("div",{className:"relative",children:[d,(0,t.jsx)(i.AnimatePresence,{children:c&&Date.now()-c<1100&&(0,t.jsx)(l.motion.div,{initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6},transition:{duration:.18},className:"absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full flex items-center justify-center pointer-events-none z-10",style:{background:"#10B981",boxShadow:"0 0 8px rgba(16,185,129,0.5)"},children:(0,t.jsx)(E.CheckIcon,{className:"w-2 h-2 text-white",strokeWidth:3})},`flash-${c}`)})]})}var K=e.i(735490),J=e.i(136604);function V({taskId:e,subItemId:s,subItemTitle:n,teamMembers:o=[],onAfterRead:d}){let{data:c}=(0,r.useSession)(),[u,x]=(0,a.useState)([]),[p,m]=(0,a.useState)(!1),h=(0,a.useRef)(null),g=c?.user?._id?.toString?.();["admin","super_admin"].includes(c?.user?.role);let b=(0,a.useCallback)(async()=>{try{let t=await fetch(`/api/tasks/${e}/subitems/${s}/comments`);if(!t.ok)return;let a=await t.json();x(a.messages||[])}catch{}finally{m(!0)}},[e,s]);async function f({text:t,mentions:a,creatorMentions:r,campaignMentions:n,organizationMentions:l,dealMentions:i,media:o}){if(t?.trim()||o?.length)try{if(!(await fetch(`/api/tasks/${e}/subitems/${s}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,mentions:a,creatorMentions:r,campaignMentions:n,organizationMentions:l,dealMentions:i,media:o})})).ok)throw Error("send_failed");await b(),d?.()}catch{L.default.error("Failed to send")}}return(0,a.useEffect)(()=>{let t=!1;return async function(){try{await fetch(`/api/tasks/${e}/subitems/${s}/read`,{method:"POST"})}catch{}
1t||(await b(),d?.())}(),()=>{t=!0}},[e,s,b,d]),(0,a.useEffect)(()=>{h.current&&u.length>0&&(h.current.scrollTop=h.current.scrollHeight)},[u]),(0,t.jsx)(l.motion.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.22,ease:[.25,.46,.45,.94]},className:"overflow-hidden",id:`subitem-thread-${s}`,children:(0,t.jsxs)("div",{className:"mx-0 px-4 py-3 flex flex-col gap-2",style:{background:"linear-gradient(180deg, rgba(236,72,153,0.025), rgba(249,115,22,0.015))",borderTop:"1px solid var(--surface-softer)",borderBottom:"1px solid var(--surface-softer)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.12em]",style:{color:"var(--text-label)"},children:"Subtask thread"}),(0,t.jsxs)("span",{className:"text-[10px] font-semibold truncate max-w-[200px]",style:{color:"var(--text-tertiary)"},title:n,children:["â ",n]})]}),(0,t.jsxs)("div",{ref:h,className:"flex flex-col gap-1.5 max-h-[280px] overflow-y-auto overscroll-contain",style:{scrollbarWidth:"thin"},children:[!p&&(0,t.jsx)("div",{className:"flex justify-center py-3",children:(0,t.jsx)("span",{className:"w-4 h-4 rounded-full border-2 border-t-transparent animate-spin",style:{borderColor:"rgba(236,72,153,0.4)",borderTopColor:"transparent"}})}),p&&0===u.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center py-5 gap-1.5",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center",style:{background:"rgba(236,72,153,0.08)"},children:(0,t.jsx)("svg",{className:"w-4 h-4",style:{color:"#EC4899"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.
1123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"})})}),(0,t.jsx)("p",{className:"text-[11px] font-medium text-gray-400 dark:text-zinc-500",children:"No messages yet â start the conversation"})]}),(0,t.jsx)(i.AnimatePresence,{initial:!1,children:p&&u.map((e,a)=>{let r=u[a-1],s=e.user?._id?.toString?.()===g||e.user?.toString?.()===g,n=r&&(r.user?._id?.toString?.()||r.user?.toString?.())===(e.user?._id?.toString?.()||e.user?.toString?.()),i=r?new Date(e.createdAt).getTime()-new Date(r.createdAt).getTime():1/0,o=n&&i<3e5,d=e.user?.name||"Unknown",c=d[0]?.toUpperCase()||"?",x=(0,J.getAvatarGradient)(d);return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:8,scale:.97},animate:{opacity:1,y:0,scale:1},transition:{duration:.3,ease:[.25,.46,.45,.94]},className:`flex gap-2 ${s?"flex-row-reverse":""} ${o?"mt-1":"mt-3"}`,children:[(0,t.jsx)("div",{className:"w-6 flex-shrink-0",children:!o&&(0,t.jsx)("div",{className:`w-6 h-6 rounded-full bg-gradient-to-br ${x} flex items-center justify-center text-white text-[9px] font-bold shadow-sm`,children:c})}),(0,t.jsxs)("div",{className:`flex flex-col min-w-0 max-w-[78%] ${s?"items-end":"items-start"}`,children:[!o&&(0,t.jsxs)("div",{className:`flex items-baseline gap-1.5 mb-0.5 ${s?"flex-row-reverse":""}`,children:[(0,t.jsx)("span",{className:"text-[10px] font-semibold text-gray-700 dark:text-zinc-300",children:s?"You":d}),(0,t.jsx)("span",{className:"text-[9px] text-gray-400 dark:text-zinc-500",children:function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let a=Math.floor(t/60);if(a<60)return`${a}m ago`;let r=Math.floor(a/60);if(r<24)return`${r}h ago`;let s=Math.floor(r/24);return s<7?`${s}d ago`:new Date(e).toLocaleDateString()}(e.createdAt)})]}),(0,t.jsx)("div",{className:"px-2.5 py-1.5 rounded-2xl text-[12px] leading-[1.45] whitespace-pre-wrap break-words",style:s?{background:"rgba(249,115,22,0.06)",border:"1px solid rgba(249,115,22,0.12)",color:"var(--text-primary)",borderTopRightRadius:6}:{background:"var(--surface-softer)",border:"1px solid var(--surface-softer)",color:"var(--text-primary)",borderTopLeftRadius:6},children:e.text||""})]})]},e._id||a)})})]}),(0,t.jsxs)("div",{className:"group/composer relative mt-1",children:[(0,t.jsx)("div",{className:"absolute -inset-1 rounded-2xl opacity-0 blur-xl pointer-events-none transition-opacity duration-500 group-focus-within/composer:opacity-40",style:{background:"linear-gradient(135deg, rgba(236,72,153,0.4), rgba(249,115,22,0.4))"}}),(0,t.jsx)(K.default,{teamMembers:o,placeholder:`Reply on "${n}"â¦`,onSubmit:f})]})]})})}function Y({task:e,onRefresh:r,onOpenWithSubItem:s,onCommentOnSubItem:n,columns:c=[],teamMembers:u=[],statusOptions:p=[],taskColumnWidth:m=680,unreadSummary:h={},totalSummary:g={},onUnreadRefresh:b,autoExpandSubItemId:f=null}){let[y,v]=(0,a.useState)(e.subItems||[]),[k,j]=(0,a.useState)(()=>f?new Set([f.toString()]):new Set);(0,a.useEffect)(()=>{let e=window.location.hash.match(/^#subitem-(.+)$/);if(!e)return;let t=e[1];j(e=>{if(e.has(t))return e;let a=new Set(e);return a.add(t),a}),window.history.replaceState(null,"",window.location.pathname+window.location.search)},[]);let[w,N]=(0,a.useState)(!1),C=JSON.stringify((e.subItems||[]).map(e=>({_id:e._id,completed:e.completed,completedAt:e.completedAt,title:e.title,status:e.status,priority:e.priority,dueDate:e.dueDate,assignees:(e.assignees||[]).map(e=>e?._id||e),collaborators:(e.collaborators||[]).map(e=>e?._id||e),assigner:e.assigner?._id||e.assigner})));(0,a.useEffect)(()=>{v(e.subItems||[])},[C]);let[S,z]=(0,a.useState)(!1);async function _(t,a,s){v(e=>e.map(e=>e._id===t?{...e,...a}:e));try{let n=await fetch(`/api/tasks/${e._id}/subitems`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({subItemId:t,...s||a})});if(n.ok){let e=await n.json(),a=Array.isArray(e?.subItems)?e.subItems:null,s=a&&a.some(e=>(e._id?.toString?.()||e._id)===(t?.toString?.()||t));a&&s?v(a):a&&0===a.length&&v([]),r?.()}}catch{L.default.error("Failed to update sub-task")}}async function D(e,t){let a=!t,r={completed:a},s=y.find(t=>t._id===e);a?(r.status="Done",r.statusColor="#00c875"):s?.status==="Done"&&(r.status="To Do",r.statusColor="#c4c4c4"),await _(e,r,{completed:a})}async function I(t){v(e=>e.filter(e=>e._id!==t));try{let a=await fetch(`/api/tasks/${e._id}/subitems`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({subItemId:t})});if(!a.ok){v(y),L.default.error("Failed to delete sub-task");return}let s=await a.json().catch(()=>null);s?.subItems&&v(s.subItems),r?.()}catch{v(y),L.default.error("Failed to delete sub-task")}}async function P(t){v(e=>{let a=new Map(e.map(e=>[e._id,e])),r=[],s=new Set;for(let e of t){let t=a.get(e);t&&!s.has(e)&&(r.push(t),s.add(e))}for(let[e,t]of a.entries())s.has(e)||r.push(t);return r});try{let a=await fetch(`/api/tasks/${e._id}/subitems`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({subItemOrder:t})});if(a.ok){let e=await a.json();v(e.subItems),r?.()}}catch{L.default.error("Couldn't save the new order")}}let B=(0,a.useCallback)(e=>{j(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]);(0,a.useEffect)(()=>
1{if(!f)return;let e=f.toString();j(t=>{if(t.has(e))return t;let a=new Set(t);return a.add(e),a})},[f]);let R=(0,o.useSensors)((0,o.useSensor)(o.PointerSensor,{activationConstraint:{distance:5}})),O=y.length,U=y.filter(e=>e.completed).length,W=O>0?U/O*100:0,q=[...y.filter(e=>!e.completed),...y.filter(e=>e.completed).sort((e,t)=>{let a=e.completedAt?new Date(e.completedAt).getTime():0;return(t.completedAt?new Date(t.completedAt).getTime():0)-a})],X=Date.now()-15e3,G=q.filter(e=>{if(!e.completed)return!1;let t=e.completedAt?new Date(e.completedAt).getTime():null;return t&&t<X}),K=new Set(G.map(e=>e._id?.toString?.())),J=w?q:q.filter(e=>!K.has(e._id?.toString?.()));return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.25,ease:[.25,.46,.45,.94]},onAnimationComplete:e=>{e&&"auto"===e.height&&z(!0)},onAnimationStart:()=>{z(!1)},className:`border-b ${S?"overflow-visible":"overflow-hidden"}`,style:{borderColor:"var(--surface-softer)",background:"linear-gradient(180deg, rgba(99,102,241,0.025), rgba(236,72,153,0.02))"},children:[O>0&&(0,t.jsx)("div",{className:"w-full h-1 overflow-hidden",style:{background:"var(--surface-softer)"},children:(0,t.jsx)(l.motion.div,{className:"h-full",initial:{width:0},animate:{width:`${W}%`},transition:{duration:.4},style:{background:100===W?"linear-gradient(90deg, #10B981, #059669)":"linear-gradient(90deg, #6366F1, #EC4899)"}})}),(0,t.jsx)(o.DndContext,{sensors:R,collisionDetection:o.closestCenter,onDragEnd:e=>{let{active:t,over:a}=e;if(!a||t.id===a.id)return;let r=J.map(e=>e._id),s=r.indexOf(t.id),n=r.indexOf(a.id);-1!==s&&-1!==n&&P((0,d.arrayMove)(r,s,n))},children:(0,t.jsx)(d.SortableContext,{items:J.map(e=>e._id),strategy:d.verticalListSortingStrategy,children:(0,t.jsx)(i.AnimatePresence,{children:J.map(a=>(0,t.jsx)(Z,{id:a._id,renderRow:({setNodeRef:r,attributes:n,dragListeners:o,style:d})=>{let x,f,y,v;return(0,t.jsxs)("div",{ref:r,...n,"data-subitem-id":a._id,style:d,children:[(0,t.jsxs)(l.motion.div,{layout:"position",initial:{opacity:0,x:-4},animate:{opacity:1,x:0},exit:{opacity:0,x:-4},transition:{opacity:{duration:.15},x:{duration:.15},layout:{type:"spring",stiffness:380,damping:32,mass:.9}},className:"relative flex items-stretch h-9 group/sub hover:bg-black/[0.02] dark:hover:bg-white/[0.03] transition-colors",style:{borderTop:"1px solid var(--surface-softer)"},children:[(0,t.jsxs)("div",{role:s?"button":void 0,tabIndex:s?0:void 0,onClick:s?()=>s(e,a._id):void 0,onKeyDown:s?t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),s(e,a._id))}:void 0,style:{width:m,minWidth:m},className:`flex-shrink-0 flex items-center gap-2 pl-2 pr-3 ${s?"cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-orange-300/50 rounded":""}`,children:[(0,t.jsx)("button",{type:"button",onPointerDown:e=>{e.stopPropagation(),o?.onPointerDown?.(e)},onMouseDown:e=>{e.stopPropagation(),o?.onMouseDown?.(e)},onTouchStart:e=>{e.stopPropagation(),o?.onTouchStart?.(e)},onKeyDown:o?.onKeyDown,onClick:e=>e.stopPropagation(),className:"flex-shrink-0 text-gray-300 dark:text-zinc-700 hover:text-gray-500 dark:hover:text-zinc-400 cursor-grab active:cursor-grabbing transition-colors",title:"Drag to reorder","aria-label":"Drag to reorder",children:(0,t.jsx)(F.Bars3Icon,{className:"w-3 h-3"})}),(0,t.jsx)("span",{"aria-hidden":"true",className:"text-[11px] text-gray-300 dark:text-zinc-700 select-none",children:"â³"}),(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),D(a._id,a.completed)},className:"w-[14px] h-[14px] rounded border-2 flex-shrink-0 flex items-center justify-center transition-all duration-200",style:a.completed?{borderColor:"#10B981",background:"#10B981",boxShadow:"0 0 6px rgba(16,185,129,0.3)"}:{borderColor:"var(--border-default)"},"aria-label":a.completed?"Mark incomplete":"Mark complete",children:a.completed&&(0,t.jsx)(E.CheckIcon,{className:"w-2 h-2 text-white",strokeWidth:3})}),(0,t.jsx)("span",{className:`text-[12px] leading-none flex-1 truncate font-medium ${a.completed?"text-gray-400 dark:text-zinc-500 line-through":"text-gray-700 dark:text-zinc-300"}`,title:a.title,children:a.title}),(f=h[x=a._id?.toString?.()??a._id]??0,y=g[x]??0,v=k.has(x),(0,t.jsxs)("button",{onClick:e=>{e.stopPropagation(),B(x)},className:`opacity-100 sm:opacity-0 sm:group-hover/sub:opacity-100 flex items-center gap-0.5 flex-shrink-0 p-1 -m-1 rounded transition-all ${v?"text-pink-500 bg-pink-50 dark:bg-pink-500/10":"text-gray-300 dark:text-zinc-700 hover:text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-500/10"}`,title:v?"Close subtask thread":"Open subtask thread","aria-label":v?"Close subtask thread":"Open subtask thread","aria-expanded":v,children:[(0,t.jsx)(A,{className:"w-3.5 h-3.5"}),y>0&&(0,t.jsx)("span",{className:"text-[9px] font-bold leading-none px-1 py-0.5 rounded-full",style:f>0?{background:"rgba(236,72,153,0.15)",color:"#EC4899",border:"1px solid rgba(236,72,153,0.3)"}:{background:"var(--surface-soft)",color:"var(--text-label)",border:"1px solid var(--border-subtle)"},children:y})]})),(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),I(a._id)},className:"opacity-100 sm:opacity-0 sm:group-hover/sub:opacity-100 text-gray-300 dark:text-zinc-700 hover:text-red-400 transition-all flex-shrink-0 p-1 -m-1 rounded hover:bg-red-50 dark:hover:bg-red-500/10",title:"Delete sub-task","aria-label":"Delete sub-task",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3.5 h-3.5"})})]}),c.map(e=>(0,t.jsx)("div",{className:"flex-shrink-0 px-1 border-l flex items-center justify-center min-w-0",style:{width:e.width||150,borderColor:"var(--surface-softer)"}
1,children:(0,t.jsx)(H,{column:e,subItem:a,onUpdate:e=>_(a._id,e),teamMembers:u,statusOptions:p})},e._id||e.key))]}),(0,t.jsx)(i.AnimatePresence,{children:k.has(a._id?.toString?.()??a._id)&&(0,t.jsx)(V,{taskId:e._id,subItemId:a._id,subItemTitle:a.title,teamMembers:u,onAfterRead:b},`thread-${a._id}`)})]})}},a._id))})})}),G.length>0&&(0,t.jsx)("div",{className:"flex items-center justify-center py-1.5",children:(0,t.jsx)("button",{type:"button",onClick:()=>N(e=>!e),className:"inline-flex items-center gap-1.5 text-[11px] font-semibold px-2.5 py-1 rounded-md transition-colors hover:bg-gray-50 dark:hover:bg-zinc-900",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-tertiary)"},title:w?"Hide subtasks done a while ago":`Show ${G.length} subtask${1===G.length?"":"s"} done over 15s ago`,children:w?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(M.ChevronUpIcon,{className:"w-3 h-3"}),"Hide aged-out"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x.ChevronDownIcon,{className:"w-3 h-3"}),"Show ",G.length," hidden"]})})}),(0,t.jsx)("div",{className:"flex flex-col pl-7 pr-3 py-1",style:{borderTop:"1px solid var(--surface-softer)"},children:(0,t.jsxs)("button",{type:"button",onClick:function(){s?.(e,null,{draft:!0})},className:"flex items-center gap-1.5 text-[11px] font-semibold text-gray-400 dark:text-zinc-500 hover:text-violet-500 transition-colors duration-150 h-6",children:[(0,t.jsx)($.PlusIcon,{className:"w-3 h-3"}),"Add sub-task"]})})]})}function Z({id:e,renderRow:t}){let{attributes:a,listeners:r,setNodeRef:s,transform:n,transition:l,isDragging:i}=(0,d.useSortable)({id:e});return t({setNodeRef:s,attributes:a,dragListeners:r,style:{transform:c.CSS.Transform.toString(n),transition:l,zIndex:i?20:"auto",background:i?"var(--surface-panel)":void 0,boxShadow:i?"0 12px 28px -10px rgba(236,72,153,0.28), 0 4px 10px -4px rgba(249,115,22,0.18), 0 0 0 1px rgba(236,72,153,0.18)":void 0,borderRadius:8*!!i,cursor:i?"grabbing":void 0,touchAction:"manipulation"}})}function Q({task:e,isExpanded:a,onSubItemRefresh:r,onOpenWithSubItem:s,onCommentOnSubItem:n,columns:l,teamMembers:o,statusOptions:d,taskColumnWidth:c=680,unreadSummary:u={},totalSummary:x={},onUnreadRefresh:p,autoExpandSubItemId:m=null,...h}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(I,{task:e,isSubItemsExpanded:a,columns:l,teamMembers:o,statusOptions:d,taskColumnWidth:c,...h}),(0,t.jsx)(i.AnimatePresence,{children:a&&(0,t.jsx)(Y,{task:e,onRefresh:r,onOpenWithSubItem:s,onCommentOnSubItem:n,columns:l,teamMembers:o,statusOptions:d,taskColumnWidth:c,unreadSummary:u,totalSummary:x,onUnreadRefresh:p,autoExpandSubItemId:m},`subitems-${e._id}`)})]})}function ee({group:e,taskCount:r,collapsed:s,onToggle:n,onRename:i}){let[o,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(e.name);function p(){c.trim()&&c.trim()!==e.name?i(c.trim()):u(e.name),d(!1)}return(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[3px] rounded-full",style:{background:`linear-gradient(180deg, ${e.color}, ${e.color}88)`,boxShadow:`0 0 8px ${e.color}30`}}),(0,t.jsxs)("div",{className:"flex items-center gap-3 py-2.5 px-4 pl-5 transition-all duration-200",style:{background:`linear-gradient(90deg, ${e.color}08, transparent)`},children:[(0,t.jsx)(l.motion.button,{onClick:n,whileHover:{scale:1.15},whileTap:{scale:.9},className:"flex-shrink-0 w-6 h-6 flex items-center justify-center rounded-lg transition-colors duration-200",style:{background:`${e.color}12`},children:(0,t.jsx)(l.motion.div,{animate:{rotate:s?-90:0},transition:{duration:.2,ease:[.25,.46,.45,.94]},children:(0,t.jsx)(x.ChevronDownIcon,{className:"w-3.5 h-3.5",style:{color:e.color}})})}),o?(0,t.jsx)("input",{autoFocus:!0,value:c,onChange:e=>u(e.target.value),onBlur:p,onKeyDown:t=>{"Enter"===t.key&&p(),"Escape"===t.key&&(u(e.name),d(!1))},className:"text-sm font-bold px-2 py-0.5 border rounded-lg focus:outline-none focus:ring-2 transition-all",style:{color:e.color,borderColor:`${e.color}40`,boxShadow:`0 0 0 3px ${e.color}15`}}):(0,t.jsx)("button",{onDoubleClick:()=>d(!0),className:"text-sm font-black tracking-tight transition-colors duration-200 hover:opacity-80",style:{color:e.color},children:e.name}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 rounded-full",style:{background:`${e.color}10`},children:[(0,t.jsx)("span",{className:"text-[10px] font-bold tracking-wide",style:{color:`${e.color}CC`},children:r}),(0,t.jsx)("span",{className:"text-[10px] font-medium",style:{color:`${e.color}88`},children:1===r?"task":"tasks"})]})]})]})}var et=e.i(522016),ea=e.i(482395),er=e.i(822617);
1let es={not_started:{label:"Not started",color:"#9CA3AF"},in_progress:{label:"In progress",color:"#F59E0B"},stuck:{label:"Stuck",color:"#EF4444"},completed:{label:"Completed",color:"#10B981"}};function en(e){if(!e)return null;let t=new Date(e);return isNaN(t)?null:t.toLocaleDateString(void 0,{month:"short",day:"numeric",timeZone:"UTC"})}function el({milestone:e,campaignName:a=null,campaignId:r=null,dealId:s=null,taskCount:n=0,collapsed:i=!1,onToggle:o,compact:d=!1}){let c=e?.color||"#F97316",u=es[e?.status]||es.not_started,p=Number(e?.taskCount)||0,m=Number(e?.doneTaskCount)||0,h=e?.status==="completed"?100:p>0?Math.round(m/p*100):0,g=(()=>{if("number"==typeof e?.slipDays)return e.slipDays;if(e?.baselineEndDate&&e?.endDate){let t=(0,er.businessDaysBetween)(e.baselineEndDate,e.endDate);return t>0?t:0}return 0})(),b=en(e?.startDate),f=en(e?.endDate),y=r?`/dashboard/user/campaign/${r}?tab=milestones`:s?`/dashboard/user/sales/deal/${s}`:null;return(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[3px] rounded-full",style:{background:`linear-gradient(180deg, ${c}, ${c}88)`,boxShadow:`0 0 8px ${c}30`}}),(0,t.jsxs)("div",{className:`flex items-center gap-2.5 sm:gap-3 min-w-0 transition-all duration-200 ${d?"py-1.5 px-4 pl-8":"py-2.5 px-4 pl-5"}`,style:{background:`linear-gradient(90deg, ${c}08, transparent)`},children:[(0,t.jsx)(l.motion.button,{type:"button",onClick:o,whileHover:{scale:1.15},whileTap:{scale:.9},className:`flex-shrink-0 flex items-center justify-center rounded-lg transition-colors duration-200 ${d?"w-5 h-5":"w-6 h-6"}`,style:{background:`${c}12`},title:i?"Expand milestone":"Collapse milestone","aria-label":i?"Expand milestone":"Collapse milestone",children:(0,t.jsx)(l.motion.div,{animate:{rotate:i?-90:0},transition:{duration:.2,ease:[.25,.46,.45,.94]},children:(0,t.jsx)(x.ChevronDownIcon,{className:"w-3.5 h-3.5",style:{color:c}})})}),(0,t.jsx)(ea.FlagIcon,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:c}}),(0,t.jsx)("span",{className:`tracking-tight truncate max-w-[220px] sm:max-w-[320px] ${d?"text-[12.5px] font-bold":"text-sm font-black"}`,style:{color:c},title:e?.title,children:e?.title||"Milestone"}),a&&(y?(0,t.jsx)(et.default,{href:y,onClick:e=>e.stopPropagation(),className:"hidden sm:inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-semibold truncate max-w-[180px] transition-colors hover:opacity-80",style:{background:"var(--surface-soft)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},title:`Open ${a} milestones`,children:a}):(0,t.jsx)("span",{className:"hidden sm:inline-flex items-center px-2 py-0.5 rounded-md text-[10px] font-semibold truncate max-w-[180px]",style:{background:"var(--surface-soft)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:a})),(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold tracking-wide flex-shrink-0",style:{background:`${u.color}14`,color:u.color,border:`1px solid ${u.color}30`},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:u.color}}),u.label]}),p>0&&(0,t.jsxs)("span",{className:"hidden md:inline-flex items-center gap-2 flex-shrink-0",title:`${m} of ${p} tasks done`,children:[(0,t.jsx)("span",{className:"relative h-1.5 w-16 rounded-full overflow-hidden",style:{background:`${c}20`},children:(0,t.jsx)("span",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-500",style:{width:`${h}%`,background:`linear-gradient(90deg, ${c}, ${c}AA)`}})}),(0,t.jsxs)("span",{className:"text-[10px] font-bold tabular-nums",style:{color:`${c}CC`},children:[m,"/",p]})]}),(b||f)&&(0,t.jsx)("span",{className:"hidden lg:inline text-[10.5px] font-medium text-gray-400 dark:text-zinc-500 flex-shrink-0 tabular-nums",children:b&&f&&b!==f?`${b} â ${f}`:f||b}),g>0&&(0,t.jsxs)("span",{className:"text-[9px] font-black px-1.5 py-0.5 rounded-full flex-shrink-0",style:{background:"#EF444414",color:"#EF4444",border:"1px solid #EF444425"},title:`Slipping ${g} business day${1===g?"":"s"} past baseline`,children:["+",g,"d"]}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1.5 px-2.5 py-0.5 rounded-full flex-shrink-0",style:{background:`${c}10`},children:[(0,t.jsx)("span",{className:"text-[10px] font-bold tracking-wide",style:{color:`${c}CC`},children:n}),(0,t.jsx)("span",{className:"text-[10px] font-medium",style:{color:`${c}88`},children:1===n?"task":"tasks"})]})]})]})}var ei=e.i(63495);function eo({group:e,groupColor:r="#6366F1",onAdd:s,teamMembers:n=[],defaultPrivate:o=!1}){let[d,c]=(0,a.useState)(!1);return d?(0,t.jsx)(i.AnimatePresence,{children:(0,t.jsx)(l.motion.div,{initial:{opacity:0,y:-4}
1,animate:{opacity:1,y:0},transition:{duration:.2,ease:[.25,.46,.45,.94]},children:(0,t.jsx)(ei.default,{teamMembers:n,groupColor:r,defaultPrivate:o,onSubmit:t=>{s(t,e),c(!1)},onCancel:()=>c(!1)})})}):(0,t.jsxs)("button",{onClick:()=>c(!0),className:"w-full text-left px-5 py-2.5 flex items-center gap-2 text-xs transition-all duration-300 group border-b",style:{borderColor:"var(--shadow-ambient-xs)"},children:[(0,t.jsx)("div",{className:"w-5 h-5 rounded-lg flex items-center justify-center transition-all duration-300 group-hover:shadow-sm",style:{background:`${r}08`,border:`1px dashed ${r}30`},children:(0,t.jsx)($.PlusIcon,{className:"w-3 h-3 transition-all duration-300 group-hover:rotate-90",style:{color:`${r}80`}})}),(0,t.jsx)("span",{className:"font-semibold transition-colors duration-200",style:{color:`${r}60`},children:"Add task"})]})}var ed=e.i(231822);let ec=a.forwardRef(function({title:e,titleId:t,...r},s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},r),e?a.createElement("title",{id:t},e):null,a.createElement("path",{fillRule:"evenodd",d:"M16.5 4.478v.227a48.816 48.816 0 0 1 3.878.512.75.75 0 1 1-.256 1.478l-.209-.035-1.005 13.07a3 3 0 0 1-2.991 2.77H8.084a3 3 0 0 1-2.991-2.77L4.087 6.66l-.209.035a.75.75 0 0 1-.256-1.478A48.567 48.567 0 0 1 7.5 4.705v-.227c0-1.564 1.213-2.9 2.816-2.951a52.662 52.662 0 0 1 3.369 0c1.603.051 2.815 1.387 2.815 2.951Zm-6.136-1.452a51.196 51.196 0 0 1 3.273 0C14.39 3.05 15 3.684 15 4.478v.113a49.488 49.488 0 0 0-6 0v-.113c0-.794.609-1.428 1.364-1.452Zm-.355 5.945a.75.75 0 1 0-1.5.058l.347 9a.75.75 0 1 0 1.499-.058l-.346-9Zm5.48.058a.75.75 0 1 0-1.498-.058l-.347 9a.75.75 0 0 0 1.5.058l.345-9Z",clipRule:"evenodd"}))}),eu=[{value:"status",label:"Status"},{value:"person",label:"Owner"},{value:"collaborators",label:"Collaborators"},{value:"assigner",label:"Assigner"},{value:"creator",label:"Creator"},{value:"date",label:"Date"},{value:"priority",label:"Priority"},{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"link",label:"Link"},{value:"dropdown",label:"Dropdown"},{value:"linked_tasks",label:"Connect Boards"}],ex=["#3b82f6","#10b981","#8b5cf6","#f59e0b","#ec4899","#ef4444","#6366f1","#f97316","#14b8a6","#06b6d4","#a855f7","#84cc16","#e2445c","#00c875","#c4c4c4","#fdab3d","#0073ea","#df2f4a","#ff5ac4","#007038","#169a7e","#037f4c","#cab641","#9d99b9"];function ep({color:e,onChange:r,onClose:s}){let n=(0,a.useRef)(null),[i,o]=(0,a.useState)(e||"#3b82f6"),[d,c]=(0,a.useState)(e||"#3b82f6");function u(e){let t=e.startsWith("#")?e:`#${e}`;/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t)&&(o(t),r(t))}return(0,a.useEffect)(()=>{function e(e){n.current&&!n.current.contains(e.target)&&s()}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s]),(0,t.jsxs)(l.motion.div,{ref:n,initial:{opacity:0,y:-4,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.96},transition:{duration:.15,ease:[.25,.46,.45,.94]},className:"absolute z-[200] left-0 top-full mt-1.5 rounded-xl p-2.5 w-[196px]",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 12px 40px var(--shadow-ambient-lg), 0 2px 8px var(--border-subtle)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"grid grid-cols-6 gap-1 mb-2",children:ex.map(a=>{let s,n;return(0,t.jsx)("button",{onClick:()=>{o(a),c(a),r(a)},className:"w-7 h-7 rounded-md transition-transform hover:scale-110 focus:outline-none relative flex-shrink-0",style:{backgroundColor:a},title:a,children:(i===a||e===a)&&(0,t.jsx)(E.CheckIcon,{className:"w-3.5 h-3.5 absolute inset-0 m-auto",style:{color:function([e,t,a]){let r=e=>{let t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)};return .2126*r(e)+.7152*r(t)+.0722*r(a)}([(n=parseInt(3===(s=a.replace("#","")).length?s.split("").map(e=>e+e).join(""):s,16))>>16&255,n>>8&255,255&n])>.4?"#1f2937":"#ffffff"}})},a)})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("div",{className:"w-6 h-6 rounded-md flex-shrink-0 border",style:{backgroundColor:i,borderColor:"var(--border-subtle)"}}),(0,t.jsx)("input",{type:"text",value:d,onChange:e=>c(e.target.value),onBlur:e=>u(e.target.value),onKeyDown:e=>{"Enter"===e.key&&u(d)},maxLength:7,placeholder:"#3b82f6",className:"flex-1 text-[11px] px-2 py-1.5 rounded-lg focus:outline-none focus:ring-1 focus:ring-orange-300 text-gray-700 dark:text-zinc-300",style:{background:"var(--surface-soft)",border:"1px solid var(--border-default)"}})]})]})}function em({count:e,label:a,onConfirm:r,onCancel:s,loading:n}){return(0,t.jsx)(l.motion.div,{initial:{opacity:0,scale:.95}
1,animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15,ease:[.25,.46,.45,.94]},className:"fixed inset-0 z-[300] flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.35)",backdropFilter:"blur(4px)"},children:(0,t.jsxs)("div",{className:"rounded-2xl p-5 w-full max-w-[320px]",style:{background:"var(--surface-panel)",border:"1px solid var(--border-subtle)",boxShadow:"0 20px 60px var(--shadow-ambient-2xl)"},children:[(0,t.jsxs)("div",{className:"flex items-start gap-3 mb-4",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(239,68,68,0.10)",border:"1px solid rgba(239,68,68,0.20)"},children:(0,t.jsx)(ec,{className:"w-4 h-4 text-red-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"text-[13px] font-bold text-gray-800 dark:text-zinc-100 leading-snug",children:["Delete â",a,"â?"]}),n?(0,t.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-zinc-500 mt-1",children:"Checking usageâ¦"}):e>0?(0,t.jsxs)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-1 leading-relaxed",children:[(0,t.jsxs)("span",{className:"font-semibold text-red-500",children:[e," task",1!==e?"s":""]})," ","use this value. They'll show as an unlinked chip until you remap them."]}):(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-1",children:"This option isn't used by any tasks."})]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:r,className:"flex-1 text-xs py-2 rounded-xl font-semibold text-white transition-all hover:shadow-md",style:{background:"linear-gradient(135deg, #ef4444, #dc2626)"},children:"Delete"}),(0,t.jsx)("button",{onClick:s,className:"px-4 text-xs py-2 rounded-xl font-semibold text-gray-600 dark:text-zinc-300 hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors",style:{border:"1px solid var(--border-subtle)"},children:"Cancel"})]})]})})}function eh({options:e,onChange:r,boardId:s,columnId:n}){let[l,o]=(0,a.useState)(null),[d,c]=(0,a.useState)(null),[u,p]=(0,a.useState)(null),[m,h]=(0,a.useState)(!1);function g(t,a){r(e.map((e,r)=>{if(r!==t)return e;let s={...e,...a};return"label"in a&&(s.value=a.label.toLowerCase().trim().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")),s}))}function b(t,a){let s=[...e],n=t+a;n<0||n>=s.length||([s[t],s[n]]=[s[n],s[t]],r(s))}async function f(e,t){if(c({idx:e,option:t}),p(null),!s||!n||!t.value)return void p(0);h(!0);try{let e=await fetch(`/api/task-boards/${s}/columns/${n}/option-usage?value=${encodeURIComponent(t.value)}`);if(e.ok){let t=await e.json();p(t.count??0)}else p(0)}catch{p(0)}finally{h(!1)}}return(0,t.jsxs)("div",{className:"mt-3",children:[(0,t.jsx)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.12em] mb-2 block",children:"Options"}),(0,t.jsx)("div",{className:"space-y-1.5",children:e.map((a,r)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 group/optrow",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("button",{type:"button",onClick:()=>o(l===r?null:r),className:"w-6 h-6 rounded-md flex-shrink-0 border-2 transition-transform hover:scale-110 focus:outline-none",style:{backgroundColor:a.color||"#3b82f6",borderColor:a.color?`${a.color}60`:"rgba(0,0,0,0.1)"},title:"Change colour"}),(0,t.jsx)(i.AnimatePresence,{children:l===r&&(0,t.jsx)(ep,{color:a.color,onChange:e=>{g(r,{color:e})},onClose:()=>o(null)})})]}),(0,t.jsx)("input",{type:"text",value:a.label,onChange:e=>g(r,{label:e.target.value}),placeholder:`Option ${r+1}`,className:"flex-1 text-[12px] px-2.5 py-1.5 rounded-lg text-gray-700 dark:text-zinc-300 focus:outline-none focus:ring-1 focus:ring-orange-300 placeholder-gray-300 dark:placeholder-zinc-700 transition-all",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 opacity-100 md:opacity-0 md:group-hover/optrow:opacity-100 transition-opacity",children:[(0,t.jsx)("button",{type:"button",onClick:()=>b(r,-1),disabled:0===r,className:"w-4 h-4 flex items-center justify-center rounded text-gray-400 dark:text-zinc-600 hover:text-gray-700 dark:hover:text-zinc-300 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:(0,t.jsx)(M.ChevronUpIcon,{className:"w-3 h-3"})}),(0,t.jsx)("button",{type:"button",onClick:()=>b(r,1),disabled:r===e.length-1,className:"w-4 h-4 flex items-center justify-center rounded text-gray-400 dark:text-zinc-600 hover:text-gray-700 dark:hover:text-zinc-300 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:(0,t.jsx)(x.ChevronDownIcon,{className:"w-3 h-3"})})]}),(0,t.jsx)("button",{type:"button",onClick:()=>f(r,a),className:"w-6 h-6 flex items-center justify-center rounded-md text-gray-300 dark:text-zinc-700 hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-500/10 transition-colors flex-shrink-0",title:"Delete option",children:(0,t.jsx)(ec,{className:"w-3.5 h-3.5"})})]},r))}),(0,t.jsxs)("button",{type:"button",onClick:function(){let t=ex[e.length%ex.length];r([...e,{label:"",color:t,value:""}])},className:"mt-2 w-full text-[11px] py-1.5 text-gray-400 dark:text-zinc-500 hover:text-orange-500 hover:bg-orange-50 dark:hover:bg-orange-500/10 rounded-lg transition-colors flex items-center justify-center gap-1",children:[(0,t.jsx)($.PlusIcon,{className:"w-3 h-3"}),"Add option"]}),(0,t.jsx)(i.AnimatePresence,{children:d&&(0,t.jsx)(em,{count:u,label:d.option.label||d.option.value||"this option",loading:m,onConfirm:function(){d&&(r(e.filter((e,t)=>
1t!==d.idx)),c(null),p(null))},onCancel:()=>{c(null),p(null)}})})]})}function eg({columns:e,boardId:r,onClose:s,onSave:n}){let[o,d]=(0,a.useState)(""),[c,u]=(0,a.useState)("text"),[x,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(null),[g,b]=(0,a.useState)({}),[f,y]=(0,a.useState)(!1);async function v(t){let a=t._id||t.key,s=g[a]||[];if(!r||!t._id){n(e.map(e=>(e._id||e.key)===a?{...e,options:s}:e)),h(null),L.default.success("Options saved");return}y(!0);try{let e=await fetch(`/api/task-boards/${r}/columns`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({columnId:t._id,options:s})});if(e.ok){let t=await e.json();n(t.columns),h(null),L.default.success("Options saved")}else{let t=await e.json();L.default.error(t.error||"Failed to save options")}}catch{L.default.error("Failed to save options")}finally{y(!1)}}async function k(){if(!o.trim())return;let t=o.trim().toLowerCase().replace(/\s+/g,"_");if(r)try{let e=await fetch(`/api/task-boards/${r}/columns`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,label:o.trim(),type:c})});if(e.ok){let t=await e.json();n(t.columns),L.default.success("Column added")}else{let t=await e.json();L.default.error(t.error||"Failed to add column")}}catch{L.default.error("Failed to add column")}else n([...e,{key:t,label:o.trim(),type:c,position:e.length,width:150,isVisible:!0}]);d(""),u("text"),p(!1)}async function j(t){if(r&&t._id)try{await fetch(`/api/task-boards/${r}/columns`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({columnId:t._id})}),n(e.filter(e=>e._id!==t._id)),L.default.success("Column removed")}catch{L.default.error("Failed to remove column")}else n(e.filter(e=>e.key!==t.key))}return(0,t.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/30 backdrop-blur-sm",children:(0,t.jsxs)("div",{className:"rounded-2xl w-[440px] max-h-[85vh] flex flex-col overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 20px 60px var(--shadow-ambient-2xl)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500 via-orange-400 to-violet-500 flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100 dark:border-zinc-800 flex-shrink-0",children:[(0,t.jsx)("h3",{className:"text-sm font-bold text-gray-800 dark:text-zinc-100 tracking-tight",children:"Configure Columns"}),(0,t.jsx)("button",{onClick:s,className:"w-7 h-7 flex items-center justify-center rounded-full hover:bg-gray-100 dark:hover:bg-zinc-900",children:(0,t.jsx)(T.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-5 space-y-1.5",children:e.map(e=>{let a=e._id||e.key,s=m===a,n="dropdown"===e.type,o=Array.isArray(e.options)&&e.options.length>0,d=g[a]||e.options||[],c=["status","person","collaborators","assigner","dueDate","priority"].includes(e.key);return(0,t.jsxs)("div",{className:"rounded-xl overflow-hidden transition-all",style:{background:"var(--surface-soft)",border:s?"1px solid rgba(249,115,22,0.25)":"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-xs font-semibold text-gray-700 dark:text-zinc-300 truncate",children:e.label}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-zinc-500 bg-gray-200/60 dark:bg-zinc-800/60 px-1.5 py-0.5 rounded flex-shrink-0",children:e.type}),n&&o&&(0,t.jsxs)("span",{className:"text-[10px] text-orange-500/80 dark:text-orange-400/80 flex-shrink-0",children:[e.options.length," option",1!==e.options.length?"s":""]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n&&(0,t.jsx)("button",{onClick:()=>{let t;m===(t=e._id||e.key)?h(null):(h(t),b(a=>({...a,[t]:(e.options||[]).map(e=>({...e}))})))},className:"text-[10px] font-semibold px-2 py-1 rounded-lg transition-colors",style:s?{background:"rgba(249,115,22,0.10)",color:"#F97316",border:"1px solid rgba(249,115,22,0.25)"}:{background:"var(--surface-softer, rgba(0,0,0,0.03))",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s?"Done":"Edit options"}),!c&&(0,t.jsx)("button",{onClick:()=>j(e),className:"w-7 h-7 flex items-center justify-center rounded-lg text-gray-300 dark:text-zinc-700 hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-500/10 transition-colors",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsx)(i.AnimatePresence,{children:s&&n&&(0,t.jsx)(l.motion.div,{initial:{opacity:0,height:0}
1,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,ease:[.25,.46,.45,.94]},className:"overflow-hidden",children:(0,t.jsxs)("div",{className:"px-3 pb-3 border-t border-gray-100 dark:border-zinc-800",children:[(0,t.jsx)(eh,{options:d,onChange:e=>b(t=>({...t,[a]:e})),boardId:r,columnId:e._id}),!o&&0===d.length&&(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-1 italic",children:"No options yet. Add some above, then save."}),(0,t.jsx)("button",{onClick:()=>v(e),disabled:f,className:"mt-3 w-full text-xs py-2 rounded-xl font-semibold text-white transition-all hover:shadow-md disabled:opacity-50",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 12px rgba(236,72,153,0.20)"},children:f?"Savingâ¦":"Save options"})]})})})]},a)})}),(0,t.jsx)("div",{className:"px-5 pb-5 pt-2 flex-shrink-0 border-t border-gray-100 dark:border-zinc-800",children:x?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("input",{autoFocus:!0,type:"text",placeholder:"Column name",value:o,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&k(),className:"w-full text-sm px-3 py-2 rounded-xl focus:outline-none focus:ring-1 focus:ring-orange-300 text-gray-700 dark:text-zinc-300",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),(0,t.jsx)("select",{value:c,onChange:e=>u(e.target.value),className:"w-full text-sm px-3 py-2 rounded-xl focus:outline-none focus:ring-1 focus:ring-orange-300 text-gray-700 dark:text-zinc-300",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:eu.map(e=>(0,t.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:k,className:"flex-1 text-xs py-2 rounded-xl font-semibold text-white transition-all hover:shadow-md",style:{background:"linear-gradient(135deg, #F97316, #EC4899)"},children:"Add Column"}),(0,t.jsx)("button",{onClick:()=>{p(!1),d("")},className:"px-4 text-xs py-2 text-gray-500 dark:text-zinc-400 hover:bg-gray-100 dark:hover:bg-zinc-900 rounded-xl transition-colors",children:"Cancel"})]})]}):(0,t.jsxs)("button",{onClick:()=>p(!0),className:"w-full text-xs py-2 text-gray-400 dark:text-zinc-500 hover:text-orange-500 hover:bg-orange-50 dark:hover:bg-orange-500/10 rounded-xl transition-colors flex items-center justify-center gap-1",children:[(0,t.jsx)($.PlusIcon,{className:"w-3.5 h-3.5"}),"Add Column"]})})]})})}var eb=e.i(984174),ef=e.i(42473),ey=e.i(639793);let ev="ss-tasks-onboarding-v1",ek=[{title:"Type @ to tag",body:"Mention people, creators, or campaigns inline. Tasks auto-link to whatever you tag.",icon:ey.AtSymbolIcon,color:"#A855F7"},{title:"Type / for quick actions",body:"Slash commands set due dates, priority, and status without opening menus.",icon:ef.CommandLineIcon,color:"#F59E0B"},{title:"S, P, E shortcuts on any row",body:"Hover a task and tap S to cycle status, P for priority, E to archive. Shift+â« deletes.",icon:eb.SparklesIcon,color:"#EC4899"},{title:"âK creates from anywhere",body:"Hit âK anywhere in the app to add a task. Use the Paste tab to turn meeting notes into tasks.",icon:eb.SparklesIcon,color:"#6366F1"}];function ej(){let[e,r]=(0,a.useState)(!1),[s,n]=(0,a.useState)(0);function o(){r(!1),localStorage.setItem(ev,new Date().toISOString())}(0,a.useEffect)(()=>{if(!localStorage.getItem(ev)){let e=setTimeout(()=>r(!0),800);return()=>clearTimeout(e)}},[]);let d=ek[s],c=d?.icon;return(0,t.jsx)(i.AnimatePresence,{children:e&&d&&(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:16,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.96},transition:{duration:.3,ease:[.25,.46,.45,.94]},className:"fixed bottom-6 left-6 z-[80] w-[340px] rounded-2xl overflow-hidden",style:{background:"var(--panel-95)",backdropFilter:"blur(20px)",boxShadow:"0 16px 48px var(--shadow-ambient-lg), 0 4px 12px var(--surface-softer)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)(l.motion.div,{initial:{width:"0%"},animate:{width:"100%"},transition:{duration:.4},className:"h-[3px]",style:{background:d.color}},`bar-${s}`),(0,t.jsx)("div",{className:"absolute -top-8 -right-8 w-28 h-28 rounded-full opacity-20 blur-3xl pointer-events-none",style:{background:d.color}}),(0,t.jsxs)("div",{className:"relative p-5",children:[(0,t.jsx)("button",{onClick:o,className:"absolute top-3 right-3 w-7 h-7 flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors",children:(0,t.jsx)(T.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})}),(0,t.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:`${d.color}18`,border:`1px solid ${d.color}30`},children:(0,t.jsx)(c,{className:"w-4 h-4",style:{color:d.color}})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 pr-6",children:[(0,t.jsxs)("div",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:["Tip ",s+1," of ",ek.length]}),(0,t.jsx)("h3",{className:"text-sm font-black text-gray-900 dark:text-zinc-100 mt-0.5 tracking-tight",children:d.title})]})]}),(0,t.jsx)("p",{className:"text-[12px] text-gray-600 dark:text-zinc-400 leading-relaxed mb-4",children:d.body}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("div",{className:"flex items-center gap-1.5",children:ek.map((e,a)=>(0,t.jsx)("button",{onClick:()=>n(a),className:"h-1.5 rounded-full transition-all duration-200",style:{width:a===s?18:6,background:a===s?d.color:"var(--shadow-ambient-lg)"}},a))}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[s>0&&(0,t.jsx)("button",{onClick:function(){s>0&&n(s-1)},className:"text-[11px] font-semibold px-2.5 py-1 rounded-lg text-gray-500 dark:text-zinc-400 hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors",children:"Back"}),(0,t.jsx)("button",{onClick:function(){s<ek.length-1?n(s+1):o()},className:"text-[11px] font-bold px-3 py-1 text-white rounded-lg transition-all duration-200 hover:shadow-md",style:{background:d.color,boxShadow:`0 2px 8px ${d.color}30`},children:s===ek.length-1?"Got it":"Next"})]})]})]})]})})}var ew=e.i(191929),eN=e.i(633576),eC=e.i(365178),eS=e.i(592642),ez=e.i(586177);let e_=a.forwardRef(function({title:e,titleId:t,...r},s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},r),e?a.createElement("title",{id:t},e):null,a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m12.75 15 3-3m0 0-3-3m3 3h-7.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))});function eD({board:e,boards:r=[],taskCount:s=null,onClose:n,onArchived:i,onDeleted:o}){let[d,c]=(0,a.useState)(s),[u,x]=(0,a.useState)(""),[h,g]=(0,a.useState)(!1);(0,a.useEffect)(()=>
1{if(null!=d||!e?._id)return;let t=!1;return fetch(`/api/tasks?board=${e._id}&limit=1`).then(e=>e.ok?e.json():null).then(e=>{t||"number"==typeof e?.total&&c(e.total)}).catch(()=>{}),()=>{t=!0}},[e?._id,d]);let b=r.filter(t=>t._id?.toString()!==e?._id?.toString()&&!t.archived),f=null==d?"â¦":`${d} task${1===d?"":"s"}`;async function y(){if(!h){g(!0);try{let t=await fetch(`/api/task-boards/${e._id}/archive`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({archived:!0})});if(t.ok){let e=await t.json();L.default.success("Board archived"),i?.(e.board),n()}else{let e=await t.json().catch(()=>({}));L.default.error(e.error||"Couldn't archive")}}catch{L.default.error("Couldn't archive")}finally{g(!1)}}}async function v(){if(!h){g(!0);try{let t=await fetch(`/api/task-boards/${e._id}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(u?{transferTo:u}:{})});if(t.ok)L.default.success(u?"Board deleted, tasks moved":"Board deleted"),o?.({transferTo:u||null}),n();else{let e=await t.json().catch(()=>({}));L.default.error(e.error||"Couldn't delete")}}catch{L.default.error("Couldn't delete")}finally{g(!1)}}}return(0,t.jsx)(l.motion.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 z-[120] flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm",onClick:n,children:(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:14,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:14,scale:.97},transition:{duration:.22,ease:[.25,.46,.45,.94]},className:"relative w-full max-w-md rounded-2xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 20px 60px var(--shadow-ambient-2xl)",border:"1px solid var(--border-subtle)"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-amber-400 via-pink-500 to-red-500"}),(0,t.jsxs)("div",{className:"relative p-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(245,158,11,0.14), rgba(239,68,68,0.10))",border:"1px solid rgba(245,158,11,0.22)"},children:(0,t.jsx)(p.ArchiveBoxIcon,{className:"w-4 h-4 text-amber-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-[15px] font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:"Manage board"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-zinc-500 mt-0.5 truncate max-w-[260px]",children:e?.name})]})]}),(0,t.jsx)("button",{onClick:n,className:"w-7 h-7 flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900","aria-label":"Close",children:(0,t.jsx)(T.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})})]}),(0,t.jsxs)("div",{className:"rounded-lg p-2.5 mb-4 text-[11.5px] flex items-start gap-2",style:{background:"rgba(99,102,241,0.06)",border:"1px solid rgba(99,102,241,0.18)",color:"var(--text-secondary)"},children:[(0,t.jsx)(e_,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 text-indigo-500"}),(0,t.jsxs)("span",{children:["This board has ",(0,t.jsx)("b",{children:f}),". Archive keeps everything intact â you can restore it later. Delete is permanent."]})]}),(0,t.jsx)("div",{className:"rounded-xl p-3 mb-3",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:(0,t.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:"linear-gradient(135deg, rgba(245,158,11,0.16), rgba(245,158,11,0.06))"},children:(0,t.jsx)(p.ArchiveBoxIcon,{className:"w-4 h-4 text-amber-600"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h4",{className:"text-[12.5px] font-bold text-gray-800 dark:text-zinc-100 mb-0.5",children:"Archive (recommended)"}),(0,t.jsx)("p",{className:"text-[11.5px] text-gray-500 dark:text-zinc-400 mb-2.5",children:'Hides the board from the dropdown. Tasks stay where they are â toggle "Show archived boards" to bring it back.'}),(0,t.jsx)("button",{onClick:y,disabled:h,className:"text-[12px] font-bold px-3 py-2 rounded-lg text-white disabled:opacity-50 transition-all duration-200 hover:shadow-md",style:{background:"linear-gradient(135deg, #F59E0B, #D97706)",boxShadow:"0 4px 12px rgba(245,158,11,0.25)"},children:h?"Workingâ¦":"Archive board"})]})]})}),(0,t.jsx)("div",{className:"rounded-xl p-3",style:{background:"rgba(239,68,68,0.04)",border:"1px solid rgba(239,68,68,0.18)"},children:(0,t.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:"linear-gradient(135deg, rgba(239,68,68,0.16), rgba(239,68,68,0.06))"},children:(0,t.jsx)(m.TrashIcon,{className:"w-4 h-4 text-red-600"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h4",{className:"text-[12.5px] font-bold text-gray-800 dark:text-zinc-100 mb-0.5",children:"Delete permanently"}),(0,t.jsx)("p",{className:"text-[11.5px] text-gray-500 dark:text-zinc-400 mb-2.5",children:"Removes the board for everyone. Pick what happens to its tasks below."}),(0,t.jsx)("label",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1 block",children:"Move tasks to"}),(0,t.jsxs)("select",{value:u,onChange:e=>x(e.target.value),className:"w-full text-[12.5px] px-2.5 py-1.5 rounded-lg bg-white dark:bg-zinc-900 mb-2.5",style:{border:"1px solid var(--border-default)"},disabled:h,children:[(0,t.jsx)("option",{value:"",children:"â don't move (unlink tasks) â"}),b.map(e=>(0,t.jsx)("option",{value:e._id,children:e.name},e._id))]}),(0,t.jsx)("button",{onClick:()=>{window.confirm(`Permanently delete "${e?.name}
1"? This can't be undone.`)&&v()},disabled:h,className:"text-[12px] font-bold px-3 py-2 rounded-lg text-white disabled:opacity-50 transition-all duration-200 hover:shadow-md",style:{background:"linear-gradient(135deg, #DC2626, #B91C1C)",boxShadow:"0 4px 12px rgba(220,38,38,0.25)"},children:h?"Workingâ¦":"Delete board"})]})]})}),(0,t.jsx)("div",{className:"flex justify-end mt-4",children:(0,t.jsx)("button",{onClick:n,disabled:h,className:"text-[11.5px] font-semibold text-gray-500 dark:text-zinc-400 hover:text-gray-800 dark:hover:text-zinc-100 px-3 py-1.5",children:"Cancel"})})]})]})})}let eI=[{id:"complete-unblocks-dependents",name:"Complete unblocks dependents",description:"When a task is marked Done, every dependent task on linked boards is automatically restored from Stuck to its previous status.",plainEnglish:"When a task is marked Done, dependent tasks on linked boards automatically unblock.",rule:{name:"Recipe: Complete unblocks dependents",enabled:!0,trigger:{type:"status_changed",to:null},conditionGroups:[],conditions:[],conditionLogic:"AND",actions:[{type:"restore_from_stuck",target:"blocks"}]}}],eE=["from-pink-500 to-rose-400","from-orange-500 to-amber-400","from-violet-500 to-purple-400","from-blue-500 to-cyan-400","from-emerald-500 to-teal-400"];function e$(e){let t=(e||"").charCodeAt(0)%eE.length;return eE[t]}let eT=[{key:"agency",label:"Agency",description:"Anyone in your agency can see this board",icon:ew.GlobeAltIcon,color:"#6366F1"},{key:"team",label:"Team",description:"Only invited members can see this board",icon:eN.UserGroupIcon,color:"#F59E0B"},{key:"private",label:"Private",description:"Locked down â only invited members get access",icon:b.LockClosedIcon,color:"#EF4444"}];function eF({board:e,boards:r=[],teamMembers:s=[],currentUser:n,onClose:o,onSaved:d,onDelete:c,onArchived:u,initialTab:x}){let m=(0,a.useRef)(null),[h,g]=(0,a.useState)(!1),[f,v]=(0,a.useState)(e.visibility||"team"),[k,j]=(0,a.useState)(e.dueDateMode||"single"),[w,N]=(0,a.useState)((e.automations||[]).map((e,t)=>{let a=Array.isArray(e.conditionGroups)?e.conditionGroups:[],r=a.length>0?a.map(e=>({logic:"OR"===e.logic?"OR":"AND",conditions:(e.conditions||[]).map(e=>({field:e.field||"status",op:e.op||"equals",value:e.value||""}))})):(e.conditions||[]).length>0?[{logic:"OR"===e.conditionLogic?"OR":"AND",conditions:(e.conditions||[]).map(e=>({field:e.field||"status",op:e.op||"equals",value:e.value||""}))}]:[];return{_id:e._id||`local-${t}-${Math.random().toString(36).slice(2,8)}`,name:e.name||"",enabled:!1!==e.enabled,trigger:{type:e.trigger?.type||"status_changed",to:e.trigger?.to||""},conditionLogic:"OR"===e.conditionLogic?"OR":"AND",conditionGroups:r,actions:(e.actions||[]).map(e=>({type:e.type||"set_status",value:e.value||"",userId:e.userId?._id||e.userId||null,message:e.message||"",target:e.target||"self",field:e.field||"",destinationBoard:e.destinationBoard?._id||e.destinationBoard||"",linkBack:!1!==e.linkBack,taskTemplate:{title:e.taskTemplate?.title||"{{title}}",status:e.taskTemplate?.status||"",group:e.taskTemplate?.group||"",priority:e.taskTemplate?.priority||"",copyDescription:e.taskTemplate?.copyDescription||!1,copyLinks:e.taskTemplate?.copyLinks||!1,ownerMapping:e.taskTemplate?.ownerMapping||"none",mirrorFields:e.taskTemplate?.mirrorFields||[]}}))}})),[C,S]=(0,a.useState)(e.automations||[]),[z,_]=(0,a.useState)(null),[D,I]=(0,a.useState)((e.members||[]).map(e=>({_id:e._id||e,name:e.name,email:e.email,image:e.image}))),[E,F]=(0,a.useState)(e.header?.notes||""),[M,A]=(0,a.useState)((e.header?.links||[]).map(e=>({_id:e._id||crypto.randomUUID?.()||`local-${Math.random()}`,label:e.label||"",url:e.url||""}))),[P,B]=(0,a.useState)((e.header?.people||[]).map(e=>({_id:e._id||crypto.randomUUID?.()||`local-${Math.random()}`,user:"object"==typeof e.user?{_id:e.user?._id,name:e.user?.name,email:e.user?.email,image:e.user?.image}:{_id:e.user},role:e.role||""}))),[R,O]=(0,a.useState)(""),[U,W]=(0,a.useState)(""),[q,X]=(0,a.useState)(!1),[G,H]=(0,a.useState)(!1),[K,J]=(0,a.useState)((e.collaboratingAgencies||[]).map(e=>({_id:e._id||e,name:e.name,image:e.image}))),[V,Y]=(0,a.useState)((e.collaboratingUsers||[]).map(e=>({_id:e._id||e,name:e.name,email:e.email,image:e.image,agency:e.agency||null}))),[Z,Q]=(0,a.useState)(""),[ee,et]=(0,a.useState)([]),[ea,er]=(0,a.useState)(!1),[es,en]=(0,a.useState)(""),[el,ei]=(0,a.useState)([]),[eo,ed]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=Z.trim();if(e.length<2)return void et([]);let t=!1;er(!0);let a=setTimeout(async()=>{try{let a=await fetch(`/api/agencies/search?q=${encodeURIComponent(e)}`);
1if(!a.ok)return;let r=await a.json();t||et(r.agencies||[])}finally{t||er(!1)}},200);return()=>{t=!0,clearTimeout(a)}},[Z]),(0,a.useEffect)(()=>{let e=es.trim();if(e.length<2)return void ei([]);let t=!1;ed(!0);let a=setTimeout(async()=>{try{let a=await fetch(`/api/users/search?crossAgency=true&q=${encodeURIComponent(e)}`);if(!a.ok)return;let r=await a.json();t||ei(Array.isArray(r)?r:[])}finally{t||ed(!1)}},200);return()=>{t=!0,clearTimeout(a)}},[es]),(0,a.useEffect)(()=>{"automations"===x&&m.current&&requestAnimationFrame(()=>{m.current?.scrollIntoView({behavior:"smooth",block:"start"})})},[]);let ec=new Set(D.map(e=>e._id)),eu=e.createdBy?._id||e.createdBy,ex=n?.role==="super_admin"||n?._id?.toString()===eu?.toString();function ep(){let e=U.trim();if(!e)return;let t=/^https?:\/\//i.test(e)?e:`https://${e}`;A(e=>[...e,{_id:`local-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,label:R.trim(),url:t}]),O(""),W("")}async function em(t){if(!z){_(t);try{let a=await fetch(`/api/task-boards/${e._id}/recipes/${t}/apply`,{method:"POST"});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||"Failed to apply recipe")}let r=await a.json();S(r.board?.automations||[]),L.default.success("Recipe applied")}catch(e){L.default.error(e.message||"Couldn't apply recipe")}finally{_(null)}}}async function eh(t){if(!z){_(t);try{let a=await fetch(`/api/task-boards/${e._id}/recipes/${t}`,{method:"DELETE"});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||"Failed to remove recipe")}let r=await a.json();S(r.board?.automations||[]),L.default.success("Recipe removed")}catch(e){L.default.error(e.message||"Couldn't remove recipe")}finally{_(null)}}}async function eg(){H(!0);try{let t=U.trim(),a=t.length>0?[...M,{_id:`local-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,label:R.trim(),url:/^https?:\/\//i.test(t)?t:`https://${t}`}]:M;a!==M&&(A(a),O(""),W(""));let r=a.filter(e=>e.url?.trim()).map(e=>{let t=e.url.trim(),a=/^https?:\/\//i.test(t)?t:`https://${t}`;return{...e._id&&!String(e._id).startsWith("local-")?{_id:e._id}:{},label:e.label?.trim()||"",url:a}}),s=P.filter(e=>e.user?._id).map(e=>({...e._id&&!String(e._id).startsWith("local-")?{_id:e._id}:{},user:e.user._id,role:e.role?.trim()||""})),n=w.map(e=>{let t=(e.conditionGroups||[]).map(e=>({logic:"OR"===e.logic?"OR":"AND",conditions:(e.conditions||[]).filter(e=>e.field&&e.op).map(e=>({field:e.field,op:e.op,value:e.value?.toString?.().trim?.()||null}))})).filter(e=>e.conditions.length>0);return{...e._id&&!String(e._id).startsWith("local-")?{_id:e._id}:{},name:e.name?.trim()||"",enabled:!1!==e.enabled,trigger:{type:e.trigger.type,to:e.trigger.to?.trim()||null},conditionLogic:"OR"===e.conditionLogic?"OR":"AND",conditionGroups:t,conditions:t.flatMap(e=>e.conditions),actions:(e.actions||[]).map(e=>({type:e.type,value:e.value?.trim()||null,userId:e.userId||null,message:e.message?.trim()||"",target:e.target||null,field:e.field?.trim()||null,destinationBoard:e.destinationBoard||null,linkBack:!1!==e.linkBack,taskTemplate:e.taskTemplate?{title:e.taskTemplate.title?.trim()||"{{title}}",status:e.taskTemplate.status?.trim()||null,group:e.taskTemplate.group?.trim()||null,priority:e.taskTemplate.priority?.trim()||null,copyDescription:e.taskTemplate.copyDescription||!1,copyLinks:e.taskTemplate.copyLinks||!1,ownerMapping:e.taskTemplate.ownerMapping||"none",mirrorFields:e.taskTemplate.mirrorFields||[]}:void 0}))}}),l=await fetch(`/api/task-boards/${e._id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({visibility:f,members:D.map(e=>e._id),collaboratingAgencies:K.map(e=>e._id),collaboratingUsers:V.map(e=>e._id),dueDateMode:k,automations:n,header:{notes:E.trim(),links:r,people:s}})});if(l.ok){let e=await l.json();L.default.success("Board settings updated"),d?.(e.board),o()}else{let e=await l.json();L.default.error(e.error||"Failed to update")}}catch{L.default.error("Failed to update")}finally{H(!1)}}return(0,t.jsxs)(l.motion.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-[110] flex items-center justify-center p-4 bg-black/30 backdrop-blur-sm",onClick:o,children:[(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:16,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.96},transition:{duration:.25,ease:[.25,.46,.45,.94]},className:"relative w-full max-w-lg max-h-[90vh] flex flex-col rounded-2xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 20px 60px var(--shadow-ambient-2xl)",border:"1px solid var(--border-subtle)"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500 via-orange-400 to-violet-500"}),(0,t.jsx)("div",{className:"absolute -top-12 -right-12 w-40 h-40 rounded-full opacity-15 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, #F59E0B, #EC4899)"}}),(0,t.jsxs)("div",{className:"relative p-5 overflow-y-auto flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(99,102,241,0.12), rgba(236,72,153,0.12))",border:"1px solid rgba(99,102,241,0.18)"},children:(0,t.jsx)(eC.Cog6ToothIcon,{className:"w-4 h-4 text-indigo-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:"Board settings"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-0.5 truncate max-w-[260px]",children:e.name})]})]}),(0,t.jsx)("button",{onClick:o,className:"w-7 h-7 flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900",children:(0,t.jsx)(T.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})})]}),!ex&&(0,t.jsxs)("div",{className:"mb-4 rounded-lg p-2.5 text-[11px] flex items-start gap-2 text-amber-800 dark:text-amber-300",style:{background:"rgba(245,158,11,0.08)",border:"1px solid rgba(245,158,11,0.2)"},children:[(0,t.jsx)(b.LockClosedIcon,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),(0,t.jsx)("span",{children:"Only the board creator can change these settings. You can view them in read-only mode."})]}),(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsx)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-2 block",children:"Who can see this board"}),(0,t.jsx)("div",{className:"space-y-1.5",children:eT.map(e=>{let a=f===e.key,r=e.icon;return(0,t.jsxs)("button",{onClick:()=>ex&&v(e.key),disabled:!ex,className:"w-full text-left p-3 rounded-xl transition-all duration-150 flex items-start gap-2.5 disabled:cursor-not-allowed",style:{background:a?`linear-gradient(135deg, ${e.color}10, ${e.color}06)`:"var(--surface-soft)",border:a?`1.5px solid ${e.color}45`:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:a?e.color:`${e.color}15`},children:(0,t.jsx)(r,{className:"w-3.5 h-3.5",style:{color:a?"white":e.color}})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-[13px] font-bold text-gray-800 dark:text-zinc-100",children:e.label}),a&&(0,t.jsx)("span",{className:"text-[9px] font-black uppercase tracking-wider px-1.5 py-0.5 rounded flex-shrink-0",style:{background:e.color,color:"white"},children:"Active"})]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-0.5",children:e.description})]})]},e.key)})})]}),("team"===f||"private"===f)&&(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,t.jsxs)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em]",children:["Members (",D.length,")"]})}),(0,t.jsx)("div",{className:"rounded-xl p-2 max-h-56 overflow-y-auto",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:0===s.length?(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-3",children:"No teammates available"}):s.map(e=>
1{let a=ec.has(e._id),r=e._id?.toString()===eu?.toString();return(0,t.jsxs)("button",{onClick:()=>ex&&void(ec.has(e._id)?I(t=>t.filter(t=>t._id!==e._id)):I(t=>[...t,e])),disabled:!ex||r,className:"w-full p-2 rounded-lg flex items-center gap-2.5 transition-colors duration-100 hover:bg-white/60 dark:hover:bg-zinc-900/60 disabled:cursor-not-allowed",children:[(0,t.jsx)("div",{className:`w-7 h-7 rounded-full bg-gradient-to-br ${e$(e.name)} flex items-center justify-center text-white text-[10px] font-bold shadow-sm`,children:(e.name||"?")[0].toUpperCase()}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 text-left",children:[(0,t.jsxs)("div",{className:"text-[13px] font-semibold text-gray-800 dark:text-zinc-100 truncate",children:[e.name,r&&(0,t.jsx)("span",{className:"ml-1.5 text-[9px] font-bold uppercase tracking-wider text-violet-500 bg-violet-50 dark:bg-violet-500/15 dark:text-violet-300 px-1.5 py-0.5 rounded",children:"Creator"})]}),e.email&&(0,t.jsx)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500 truncate",children:e.email})]}),(0,t.jsx)("div",{className:"w-5 h-5 rounded-md flex-shrink-0 flex items-center justify-center transition-all",style:a||r?{background:"#10B981",boxShadow:"0 0 6px rgba(16,185,129,0.3)"}:{border:"1.5px dashed var(--shadow-ambient-xl)"},children:(a||r)&&(0,t.jsx)("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})]},e._id)})}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-1.5",children:"The creator always retains access."})]}),ex&&(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-2 flex items-center gap-1.5",children:[(0,t.jsx)(eN.UserGroupIcon,{className:"w-3 h-3"}),"Collaborate across agencies"]}),(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("div",{className:"text-[11px] font-semibold text-gray-600 dark:text-zinc-400 mb-1.5",children:["Invited agencies (",K.length,")"]}),K.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-2",children:K.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 pl-1 pr-2 py-1 rounded-full text-[11px] font-medium",style:{background:"rgba(99,102,241,0.08)",border:"1px solid rgba(99,102,241,0.2)",color:"#4F46E5"},children:[(0,t.jsx)("span",{className:`w-5 h-5 rounded-full bg-gradient-to-br ${e$(e.name)} text-white flex items-center justify-center text-[9px] font-bold shadow-sm`,children:(e.name||"?")[0].toUpperCase()}),(0,t.jsx)("span",{className:"truncate max-w-[180px]",children:e.name}),(0,t.jsx)("button",{type:"button",onClick:()=>{var t;return t=e._id,void J(e=>e.filter(e=>e._id!==t))},className:"ml-0.5 text-indigo-400 hover:text-indigo-700 transition-colors",title:"Remove agency",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3 h-3"})})]},e._id))}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"text",value:Z,onChange:e=>Q(e.target.value),placeholder:"Search agencies by nameâ¦",className:"w-full text-[12px] px-3 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-300/50",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),(ee.length>0||ea)&&Z.trim()&&(0,t.jsxs)("div",{className:"absolute z-10 left-0 right-0 mt-1 rounded-lg overflow-hidden",style:{background:"var(--surface-panel)",border:"1px solid var(--border-default)",boxShadow:"0 12px 32px var(--shadow-ambient-lg)"},children:[ea&&0===ee.length&&(0,t.jsx)("div",{className:"px-3 py-2 text-[11px] text-gray-400 dark:text-zinc-500",children:"Searchingâ¦"}),ee.filter(e=>!K.some(t=>t._id?.toString()===e._id?.toString())).map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{!K.some(t=>t._id===e._id)&&(J(t=>[...t,e]),Q(""),et([]))},className:"w-full px-3 py-2 flex items-center gap-2 hover:bg-gray-50 dark:hover:bg-zinc-900 text-left text-[12px]",children:[(0,t.jsx)("span",{className:`w-6 h-6 rounded-md bg-gradient-to-br ${e$(e.name)}
1 text-white flex items-center justify-center text-[10px] font-bold shadow-sm`,children:(e.name||"?")[0].toUpperCase()}),(0,t.jsx)("span",{className:"font-medium text-gray-700 dark:text-zinc-300 truncate",children:e.name}),e.country&&(0,t.jsx)("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-zinc-500",children:e.country})]},e._id))]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"text-[11px] font-semibold text-gray-600 dark:text-zinc-400 mb-1.5",children:["Individual guests (",V.length,")"]}),V.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-2",children:V.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 pl-1 pr-2 py-1 rounded-full text-[11px] font-medium",style:{background:"rgba(245,158,11,0.08)",border:"1px solid rgba(245,158,11,0.25)",color:"#B45309"},children:[e.image?(0,t.jsx)("img",{src:e.image,alt:e.name||"",className:"w-5 h-5 rounded-full object-cover"}):(0,t.jsx)("span",{className:`w-5 h-5 rounded-full bg-gradient-to-br ${e$(e.name)} text-white flex items-center justify-center text-[9px] font-bold`,children:(e.name||e.email||"?")[0].toUpperCase()}),(0,t.jsx)("span",{className:"truncate max-w-[180px]",children:e.name||e.email}),(0,t.jsx)("button",{type:"button",onClick:()=>{var t;return t=e._id,void Y(e=>e.filter(e=>e._id!==t))},className:"ml-0.5 text-amber-500 hover:text-amber-700 transition-colors",title:"Remove guest",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3 h-3"})})]},e._id))}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"text",value:es,onChange:e=>en(e.target.value),placeholder:"Search by name or emailâ¦",className:"w-full text-[12px] px-3 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-300/50",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),(el.length>0||eo)&&es.trim()&&(0,t.jsxs)("div",{className:"absolute z-10 left-0 right-0 mt-1 rounded-lg overflow-hidden",style:{background:"var(--surface-panel)",border:"1px solid var(--border-default)",boxShadow:"0 12px 32px var(--shadow-ambient-lg)"},children:[eo&&0===el.length&&(0,t.jsx)("div",{className:"px-3 py-2 text-[11px] text-gray-400 dark:text-zinc-500",children:"Searchingâ¦"}),el.filter(t=>!V.some(e=>e._id?.toString()===t._id?.toString())&&t._id?.toString()!==n?._id?.toString()&&(!t.agency||("object"==typeof t.agency?t.agency._id?.toString():t.agency.toString())!==(e.agency?._id?.toString()||e.agency?.toString?.()))).map(e=>{let a="object"==typeof e.agency&&e.agency?e.agency.name:null;return(0,t.jsxs)("button",{type:"button",onClick:()=>{var t;return t={_id:e._id,name:e.name,email:e.email,image:e.image,agency:e.agency||null},void(!V.some(e=>e._id===t._id)&&(Y(e=>[...e,t]),en(""),ei([])))},className:"w-full px-3 py-2 flex items-center gap-2 hover:bg-gray-50 dark:hover:bg-zinc-900 text-left text-[12px]",children:[e.image?(0,t.jsx)("img",{src:e.image,alt:e.name||"",className:"w-6 h-6 rounded-full object-cover"}):(0,t.jsx)("span",{className:`w-6 h-6 rounded-full bg-gradient-to-br ${e$(e.name||e.email)} text-white flex items-center justify-center text-[10px] font-bold`,children:(e.name||e.email||"?")[0].toUpperCase()}),(0,t.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"block font-medium text-gray-700 dark:text-zinc-300 truncate",children:e.name||e.email}),a&&(0,t.jsxs)("span",{className:"block text-[10px] text-gray-400 dark:text-zinc-500 truncate",children:[e.email," · ",a]})]}),(0,t.jsx)("span",{className:"text-[9px] uppercase font-bold px-1.5 py-0.5 rounded",style:{background:"rgba(245,158,11,0.1)",color:"#B45309"},children:"External"})]},e._id)})]})]}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-1.5",children:"Invited agencies + individual guests can be assigned tasks on this board. Only you can change board settings."})]})]}),(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-2 flex items-center gap-1.5",children:[(0,t.jsx)(eS.ChatBubbleBottomCenterTextIcon,{className:"w-3 h-3"}),"Board context"]}),(0,t.jsx)("textarea",{value:E,onChange:e=>ex&&F(e.target.value),disabled:!ex,placeholder:"Notes about this board â what it's for, who it serves, anything teammates should know.",rows:3,className:"w-full text-[12.5px] leading-relaxed text-gray-700 dark:text-zinc-300 placeholder-gray-300 dark:placeholder-zinc-500 bg-transparent roun
1ded-xl p-2.5 focus:outline-none focus:ring-2 focus:ring-orange-300/40 transition-all disabled:cursor-not-allowed mb-3",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",resize:"vertical"}}),(0,t.jsxs)("div",{className:"mb-3",children:[(0,t.jsxs)("div",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5 flex items-center gap-1.5",children:[(0,t.jsx)(y.LinkIcon,{className:"w-3 h-3"}),"Pinned links (",M.length,")"]}),(0,t.jsx)("div",{className:"space-y-1.5",children:M.map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("input",{type:"text",value:e.label,onChange:e=>ex&&A(t=>t.map((t,r)=>r===a?{...t,label:e.target.value}:t)),placeholder:"Label",disabled:!ex,className:"text-[12px] px-2 py-1.5 rounded-lg w-28 focus:outline-none focus:ring-2 focus:ring-orange-300/40 disabled:cursor-not-allowed",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),(0,t.jsx)("input",{type:"url",value:e.url,onChange:e=>ex&&A(t=>t.map((t,r)=>r===a?{...t,url:e.target.value}:t)),placeholder:"https://â¦",disabled:!ex,className:"text-[12px] px-2 py-1.5 rounded-lg flex-1 focus:outline-none focus:ring-2 focus:ring-orange-300/40 disabled:cursor-not-allowed",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),ex&&(0,t.jsx)("button",{type:"button",onClick:()=>A(e=>e.filter((e,t)=>t!==a)),className:"w-7 h-7 rounded-lg flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10",title:"Remove link",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3.5 h-3.5"})})]},e._id))}),ex&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5",children:[(0,t.jsx)("input",{type:"text",value:R,onChange:e=>O(e.target.value),placeholder:"Label",className:"text-[12px] px-2 py-1.5 rounded-lg w-28 focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px dashed var(--border-default)"}}),(0,t.jsx)("input",{type:"url",value:U,onChange:e=>W(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),ep())},placeholder:"https://â¦",className:"text-[12px] px-2 py-1.5 rounded-lg flex-1 focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px dashed var(--border-default)"}}),(0,t.jsx)("button",{type:"button",onClick:ep,className:"w-7 h-7 rounded-lg flex items-center justify-center text-gray-500 dark:text-zinc-400 hover:text-violet-500 hover:bg-violet-50 dark:hover:bg-violet-500/10",title:"Add link",children:(0,t.jsx)($.PlusIcon,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5 flex items-center gap-1.5",children:[(0,t.jsx)(eN.UserGroupIcon,{className:"w-3 h-3"}),"Tagged people (",P.length,")"]}),(0,t.jsx)("div",{className:"space-y-1.5",children:P.map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 p-1.5 rounded-lg",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:`w-7 h-7 rounded-full bg-gradient-to-br ${e$(e.user?.name)} flex items-center justify-center text-white text-[10px] font-bold shadow-sm flex-shrink-0`,children:(e.user?.name||"?")[0]?.toUpperCase()}),(0,t.jsx)("span",{className:"text-[12.5px] font-semibold text-gray-800 dark:text-zinc-100 truncate flex-shrink-0 max-w-[120px]",children:e.user?.name||"Member"}),(0,t.jsx)("input",{type:"text",value:e.role,onChange:e=>ex&&B(t=>t.map((t,r)=>r===a?{...t,role:e.target.value}:t)),placeholder:"Role (e.g. Account Manager)",disabled:!ex,className:"text-[12px] px-2 py-1 rounded-md flex-1 focus:outline-none focus:ring-2 focus:ring-orange-300/40 bg-transparent disabled:cursor-not-allowed"}),ex&&(0,t.jsx)("button",{type:"button",onClick:()=>B(e=>e.filter((e,t)=>t!==a)),className:"w-7 h-7 rounded-lg flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10 flex-shrink-0",title:"Remove person",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3.5 h-3.5"})})]},e._id))}),ex&&(0,t.jsxs)("div",{className:"mt-1.5",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>X(e=>!e),className:"inline-flex items-center gap-1.5 text-[11.5px] font-semibold px-2.5 py-1.5 rounded-lg transition-colors",style:{background:"var(--surface-soft)",border:"1px dashed var(--border-default)",color:"var(--text-secondary)"},children:[(0,t.jsx)($.PlusIcon,{className:"w-3 h-3"}),q?"Close picker":"Tag a teammate"]}),q&&(0,t.jsx)("div",{className:"rounded-xl p-2 mt-1.5 max-h-48 overflow-y-auto",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:0===s.filter(e=>!P.some(t=>t.user?._id?.toString()===e._id?.toString())).length?(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-2",children:"Everyone's already tagged."}):s.filter(e=>!P.some(t=>t.user?._id?.toString()===e._id?.toString())).map(e=>(0,t.jsxs)("button",{onClick:()=>{B(t=>[...t,{_id:`local-${e._id}-${Date.now()}`,user:{_id:e._id,name:e.name,email:e.email,image:e.image},role:""}]),X(!1)},className:"w-full p-1.5 rounded-md flex items-center gap-2.5 hover:bg-white/60 dark:hover:bg-zinc-900/60",children:[(0,t.jsx)("div",{className:`w-6 h-6 rounded-full bg-gradient-to-br ${e$(e.name)}
1 flex items-center justify-center text-white text-[10px] font-bold shadow-sm`,children:(e.name||"?")[0]?.toUpperCase()}),(0,t.jsx)("span",{className:"text-[12.5px] font-semibold text-gray-800 dark:text-zinc-100 truncate text-left flex-1",children:e.name})]},e._id))})]})]})]}),(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsx)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-2 block",children:"Due dates"}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2",children:[{key:"single",label:"Single date",hint:"One due date per task â best for to-dos."},{key:"range",label:"Timeline",hint:"Start + end date â best for sprints."}].map(e=>{let a=k===e.key;return(0,t.jsxs)("button",{onClick:()=>ex&&j(e.key),disabled:!ex,className:"text-left p-3 rounded-xl transition-all disabled:cursor-not-allowed",style:{background:a?"linear-gradient(135deg, rgba(249,115,22,0.10), rgba(236,72,153,0.06))":"var(--surface-soft)",border:a?"1.5px solid rgba(249,115,22,0.45)":"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"text-[13px] font-bold text-gray-800 dark:text-zinc-100",children:e.label}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-0.5",children:e.hint})]},e.key)})})]}),(0,t.jsxs)("div",{ref:m,className:"mb-5",children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-2 flex items-center gap-1.5",children:[(0,t.jsx)(ez.BoltIcon,{className:"w-3 h-3"}),"Recipes"]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-zinc-500 mb-2",children:"One-click automation presets â apply to instantly enable common workflows."}),(0,t.jsx)("div",{className:"space-y-2",children:eI.map(e=>{let a=C.some(t=>t.recipeId===e.id),r=z===e.id;return(0,t.jsx)("div",{className:"rounded-xl p-3",style:{background:a?"linear-gradient(135deg, rgba(16,185,129,0.06), rgba(99,102,241,0.04))":"var(--surface-soft)",border:a?"1px solid rgba(16,185,129,0.28)":"1px solid var(--border-subtle)"},children:(0,t.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:a?"rgba(16,185,129,0.15)":"rgba(99,102,241,0.10)"},children:(0,t.jsx)(ez.BoltIcon,{className:"w-3.5 h-3.5",style:{color:a?"#059669":"#6366F1"}})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[13px] font-bold text-gray-800 dark:text-zinc-100 tracking-tight",children:e.name}),(0,t.jsx)("span",{className:"text-[9px] font-black uppercase tracking-wider px-1.5 py-0.5 rounded flex-shrink-0",style:a?{background:"rgba(16,185,129,0.15)",color:"#059669",border:"1px solid rgba(16,185,129,0.30)"}:{background:"var(--surface-softer)",color:"var(--text-label)",border:"1px solid var(--border-subtle)"},children:a?"Active":"Not active"})]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-0.5 leading-relaxed",children:e.description}),(0,t.jsx)("p",{className:"text-[10.5px] text-gray-400 dark:text-zinc-500 mt-0.5 italic leading-snug",children:e.plainEnglish}),ex&&(0,t.jsx)("button",{type:"button",onClick:()=>a?eh(e.id):em(e.id),disabled:r,className:"mt-2 text-[11px] font-semibold px-3 py-1.5 rounded-lg transition-all duration-150 disabled:opacity-50",style:a?{background:"rgba(239,68,68,0.08)",color:"#DC2626",border:"1px solid rgba(239,68,68,0.20)"}:{background:"linear-gradient(135deg, rgba(99,102,241,0.12), rgba(16,185,129,0.08))",color:"#4F46E5",border:"1px solid rgba(99,102,241,0.25)"},children:r?a?"Removingâ¦":"Applyingâ¦":a?"Remove":"Apply"})]})]})},e.id)})})]}),(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-2 flex items-center justify-between",children:[(0,t.jsxs)("span",{children:["Automations (",w.length,")"]}),ex&&(0,t.jsx)("button",{onClick:()=>N(e=>[...e,{_id:`local-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:"",enabled:!0,trigger:{type:"status_changed",to:""},conditionLogic:"AND",conditionGroups:[],actions:[{type:"set_status",value:""}]}]),className:"text-[10px] font-bold text-violet-600 hover:text-violet-700 normal-case tracking-normal",children:"+ New rule"})]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-zinc-500 mb-2",children:'Run "when X â do Y" rules on tasks in this board.'}),(0,t.jsxs)("div",{className:"space-y-2",children:[0===w.length&&(0,t.jsx)("p",{className:"text-[11.5px] text-gray-400 dark:text-zinc-500 italic",children:"No automations yet. Add one to auto-set status, assign people, or notify on common patterns."}),w.map((a,n)=>(0,t.jsx)(eL,{rule:a,teamMembers:s,boards:r,currentBoardId:e._id,disabled:!ex,onChange:e=>N(t=>t.map((t,a)=>a===n?e:t)),onRemove:()=>N(e=>e.filter((e,t)=>
1t!==n))},a._id))]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:eg,disabled:!ex||G,className:"flex-1 text-xs px-4 py-2.5 text-white rounded-xl font-semibold disabled:opacity-40 transition-all duration-200 hover:shadow-md",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 12px rgba(236,72,153,0.25)"},children:G?"Savingâ¦":"Save settings"}),ex&&(0,t.jsxs)("button",{onClick:()=>g(!0),className:"text-xs px-3 py-2.5 rounded-xl font-semibold transition-all duration-200 flex items-center gap-1.5",style:{background:"rgba(239,68,68,0.06)",border:"1px solid rgba(239,68,68,0.18)",color:"#DC2626"},title:"Archive or delete this board",children:[(0,t.jsx)(p.ArchiveBoxIcon,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Archive / Delete"})]})]})]})]}),(0,t.jsx)(i.AnimatePresence,{children:h&&(0,t.jsx)(eD,{board:e,boards:r,onClose:()=>g(!1),onArchived:e=>{u?.(e),o?.()},onDeleted:()=>{c?.()}})})]})}let eM=new Set(["update_linked_task","restore_from_stuck","unblock_linked_tasks","notify_linked_board"]),eA=[{value:"status",label:"Status"},{value:"priority",label:"Priority"},{value:"dueDate",label:"Due date"},{value:"title",label:"Title"},{value:"description",label:"Description"}];function eL({rule:e,teamMembers:a=[],boards:r=[],currentBoardId:s,disabled:n=!1,onChange:l,onRemove:i}){function o(t){l({...e,trigger:{...e.trigger,...t}})}function d(t,a){l({...e,actions:e.actions.map((e,r)=>r===t?{...e,...a}:e)})}let c=e.conditionGroups||[];function u(t,a){l({...e,conditionGroups:c.map((e,r)=>r===t?{...e,...a}:e)})}function x(e,t,a){u(e,{conditions:c[e].conditions.map((e,r)=>r===t?{...e,...a}:e)})}return(0,t.jsxs)("div",{className:"rounded-xl p-2.5 space-y-2",style:{background:e.enabled?"var(--surface-soft)":"transparent",border:e.enabled?"1px solid rgba(99,102,241,0.18)":"1px dashed var(--border-default)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{value:e.name||"",onChange:t=>l({...e,name:t.target.value}),placeholder:"Untitled rule",disabled:n,className:"flex-1 text-[12px] font-bold text-gray-800 dark:text-zinc-100 bg-transparent focus:outline-none disabled:cursor-not-allowed"}),(0,t.jsx)("button",{onClick:()=>l({...e,enabled:!e.enabled}),disabled:n,className:"text-[10px] font-bold uppercase tracking-wider px-2 py-1 rounded-md disabled:cursor-not-allowed",style:{background:e.enabled?"rgba(16,185,129,0.12)":"var(--shadow-ambient-sm)",color:e.enabled?"#059669":"var(--text-tertiary)",border:e.enabled?"1px solid rgba(16,185,129,0.25)":"1px solid var(--border-subtle)"},children:e.enabled?"On":"Off"}),!n&&(0,t.jsx)("button",{onClick:i,className:"w-7 h-7 rounded-md flex items-center justify-center hover:bg-red-50 dark:hover:bg-red-500/10 text-gray-400 dark:text-zinc-500 hover:text-red-500",title:"Remove rule",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3.5 h-3.5"})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500",children:"When"}),(0,t.jsxs)("select",{value:e.trigger?.type||"status_changed",onChange:e=>o({type:e.target.value}),disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"},children:[(0,t.jsx)("option",{value:"status_changed",children:"status changes"}),(0,t.jsx)("option",{value:"priority_changed",children:"priority changes"}),(0,t.jsx)("option",{value:"task_created",children:"a task is created"}),(0,t.jsx)("option",{value:"due_overdue",children:"a task is overdue"})]}),(e.trigger?.type==="status_changed"||e.trigger?.type==="priority_changed")&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500",children:"to"}),(0,t.jsx)("input",{value:e.trigger?.to||"",onChange:e=>o({to:e.target.value}),placeholder:e.trigger?.type==="priority_changed"?"critical":"Done",disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md w-32 bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"}})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[c.map((r,s)=>(0,t.jsxs)("div",{children:[s>0&&(0,t.jsx)("div",{className:"flex items-center justify-center my-1",children:(0,t.jsx)("button",{onClick:()=>l({...e,conditionLogic:"OR"===e.conditionLogic?"AND":"OR"}),disabled:n,className:"text-[10px] font-bold uppercase tracking-[0.18em] px-2.5 py-1 rounded-full disabled:cursor-not-allowed",style:{background:"OR"===e.conditionLogic?"rgba(168,85,247,0.12)":"rgba(99,102,241,0.12)",color:"OR"===e.conditionLogic?"#9333EA":"#6366F1",border:"OR"===e.conditionLogic?"1px solid rgba(168,85,247,0.25)":"1px solid rgba(99,102,241,0.25)"},title:"Click to toggle AND / OR between groups",children:"OR"===e.conditionLogic?"Or":"And"})}),(0,t.jsxs)("div",{className:"rounded-lg p-2 space-y-1.5",style:{background:"rgba(99,102,241,0.04)",border:"1px dashed rgba(99,102,241,0.22)"},children:[(r.conditions||[]).map((e,l)=>{var i;return(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[0===l?(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500",children:"If"}):(0,t.jsx)("button",{onClick:()=>u(s,{logic:"OR"===r.logic?"AND":"OR"}),disabled:n,className:"text-[10px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-md disabled:cursor-not-allowed",style:{background:"OR"===r.logic?"rgba(168,85,247,0.12)":"rgba(99,102,241,0.12)",color:"OR"===r.logic?"#9333EA":"#6366F1",border:"OR"===r.logic?"1px solid rgba(168,85,247,0.25)":"1px solid rgba(99,102,241,0.25)"},title:"Click to toggle AND / OR within this group",children:"OR"===r.logic?"Or":"And"}),(0,t.jsxs)("select",{value:e.field,onChange:e=>x(s,l,{field:e.target.value}),disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"},children:[(0,t.jsx)("option",{value:"status",children:"status"}),(0,t.jsx)("option",{value:"priority",children:"priority"}),(0,t.jsx)("option",{value:"assignees",children:"assignee"}),(0,t.jsx)("option",{value:"collaborators",children:"collaborator"}),(0,t.jsx)("option",{value:"linkedCampaign",children:"campaign"}),(0,t.jsx)("option",{value:"linkedCreator",children:"creator"}),(0,t.jsx)("option",{value:"organization",children:"organization"}),(0,t.jsx)("option",{value:"dueDate",children:"due date"}),(0,t.jsx)("option",{value:"tags",children:"tag"})]}),(0,t.jsx)("select",{value:e.op,onChange:e=>{let t=e.target.value;x(s,l,"is_set"===t||"is_empty"===t?{op:t,value:""}:{op:t})},disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"},children:("dueDate"===(i=e.field)?[{value:"is_set",label:"is set"},{value:"is_empty",label:"is empty"},{value:"before",label:"is before"},{value:"after",label:"is after"}]:"assignees"===i||"collaborators"===i||"tags"===i?[{value:"contains",label:"contains"},{value:"not_contains",label:"does not contain"},{value:"is_set",label:"is set"},{value:"is_empty",label:"is empty"}]:[{value:"equals",label:"equals"},{value:"not_equals",label:"does not equal"},{value:"is_set",label:"is set"},{value:"is_empty",label:"is empty"}]).map(e=>(0,t.jsx)("option",{value:e.value,children:e.label},e.value))}),"is_set"!==e.op&&"is_empty"!==e.op&&(0,t.jsx)(eP,{cond:e,teamMembers:a,disabled:n,onChange:e=>x(s,l,{value:e})}),!n&&(0,t.jsx)("button",{onClick:()=>{u(s,{conditions:c[s].conditions.filter((e,t)=>
1t!==l)})},className:"w-6 h-6 rounded-md flex items-center justify-center hover:bg-red-50 dark:hover:bg-red-500/10 text-gray-400 dark:text-zinc-500 hover:text-red-500",title:"Remove condition",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3 h-3"})})]},l)}),(0,t.jsxs)("div",{className:"flex items-center justify-between pt-1",children:[n?(0,t.jsx)("span",{}):(0,t.jsx)("button",{onClick:()=>{u(s,{conditions:[...c[s].conditions||[],{field:"status",op:"equals",value:""}]})},className:"text-[11px] font-semibold text-violet-500 hover:text-violet-700 dark:text-violet-300",children:"+ Add to this group"}),!n&&c.length>1&&(0,t.jsx)("button",{onClick:()=>{l({...e,conditionGroups:c.filter((e,t)=>t!==s)})},className:"text-[10px] font-semibold text-gray-400 dark:text-zinc-500 hover:text-red-500",title:"Remove this group",children:"Remove group"})]})]})]},s)),!n&&(0,t.jsx)("button",{onClick:function(){l({...e,conditionGroups:[...c,{logic:"AND",conditions:[{field:"status",op:"equals",value:""}]}]})},className:"text-[11px] font-semibold text-violet-500 hover:text-violet-700 dark:text-violet-300",children:0===c.length?"+ Add condition":"+ Add another group"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(e.actions||[]).map((i,o)=>(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500",children:0===o?"Then":"And"}),(0,t.jsxs)("select",{value:i.type,onChange:e=>d(o,{type:e.target.value}),disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"},children:[(0,t.jsxs)("optgroup",{label:"This task",children:[(0,t.jsx)("option",{value:"set_status",children:"set status"}),(0,t.jsx)("option",{value:"set_priority",children:"set priority"}),(0,t.jsx)("option",{value:"assign_user",children:"assign user"}),(0,t.jsx)("option",{value:"notify_user",children:"notify user"})]}),(0,t.jsxs)("optgroup",{label:"Cross-board",children:[(0,t.jsx)("option",{value:"create_task_on_board",children:"create task on board"}),(0,t.jsx)("option",{value:"update_linked_task",children:"update linked task"}),(0,t.jsx)("option",{value:"unblock_linked_tasks",children:"unblock linked tasks"}),(0,t.jsx)("option",{value:"notify_linked_board",children:"notify linked board"}),(0,t.jsx)("option",{value:"restore_from_stuck",children:"restore linked from stuck"})]})]}),eM.has(i.type)&&(0,t.jsxs)("select",{value:i.target||"linkedTasks",onChange:e=>d(o,{target:e.target.value}),disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"},children:[(0,t.jsx)("option",{value:"self",children:"self"}),(0,t.jsx)("option",{value:"linkedTasks",children:"linked tasks"}),(0,t.jsx)("option",{value:"blocks",children:"tasks this blocks"}),(0,t.jsx)("option",{value:"blockedBy",children:"tasks blocking this"})]}),("set_status"===i.type||"set_priority"===i.type)&&(0,t.jsx)("input",{value:i.value||"",onChange:e=>d(o,{value:e.target.value}),placeholder:"set_priority"===i.type?"low":"Done",disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md w-32 bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"}}),("assign_user"===i.type||"notify_user"===i.type)&&(0,t.jsxs)("select",{value:i.userId||"",onChange:e=>d(o,{userId:e.target.value}),disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed flex-1 min-w-[140px]",style:{border:"1px solid var(--border-default)"},children:[(0,t.jsx)("option",{value:"",children:"â pick a teammate â"}),a.map(e=>(0,t.jsx)("option",{value:e._id,children:e.name},e._id))]}),"notify_user"===i.type&&(0,t.jsx)("input",{value:i.message||"",onChange:e=>d(o,{message:e.target.value}),placeholder:"Optional message",disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md flex-1 bg-white dark:bg-zinc-900 disabled:cursor-not-allowed min-w-[140px]",style:{border:"1px solid var(--border-default)"}}
1),"notify_linked_board"===i.type&&(0,t.jsx)("input",{value:i.message||"",onChange:e=>d(o,{message:e.target.value}),placeholder:"Optional message to linked board",disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md flex-1 bg-white dark:bg-zinc-900 disabled:cursor-not-allowed min-w-[140px]",style:{border:"1px solid var(--border-default)"}}),"update_linked_task"===i.type&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("select",{value:i.field||"status",onChange:e=>d(o,{field:e.target.value}),disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"},children:[(0,t.jsx)("option",{value:"status",children:"status"}),(0,t.jsx)("option",{value:"priority",children:"priority"}),(0,t.jsx)("option",{value:"dueDate",children:"due date"})]}),(0,t.jsx)("input",{value:i.value||"",onChange:e=>d(o,{value:e.target.value}),placeholder:"priority"===i.field?"low":"dueDate"===i.field?"YYYY-MM-DD":"Done",disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md w-32 bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"}})]}),!n&&e.actions.length>1&&(0,t.jsx)("button",{onClick:()=>{l({...e,actions:e.actions.filter((e,t)=>t!==o)})},className:"w-6 h-6 rounded-md flex items-center justify-center hover:bg-red-50 dark:hover:bg-red-500/10 text-gray-400 dark:text-zinc-500 hover:text-red-500",title:"Remove action",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3 h-3"})})]}),"create_task_on_board"===i.type&&(0,t.jsxs)("div",{className:"ml-8 rounded-lg p-2.5 space-y-2",style:{background:"rgba(99,102,241,0.04)",border:"1px dashed rgba(99,102,241,0.22)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 w-20 shrink-0",children:"Board"}),(0,t.jsxs)("select",{value:i.destinationBoard||"",onChange:e=>d(o,{destinationBoard:e.target.value}),disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md flex-1 min-w-[160px] bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"},children:[(0,t.jsx)("option",{value:"",children:"â pick a destination board â"}),r.map(e=>(0,t.jsxs)("option",{value:e._id,children:[e.name,e._id===s?" (this board)":""]},e._id))]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 w-20 shrink-0",children:"Title"}),(0,t.jsx)("input",{value:i.taskTemplate?.title??"{{title}}",onChange:e=>d(o,{taskTemplate:{...i.taskTemplate,title:e.target.value}}),placeholder:"{{title}}",disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md flex-1 min-w-[160px] bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"},title:"Use {{title}} to copy the source task's title"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 w-20 shrink-0",children:"Status"}),(0,t.jsx)("input",{value:i.taskTemplate?.status||"",onChange:e=>d(o,{taskTemplate:{...i.taskTemplate,status:e.target.value}}),placeholder:"leave blank for board default",disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md w-40 bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"}}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500",children:"Priority"}),(0,t.jsx)("input",{value:i.taskTemplate?.priority||"",onChange:e=>d(o,{taskTemplate:{...i.taskTemplate,priority:e.target.value}}),placeholder:"optional",disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md w-24 bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"}})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 w-20 shrink-0",children:"Group"}),(0,t.jsx)("input",{value:i.taskTemplate?.group||"",onChange:e=>d(o,{taskTemplate:{...i.taskTemplate,group:e.target.value}}),placeholder:"section / group name (optional)",disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md flex-1 min-w-[160px] bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"}})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 w-20 shrink-0",children:"Owner"}),(0,t.jsxs)("select",{value:i.taskTemplate?.ownerMapping||"none",onChange:e=>d(o,{taskTemplate:{...i.taskTemplate,ownerMapping:e.target.value}}),disabled:n,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"},children:[(0,t.jsx)("option",{value:"none",children:"no owner"}),(0,t.jsx)("option",{value:"copyAssignees",children:"copy assignees"}),(0,t.jsx)("option",{value:"sourceCreator",children:"source creator"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,t.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:i.taskTemplate?.copyDescription||!1,onChange:e=>d(o,{taskTemplate:{...i.taskTemplate,copyDescription:e.target.checked}}),disabled:n,className:"w-3 h-3 rounded accent-indigo-500 disabled:cursor-not-allowed"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-600 dark:text-zinc-400",children:"Copy description"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:i.taskTemplate?.copyLinks||!1,onChange:e=>d(o,{taskTemplate:{...i.taskTemplate,copyLinks:e.target.checked}}),disabled:n,className:"w-3 h-3 rounded accent-indigo-500 disabled:cursor-not-allowed"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-600 dark:text-zinc-400",children:"Copy links"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:!1!==i.linkBack,onChange:e=>d(o,{linkBack:e.target.checked}),disabled:n,className:"w-3 h-3 rounded accent-indigo-500 disabled:cursor-not-allowed"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-600 dark:text-zinc-400",children:"Link back (reciprocal)"})]})]}),(0,t.jsxs)("div",{className:"flex items-start gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 w-20 shrink-0 pt-0.5",children:"Mirror"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:eA.map(e=>{let a=(i.taskTemplate?.mirrorFields||[]).includes(e.value);return(0,t.jsx)("button",{type:"button",disabled:n,onClick:()=>{let t=i.taskTemplate?.mirrorFields||[],r=a?t.filter(t=>t!==e.value):[...t,e.value];d(o,{taskTemplate:{...i.taskTemplate,mirrorFields:r}})},className:"text-[10px] font-semibold px-2 py-0.5 rounded-full transition-all disabled:cursor-not-allowed",style:a?{background:"rgba(99,102,241,0.15)",color:"#4F46E5",border:"1px solid rgba(99,102,241,0.35)"}:{background:"var(--surface-soft)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:e.label},e.value)})}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-zinc-500 italic self-end ml-1",children:"keep connected (mirror)"})]})]})]},o)),!n&&(0,t.jsx)("button",{onClick:function(){l({...e,actions:[...e.actions||[],{type:"notify_user",value:""}]})},className:"text-[11px] font-semibold text-violet-500 hover:text-violet-700 dark:text-violet-300",children:"+ Add another action"})]})]})}function eP({cond:e,teamMembers:a,disabled:r,onChange:s}){return"assignees"===e.field||"collaborators"===e.field?(0,t.jsxs)("select",{value:e.value||"",onChange:e=>s(e.target.value),disabled:r,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed flex-1 min-w-[140px]",style:{border:"1px solid var(--border-default)"},children:[(0,t.jsx)("option",{value:"",children:"â pick a teammate â"}),a.map(e=>(0,t.jsx)("option",{value:e._id,children:e.name},e._id))]}):"dueDate"===e.field&&("before"===e.op||"after"===e.op)?(0,t.jsx)("input",{type:"date",value:e.value||"",onChange:e=>s(e.target.value),disabled:r,className:"text-[11.5px] px-2 py-1 rounded-md bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"}}):(0,t.jsx)("input",{value:e.value||"",onChange:e=>s(e.target.value),placeholder:"priority"===e.field?"critical":"status"===e.field?"Done":"value",disabled:r,className:"text-[11.5px] px-2 py-1 rounded-md flex-1 min-w-[120px] bg-white dark:bg-zinc-900 disabled:cursor-not-allowed",style:{border:"1px solid var(--border-default)"}})}var eB=e.i(541179),eR=e.i(39875);let eO=["from-pink-500 to-rose-400","from-orange-500 to-amber-400","from-violet-500 to-purple-400","from-blue-500 to-cyan-400","from-emerald-500 to-teal-400"],eU=[{key:"agency",label:"Agency",de
1scription:"Anyone in your agency can see this board",icon:ew.GlobeAltIcon,color:"#6366F1"},{key:"team",label:"Team",description:"Only invited members can see this board",icon:eN.UserGroupIcon,color:"#F59E0B"},{key:"private",label:"Private",description:"Locked down â only invited members get access",icon:b.LockClosedIcon,color:"#EF4444"}],eW=[{key:"blank",label:"Blank",description:"Just a clean board",icon:eB.ClipboardDocumentListIcon,color:"var(--text-tertiary)"},{key:"kanban",label:"Kanban",description:"To Do â In Progress â Review â Done",icon:eb.SparklesIcon,color:"#F97316",groups:[{name:"To Do",color:"#6366F1",position:0},{name:"In Progress",color:"#F59E0B",position:1},{name:"Review",color:"#A855F7",position:2},{name:"Done",color:"#10B981",position:3}]},{key:"campaign",label:"Campaign",description:"Brief â Production â Live â Wrap",icon:eb.SparklesIcon,color:"#EC4899",groups:[{name:"Brief",color:"#6366F1",position:0},{name:"Production",color:"#F59E0B",position:1},{name:"Live",color:"#10B981",position:2},{name:"Wrap",color:"var(--text-label)",position:3}]}];function eq({teamMembers:e=[],currentUser:r,onClose:s,onCreated:n}){let[o,d]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[x,p]=(0,a.useState)("team"),[m,h]=(0,a.useState)("kanban"),[g,b]=(0,a.useState)([]),[f,y]=(0,a.useState)(""),[v,k]=(0,a.useState)(!1),j=new Set(g.map(e=>e._id)),w=(0,a.useMemo)(()=>{let t=f.trim().toLowerCase(),a=(e||[]).filter(e=>e._id!==r?._id);return[...t?a.filter(e=>e.name?.toLowerCase().includes(t)||e.email?.toLowerCase().includes(t)):a].sort((e,t)=>{let a=+!!j.has(e._id),r=+!!j.has(t._id);return a!==r?r-a:(e.name||"").localeCompare(t.name||"")})},[e,r?._id,f,g]);async function N(){if(o.trim()){k(!0);try{let e=eW.find(e=>e.key===m),t=await fetch("/api/task-boards",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o.trim(),description:c.trim(),visibility:x,members:g.map(e=>e._id),...e?.groups?{groups:e.groups}:{}})});if(t.ok){let e=await t.json();L.default.success(`Board "${o.trim()}" created`),n?.(e.board),s()}else{let e=await t.json().catch(()=>({}));L.default.error(e.error||"Failed to create board")}}catch{L.default.error("Failed to create board")}finally{k(!1)}}}let C=eU.find(e=>e.key===x)?.icon||eN.UserGroupIcon;return(0,t.jsx)(l.motion.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-[110] flex items-center justify-center p-4 bg-black/30 backdrop-blur-sm",onClick:s,children:(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:16,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.96},transition:{duration:.25,ease:[.25,.46,.45,.94]},className:"relative w-full max-w-lg rounded-2xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 20px 60px var(--shadow-ambient-2xl)",border:"1px solid var(--border-subtle)"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500 via-orange-400 to-violet-500"}),(0,t.jsx)("div",{className:"absolute -top-12 -right-12 w-44 h-44 rounded-full opacity-20 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, #F59E0B, #EC4899)"}}),(0,t.jsx)("div",{className:"absolute -bottom-12 -left-12 w-44 h-44 rounded-full opacity-15 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, #6366F1, #A855F7)"}}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("div",{className:"px-6 pt-5 pb-3 flex items-start justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(249,115,22,0.15), rgba(236,72,153,0.15))",border:"1px solid rgba(249,115,22,0.2)"},children:(0,t.jsx)(eB.ClipboardDocumentListIcon,{className:"w-4 h-4 text-orange-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"New board"}),(0,t.jsx)("h3",{className:"text-base font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:"Create a board"})]})]}),(0,t.jsx)("button",{onClick:s,className:"w-7 h-7 flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900",children:(0,t.jsx)(T.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})})]}),(0,t.jsxs)("div",{className:"px-6 pb-5 space-y-5 max-h-[calc(85vh-120px)] overflow-y-auto",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-1.5 block",children:"Board name"}),(0,t.jsx)("input",{autoFocus:!0,value:o,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&o.trim()&&N()},placeholder:"e.g. Q4 launches, Acme org, Editorial pipeline",className:"w-full text-sm font-medium px-3.5 py-2.5 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300/50 transition-all",style:{background:"var(--surface-soft)",border:"1px solid var(--border-default)"}})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-1.5 block",children:["Description",(0,t.jsx)("span",{className:"ml-1.5 text-gray-300 dark:text-zinc-700 normal-case tracking-normal font-normal",children:"optional"})]}),(0,t.jsx)("input",{value:c,onChange:e=>u(e.target.value),placeholder:"What's this board for?",className:"w-full text-sm px-3.5 py-2.5 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300/50 transition-all",style:{background:"var(--surface-soft)",border:"1px solid var(--border-default)"}})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-2 block",children:"Starting template"}),(0,t.jsx)("div",{className:"grid grid-cols-3 gap-2",children:eW.map(e=>{let a=m===e.key,r=e.icon;return(0,t.jsxs)("button",{onClick:()=>h(e.key),className:"text-left p-2.5 rounded-xl transition-all duration-200",style:{background:a?`linear-gradient(135deg, ${e.color}10, ${e.color}06)`:"var(--surface-soft)",border:a?`1.5px solid ${e.color}40`:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center mb-1.5",style:{background:a?e.color:`${e.color}15`},children:(0,t.jsx)(r,{className:"w-3.5 h-3.5",style:{color:a?"white":e.color}})}),(0,t.jsx)("div",{className:"text-[12px] font-bold text-gray-800 dark:text-zinc-100",children:e.label}),(0,t.jsx)("div",{className:"text-[10px] text-gray-500 dark:text-zinc-400 mt-0.5 leading-snug",children:e.description})]},e.key)})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] mb-2 block",children:"Who can see this board"}),(0,t.jsx)("div",{className:"space-y-1.5",children:eU.map(e=>{let a=x===e.key,r=e.icon;return(0,t.jsxs)("button",{onClick:()=>p(e.key),className:"w-full text-left p-2.5 rounded-xl transition-all duration-150 flex items-start gap-2.5",style:{background:a?`linear-gradient(135deg, ${e.color}10, ${e.color}06)`:"var(--surface-soft)",border:a?`1.5px solid ${e.color}45`:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:a?e.color:`${e.color}15`},children:(0,t.jsx)(r,{className:"w-3.5 h-3.5",style:{color:a?"white":e.color}})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-[13px] font-bold text-gray-800 dark:text-zinc-100",children:e.label}),a&&(0,t.jsx)("span",{className:"text-[9px] font-black uppercase tracking-wider px-1.5 py-0.5 rounded flex-shrink-0",style:{background:e.color,color:"white"},children:"Active"})]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-0.5",children:e.description})]})]},e.key)})})]}),(0,t.jsx)(i.AnimatePresence,{children:("team"===x||"private"===x)&&(0,t.jsxs)(l.motion.div,{initial:{opacity:0,height:0}
1,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em]",children:["Members (",g.length,")"]}),g.length>0&&(0,t.jsx)("button",{type:"button",onClick:()=>b([]),className:"text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-zinc-500 hover:text-red-500 transition-colors",children:"Clear"})]}),(0,t.jsxs)("div",{className:"relative mb-2 rounded-xl",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)(eR.MagnifyingGlassIcon,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400 dark:text-zinc-500 pointer-events-none"}),(0,t.jsx)("input",{type:"text",value:f,onChange:e=>y(e.target.value),placeholder:"Search teammates by name or email",className:"w-full text-[12.5px] pl-7 pr-7 py-2 rounded-xl bg-transparent text-gray-900 dark:text-zinc-100 placeholder-gray-400 dark:placeholder-zinc-500 focus:outline-none focus:ring-2 focus:ring-orange-300/40"}),f&&(0,t.jsx)("button",{type:"button",onClick:()=>y(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 w-6 h-6 rounded-md flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-gray-600 dark:hover:text-zinc-300 hover:bg-gray-100 dark:hover:bg-zinc-900","aria-label":"Clear search",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3 h-3"})})]}),(0,t.jsx)("div",{className:"rounded-xl p-2 max-h-64 overflow-y-auto",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:0===e.length?(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-3",children:"No teammates available"}):0===w.length?(0,t.jsxs)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-3",children:["No matches for â",f,"â"]}):w.map(e=>{let a,r=j.has(e._id);return(0,t.jsxs)("button",{type:"button",onClick:()=>{j.has(e._id)?b(t=>t.filter(t=>t._id!==e._id)):b(t=>[...t,e])},className:"w-full p-2 rounded-lg flex items-center gap-2.5 transition-colors duration-100 hover:bg-white/60 dark:hover:bg-zinc-900/60",children:[e.image?(0,t.jsx)("img",{src:e.image,alt:e.name||"",className:"w-7 h-7 rounded-full object-cover flex-shrink-0 shadow-sm"}):(0,t.jsx)("div",{className:`w-7 h-7 rounded-full bg-gradient-to-br ${(a=(e.name||"").charCodeAt(0)%eO.length,eO[a])} flex items-center justify-center text-white text-[10px] font-bold shadow-sm flex-shrink-0`,children:(e.name||"?")[0].toUpperCase()}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 text-left",children:[(0,t.jsx)("div",{className:"text-[13px] font-semibold text-gray-800 dark:text-zinc-100 truncate",children:e.name}),e.email&&(0,t.jsx)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500 truncate",children:e.email})]}),(0,t.jsx)("div",{className:"w-5 h-5 rounded-md flex-shrink-0 flex items-center justify-center transition-all",style:r?{background:"#10B981",boxShadow:"0 0 6px rgba(16,185,129,0.3)"}:{border:"1.5px dashed var(--border-default)"},children:r&&(0,t.jsx)("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})]},e._id)})}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-1.5",children:"You'll always have access as the creator. Add anyone else who needs to see this board."})]})})]}),(0,t.jsxs)("div",{className:"px-6 py-3.5 flex items-center justify-between gap-3 border-t",style:{borderColor:"var(--border-subtle)",background:"var(--shadow-ambient-xs)"},children:[(0,t.jsxs)("span",{className:"text-[11px] text-gray-400 dark:text-zinc-500 flex items-center gap-1.5",children:[(0,t.jsx)(C,{className:"w-3 h-3"}),"agency"===x?"Visible to your whole agency":`${g.length} member${1===g.length?"":"s"} invited`]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:s,className:"text-xs font-semibold px-3 py-2 rounded-xl text-gray-600 dark:text-zinc-400 hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors",children:"Cancel"}),(0,t.jsx)("button",{onClick:N,disabled:!o.trim()||v,className:"text-xs font-bold px-4 py-2 text-white rounded-xl disabled:opacity-40 transition-all duration-300 hover:shadow-md hover:-translate-y-0.5",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 12px rgba(236,72,153,0.25)"},children:v?"Creatingâ¦":"Create board"})]})]})]})]})})}var eX=e.i(263150);function eG({task:e,onClose:r,onDelete:s,onArchive:n}){let[i,o]=(0,a.useState)(!1);async function d(){o(!0);try{await s?.()}finally{o(!1)}}async function c(){if(n){o(!0);try{await n()}finally{o(!1)}}}return(0,a.useEffect)(()=>{function e(e){"Escape"!==e.key||i||r()}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i,r]),(0,t.jsx)(l.motion.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-[120] flex items-center justify-center p-4 bg-black/35 backdrop-blur-sm",onClick:r,children:(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:16,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.96},transition:{duration:.25,ease:[.25,.46,.45,.94]},className:"relative w-full max-w-md rounded-2xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 20px 60px var(--shadow-ambient-xl)",border:"1px solid var(--border-default)"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-red-500 via-rose-500 to-orange-500"}),(0,t.jsx)("div",{className:"absolute -top-12 -right-12 w-44 h-44 rounded-full opacity-15 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, #EF4444, #F97316)"}}),(0,t.jsxs)("div",{className:"relative p-5",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(239,68,68,0.15), rgba(249,115,22,0.15))",border:"1px solid rgba(239,68,68,0.2)"},children:(0,t.jsx)(eX.ExclamationTriangleIcon,{className:"w-4 h-4 text-red-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-red-500",children:"Permanent action"}),(0,t.jsx)("h3",{className:"text-base font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:"Delete this task?"})]})]}),(0,t.jsx)("button",{onClick:r,className:"w-7 h-7 flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900",children:(0,t.jsx)(T.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})})]}),(0,t.jsxs)("div",{className:"rounded-xl p-3 mb-4",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-[0.14em] mb-1",style:{color:e?.status==="Done"||e?.status==="Complete"?"#10B981":"var(--text-tertiary)"},children:e?.status||"Task"}),(0,t.jsx)("div",{className:"text-sm font-semibold text-gray-800 dark:text-zinc-100 truncate",children:e?.title}),e?.description&&(0,t.jsx)("div",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-1 line-clamp-2",children:e.description}),(e?.comments?.length>0||e?.subItems?.length>0||e?.assignees?.length>0)&&(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-gray-100 dark:border-zinc-800",children:[e.assignees?.length>0&&(0,t.jsxs)("span",{className:"text-[10px] text-gray-500 dark:text-zinc-400",children:[(0,t.jsx)("span",{className:"font-bold",children:e.assignees.length})," ","assignee",1===e.assignees.length?"":"s"]}),e.subItems?.length>0&&(0,t.jsxs)("span",{className:"text-[10px] text-gray-500 dark:text-zinc-400",children:[(0,t.jsx)("span",{className:"font-bold",children:e.subItems.length})," ","sub-task",1===e.subItems.length?"":"s"]}),e.comments?.length>0&&(0,t.jsxs)("span",{className:"text-[10px] text-gray-500 dark:text-zinc-400",children:[(0,t.jsx)("span",{className:"font-bold",children:e.comments.length})," ","comment",1===e.comments.length?"":"s"]})]})]}),(0,t.jsxs)("p",{className:"text-[12px] text-gray-500 dark:text-zinc-400 leading-relaxed mb-5",children:["This permanently removes the task and all of its sub-tasks, comments, and history. This cannot be undone.",n&&(0,t.jsxs)("span",{className:"block mt-1.5",children:["If you might want it back later, consider"," ",(0,t.jsx)("strong",{className:"text-amber-600",children:"archiving"})," instead â hidden from the board but recoverable."]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{onClick:r,disabled:i,className:"text-xs font-semibold px-3 py-2 rounded-xl text-gray-600 dark:text-zinc-400 hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors disabled:opacity-40",children:"Cancel"}),n&&(0,t.jsxs)("button",{onClick:c,disabled:i,className:"text-xs font-bold px-3 py-2 rounded-xl flex items-center gap-1.5 transition-all duration-200 hover:shadow-md disabled:opacity-40",style:{background:"linear-gradient(135deg, rgba(245,158,11,0.1), rgba(245,158,11,0.06))",color:"#D97706",border:"1px solid rgba(245,158,11,0.25)"},children:[(0,t.jsx)(p.ArchiveBoxIcon,{className:"w-3 h-3"}),"Archive instead"]}),(0,t.jsxs)("button",{onClick:d,disabled:i,className:"text-xs font-bold px-4 py-2 text-white rounded-xl flex items-center gap-1.5 transition-all duration-200 hover:shadow-md hover:-translate-y-0.5 disabled:opacity-40",style:{background:"linear-gradient(135deg, #EF4444, #DC2626)",boxShadow:"0 4px 12px rgba(239,68,68,0.25)"},autoFocus:!0,children:[(0,t.jsx)(m.TrashIcon,{className:"w-3 h-3"}),i?"Deletingâ¦":"Delete task"]})]})]})]})})}var eH=e.i(174080),eK=e.i(858690);let eJ=a.forwardRef(function({title:e,titleId:t,...r},s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"
1currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},r),e?a.createElement("title",{id:t},e):null,a.createElement("path",{fillRule:"evenodd",d:"M6.32 2.577a49.255 49.255 0 0 1 11.36 0c1.497.174 2.57 1.46 2.57 2.93V21a.75.75 0 0 1-1.085.67L12 18.089l-7.165 3.583A.75.75 0 0 1 3.75 21V5.507c0-1.47 1.073-2.756 2.57-2.93Z",clipRule:"evenodd"}))});var eV=e.i(647187);let eY=["from-pink-500 to-rose-400","from-orange-500 to-amber-400","from-violet-500 to-purple-400","from-blue-500 to-cyan-400","from-emerald-500 to-teal-400"],eZ=[{value:"critical",label:"Critical",color:"#EF4444"},{value:"high",label:"High",color:"#F59E0B"},{value:"medium",label:"Medium",color:"#6366F1"},{value:"low",label:"Low",color:"var(--text-label)"}],eQ=[{value:"all",label:"Any time"},{value:"overdue",label:"Overdue",color:"#EF4444"},{value:"today",label:"Due today",color:"#F59E0B"},{value:"thisWeek",label:"This week",color:"#6366F1"},{value:"noDueDate",label:"No due date",color:"var(--text-label)"}];function e0(){return{assignees:[],campaigns:[],organizations:[],creators:[],statuses:[],priorities:[],dueRange:"all",viewType:"all",query:"",parentDeal:null,parentDealLabel:null,milestone:null,milestoneLabel:null}}let e1=a.useLayoutEffect;function e5({filters:e,onChange:r,teamMembers:s=[],statusOptions:n=[],scope:o,availableColumns:d=[],activeColumnKeys:c=[],onColumnKeysChange:u,filterCampaignId:p=null,filterParentDealId:h=null,hiddenChips:g=[]}){let b=new Set(g),[f,y]=(0,a.useState)([]),[v,k]=(0,a.useState)(null),[j,w]=(0,a.useState)(!1),[N,C]=(0,a.useState)(!1),[S,z]=(0,a.useState)(""),[_,D]=(0,a.useState)(null),[I,E]=(0,a.useState)(!1),[$,F]=(0,a.useState)(null),M=(0,a.useRef)(null),A=(0,a.useRef)(null);(0,a.useEffect)(()=>E(!0),[]),e1(()=>{if(j&&M.current)return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)};function e(){if(!M.current)return;let e=M.current.getBoundingClientRect(),t=Math.max(8,Math.min(e.right-288,window.innerWidth-288-8));D({top:e.bottom+6,left:t})}},[j]);let[P,B]=(0,a.useState)(""),[R,O]=(0,a.useState)([]),[U,W]=(0,a.useState)(""),[q,X]=(0,a.useState)([]),[G,H]=(0,a.useState)(""),[K,J]=(0,a.useState)([]),[V,Y]=(0,a.useState)(""),[Z,Q]=(0,a.useState)([]),[ee,et]=(0,a.useState)([]),[ea,er]=(0,a.useState)(!1),es=(e.assignees?.length||0)+(e.campaigns?.length||0)+(e.organizations?.length||0)+(e.creators?.length||0)+(e.statuses?.length||0)+(e.priorities?.length||0)+(e.dueRange&&"all"!==e.dueRange?1:0)+ +!!e.query+ +!!e.parentDeal+ +!!e.milestone;(0,a.useEffect)(()=>{let e=!1;return async function(){let t=new URLSearchParams;o?.type&&t.set("scopeType",o.type),o?.id&&t.set("scopeId",o.id);try{let a=await fetch(`/api/task-views?${t.toString()}`);if(!a.ok)return;let s=await a.json();if(e)return;y(s.views||[]);let n=(s.views||[]).find(e=>e.isDefault);n&&0===es&&(r(el(n)),k(n._id))}catch{}}(),()=>{e=!0}},[o?.type,o?.id]),(0,a.useEffect)(()=>{if(j)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){M.current?.contains(e.target)||A.current?.contains(e.target)||w(!1)}},[j]),(0,a.useEffect)(()=>{let e=setTimeout(async()=>{if(!P.trim())return O([]);try{let e=await fetch(`/api/searchAutoCompleteCampaigns?query=${encodeURIComponent(P.trim())}`);e.ok&&O(await e.json())}catch{}},200);return()=>clearTimeout(e)},[P]),(0,a.useEffect)(()=>{let e=setTimeout(async()=>{if(!U.trim())return X([]);try{let e=await fetch(`/api/searchAutoCompleteCreators?query=${encodeURIComponent(U.trim())}`);e.ok&&X(await e.json())}catch{}},200);return()=>clearTimeout(e)},[U]),(0,a.useEffect)(()=>{let e=setTimeout(async()=>{if(!G.trim())return J([]);try{let e=await fetch(`/api/searchAutoCompleteOrganizations?query=${encodeURIComponent(G.trim())}`);e.ok&&J(await e.json())}catch{}},200);return()=>clearTimeout(e)},[G]),(0,a.useEffect)(()=>{let e=setTimeout(async()=>{try{let e=new URLSearchParams({limit:"10"});V.trim()&&e.set("search",V.trim());let t=await fetch(`/api/deals?${e.toString()}`);if(t.ok){let e=await t.json();Q(e.deals||[])}}catch{}},250);return()=>clearTimeout(e)},[V]);let en=p||(e.campaigns?.length===1?e.campaigns[0]:null);function el(e){let t=e.filters||{};return{...e0(),...t,assignees:(t.assignees||[]).map(e=>e?._id||e?.toString?.()||e),campaigns:(t.campaigns||[]).map(e=>e?._id||e?.toString?.()||e),organizations:(t.organizations||[]).map(e=>e?._id||e?.toString?.()||e),creators:(t.creators||[]).map(e=>e?._id||e?.toString?.()||e)}}async function ei(){if(S.trim())try{let t=await fetch("/api/task-views",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S.trim(),scope:o||{type:"global"},filters:e,columnKeys:c})});if(t.ok){let e=await t.json();y(t=>[e.view,...t]),k(e.view._id),L.default.success(`Saved view "${S}"`),z(""),C(!1)}}catch{L.default.error("Failed to save view")}}async function eo(e,t){let a=e.columnKeys?.length?e.columnKeys:d.map(e=>e.key),r=a.includes(t)?a.filter(e=>e!==t):[...a,t];y(t=>t.map(t=>t._id===e._id?{...t,columnKeys:r}:t)),v===e._id&&u?.(r);try{await fetch(`/api/task-views/${e._id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({columnKeys:r})})}catch{L.default.error("Failed to update view")}}async function ed(e,t){if(t?.stopPropagation(),confirm("Delete this saved view?"))try{await fetch(`/api/task-views/${e}`,{method:"DELETE"}),y(t=>t.filter(t=>t._id!==e)),v===e&&k(null)}catch{L.default.error("Failed to delete view")}}async function ec(e){try{(await fetch(`/api/task-views/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isDefault:!0})})).ok&&(y(t=>t.map(t=>({...t,isDefault:t._id===e}))),L.default.success("Default view set"))}catch{}}function eu(t,a){let s=e[t]||[],n=s.includes(a)?s.filter(e=>e!==a):[...s,a],l={...e,[t]:n};"campaigns"===t&&!p&&e.milestone&&(1!==n.length||n[0]!==e.campaigns?.[0])&&(l.milestone=null,l.milestoneLabel=null),r(l),k(null)}function ex(t,a){r({...e,[t]:a}),k(null)}function ep(t,a,s,n){let l=e[t]===s?null:s;r({...e,[t]:l,[a]:l?n:null}),k(null)}return(0,a.useEffect)(()=>
1{if(!en)return void et([]);let e=!1;return er(!0),fetch(`/api/campaigns/${en}/milestones`).then(e=>e.ok?e.json():{milestones:[]}).then(t=>{e||et(t.milestones||[])}).catch(()=>{}).finally(()=>{e||er(!1)}),()=>{e=!0}},[en]),(0,t.jsxs)("div",{className:"mb-3",children:[(0,t.jsx)("div",{className:"flex items-center gap-2 mb-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl flex-1 min-w-0 sm:max-w-[280px]",style:{background:"var(--surface-frosted)",backdropFilter:"blur(12px)",border:"1px solid var(--border-subtle)",boxShadow:"0 2px 8px var(--shadow-ambient-xs)"},children:[(0,t.jsx)(eR.MagnifyingGlassIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500 flex-shrink-0"}),(0,t.jsx)("input",{value:e.query||"",onChange:e=>ex("query",e.target.value),placeholder:"Search tasksâ¦",className:"flex-1 text-xs bg-transparent border-none focus:outline-none placeholder-gray-300 dark:placeholder-zinc-500 text-gray-900 dark:text-zinc-100 min-w-0"}),e.query&&(0,t.jsx)("button",{onClick:()=>ex("query",""),className:"text-gray-300 dark:text-zinc-700 hover:text-gray-500 dark:hover:text-zinc-400 p-0.5 -m-0.5","aria-label":"Clear search",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3 h-3"})})]})}),(0,t.jsx)(e2,{active:e.viewType||"all",onChange:e=>ex("viewType",e)}),(0,t.jsxs)("div",{className:"flex items-center gap-2 overflow-x-auto sm:flex-wrap scrollbar-hide -mx-1 px-1 pb-1 sm:mx-0 sm:px-0 sm:pb-0",children:[(0,t.jsx)(eV.FilterChip,{label:"Status",activeCount:e.statuses?.length||0,accent:"#10B981",children:(n.length>0?n:[{label:"To Do",color:"#c4c4c4"},{label:"In Progress",color:"#fdab3d"},{label:"Review",color:"#e2445c"},{label:"Done",color:"#00c875"},{label:"Stuck",color:"#df2f4a"}]).map(a=>(0,t.jsx)(eV.CheckOption,{label:a.label,dot:a.color,checked:(e.statuses||[]).includes(a.label),onClick:()=>eu("statuses",a.label)},a.label))}),(0,t.jsx)(eV.FilterChip,{label:"Priority",activeCount:e.priorities?.length||0,accent:"#EF4444",children:eZ.map(a=>(0,t.jsx)(eV.CheckOption,{label:a.label,dot:a.color,checked:(e.priorities||[]).includes(a.value),onClick:()=>eu("priorities",a.value)},a.value))}),(0,t.jsx)(eV.FilterChip,{label:"Assignee",activeCount:e.assignees?.length||0,accent:"#6366F1",children:0===s.length?(0,t.jsx)("p",{className:"px-3 py-3 text-xs text-gray-400 dark:text-zinc-500 text-center",children:"No team members"}):s.map(a=>{let r;return(0,t.jsx)(eV.CheckOption,{label:a.name||a.email,checked:(e.assignees||[]).includes(a._id),onClick:()=>eu("assignees",a._id),avatar:(0,t.jsx)("div",{className:`w-6 h-6 rounded-full bg-gradient-to-br ${(r=(a.name||"").charCodeAt(0)%eY.length,eY[r])} flex items-center justify-center text-white text-[9px] font-bold`,children:(a.name||"?")[0].toUpperCase()})},a._id)})}),!b.has("campaigns")&&(0,t.jsxs)(eV.FilterChip,{label:"Campaign",activeCount:e.campaigns?.length||0,accent:"#EC4899",children:[(0,t.jsx)(eV.SearchInput,{value:P,onChange:B,placeholder:"Search campaignsâ¦"}),R.map(a=>(0,t.jsx)(eV.CheckOption,{label:a.name,checked:(e.campaigns||[]).includes(a._id),onClick:()=>eu("campaigns",a._id),avatar:a.image?(0,t.jsx)("img",{src:a.image,alt:"",className:"w-6 h-6 rounded-full object-cover ring-1 ring-pink-200/60"}):(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-pink-100"})},a._id)),P&&0===R.length&&(0,t.jsx)("p",{className:"px-3 py-2 text-xs text-gray-400 dark:text-zinc-500",children:"No campaigns match"})]}),!b.has("organizations")&&(0,t.jsxs)(eV.FilterChip,{label:"Organization",activeCount:e.organizations?.length||0,accent:"#0EA5E9",children:[(0,t.jsx)(eV.SearchInput,{value:G,onChange:H,placeholder:"Search orgsâ¦"}),K.map(a=>(0,t.jsx)(eV.CheckOption,{label:a.name,checked:(e.organizations||[]).includes(a._id),onClick:()=>eu("organizations",a._id),avatar:a.image?(0,t.jsx)("img",{src:a.image,alt:"",className:"w-6 h-6 rounded-full object-cover ring-1 ring-sky-200/60"}):(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-sky-100"})},a._id)),G&&0===K.length&&(0,t.jsx)("p",{className:"px-3 py-2 text-xs text-gray-400 dark:text-zinc-500",children:"No orgs match"})]}),!b.has("creators")&&(0,t.jsxs)(eV.FilterChip,{label:"Creator",activeCount:e.creators?.length||0,accent:"#A855F7",children:[(0,t.jsx)(eV.SearchInput,{value:U,onChange:W,placeholder:"Search creatorsâ¦"}),q.map(a=>(0,t.jsx)(eV.CheckOption,{label:a.name,checked:(e.creators||[]).includes(a._id),onClick:()=>eu("creators",a._id),avatar:a.image?(0,t.jsx)("img",{src:a.image,alt:"",className:"w-6 h-6 rounded-full object-cover ring-1 ring-purple-200/60"}):(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-purple-100"})},a._id)),U&&0===q.length&&(0,t.jsx)("p",{className:"px-3 py-2 text-xs text-gray-400 dark:text-zinc-500",children:"No creators match"})]}),(0,t.jsx)(eV.FilterChip,{label:"Due",activeCount:e.dueRange&&"all"!==e.dueRange?1:0,accent:"#F59E0B",children:eQ.map(a=>(0,t.jsx)(eV.CheckOption,{label:a.label,dot:a.color,checked:e.dueRange===a.value,onClick:()=>ex("dueRange",a.value)},a.value))}),!h&&(0,t.jsxs)(eV.FilterChip,{label:"Deal",activeCount:+!!e.parentDeal,accent:"#F97316",children:[(0,t.jsx)(eV.SearchInput,{value:V,onChange:Y,placeholder:"Search dealsâ¦"}),Z.map(a=>(0,t.jsx)(eV.CheckOption,{label:a.name,checked:e.parentDeal===a._id,onClick:()=>ep("parentDeal","parentDealLabel",a._id,a.name)},a._id)),V&&0===Z.length&&(0,t.jsx)("p",{className:"px-3 py-2 text-xs text-gray-400 dark:text-zinc-500",children:"No deals match"})]}),en&&(0,t.jsx)(eV.FilterChip,{label:"Milestone",activeCount:+!!e.milestone,accent:"#EC4899",children:ea?(0,t.jsx)("p",{className:"px-3 py-3 text-xs text-gray-400 dark:text-zinc-500 text-center",children:"Loadingâ¦"}):0===ee.length?(0,t.jsx)("p",{className:"px-3 py-3 text-xs text-gray-400 dark:text-zinc-500 text-center",children:"No milestones on this campaign"}):ee.map(a=>(0,t.jsx)(eV.CheckOption,{label:a.title,dot:a.color||"#EC4899",checked:e.milestone===a._id,onClick:()=>ep("milestone","milestoneLabel",a._id,a.title)},a._id))}),(0,t.jsxs)("div",{ref:M,className:"relative",children:[(0,t.jsxs)("button",{onClick:()=>w(!j),className:"text-xs font-bold px-3 py-2 rounded-xl flex items-center gap-1.5 transition-all duration-200",style:{background:v?"linear-gradient(135deg, rgba(99,102,241,0.12), rgba(168,85,247,0.12))":"var(--surface-soft)",border:v?"1px solid rgba(99,102,241,0.25)":"1px solid var(--border-default)",color:v?"#6366F1":"var(--text-tertiary)"},children:[(0,t.jsx)(eJ,{className:"w-3 h-3"}),v&&f.find(e=>e._id===v)?.name||"Views",f.length>0&&(0,t.jsx)("span",{className:"text-[9px] font-bold px-1 rounded",style:{background:"var(--border-subtle)",color:"var(--text-tertiary)"},children:f.length}),(0,t.jsx)(x.ChevronDownIcon,{className:"w-3 h-3 opacity-60"})]}),I&&(0,eH.createPortal)((0,t.jsx)(i.AnimatePresence,{children:j&&_&&(0,t.jsxs)(l.motion.div,{ref:A,initial:{opacity:0,y:-4,scale:.96}
1,animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.96},transition:{duration:.14},className:"fixed z-[100] w-72 rounded-xl py-1.5 max-h-80 overflow-y-auto",style:{top:_.top,left:_.left,background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 12px 40px var(--shadow-ambient-lg), 0 2px 8px var(--border-subtle)",border:"1px solid var(--border-default)"},children:[es>0&&(0,t.jsx)("div",{className:"px-3 py-2 border-b mb-1",style:{borderColor:"var(--surface-softer)"},children:N?(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("input",{autoFocus:!0,value:S,onChange:e=>z(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ei(),"Escape"===e.key&&C(!1)},placeholder:"View nameâ¦",className:"flex-1 text-xs px-2 py-1.5 rounded-lg focus:outline-none focus:ring-2 focus:ring-orange-300/50 text-gray-900 dark:text-zinc-100 placeholder-gray-400 dark:placeholder-zinc-500",style:{background:"var(--surface-soft)",border:"1px solid var(--border-default)"}}),(0,t.jsx)("button",{onClick:ei,disabled:!S.trim(),className:"text-[11px] font-bold text-white px-2.5 py-1.5 rounded-lg transition-all disabled:opacity-40",style:{background:"linear-gradient(135deg, #F97316, #EC4899)"},children:"Save"})]}):(0,t.jsxs)("button",{onClick:()=>C(!0),className:"w-full text-[11px] font-bold flex items-center gap-1.5 px-2 py-1.5 rounded-lg transition-all",style:{background:"linear-gradient(135deg, rgba(249,115,22,0.1), rgba(236,72,153,0.1))",color:"#F97316",border:"1px solid rgba(249,115,22,0.18)"},children:[(0,t.jsx)(eK.BookmarkIcon,{className:"w-3 h-3"}),"Save current as view"]})}),0===f.length?(0,t.jsx)("p",{className:"px-3 py-3 text-[11px] text-gray-400 dark:text-zinc-500 text-center",children:"No saved views yet. Apply filters and save."}):f.map(e=>{let a=e.columnKeys?.length?e.columnKeys:d.map(e=>e.key),s=a.length,n=$===e._id;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"group flex items-center gap-2 px-3 py-2 hover:bg-gray-50/80 dark:hover:bg-zinc-900/80 transition-colors",children:[(0,t.jsxs)("button",{onClick:()=>{r(el(e)),e.columnKeys&&e.columnKeys.length>0?u?.(e.columnKeys):u?.(null),k(e._id),w(!1)},className:"flex-1 min-w-0 text-left flex items-center gap-2",children:[e.isDefault?(0,t.jsx)(eJ,{className:"w-3 h-3 text-orange-500 flex-shrink-0"}):(0,t.jsx)(eK.BookmarkIcon,{className:"w-3 h-3 text-gray-300 dark:text-zinc-700 flex-shrink-0"}),(0,t.jsx)("span",{className:`text-xs font-semibold truncate ${v===e._id?"text-orange-600":"text-gray-700 dark:text-zinc-300"}`,children:e.name}),e.isDefault&&(0,t.jsx)("span",{className:"text-[8px] font-black tracking-wider text-orange-500 bg-orange-50 dark:bg-orange-500/15 px-1 py-0.5 rounded",children:"DEFAULT"})]}),d.length>0&&(0,t.jsxs)("button",{onClick:()=>F(n?null:e._id),className:`text-[9px] font-bold tracking-wider px-1.5 py-0.5 rounded transition-colors ${n?"bg-orange-500/10 text-orange-600":"text-gray-400 dark:text-zinc-500 hover:bg-gray-100 dark:hover:bg-zinc-900"}`,title:"Edit which columns this view shows",children:[s,"/",d.length," COLS"]}),(0,t.jsx)("button",{onClick:()=>ec(e._id),className:"opacity-0 group-hover:opacity-100 text-[9px] font-semibold text-gray-400 dark:text-zinc-500 hover:text-orange-500 transition-all",title:"Set as default for this scope",children:e.isDefault?"":"Set default"}),(0,t.jsx)("button",{onClick:t=>ed(e._id,t),className:"opacity-0 group-hover:opacity-100 text-gray-300 dark:text-zinc-700 hover:text-red-500 transition-all",children:(0,t.jsx)(m.TrashIcon,{className:"w-3 h-3"})})]}),n&&d.length>0&&(0,t.jsxs)("div",{className:"px-3 pb-2 space-y-0.5",style:{borderTop:"1px solid var(--surface-softer)",borderBottom:"1px solid var(--surface-softer)",background:"var(--surface-soft)"},children:[(0,t.jsx)("div",{className:"pt-1.5 pb-1 text-[9px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Columns in this view"}),d.map(r=>{let s=a.includes(r.key);return(0,t.jsxs)("label",{className:"flex items-center gap-2 px-1 py-1 rounded cursor-pointer hover:bg-white/60 dark:hover:bg-zinc-900/60",children:[(0,t.jsx)("input",{type:"checkbox",checked:s,onChange:()=>eo(e,r.key),className:"w-3 h-3 accent-orange-500 cursor-pointer"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-700 dark:text-zinc-300 font-medium truncate",children:r.label}),(0,t.jsx)("span",{className:"ml-auto text-[9px] text-gray-400 dark:text-zinc-500 font-medium uppercase tracking-wider",children:r.type})]},r.key)})]})]},e._id)})]})}),document.body)]}),es>0&&(0,t.jsxs)("button",{onClick:function(){r(e0()),u?.(null),k(null)},className:"text-xs font-bold px-3 py-2 rounded-xl flex items-center gap-1.5 transition-all duration-200",style:{background:"rgba(239,68,68,0.06)",color:"#DC2626",border:"1px solid rgba(239,68,68,0.18)"},title:"Clear all filters",children:[(0,t.jsx)(T.XMarkIcon,{className:"w-3 h-3"}),"Clear (",es,")"]})]})]})}
1function e2({active:e,onChange:a}){return(0,t.jsx)("div",{className:"inline-flex items-center p-0.5 rounded-xl mb-2",style:{background:"var(--surface-frosted)",border:"1px solid var(--border-subtle)"},children:[{key:"all",label:"All"},{key:"my",label:"My Tasks"},{key:"assigned",label:"Assigned"},{key:"collaborator",label:"Collaborator"}].map(r=>{let s=e===r.key;return(0,t.jsx)("button",{type:"button",onClick:()=>a(r.key),className:"text-[11px] font-bold px-2.5 sm:px-3 py-1.5 rounded-lg transition-colors duration-150",style:{background:s?"linear-gradient(135deg, #F97316, #EC4899)":"transparent",color:s?"white":"var(--text-tertiary)",boxShadow:s?"0 2px 8px rgba(236,72,153,0.22)":"none"},children:r.label},r.key)})})}e.i(245368);var e4=e.i(6487),e3=e.i(163858),e6=e.i(80843),e9=e.i(817264),e8=e.i(163341);function e7({option:e,height:r=220}){let s=(0,a.useRef)(null),n=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!s.current)return;n.current=e4.init(s.current),n.current.setOption(e);let t=()=>n.current?.resize();return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),n.current?.dispose()}},[]),(0,a.useEffect)(()=>{n.current?.setOption(e,!0)},[e]),(0,t.jsx)("div",{ref:s,style:{width:"100%",height:r}})}let te=["from-pink-500 to-rose-400","from-orange-500 to-amber-400","from-violet-500 to-purple-400","from-blue-500 to-cyan-400","from-emerald-500 to-teal-400"];function tt(e){let t=(e||"").charCodeAt(0)%te.length;return te[t]}function ta(e){return`${Math.round(100*(e||0))}%`}function tr({scopeParams:e}){var r;let[s,n]=(0,a.useState)(null),[i,o]=(0,a.useState)(!0);if((0,a.useEffect)(()=>{let t=!1;return async function(){o(!0);try{let a=new URLSearchParams(e||{}),r=await fetch(`/api/tasks/insights?${a.toString()}`);if(r.ok){let e=await r.json();t||n(e)}}finally{t||o(!1)}}(),()=>{t=!0}},[JSON.stringify(e)]),i)return(0,t.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[1,2,3,4].map(e=>(0,t.jsx)("div",{className:"rounded-2xl p-5 animate-pulse min-h-[220px]",style:{background:"var(--surface-frosted)",border:"1px solid var(--surface-softer)"}},e))});if(!s)return(0,t.jsx)("div",{className:"text-center py-16 text-sm text-gray-400 dark:text-zinc-500",children:"Couldn't load insights"});let d=s.statusBreakdown.reduce((e,t)=>e+t.count,0);return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35,ease:[.25,.46,.45,.94]},className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3",children:[(0,t.jsx)(ts,{label:"Open",value:s.totals.open,icon:e8.ChartBarIcon,color:"#6366F1"}),(0,t.jsx)(ts,{label:"Completed (30d)",value:s.completionByPerson.reduce((e,t)=>e+t.completed,0),icon:e3.CheckCircleIcon,color:"#10B981"}),(0,t.jsx)(ts,{label:"Overdue",value:s.totals.overdue,icon:eX.ExclamationTriangleIcon,color:s.totals.overdue>0?"#EF4444":"var(--text-label)",pulse:s.totals.overdue>0}),(0,t.jsx)(ts,{label:"On-time rate",value:ta(s.onTimeRate),icon:ez.BoltIcon,color:"#F59E0B"}),(0,t.jsx)(ts,{label:"Avg time-to-done",value:(r=s.avgHoursToComplete)&&!(r<=0)?r<1?`${Math.round(60*r)}m`:r<48?`${r.toFixed(1)}h`:`${Math.round(r/24)}d`:"â",icon:h.ClockIcon,color:"#A855F7"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,t.jsx)(tn,{title:"Status breakdown",subtitle:`${d} tasks total`,children:(0,t.jsx)(tl,{breakdown:s.statusBreakdown})}),(0,t.jsx)(tn,{title:"Priority mix",subtitle:"Active workload",children:(0,t.jsx)(ti,{breakdown:s.priorityBreakdown})}),(0,t.jsx)(tn,{title:"Throughput",subtitle:"Last 8 weeks · completed per ISO week",children:(0,t.jsx)(to,{data:s.throughputByWeek})}),(0,t.jsx)(tn,{title:"Top contributors",subtitle:"Last 30 days · who's shipping",icon:e9.TrophyIcon,children:(0,t.jsx)(td,{people:s.completionByPerson})}),(0,t.jsx)(tn,{title:"Current load",subtitle:"Open tasks per assignee",icon:e6.FireIcon,children:(0,t.jsx)(tc,{people:s.loadByPerson})}
1),(0,t.jsx)(tn,{title:"Task timeline",subtitle:"30 days · sorted by due date",children:(0,t.jsx)(tu,{tasks:s.ganttBuckets,now:new Date(s.windowEnd)})})]})]})}function ts({label:e,value:a,icon:r,color:s,pulse:n}){return(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl p-3.5",style:{background:"var(--surface-frosted)",backdropFilter:"blur(16px)",border:`1px solid ${s}20`,boxShadow:`0 2px 16px ${s}08`},children:[n&&(0,t.jsxs)("span",{className:"absolute top-2.5 right-2.5 flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{background:s}}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{background:s}})]}),(0,t.jsx)("div",{className:"absolute -top-6 -right-6 w-20 h-20 rounded-full opacity-15 blur-2xl pointer-events-none",style:{background:s}}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,t.jsx)(r,{className:"w-3.5 h-3.5",style:{color:s}}),(0,t.jsx)("span",{className:"text-[9px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500",children:e})]}),(0,t.jsx)("div",{className:"text-2xl font-black tracking-tight leading-none",style:{color:s},children:a})]})]})}function tn({title:e,subtitle:a,icon:r,children:s}){return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"relative overflow-hidden rounded-2xl p-5",style:{background:"var(--surface-frosted)",backdropFilter:"blur(16px)",border:"1px solid var(--surface-softer)",boxShadow:"0 4px 24px var(--shadow-ambient-xs)"},children:[(0,t.jsx)("div",{className:"absolute -top-12 -right-12 w-40 h-40 rounded-full opacity-10 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, #F59E0B, #EC4899)"}}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[r&&(0,t.jsx)("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center",style:{background:"rgba(99,102,241,0.1)"},children:(0,t.jsx)(r,{className:"w-3.5 h-3.5 text-indigo-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:e}),a&&(0,t.jsx)("div",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-0.5",children:a})]})]}),s]})]})}function tl({breakdown:e}){if(!e||0===e.length)return(0,t.jsx)(tx,{label:"No tasks yet"});let a={tooltip:{trigger:"item"},legend:{bottom:0,icon:"circle",itemWidth:8,itemHeight:8,textStyle:{fontSize:10,color:"var(--text-tertiary)"}},series:[{type:"pie",radius:["55%","78%"],avoidLabelOverlap:!0,label:{show:!1},labelLine:{show:!1},itemStyle:{borderRadius:6,borderColor:"#fff",borderWidth:2},data:e.map(e=>({value:e.count,name:e.status,itemStyle:{color:e.color}}))}]};return(0,t.jsx)(e7,{option:a,height:220})}function ti({breakdown:e}){let a=["critical","high","medium","low"],r={critical:"#EF4444",high:"#F59E0B",medium:"#6366F1",low:"var(--text-label)",unset:"var(--text-disabled)"},s=[...e].sort((e,t)=>a.indexOf(e.priority)-a.indexOf(t.priority));if(0===s.length)return(0,t.jsx)(tx,{label:"No priority data"});let n=Math.max(1,...s.map(e=>e.count));return(0,t.jsx)("div",{className:"space-y-2.5 py-1",children:s.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[11px] font-bold text-gray-700 dark:text-zinc-300 capitalize w-16",children:e.priority}),(0,t.jsx)("div",{className:"flex-1 h-5 rounded-md overflow-hidden bg-gray-100/60 dark:bg-zinc-900/60 relative",children:(0,t.jsx)(l.motion.div,{initial:{width:0},animate:{width:`${e.count/n*100}%`},transition:{duration:.5,ease:[.25,.46,.45,.94]},className:"absolute inset-y-0 left-0 rounded-md",style:{background:`linear-gradient(90deg, ${r[e.priority]||"var(--text-label)"}, ${r[e.priority]||"var(--text-label)"}AA)`}})}),(0,t.jsx)("span",{className:"text-[11px] font-bold text-gray-700 dark:text-zinc-300 w-6 text-right",children:e.count})]},e.priority))})}function to({data:e}){if(!e||0===e.length)return(0,t.jsx)(tx,{label:"No completions yet"});let a={tooltip:{trigger:"axis",formatter:t=>{let a=t[0];return`Week of ${new Date(e[a.dataIndex].weekStart).toLocaleDateString()}<br/><b>${a.value}</b> task${1===a.value?"":"s"}`}},grid:{left:30,right:10,top:10,bottom:24},xAxis:{type:"category",data:e.map(e=>{let t=new Date(e.weekStart);return`${t.getMonth()+1}/${t.getDate()}`}
1),axisLine:{lineStyle:{color:"var(--border-default)"}},axisLabel:{color:"var(--text-label)",fontSize:10},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{color:"#F3F4F6"}},axisLabel:{color:"var(--text-label)",fontSize:10},axisLine:{show:!1},axisTick:{show:!1}},series:[{type:"bar",data:e.map(e=>e.completed),barWidth:"50%",itemStyle:{borderRadius:[6,6,0,0],color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"#F97316"},{offset:1,color:"#EC4899"}]}}}]};return(0,t.jsx)(e7,{option:a,height:220})}function td({people:e}){if(!e||0===e.length)return(0,t.jsx)(tx,{label:"No completions"});let a=Math.max(1,...e.map(e=>e.completed));return(0,t.jsx)("div",{className:"space-y-2",children:e.map((e,r)=>(0,t.jsxs)(l.motion.div,{initial:{opacity:0,x:-4},animate:{opacity:1,x:0},transition:{delay:.04*r,duration:.25},className:"flex items-center gap-2.5",children:[(0,t.jsx)("span",{className:"text-[10px] font-black w-4 text-center",style:{color:0===r?"#F59E0B":1===r?"var(--text-label)":2===r?"#A16207":"var(--text-disabled)"},children:r+1}),e.image?(0,t.jsx)("img",{src:e.image,alt:e.name,className:"w-7 h-7 rounded-full object-cover ring-2 ring-white shadow-sm dark:ring-zinc-700"}):(0,t.jsx)("div",{className:`w-7 h-7 rounded-full bg-gradient-to-br ${tt(e.name)} flex items-center justify-center text-white text-[10px] font-bold shadow-sm`,children:(e.name||"?")[0].toUpperCase()}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-[12px] font-semibold text-gray-800 dark:text-zinc-100 truncate",children:e.name||"Unknown"}),(0,t.jsxs)("span",{className:"text-[10px] font-bold text-gray-500 dark:text-zinc-400 whitespace-nowrap",children:[e.completed," · ",ta(e.onTimeRate)," on-time"]})]}),(0,t.jsx)("div",{className:"h-1.5 mt-1 rounded-full bg-gray-100/70 dark:bg-zinc-900/70 overflow-hidden",children:(0,t.jsx)(l.motion.div,{initial:{width:0},animate:{width:`${e.completed/a*100}%`},transition:{duration:.45,delay:.04*r},className:"h-full rounded-full",style:{background:"linear-gradient(90deg, #10B981, #059669)"}})})]})]},e.userId))})}function tc({people:e}){if(!e||0===e.length)return(0,t.jsx)(tx,{label:"No open tasks"});let a=Math.max(1,...e.map(e=>e.open));return(0,t.jsx)("div",{className:"space-y-2",children:e.map((e,r)=>(0,t.jsxs)(l.motion.div,{initial:{opacity:0,x:-4},animate:{opacity:1,x:0},transition:{delay:.04*r,duration:.25},className:"flex items-center gap-2.5",children:[e.image?(0,t.jsx)("img",{src:e.image,alt:e.name,className:"w-7 h-7 rounded-full object-cover ring-2 ring-white shadow-sm dark:ring-zinc-700"}):(0,t.jsx)("div",{className:`w-7 h-7 rounded-full bg-gradient-to-br ${tt(e.name)} flex items-center justify-center text-white text-[10px] font-bold shadow-sm`,children:(e.name||"?")[0].toUpperCase()}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-[12px] font-semibold text-gray-800 dark:text-zinc-100 truncate",children:e.name||"Unknown"}),(0,t.jsxs)("span",{className:"text-[10px] font-bold text-gray-500 dark:text-zinc-400 whitespace-nowrap flex items-center gap-1",children:[e.open," open",e.overdue>0&&(0,t.jsxs)("span",{className:"text-[9px] font-black uppercase tracking-wide px-1 py-0.5 rounded",style:{background:"rgba(239,68,68,0.1)",color:"#DC2626"},children:[e.overdue," overdue"]})]})]}),(0,t.jsxs)("div",{className:"h-1.5 mt-1 rounded-full bg-gray-100/70 dark:bg-zinc-900/70 overflow-hidden flex",children:[(0,t.jsx)(l.motion.div,{initial:{width:0},animate:{width:`${(e.open-e.overdue)/a*100}%`},transition:{duration:.45,delay:.04*r},className:"h-full",style:{background:"linear-gradient(90deg, #6366F1, #8B5CF6)"}}),e.overdue>0&&(0,t.jsx)(l.motion.div,{initial:{width:0},animate:{width:`${e.overdue/a*100}
1%`},transition:{duration:.45,delay:.04*r+.15},className:"h-full",style:{background:"linear-gradient(90deg, #EF4444, #DC2626)"}})]})]})]},e.userId))})}function tu({tasks:e,now:a}){if(!e||0===e.length)return(0,t.jsx)(tx,{label:"No tasks in the last 30 days"});let r=new Date(a),s=new Date(r.getTime()-2592e6),n=r.getTime()-s.getTime();function l(e,t){let a=e?new Date(e).getTime():null;return a?Math.max(s.getTime(),Math.min(r.getTime(),a)):t}return(0,t.jsx)("div",{className:"space-y-1.5 max-h-[260px] overflow-y-auto pr-1",children:e.map(e=>{let a="Done"===e.status||"Complete"===e.status,i=l(e.startDate||e.createdAt,s.getTime()),o=l(e.completedAt||e.dueDate,r.getTime()),d=(i-s.getTime())/n*100,c=Math.max(1.5,(o-i)/n*100),u=!a&&e.dueDate&&new Date(e.dueDate).getTime()<r.getTime(),x=a?"#10B981":u?"#EF4444":"critical"===e.priority?"#F59E0B":"#6366F1";return(0,t.jsxs)("div",{className:"flex items-center gap-2 group",children:[(0,t.jsx)("div",{className:"text-[10px] font-medium text-gray-600 dark:text-zinc-400 truncate w-32",title:e.title,children:e.title}),(0,t.jsx)("div",{className:"flex-1 h-4 relative rounded bg-gray-50/60 dark:bg-zinc-900/60",children:(0,t.jsx)("div",{className:"absolute h-full rounded transition-all duration-200 group-hover:shadow-sm",style:{left:`${d}%`,width:`${c}%`,background:`linear-gradient(90deg, ${x}, ${x}CC)`,boxShadow:`0 1px 4px ${x}30`},title:`${e.title} \xb7 ${e.status}`})}),e.dueDate&&(0,t.jsx)("span",{className:"text-[9px] font-bold w-12 text-right whitespace-nowrap",style:{color:u?"#DC2626":"var(--text-label)"},children:new Date(e.dueDate).toLocaleDateString("en-US",{month:"numeric",day:"numeric"})})]},e._id)})})}function tx({label:e}){return(0,t.jsx)("div",{className:"text-center py-8 text-xs text-gray-400 dark:text-zinc-500 italic",children:e})}var tp=e.i(851617),tm=e.i(618969),th=e.i(879945);let tg={critical:"#EF4444",high:"#F97316",medium:"#F59E0B",low:"#9CA3AF"};function tb({tasks:e,statusOptions:r,teamMembers:s,onUpdate:n,onClick:i,onAddTask:d}){let{resolvedTheme:c}=(0,th.useTheme)(),[u,x]=(0,a.useState)(null),{columns:p,otherTasks:m}=(0,a.useMemo)(()=>{let t=new Map;for(let e of r||[])t.set(e.label,[]);let a=[];for(let r of e||[]){let e=r.status||"To Do";t.has(e)?t.get(e).push(r):a.push(r)}return{columns:(r||[]).map(e=>({...e,tasks:t.get(e.label)||[]})),otherTasks:a}},[e,r]),h=(0,o.useSensors)((0,o.useSensor)(o.PointerSensor,{activationConstraint:{distance:5}})),g=u?e.find(e=>e._id===u):null;return(0,t.jsxs)(o.DndContext,{sensors:h,onDragStart:e=>x(e.active.id),onDragEnd:function(t){x(null);let{active:a,over:s}=t;if(!s)return;let l=String(s.id).replace(/^kanban:/,""),i=(r||[]).find(e=>e.label===l);if(!i)return;let o=e.find(e=>e._id===a.id);o&&o.status!==i.label&&n(a.id,{status:i.label,statusColor:i.color})},onDragCancel:()=>x(null),children:[(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.25},className:"rounded-2xl border overflow-hidden",style:{borderColor:"var(--border-subtle)",background:"var(--surface-frosted)",backdropFilter:"blur(20px)",boxShadow:"0 8px 40px var(--surface-softer)"},children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500/60 via-orange-400/60 to-violet-500/60"}),(0,t.jsx)("div",{className:"overflow-x-auto p-4",children:(0,t.jsxs)("div",{className:"flex gap-4 items-start min-w-max",children:[p.map(e=>(0,t.jsx)(tf,{status:e,resolvedTheme:c,onClick:i,onAddTask:d},e.label)),m.length>0&&(0,t.jsx)(tf,{status:{label:"Other",color:"#9CA3AF",tasks:m},resolvedTheme:c,onClick:i,onAddTask:null})]})})]}),(0,t.jsx)(o.DragOverlay,{dropAnimation:{duration:200},children:g?(0,t.jsx)("div",{className:"pointer-events-none",children:(0,t.jsx)(tv,{task:g,onClick:()=>{},dragOverlay:!0})}):null})]})}function tf({status:e,resolvedTheme:a,onClick:r,onAddTask:s}){let{setNodeRef:n,isOver:l}=(0,o.useDroppable)({id:`kanban:${e.label}`}),d=(0,tm.adjustStatusColor)(e.color,a),c=e.tasks.length;return(0,t.jsxs)("div",{className:"w-[280px] flex-shrink-0 flex flex-col gap-2",children:[(0,t.jsx)("div",{className:"px-3 py-2 rounded-xl flex items-center justify-between",style:{background:`linear-gradient(135deg, ${d}18, ${d}08)`,border:`1px solid ${d}30`},children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full",style:{background:d,boxShadow:`0 0 6px ${d}`}}),(0,t.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-[0.14em]",style:{color:d},children:e.label}),(0,t.jsx)("span",{className:"text-[10px] font-bold tabular-nums px-1.5 py-0.5 rounded-md",style:{background:`${d}20`,color:d},children:c})]})}),(0,t.jsxs)("div",{ref:n,className:"flex flex-col gap-2 min-h-[120px] p-2 rounded-xl transition-all",style:{background:l?`${d}0d`:"transparent",outline:l?`2px dashed ${d}55`:"none",outlineOffset:-2},children:[(0,t.jsx)(i.AnimatePresence,{children:e.tasks.map(e=>(0,t.jsx)(ty,{task:e,onClick:r},e._id))}),s&&(0,t.jsxs)("button",{type:"button",onClick:()=>s(e.label),className:"mt-1 inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg text-[11px] font-semibold transition-all hover:-translate-y-0.5",style:{background:"var(--surface-soft)",border:"1px dashed var(--border-default)",color:"var(--text-secondary)"},children:[(0,t.jsx)($.PlusIcon,{className:"w-3 h-3"}),"Add task"]}),0===c&&!s&&(0,t.jsx)("div",{className:"text-center py-6 text-[11px]",style:{color:"var(--text-tertiary)"},children:"Empty"})]})]})}function ty({task:e,onClick:a}){let{setNodeRef:r,attributes:s,listeners:n,isDragging:l}=(0,o.useDraggable)({id:e._id});return(0,t.jsx)("div",{ref:r,...s,...n,style:{opacity:l?.35:1},children:(0,t.jsx)(tv,{task:e,onClick:a})})}function tv({task:e,onClick:a,dragOverlay:r=!1}){let s=function(e){if(!e)return null;let t=new Date(e),a=new Date;a.setHours(0,0,0,0);let r=new Date(a);r.setDate(r.getDate()+1);let s=Math.round((t-a)/864e5);return t<a?{label:`Overdue ${Math.abs(s)}d`,overdue:!0}:0===s?{label:"Due today",soon:!0}:1===s?{label:"Tomorrow",soon:!0}:s<7?{label:t.toLocaleDateString(void 0,{weekday:"short"})}:{label:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}}(e.dueDate),n=tg[e.priority]||null,i=(e.subItems||[]).length,o=(e.subItems||[]).filter(e=>e.completed).length,d=i>0?Math.round(o/i*100):0;return(0,t.jsxs)(l.motion.div,{layout:!r,initial:!r&&{opacity:0,y:6}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.18},onClick:t=>{r||(t.stopPropagation(),a?.(e))},className:`group relative p-3 rounded-xl transition-all ${r?"rotate-[-1.5deg]":"hover:-translate-y-0.5 cursor-pointer"}`,style:{background:"var(--surface-panel)",border:"1px solid var(--border-subtle)",boxShadow:r?"0 18px 40px -10px rgba(236,72,153,0.32), 0 8px 18px -6px rgba(249,115,22,0.18)":"0 1px 2px var(--surface-softer)"},children:[n&&(0,t.jsx)("span",{"aria-hidden":"true",className:"absolute left-0 top-2 bottom-2 w-[3px] rounded-r",style:{background:n}}),(0,t.jsxs)("div",{className:"flex items-start gap-2 mb-2 pl-1.5",children:[(0,t.jsx)("span",{className:"text-[12.5px] font-semibold text-gray-900 dark:text-zinc-100 leading-snug line-clamp-2 flex-1",children:e.title}),e.isPrivate&&(0,t.jsx)("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-md flex-shrink-0",style:{background:"rgba(99,102,241,0.1)",border:"1px solid rgba(99,102,241,0.25)",color:"#6366F1"},title:"Private â visible only to you and explicit assignees","aria-label":"Private task",children:(0,t.jsx)(b.LockClosedIcon,{className:"w-3 h-3"})})]}),(e.linkedCampaign?.name||e.linkedCreator?.name||e.organization?.name||e.parentDeal?.name)&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mb-2 pl-1.5",children:[e.linkedCampaign?.image?(0,t.jsx)("img",{src:e.linkedCampaign.image,alt:"",className:"w-4 h-4 rounded object-cover"}):e.linkedCreator?.image?(0,t.jsx)("img",{src:e.linkedCreator.image,alt:"",className:"w-4 h-4 rounded-full object-cover"}):e.organization?.image?(0,t.jsx)("img",{src:e.organization.image,alt:"",className:"w-4 h-4 rounded object-cover"}):null,(0,t.jsx)("span",{className:"text-[10px] text-gray-500 dark:text-zinc-400 truncate",children:e.linkedCampaign?.name||e.linkedCreator?.name||e.organization?.name||e.parentDeal?.name})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 pl-1.5",children:[s&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] font-bold tabular-nums",style:{background:s.overdue?"rgba(239,68,68,0.1)":s.soon?"rgba(236,72,153,0.1)":"var(--surface-soft)",color:s.overdue?"#DC2626":s.soon?"#EC4899":"var(--text-secondary)"},children:[s.overdue?(0,t.jsx)(eX.ExclamationTriangleIcon,{className:"w-3 h-3"}):(0,t.jsx)(tp.CalendarIcon,{className:"w-3 h-3"}),s.label]}),i>0&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500 dark:text-zinc-400 tabular-nums ml-auto",children:[(0,t.jsx)("span",{className:"h-1 w-10 rounded-full overflow-hidden",style:{background:"var(--surface-softer)"},children:(0,t.jsx)("span",{className:"block h-full rounded-full",style:{width:`${d}%`,background:"linear-gradient(90deg, #ec4899, #f97316)"}})}),o,"/",i]}),(e.assignees||[]).length>0&&(0,t.jsxs)("div",{className:"flex -space-x-1.5 ml-auto",children:[(e.assignees||[]).slice(0,3).map(e=>{let a=!e.image&&!e.name;return(0,t.jsx)("span",{className:`w-5 h-5 rounded-full border-2 flex items-center justify-center text-[9px] font-bold text-white overflow-hidden ${a?"animate-shimmer":""}`,style:{borderColor:"var(--surface-panel)",background:e.image?`url(${e.image}) center/cover`:a?"linear-gradient(90deg, var(--surface-soft), var(--surface-softer), var(--surface-soft))":"linear-gradient(135deg, #ec4899, #f97316)",backgroundSize:a?"200% 100%":void 0},title:e.name||"","aria-busy":a||void 0,children:!e.image&&!a&&(e.name||"").trim()[0]?.toUpperCase()},e._id||e)}),(e.assignees||[]).length>3&&(0,t.jsxs)("span",{className:"w-5 h-5 rounded-full border-2 flex items-center justify-center text-[9px] font-bold",style:{borderColor:"var(--surface-panel)",background:"var(--surface-soft)",color:"var(--text-secondary)"},children:["+",(e.assignees||[]).length-3]})]})]})]})}var tk=e.i(131011),tj=e.i(992580),tw=e.i(389472);let tN={critical:"#EF4444",high:"#F97316",medium:"#F59E0B",low:"#9CA3AF"},tC={day:64,week:24,month:8};function tS(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function tz(e,t){let a=new Date(e);return a.setDate(a.getDate()+t),a}function t_(e,t){return Math.round((tS(e)-tS(t))/864e5)}function tD({tasks:e,onUpdate:r,onClick:s}
1){let[n,i]=(0,a.useState)("week"),o=tC[n],d=(0,a.useRef)(null),{rangeStart:c,rangeEnd:u}=(0,a.useMemo)(()=>(function(e){let t=tS(new Date),a=tz(t,-7),r=tz(t,30);for(let t of e||[]){let e=t.startDate||t.createdAt,s=t.dueDate;if(e){let t=tS(e);t<a&&(a=t)}if(s){let e=tS(s);e>r&&(r=e)}}return{rangeStart:tz(a,-2),rangeEnd:tz(r,2)}})(e),[e]),x=Math.max(1,t_(u,c)),p=x*o;(0,a.useEffect)(()=>{if(!d.current)return;let e=t_(tS(new Date),c)*o;d.current.scrollLeft=Math.max(0,e-200)},[n,c,o]);let m=(0,a.useMemo)(()=>[...e||[]].sort((e,t)=>{let a=e.startDate||e.createdAt,r=t.startDate||t.createdAt;return a||r?a?r?new Date(a)-new Date(r):-1:1:0}),[e]);return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.25},className:"rounded-2xl border overflow-hidden",style:{borderColor:"var(--border-subtle)",background:"var(--surface-frosted)",backdropFilter:"blur(20px)",boxShadow:"0 8px 40px var(--surface-softer)"},children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500/60 via-orange-400/60 to-violet-500/60"}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b",style:{borderColor:"var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(tw.CalendarDaysIcon,{className:"w-4 h-4 text-pink-500"}),(0,t.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-[0.14em] text-gray-500 dark:text-zinc-400",children:"Timeline"})]}),(0,t.jsx)(tI,{zoom:n,onChange:i})]}),(0,t.jsx)("div",{ref:d,className:"overflow-x-auto",children:(0,t.jsxs)("div",{style:{width:240+p,minWidth:"100%"},children:[(0,t.jsx)(tE,{rangeStart:c,totalDays:x,dayWidth:o,zoom:n}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(t$,{rangeStart:c,dayWidth:o,rowCount:m.length}),m.map((e,a)=>(0,t.jsx)(tT,{task:e,rowIndex:a,rangeStart:c,totalDays:x,dayWidth:o,onUpdate:r,onClick:s},e._id)),0===m.length&&(0,t.jsx)("div",{className:"text-center py-12 text-[12px]",style:{color:"var(--text-tertiary)"},children:"No tasks to plot"})]})]})})]})}function tI({zoom:e,onChange:a}){let r=["month","week","day"],s=r.indexOf(e);return(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("button",{onClick:()=>a(r[Math.max(0,s-1)]),disabled:0===s,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-all hover:bg-gray-100 dark:hover:bg-zinc-900 disabled:opacity-40",title:"Zoom out",children:(0,t.jsx)(tj.MagnifyingGlassMinusIcon,{className:"w-3.5 h-3.5 text-gray-500 dark:text-zinc-400"})}),(0,t.jsx)("div",{className:"px-2 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider",style:{background:"var(--surface-soft)",color:"var(--text-secondary)",minWidth:56,textAlign:"center"},children:e}),(0,t.jsx)("button",{onClick:()=>a(r[Math.min(r.length-1,s+1)]),disabled:s===r.length-1,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-all hover:bg-gray-100 dark:hover:bg-zinc-900 disabled:opacity-40",title:"Zoom in",children:(0,t.jsx)(tk.MagnifyingGlassPlusIcon,{className:"w-3.5 h-3.5 text-gray-500 dark:text-zinc-400"})})]})}function tE({rangeStart:e,totalDays:a,dayWidth:r,zoom:s}){let n=[];for(let t=0;t<=a;t++){let a=tz(e,t),l=null,i=null,o=!1;"day"===s?(l=a.toLocaleDateString(void 0,{weekday:"short"}),i=`${a.getMonth()+1}/${a.getDate()}`,o=0===a.getDay()||6===a.getDay()):"week"===s&&1===a.getDay()?l=a.toLocaleDateString(void 0,{month:"short",day:"numeric"}):"month"===s&&1===a.getDate()&&(l=a.toLocaleDateString(void 0,{month:"short",year:"2-digit"})),l&&n.push({left:t*r,label:l,sub:i,weekend:o})}return(0,t.jsxs)("div",{className:"flex sticky top-0 z-20",style:{background:"var(--surface-frosted)",backdropFilter:"blur(8px)",borderBottom:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"w-[240px] flex-shrink-0 px-4 py-2 border-r sticky left-0 z-30",style:{borderColor:"var(--border-subtle)",background:"var(--surface-frosted)",backdropFilter:"blur(8px)"},children:(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Task"})}),(0,t.jsx)("div",{className:"relative h-9",style:{width:a*r,flexShrink:0},children:n.map(e=>e.sub?(0,t.jsxs)("div",{className:"absolute top-0 bottom-0 flex flex-col items-center justify-center leading-none",style:{left:e.left,width:r,borderLeft:"1px solid var(--border-subtle)",background:e.weekend?"var(--surface-softer)":"transparent"},children:[(0,t.jsx)("span",{className:`text-[9px] font-semibold uppercase tracking-wider whitespace-nowrap ${e.weekend?"text-gray-400 dark:text-zinc-600":"text-gray-500 dark:text-zinc-400"}`,children:e.label}),(0,t.jsx)("span",{className:`text-[10px] font-bold whitespace-nowrap mt-0.5 ${e.weekend?"text-gray-400 dark:text-zinc-600":"text-gray-700 dark:text-zinc-200"}`,children:e.sub})]},e.left):(0,t.jsx)("div",{className:"absolute top-0 bottom-0 flex items-center px-1.5",style:{left:e.left,borderLeft:"1px solid var(--border-subtle)"},children:(0,t.jsx)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-gray-500 dark:text-zinc-400 whitespace-nowrap",children:e.label})},e.left))})]})}function t$({rangeStart:e,dayWidth:a,rowCount:r}){let s=240+t_(tS(new Date),e)*a;return(0,t.jsx)("div",{"aria-hidden":"true",className:"absolute top-0 pointer-events-none z-10",style:{left:s,width:2,height:44*r,background:"linear-gradient(180deg, rgba(236,72,153,0.6), rgba(249,115,22,0.6))",boxShadow:"0 0 12px rgba(236,72,153,0.45)"}})}function tT({task:e,rowIndex:a,rangeStart:r,totalDays:s,dayWidth:n,onUpdate:l,onClick:i}){let o=e.startDate||e.createdAt,d=o?tS(o):null,c=e.dueDate?tS(e.dueDate):null,u=!!d&&!!c&&c>=d,x=u?t_(d,r)*n:0,p=u?Math.max(n,(t_(c,d)+1)*n):0,m=tN[e.priority]||e.statusColor||"#F97316";return(0,t.jsxs)("div",{className:"flex h-11 items-center border-b",style:{borderColor:"var(--surface-softer)"},children:[(0,t.jsx)("div",{className:"w-[240px] flex-shrink-0 px-4 truncate cursor-pointer hover:bg-gray-50/50 dark:hover:bg-zinc-900/30 h-full flex items-center sticky left-0 z-[12] border-r",style:{background:"var(--surface-frosted)",backdropFilter:"blur(8px)",borderColor:"var(--border-subtle)"},onClick:()=>i?.(e),title:e.title,children:(0,t.jsx)("span",{className:"text-[12.5px] font-semibold text-gray-900 dark:text-zinc-100 truncate",children:e.title})}),(0,t.jsx)("div",{className:"relative h-full flex-shrink-0",style:{width:s*n},children:u?(0,t.jsx)(tF,{task:e,start:d,end:c,barLeft:x,barWidth:p,dayWidth:n,accent:m,startInferred:!e.startDate,onUpdate:l,onClick:i}):(0,t.jsx)("div",{className:"absolute top-1/2 -translate-y-1/2 left-2 px-2 py-0.5 rounded text-[10px] font-medium",style:{background:"var(--surface-soft)",color:"var(--text-tertiary)",border:"1px dashed var(--border-default)"},title:"Add a due date to plot this task",children:"no due date"})})]})}function tF({task:e,start:r,end:s,barLeft:n,barWidth:l,dayWidth:i,accent:o,startInferred:d,onUpdate:c,onClick:u}){let[x,p]=(0,a.useState)(null),[m,h]=(0,a.useState)(n),[g,b]=(0,a.useState)(l),f=(0,a.useRef)(!1);function y(e){return t=>{t.stopPropagation(),t.preventDefault(),f.current=!1,p({mode:e,originX:t.clientX,origStart:r.getTime(),origEnd:s.getTime()})}}(0,a.useEffect)(()=>{x||(h(n),b(l))},[n,l,x]),(0,a.useEffect)(()=>
1{if(x)return window.addEventListener("mousemove",t),window.addEventListener("mouseup",a),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",a)};function t(e){let t=e.clientX-x.originX;Math.abs(t)>3&&(f.current=!0);let a=Math.round(t/i),r=x.origStart,s=x.origEnd;"move"===x.mode?(r+=864e5*a,s+=864e5*a):"left"===x.mode?(r+=864e5*a)>s&&(r=s):"right"===x.mode&&(s+=864e5*a)<r&&(s=r);let o=(r-x.origStart)/864e5,d=(s-r-(x.origEnd-x.origStart))/864e5;h(n+o*i),b(l+d*i)}function a(t){let a=Math.round((t.clientX-x.originX)/i),r=x.origStart,s=x.origEnd;if("move"===x.mode?(r+=864e5*a,s+=864e5*a):"left"===x.mode?(r+=864e5*a)>s&&(r=s):"right"===x.mode&&(s+=864e5*a)<r&&(s=r),r!==x.origStart||s!==x.origEnd){let t={};r!==x.origStart&&(t.startDate=new Date(r).toISOString()),s!==x.origEnd&&(t.dueDate=new Date(s).toISOString()),c?.(e._id,t)}p(null)}},[x,i,n,l,c,e._id]);let v=new Date(r).toLocaleDateString(void 0,{month:"short",day:"numeric"}),k=new Date(s).toLocaleDateString(void 0,{month:"short",day:"numeric"}),j=`${e.title} 2${v} â ${k}${d?" (start inferred from creation)":""}`;return(0,t.jsxs)("div",{className:"absolute top-1/2 -translate-y-1/2 group",style:{left:m,width:g,height:24},title:j,children:[(0,t.jsx)("div",{onMouseDown:y("left"),className:"absolute left-0 top-0 bottom-0 w-2 cursor-ew-resize z-10 opacity-0 group-hover:opacity-100 transition-opacity",style:{background:`linear-gradient(90deg, ${o}, transparent)`}}),(0,t.jsx)("div",{onMouseDown:y("right"),className:"absolute right-0 top-0 bottom-0 w-2 cursor-ew-resize z-10 opacity-0 group-hover:opacity-100 transition-opacity",style:{background:`linear-gradient(270deg, ${o}, transparent)`}}),(0,t.jsx)("div",{onMouseDown:y("move"),onClick:t=>{if(t.stopPropagation(),f.current){f.current=!1;return}x||u?.(e)},className:"absolute inset-0 rounded-md cursor-grab active:cursor-grabbing",style:{background:`linear-gradient(135deg, ${o}DD, ${o}AA)`,boxShadow:`0 2px 8px ${o}33`,border:d?`1px dashed ${o}`:`1px solid ${o}`},children:(0,t.jsx)("span",{className:"absolute inset-0 flex items-center px-2 truncate text-[10.5px] font-bold text-white tracking-wide",children:e.title})})]})}var tM=e.i(307163);let tA=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],tL={critical:"#EF4444",high:"#F97316",medium:"#F59E0B",low:"#9CA3AF"};function tP(e){let t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),t}function tB(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function tR(e,t){let a=new Date(e);return a.setMonth(a.getMonth()+t),a}function tO(e,t){let a=new Date(e);return a.setDate(a.getDate()+t),a}function tU({tasks:e=[],onClick:r,dueDateMode:s="single"}){let[n,o]=(0,a.useState)(()=>tP(new Date)),d=(0,a.useMemo)(()=>{let e,t;return t=tO(e=tP(n),-e.getDay()),Array.from({length:42},(e,a)=>tO(t,a))},[n]),c=(0,a.useMemo)(()=>tB(new Date),[]),x=(0,a.useMemo)(()=>{let t=new Map;for(let a of e){if(!a.dueDate)continue;let e=tB(new Date(a.dueDate)),r="range"===s&&a.startDate?tB(new Date(a.startDate)):e,n=0;for(;r.getTime()<=e.getTime()&&n<60;){let e=r.toISOString().slice(0,10);t.has(e)||t.set(e,[]),t.get(e).push(a),r=tO(r,1),n+=1}}return t},[e,s]),p=(0,a.useMemo)(()=>e.filter(e=>!e.dueDate),[e]),m=n.toLocaleDateString(void 0,{month:"long",year:"numeric"});return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3},className:"relative overflow-hidden rounded-2xl border",style:{background:"var(--surface-frosted)",backdropFilter:"blur(20px)",borderColor:"var(--border-subtle)",boxShadow:"0 8px 40px var(--surface-softer), 0 1px 3px var(--surface-soft)"},children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-emerald-500/60 via-teal-400/60 to-cyan-500/60"}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(16,185,129,0.12), rgba(20,184,166,0.12))",border:"1px solid rgba(16,185,129,0.18)"},children:(0,t.jsx)(tw.CalendarDaysIcon,{className:"w-4 h-4 text-emerald-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:m}),(0,t.jsxs)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-0.5",children:[e.length," task",1===e.length?"":"s"]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("button",{onClick:()=>o(e=>tR(e,-1)),className:"w-8 h-8 flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors","aria-label":"Previous month",children:(0,t.jsx)(tM.ChevronLeftIcon,{className:"w-4 h-4 text-gray-500 dark:text-zinc-400"})}),(0,t.jsx)("button",{onClick:()=>o(tP(new Date)),className:"text-[11px] font-bold uppercase tracking-wider px-2 py-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors text-gray-600 dark:text-zinc-300",children:"Today"}),(0,t.jsx)("button",{onClick:()=>o(e=>tR(e,1)),className:"w-8 h-8 flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors","aria-label":"Next month",children:(0,t.jsx)(u.ChevronRightIcon,{className:"w-4 h-4 text-gray-500 dark:text-zinc-400"})})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-7 border-t",style:{borderColor:"var(--border-subtle)"},children:tA.map(e=>(0,t.jsx)("div",{className:"px-2 py-2 text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 text-center",style:{borderRight:"1px solid var(--border-subtle)"},children:e},e))}),(0,t.jsx)("div",{className:"grid grid-cols-7 border-t",style:{borderColor:"var(--border-subtle)"},children:d.map((e,a)=>{let s=e.getMonth()===n.getMonth(),o=e.getFullYear()===c.getFullYear()&&e.getMonth()===c.getMonth()&&e.getDate()===c.getDate(),d=e.toISOString().slice(0,10),u=x.get(d)||[];return(0,t.jsxs)("div",{className:"min-h-[112px] flex flex-col p-1.5 gap-1",
2style:{borderRight:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)",background:o?"rgba(16,185,129,0.04)":s?"transparent":"var(--surface-softer)",opacity:s?1:.55},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:`text-[11px] font-bold ${o?"w-5 h-5 rounded-full bg-emerald-500 text-white flex items-center justify-center":"text-gray-500 dark:text-zinc-400"}`,children:e.getDate()}),u.length>3&&(0,t.jsxs)("span",{className:"text-[9px] font-bold text-gray-400 dark:text-zinc-500",children:["+",u.length-3]})]}),(0,t.jsx)("div",{className:"flex-1 flex flex-col gap-1 overflow-hidden",children:(0,t.jsx)(i.AnimatePresence,{children:u.slice(0,3).map(e=>{let a=tL[e.priority]||"#6366F1",s="Done"===e.status||"Complete"===e.status;return(0,t.jsx)(l.motion.button,{layout:!0,initial:{opacity:0,y:-2},animate:{opacity:1,y:0},exit:{opacity:0,y:-2},transition:{duration:.15},onClick:()=>r?.(e),className:"text-left px-1.5 py-1 rounded-md text-[10.5px] font-semibold truncate hover:scale-[1.02] transition-transform",style:{background:`${a}15`,border:`1px solid ${a}30`,color:s?"var(--text-tertiary)":"var(--text-primary)",textDecoration:s?"line-through":"none"},title:e.title,children:e.title},e._id)})})})]},d+a)})}),p.length>0&&(0,t.jsxs)("div",{className:"border-t px-4 py-3",style:{borderColor:"var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"flex items-center gap-2 mb-2",children:(0,t.jsxs)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:["No due date (",p.length,")"]})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[p.slice(0,12).map(e=>(0,t.jsx)("button",{onClick:()=>r?.(e),className:"text-[11px] font-semibold px-2 py-1 rounded-md transition-all hover:-translate-y-0.5",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:e.title},e._id)),p.length>12&&(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-zinc-500 self-center",children:["+ ",p.length-12," more"]})]})]})]})}let tW=a.forwardRef(function({title:e,titleId:t,...r},s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},r),e?a.createElement("title",{id:t},e):null,a.createElement("path",{fillRule:"evenodd",d:"M14.615 1.595a.75.75 0 0 1 .359.852L12.982 9.75h7.268a.75.75 0 0 1 .548 1.262l-10.5 11.25a.75.75 0 0 1-1.272-.71l1.992-7.302H3.75a.75.75 0 0 1-.548-1.262l10.5-11.25a.75.75 0 0 1 .913-.143Z",clipRule:"evenodd"}))});function tq({board:e,onClick:a}){let r=e?.automations||[],s=r.length,n=r.some(e=>!!e.recipeId);return 0===s?(0,t.jsxs)("button",{type:"button",onClick:a,title:"Workflow automations â automate cross-board actions",className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full transition-all hover:-translate-y-0.5",style:{background:"var(--surface-soft)",border:"1px dashed var(--border-subtle)"},children:[(0,t.jsx)(ez.BoltIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500 flex-shrink-0"}),(0,t.jsx)("span",{className:"text-[11px] font-semibold text-gray-500 dark:text-zinc-400 whitespace-nowrap",children:"+ Add Automation"})]}):(0,t.jsxs)("button",{type:"button",onClick:a,title:"Workflow automations â automate cross-board actions",className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full transition-all hover:-translate-y-0.5",style:{background:"rgba(236, 72, 153, 0.08)",border:"1px solid rgba(236, 72, 153, 0.25)"},children:[(0,t.jsx)(tW,{className:"w-3.5 h-3.5 text-pink-500 dark:text-pink-400 flex-shrink-0"}),(0,t.jsxs)("span",{className:"text-[11px] font-semibold text-pink-600 dark:text-pink-400 whitespace-nowrap",children:[s," Automation",1!==s?"s":""]}),n&&(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 flex-shrink-0","aria-hidden":"true"})]})}function tX({board:e,onOpenAutomations:r}){let s=e?.header,[n,o]=(0,a.useState)(!0),d=!!s?.notes?.trim(),c=(0,a.useMemo)(()=>(s?.links||[]).filter(e=>{var t;return"string"==typeof(t=e?.url)&&/^https?:\/\//i.test(t)}),[s?.links]),p=(0,a.useMemo)(()=>s?.people||[],[s?.people]),m=c.length>0,h=p.length>0;return d||m||h?(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:-4}
2,animate:{opacity:1,y:0},transition:{duration:.25},className:"rounded-2xl border overflow-hidden mb-3",style:{borderColor:"var(--border-subtle)",background:"var(--surface-frosted)",backdropFilter:"blur(20px)"},children:[(0,t.jsx)("div",{className:"h-[2px] w-full bg-gradient-to-r from-pink-500/50 via-orange-400/50 to-violet-500/50"}),(0,t.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"w-full flex items-center gap-2 px-4 py-2 text-left hover:bg-black/[0.02] dark:hover:bg-white/[0.03] transition-colors",children:[n?(0,t.jsx)(x.ChevronDownIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"}):(0,t.jsx)(u.ChevronRightIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.16em] text-gray-500 dark:text-zinc-400",children:"Board context"}),!n&&(0,t.jsxs)("span",{className:"text-[11px] text-gray-400 dark:text-zinc-500 ml-2 flex items-center gap-2",children:[m&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,t.jsx)(y.LinkIcon,{className:"w-3 h-3"}),c.length]}),h&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,t.jsx)(eN.UserGroupIcon,{className:"w-3 h-3"}),p.length]})]}),(0,t.jsx)("span",{className:"ml-auto",onClick:e=>e.stopPropagation(),children:(0,t.jsx)(tq,{board:e,onClick:r})})]}),(0,t.jsx)(i.AnimatePresence,{initial:!1,children:n&&(0,t.jsx)(l.motion.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,ease:[.25,.46,.45,.94]},className:"overflow-hidden",children:(0,t.jsxs)("div",{className:"px-4 pb-4 flex flex-col gap-3",children:[d&&(0,t.jsx)("p",{className:"text-[13px] leading-relaxed text-gray-700 dark:text-zinc-300 whitespace-pre-wrap",children:s.notes}),m&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:c.map(e=>(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex items-center gap-1.5 pl-1.5 pr-2.5 py-1 rounded-full text-[11.5px] font-semibold transition-all hover:-translate-y-0.5",style:{background:"var(--surface-soft)",border:"1px solid rgba(99,102,241,0.18)",color:"var(--text-primary)"},title:e.url,children:[(0,t.jsx)("span",{className:"w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",style:{background:"rgba(99,102,241,0.12)",color:"#6366F1"},children:(0,t.jsx)(y.LinkIcon,{className:"w-3 h-3"})}),(0,t.jsx)("span",{className:"truncate max-w-[200px]",children:e.label?.trim()||function(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}(e.url)}),(0,t.jsx)(j.ArrowTopRightOnSquareIcon,{className:"w-3 h-3 text-gray-300 dark:text-zinc-600 group-hover:text-gray-500 dark:group-hover:text-zinc-400 transition-colors"})]},e._id||e.url))}),h&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:p.map(e=>(0,t.jsx)(tG,{person:e},e._id||e.user?._id))})]})})})]}):(0,t.jsx)("div",{className:"flex items-center gap-2 mb-3 px-0.5",children:(0,t.jsx)(tq,{board:e,onClick:r})})}function tG({person:e}){let a=e?.user,r="object"==typeof a?a?.name:null,s="object"==typeof a?a?.image:null,n=(r||"?").trim()[0]?.toUpperCase()||"?",l=(e?.role||"").trim();return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 pl-0.5 pr-2.5 py-0.5 rounded-full text-[11.5px] font-semibold",style:{background:"var(--surface-soft)",border:"1px solid rgba(236,72,153,0.18)",color:"var(--text-primary)"},title:l?`${r||"Member"} \xb7 ${l}`:r||"Member",children:[s?(0,t.jsx)("img",{src:s,alt:"",className:"w-5 h-5 rounded-full object-cover flex-shrink-0"}):(0,t.jsx)("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[9px] font-bold text-white flex-shrink-0",style:{background:"linear-gradient(135deg, #ec4899, #f97316)"},children:n}),(0,t.jsx)("span",{className:"truncate max-w-[160px]",children:r||"Member"}),l&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"text-gray-300 dark:text-zinc-600",children:"·"}),(0,t.jsx)("span",{className:"text-[10.5px] text-gray-500 dark:text-zinc-400 truncate max-w-[140px]",children:l})]})]})}var tH=e.i(847604),tK=e.i(142663);let tJ=[.25,.46,.45,.94],tV=["from-pink-500 to-rose-400","from-orange-500 to-amber-400","from-violet-500 to-purple-400","from-blue-500 to-cyan-400","from-emerald-500 to-teal-400"];function tY(e){let t=String(e||"?").charCodeAt(0)%tV.length;return tV[t]}function tZ(e){return e?"string"==typeof e?e:e._id?e._id.toString():e.toString():null}function tQ({agency:e,size:a=16}){if(e?.image)return(0,t.jsx)("img",{src:e.image,alt:e.name||"",className:"rounded-full object-cover ring-1 ring-white/40 dark:ring-zinc-700/40",style:{width:a,height:a}});let r=(e?.name||"?").trim()[0]?.toUpperCase()||"?";return(0,t.jsx)("span",{className:`rounded-full flex items-center justify-center text-white font-bold bg-gradient-to-br ${tY(e?.name)}`,style:{width:a,height:a,fontSize:Math.max(8,Math.floor(a/2.2))},children:r})}function t0({board:e,currentUser:r}){let{openOrCreateDM:s,open:n}=(0,tK.useConversation)(),[l,i]=(0,a.useState)(null);if(!e)return null;let o=e.collaboratingAgencies||[],d=e.collaboratingUsers||[];if(0===o.length&&0===d.length)return null;let{agencies:c,users:u}=function(e,t){let a,r=e?.agency&&"object"==typeof e.agency?e.agency:null,s=(e?.collaboratingAgencies||[]).filter(e=>e&&"object"==typeof e),n=(e?.collaboratingUsers||[]).filter(e=>e&&"object"==typeof e),l=(a=t?.agency)?"string"==typeof a?a:a.id||a._id||null:null,i=tZ(r),o=l&&i&&l===i,d=!o&&l&&s.some(e=>tZ(e)===l);if(o)return{agencies:s,users:n};if(d){let e=[];for(let t of(r&&e.push(r),s))tZ(t)!==l&&e.push(t);return{agencies:e,users:n.filter(e=>{let t=tZ(e?.agency);return!t||t!==l})}}return{agencies:r?[r,...s]:s,users:n}}(e,r);return 0===c.length&&0===u.length?null:(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 mb-3 px-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Working with"}),c.map(e=>(0,t.jsx)(t1,{agency:e,isOpen:l===e._id,onOpen:()=>
2i(e._id),onClose:()=>i(null),currentUser:r,openOrCreateDM:s,openConversation:n},e._id)),u.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{e?._id&&s({otherUserId:e._id}).catch(()=>{})},className:"inline-flex items-center gap-1 pl-0.5 pr-2 py-0.5 rounded-full text-[11px] font-semibold transition-all hover:shadow-sm hover:-translate-y-0.5",style:{background:"rgba(245,158,11,0.08)",border:"1px solid rgba(245,158,11,0.28)",color:"#B45309"},title:`DM ${e.name||e.email}`,children:[e.image?(0,t.jsx)("img",{src:e.image,alt:e.name||"",className:"w-4 h-4 rounded-full object-cover"}):(0,t.jsx)("span",{className:`w-4 h-4 rounded-full bg-gradient-to-br ${tY(e.name||e.email)} text-white flex items-center justify-center text-[8px] font-bold`,children:(e.name||e.email||"?")[0].toUpperCase()}),(0,t.jsx)("span",{className:"truncate max-w-[120px]",children:e.name||e.email}),(0,t.jsx)(tH.ChatBubbleLeftRightIcon,{className:"w-3 h-3 opacity-70"})]},e._id))]})}function t1({agency:e,isOpen:r,onOpen:s,onClose:n,currentUser:l,openOrCreateDM:o,openConversation:d}){let c=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(r)return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)};function e(e){c.current&&!c.current.contains(e.target)&&n()}function t(e){"Escape"===e.key&&n()}},[r,n]),(0,t.jsxs)("div",{ref:c,className:"relative",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>r?n():s(),className:"inline-flex items-center gap-1 pl-0.5 pr-2 py-0.5 rounded-full text-[11px] font-semibold transition-all hover:shadow-sm hover:-translate-y-0.5",style:{background:"rgba(99,102,241,0.08)",border:"1px solid rgba(99,102,241,0.22)",color:"#4F46E5"},title:`Message someone at ${e.name}`,children:[(0,t.jsx)(tQ,{agency:e,size:16}),(0,t.jsx)("span",{className:"truncate max-w-[160px]",children:e.name}),(0,t.jsx)(tH.ChatBubbleLeftRightIcon,{className:"w-3 h-3 opacity-80"})]}),(0,t.jsx)(i.AnimatePresence,{children:r&&(0,t.jsx)(t5,{agency:e,currentUser:l,onClose:n,openOrCreateDM:o,openConversation:d})})]})}function t5({agency:e,currentUser:r,onClose:s,openOrCreateDM:n,openConversation:i}){let[o,d]=(0,a.useState)(""),[c,u]=(0,a.useState)([]),[x,p]=(0,a.useState)(!0),[m,h]=(0,a.useState)([]),[g,b]=(0,a.useState)(!1),f=(0,a.useRef)(null);async function y(){if(0!==m.length&&!g){b(!0);try{if(1===m.length){await n({otherUserId:m[0]._id}),s();return}let e=await fetch("/api/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"group",participantIds:m.map(e=>e._id)})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||"Failed to start group chat")}let t=await e.json(),a=t.conversation?._id?.toString?.();a&&(i(a),s())}catch(e){L.default.error(e.message||"Couldn't start chat")}finally{b(!1)}}}(0,a.useEffect)(()=>{f.current?.focus()},[]),(0,a.useEffect)(()=>{let t=!1,a=setTimeout(async()=>{p(!0);try{let a=new URLSearchParams({agency:e._id});o.trim().length>=2&&a.set("q",o.trim());let s=await fetch(`/api/users/search?${a.toString()}`);if(!s.ok)throw Error("Search failed");let n=await s.json();if(!t){let e=r?._id?.toString?.(),t=(n||[]).filter(t=>t._id?.toString?.()!==e);u(t)}}catch{t||u([])}finally{t||p(!1)}},150);return()=>{t=!0,clearTimeout(a)}},[e._id,o,r?._id]);let v=0===m.length?"Pick someone to message":1===m.length?`Start DM with ${m[0].name?.split(" ")[0]||"them"}`:`Start group chat (${m.length})`;return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.18,ease:tJ},className:"absolute z-50 left-0 mt-2 w-[320px] rounded-2xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(24px)",border:"1px solid var(--border-default)",boxShadow:"0 24px 64px var(--shadow-ambient-xl), 0 4px 16px var(--shadow-ambient)"},children:[(0,t.jsx)("div",{className:"h-[2px] bg-gradient-to-r from-indigo-500/70 via-violet-400/70 to-pink-500/70"}),(0,t.jsxs)("div",{className:"px-3 py-2.5 flex items-center gap-2",children:[(0,t.jsx)(tQ,{agency:e,size:22}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-[11px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Message"}),(0,t.jsx)("div",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100 truncate",children:e.name})]}),(0,t.jsx)("button",{type:"button",onClick:s,"aria-label":"Close",className:"w-7 h-7 inline-flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900",children:(0,t.jsx)(T.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})})]}),(0,t.jsx)("div",{className:"px-3 pb-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)(eR.MagnifyingGlassIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"}),(0,t.jsx)("input",{ref:f,type:"text",value:o,onChange:e=>d(e.target.value),placeholder:"Search peopleâ¦",className:"flex-1 bg-transparent border-0 outline-none text-[13px] text-gray-900 dark:text-zinc-100 placeholder:text-gray-400 dark:placeholder:text-zinc-600"})]})}),(0,t.jsx)("div",{className:"max-h-[260px] overflow-y-auto px-1.5",children:x?(0,t.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,t.jsx)("div",{className:"w-5 h-5 border-2 border-indigo-400/30 border-t-indigo-500 rounded-full animate-spin"})}):0===c.length?(0,t.jsxs)("div",{className:"px-3 py-6 text-center",children:[(0,t.jsx)(eN.UserGroupIcon,{className:"w-6 h-6 mx-auto text-gray-300 dark:text-zinc-700 mb-1.5"}),(0,t.jsx)("p",{className:"text-[12px] text-gray-400 dark:text-zinc-500",children:o.trim().length>=2?`No matches in ${e.name}`:`No teammates in ${e.name} yet`})]}):c.map(e=>{let a=m.some(t=>t._id===e._id);return(0,t.jsxs)("button",{type:"button",onClick:()=>{h(t=>t.some(t=>t._id===e._id)?t.filter(t=>t._id!==e._id):[...t,e])},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left transition-colors ${a?"bg-indigo-50 dark:bg-indigo-500/10":"hover:bg-gray-50 dark:hover:bg-zinc-900"}`,children:[e.image?(0,t.jsx)("img",{src:e.image,alt:e.name||"",className:"w-7 h-7 rounded-full object-cover shrink-0"}):(0,t.jsx)("span",{className:`w-7 h-7 shrink-0 rounded-full bg-gradient-to-br ${tY(e.name||e.email)} text-white flex items-center justify-center text-[11px] font-bold`,children:(e.name||e.email||"?")[0].toUpperCase()}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-[13px] font-semibold text-gray-900 dark:text-zinc-100 truncate",children:e.name||e.email}),e.name&&e.email&&(0,t.jsx)("div",{className:"text-[10.5px] text-gray-400 dark:text-zinc-500 truncate",children:e.email})]}),(0,t.jsx)("span",{className:`w-4 h-4 shrink-0 rounded-md flex items-center justify-center transition-all ${a?"bg-indigo-500 text-white":"border border-gray-300 dark:border-zinc-700"}`,children:a&&(0,t.jsx)(E.CheckIcon,{className:"w-3 h-3"})})]},e._id)})}),(0,t.jsx)("div",{className:"px-3 py-2 flex items-center justify-end gap-2",style:{borderTop:"1px solid var(--border-subtle)"},children:(0,t.jsxs)("button",{type:"button",onClick:y,disabled:0===m.length||g,className:"inline-flex items-center gap-1.5 text-[12px] font-bold px-3 py-1.5 rounded-lg text-white transition-all hover:shadow-md disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none",style:{background:0===m.length?"var(--surface-softer)":"linear-gradient(135deg, #6366F1, #8B5CF6)",color:0===m.length?"var(--text-tertiary)":"white"},children:[g?(0,t.jsx)("span",{className:"w-3 h-3 border-2 border-white/40 border-t-white rounded-full animate-spin dark:border-zinc-800/40"}):(0,t.jsx)(tH.ChatBubbleLeftRightIcon,{className:"w-3.5 h-3.5"}),v]})})]})}var t2=e.i(979259),t4=e.i(359161);let t3=[{value:"text",label:"Short text"},{value:"textarea",label:"Long text"},{value:"select",label:"Single select"},{value:"multi",label:"Multi-select"},{value:"date",label:"Date"},{value:"number",label:"Number"},{value:"file",label:"File / screenshot"},{value:"person",label:"Person picker"}],t6=[{key:"submitter",label:"Submitters see their own",description:"Each submitter sees only their own submissions. Board managers see everything."},{key:"open",label:"Everyone sees all",description:"Any board viewer can see every submission."},{key:"restricted",label:"Restricted viewers",description:"Only the people you list below see all submissions. Everyone else sees only their own."}];function t9(e){return String(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,40)||`field_${Date.now().toString(36)}`}function t8({boardId:e,form:r,teamMembers:s=[],onClose:n,onSaved:c}){let u=!!r?._id,[x,p]=(0,a.useState)(r?.title||""),[m,h]=(0,a.useState)(r?.description||""),[g,b]=(0,a.useState)((r?.fields||[]).map(e=>({_local:e._id||`local-${Math.random().toString(36).slice(2)}`,...e}))),[f,y]=(0,a.useState)(r?.submissionVisibility||"submitter"),[v,k]=(0,a.useState)((r?.allowedViewers||[]).map(e=>"object"==typeof e?e._id:e)),[j,w]=(0,a.useState)(!!r?.publicShare?.enabled),[N,C]=(0,a.useState)(r?.publicShare?.token||null),[S,z]=(0,a.useState)(!1),[_,D]=(0,a.useState)(!1),I=(0,o.useSensors)((0,o.useSensor)(o.PointerSensor,{activationConstraint:{distance:5}}));
2async function E(){if(!x.trim())return void L.default.error("Form needs a title");if(0===g.length)return void L.default.error("Add at least one field");let t=g.map((e,t)=>{let a=e.key&&e.key.trim()||t9(e.label)||`field_${t+1}`;return{...e._id?{_id:e._id}:{},key:a,label:(e.label||"").trim(),type:e.type,required:!!e.required,options:"select"===e.type||"multi"===e.type?(e.options||[]).filter(e=>e.label?.trim()&&e.value?.trim()):[],placeholder:e.placeholder||"",position:t}});for(let e of t)if(!e.label)return void L.default.error("Every field needs a label");z(!0);try{let a=u?`/api/task-boards/${e}/forms/${r._id}`:`/api/task-boards/${e}/forms`,s=await fetch(a,{method:u?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:x.trim(),description:m.trim(),fields:t,submissionVisibility:f,allowedViewers:"restricted"===f?v:[],publicShare:{enabled:j}})});if(s.ok){let e=await s.json();L.default.success(u?"Form updated":"Form created"),c?.(e.form),!u&&j&&e.form?.publicShare?.token?(C(e.form.publicShare.token),D(!0)):n()}else{let e=await s.json().catch(()=>({}));L.default.error(e.error||"Couldn't save the form")}}catch{L.default.error("Couldn't save the form")}finally{z(!1)}}return(0,t.jsx)(l.motion.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-[110] flex items-center justify-center p-4 bg-black/30 backdrop-blur-sm",onClick:n,children:(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:16,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.96},transition:{duration:.25,ease:[.25,.46,.45,.94]},className:"relative w-full max-w-2xl max-h-[92vh] flex flex-col rounded-2xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 20px 60px var(--shadow-ambient-2xl)",border:"1px solid var(--border-subtle)"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500 via-orange-400 to-violet-500"}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b",style:{borderColor:"var(--border-subtle)"},children:[(0,t.jsx)("h3",{className:"text-sm font-black tracking-tight text-gray-900 dark:text-zinc-100",children:u?"Edit form":"Create form"}),(0,t.jsx)("button",{onClick:n,className:"w-7 h-7 flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900",children:(0,t.jsx)(T.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})})]}),_?(0,t.jsxs)("div",{className:"p-5 space-y-4",children:[(0,t.jsxs)("div",{className:"rounded-xl p-4",style:{background:"linear-gradient(135deg, rgba(16,185,129,0.08), rgba(20,184,166,0.06))",border:"1.5px solid rgba(16,185,129,0.4)"},children:[(0,t.jsx)("div",{className:"text-[13px] font-bold text-gray-900 dark:text-zinc-100",children:"Form created â your share link is live"}),(0,t.jsx)("p",{className:"text-[11.5px] text-gray-500 dark:text-zinc-400 mt-1 leading-relaxed",children:"Anyone with this link can submit without an account. You can copy it again anytime from the form list or by editing the form."}),(0,t.jsx)(at,{token:N})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)("button",{type:"button",onClick:n,className:"text-xs px-4 py-2 text-white rounded-xl font-semibold",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 12px rgba(236,72,153,0.25)"},children:"Done"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Title"}),(0,t.jsx)("input",{type:"text",value:x,onChange:e=>p(e.target.value),placeholder:"e.g. Brief intake",className:"w-full text-sm px-3 py-2 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300/40 text-gray-900 dark:text-zinc-100",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),(0,t.jsx)("textarea",{value:m,onChange:e=>h(e.target.value),placeholder:"Describe what submitters need to provide",rows:2,className:"w-full text-[12.5px] px-3 py-2 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300/40 text-gray-700 dark:text-zinc-300 placeholder-gray-300 dark:placeholder-zinc-500",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:["Fields (",g.length,")"]}),(0,t.jsxs)("button",{type:"button",onClick:function(){let e={_local:`local-${Math.random().toString(36).slice(2)}`,key:"",label:"",type:"text",required:!1,options:[],placeholder:"",position:g.length};b(t=>[...t,e])},className:"inline-flex items-center gap-1.5 text-[11px] font-semibold px-2.5 py-1.5 rounded-lg",style:{background:"var(--surface-soft)",border:"1px dashed var(--border-default)",color:"var(--text-secondary)"},children:[(0,t.jsx)($.PlusIcon,{className:"w-3 h-3"}),"Add field"]})]}),(0,t.jsx)(o.DndContext,{sensors:I,collisionDetection:o.closestCenter,onDragEnd:e=>{let{active:t,over:a}=e;if(!a||t.id===a.id)return;let r=g.map(e=>e._local),s=r.indexOf(t.id),n=r.indexOf(a.id);s<0||n<0||b((0,d.arrayMove)(g,s,n))},children:(0,t.jsx)(d.SortableContext,{items:g.map(e=>e._local),strategy:d.verticalListSortingStrategy,children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.AnimatePresence,{children:g.map(e=>(0,t.jsx)(t7,{field:e,onChange:t=>{var a;return a=e._local,void b(e=>e.map(e=>e._local===a?{...e,...t}:e))},onRemove:()=>{var t;return t=e._local,void b(e=>e.filter(e=>e._local!==t))}},e._local))}),0===g.length&&(0,t.jsx)("div",{className:"text-center py-6 text-[12px] rounded-xl",style:{background:"var(--surface-soft)",border:"1px dashed var(--border-default)",color:"var(--text-tertiary)"},children:'No fields yet. Click "Add field" to start.'})]})})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 mb-2 block",children:"Who can see submissions"}),(0,t.jsx)("div",{className:"space-y-1.5",children:t6.map(e=>{let a=f===e.key;return(0,t.jsxs)("button",{type:"button",onClick:()=>y(e.key),className:"w-full text-left p-3 rounded-xl transition-all duration-150",style:{background:a?"linear-gradient(135deg, rgba(236,72,153,0.08), rgba(249,115,22,0.06))":"var(--surface-soft)",border:a?"1.5px solid rgba(236,72,153,0.4)":"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-[13px] font-bold text-gray-800 dark:text-zinc-100",children:e.label}),a&&(0,t.jsx)("span",{className:"text-[9px] font-black uppercase tracking-wider px-1.5 py-0.5 rounded text-white",style:{background:"linear-gradient(135deg, #EC4899, #F97316)"},children:"Active"})]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-0.5",children:e.description})]},e.key)})}),"restricted"===f&&(0,t.jsxs)("div",{className:"mt-2.5",children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 mb-1.5 block",children:["Allowed viewers (",v.length,")"]}),(0,t.jsx)("div",{className:"rounded-xl p-2 max-h-44 overflow-y-auto",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:0===s.length?(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-2",children:"No teammates available"}):s.map(e=>{let a=v.includes(e._id);return(0,t.jsxs)("button",{type:"button",onClick:()=>k(t=>a?t.filter(t=>t!==e._id):[...t,e._id]),className:"w-full p-2 rounded-lg flex items-center gap-2.5 hover:bg-white/60 dark:hover:bg-zinc-900/60",children:[(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-gradient-to-br from-pink-500 to-orange-400 flex items-center justify-center text-white text-[10px] font-bold",children:(e.name||"?")[0]?.toUpperCase()}),(0,t.jsx)("span",{className:"flex-1 text-left text-[12.5px] font-semibold text-gray-800 dark:text-zinc-100 truncate",children:e.name}),(0,t.jsx)("span",{className:"w-5 h-5 rounded-md flex items-center justify-center transition-all",style:a?{background:"#10B981",boxShadow:"0 0 6px rgba(16,185,129,0.3)"}:{border:"1.5px dashed var(--shadow-ambient-xl)"}
2,children:a&&(0,t.jsx)("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})]},e._id)})})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 mb-2 block",children:"Public link"}),(0,t.jsxs)("div",{className:"rounded-xl p-3 flex items-start gap-3",style:{background:j?"linear-gradient(135deg, rgba(16,185,129,0.08), rgba(20,184,166,0.06))":"var(--surface-soft)",border:j?"1.5px solid rgba(16,185,129,0.4)":"1px solid var(--border-subtle)"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>w(e=>!e),role:"switch","aria-checked":j,className:"relative rounded-full flex-shrink-0 mt-0.5 transition-colors",style:{width:40,height:22,background:j?"linear-gradient(135deg, #10B981, #059669)":"var(--surface-softer)",border:j?"1px solid transparent":"1px solid var(--border-default)",boxShadow:j?"0 2px 8px rgba(16,185,129,0.25)":"none"},children:(0,t.jsx)("span",{className:"block rounded-full bg-white dark:bg-white shadow-sm transition-transform",style:{position:"absolute",top:2,left:2,width:16,height:16,transform:j?"translateX(18px)":"translateX(0px)"}})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-[12.5px] font-bold text-gray-800 dark:text-zinc-100",children:j?"Anyone with the link can submit":"Public link is off"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-0.5 leading-relaxed",children:"Submitters don't need an account. Visibility of the responses still follows the access tier above â only managers + invited viewers can read submissions."}),j&&N&&(0,t.jsx)(at,{token:N}),j&&!N&&!u&&(0,t.jsx)("p",{className:"text-[11px] mt-2 italic",style:{color:"var(--text-tertiary)"},children:"A share link will be generated as soon as you save the form."}),j&&!N&&u&&(0,t.jsx)("p",{className:"text-[11px] mt-2 italic",style:{color:"var(--text-tertiary)"},children:"Save to generate the share link."})]})]})]})]}),(0,t.jsxs)("div",{className:"px-5 py-3 border-t flex items-center justify-end gap-2",style:{borderColor:"var(--border-subtle)"},children:[(0,t.jsx)("button",{type:"button",onClick:n,className:"text-xs font-semibold px-3 py-2 rounded-xl transition-colors",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:"Cancel"}),(0,t.jsx)("button",{type:"button",onClick:E,disabled:S,className:"text-xs px-4 py-2 text-white rounded-xl font-semibold disabled:opacity-40",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 12px rgba(236,72,153,0.25)"},children:S?"Savingâ¦":u?"Save changes":"Create form"})]})]})]})})}function t7({field:e,onChange:a,onRemove:r}){let{attributes:s,listeners:n,setNodeRef:l,transform:i,transition:o,isDragging:u}=(0,d.useSortable)({id:e._local}),x={transform:c.CSS.Transform.toString(i),transition:o,opacity:u?.5:1},p="select"===e.type||"multi"===e.type;return(0,t.jsx)("div",{ref:l,style:x,...s,className:"rounded-xl p-2.5",children:(0,t.jsxs)("div",{className:"rounded-xl p-3",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,t.jsx)("button",{type:"button",...n,className:"text-gray-300 dark:text-zinc-700 hover:text-gray-500 dark:hover:text-zinc-400 cursor-grab active:cursor-grabbing flex-shrink-0",title:"Drag to reorder","aria-label":"Drag to reorder",children:(0,t.jsx)(F.Bars3Icon,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("input",{type:"text",value:e.label,onChange:e=>a({label:e.target.value}),placeholder:"Field label",className:"text-[13px] font-semibold flex-1 px-2 py-1 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-300/40 text-gray-900 dark:text-zinc-100 bg-transparent",style:{border:"1px solid var(--border-subtle)"}}
2),(0,t.jsx)("select",{value:e.type,onChange:e=>a({type:e.target.value}),className:"text-[12px] px-2 py-1 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-300/40 text-gray-700 dark:text-zinc-200 bg-transparent",style:{border:"1px solid var(--border-subtle)"},children:t3.map(e=>(0,t.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,t.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-zinc-400 select-none",children:[(0,t.jsx)("input",{type:"checkbox",checked:e.required,onChange:e=>a({required:e.target.checked}),className:"accent-orange-500"}),"Required"]}),(0,t.jsx)("button",{type:"button",onClick:r,className:"w-7 h-7 rounded-lg flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10",title:"Remove field",children:(0,t.jsx)(m.TrashIcon,{className:"w-3.5 h-3.5"})})]}),(0,t.jsx)("input",{type:"text",value:e.placeholder||"",onChange:e=>a({placeholder:e.target.value}),placeholder:"Placeholder / hint",className:"text-[12px] w-full px-2 py-1 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-300/40 text-gray-700 dark:text-zinc-300 placeholder-gray-300 dark:placeholder-zinc-500 bg-transparent",style:{border:"1px solid var(--border-subtle)"}}),p&&(0,t.jsx)(ae,{options:e.options||[],onChange:e=>a({options:e})})]})})}function ae({options:e,onChange:a}){function r(t,r){a(e.map((e,a)=>a===t?{...e,...r}:e))}return(0,t.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,t.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500",children:"Options"}),e.map((s,n)=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("input",{type:"text",value:s.label,onChange:e=>r(n,{label:e.target.value,value:s.value||t9(e.target.value)}),placeholder:"Label",className:"text-[11.5px] flex-1 px-2 py-1 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-300/40 text-gray-800 dark:text-zinc-200 bg-transparent",style:{border:"1px solid var(--border-subtle)"}}),(0,t.jsx)("input",{type:"text",value:s.value,onChange:e=>r(n,{value:e.target.value}),placeholder:"value",className:"text-[11.5px] w-28 px-2 py-1 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-300/40 text-gray-500 dark:text-zinc-400 bg-transparent",style:{border:"1px solid var(--border-subtle)"}}),(0,t.jsx)("button",{type:"button",onClick:()=>{a(e.filter((e,t)=>t!==n))},className:"w-6 h-6 rounded-md flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3 h-3"})})]},n)),(0,t.jsxs)("button",{type:"button",onClick:function(){a([...e,{label:"",value:""}])},className:"inline-flex items-center gap-1 text-[11px] font-semibold text-violet-500 hover:text-violet-600",children:[(0,t.jsx)($.PlusIcon,{className:"w-3 h-3"}),"Add option"]})]})}function at({token:e}){let a=`${window.location.origin}/forms/${e}`;return(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-1.5 rounded-md px-2 py-1.5",style:{background:"var(--surface-panel)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("code",{className:"flex-1 text-[11px] text-gray-700 dark:text-zinc-300 truncate font-mono",children:a}),(0,t.jsx)("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(a),L.default.success("Link copied")}catch{L.default.error("Couldn't copy")}},className:"text-[10px] font-bold uppercase tracking-wider px-2 py-1 rounded text-white",style:{background:"linear-gradient(135deg, #10B981, #059669)"},children:"Copy"})]})}function aa(e){return"multi"===e.type||"person"===e.type?[]:""}function ar({boardId:e,form:r,teamMembers:s=[],onSubmitted:n}){let[i,o]=(0,a.useState)(()=>{let e={};for(let t of r.fields||[])e[t.key]=aa(t);return e}),[d,c]=(0,a.useState)({}),[u,x]=(0,a.useState)(!1);async function p(){let e=[];for(let[t,a]of Object.entries(d))for(let r of a||[])try{let a=new FormData;a.append("file",r);let s=await fetch("/api/tasks/upload-attachment",{method:"POST",body:a});if(!s.ok)throw Error("upload_failed");let n=await s.json();e.push({key:t,url:n.url,name:n.name||r.name||"",size:n.size||r.size||0,mimeType:n.mimeType||r.type||""})}catch{L.default.error(`Couldn't upload ${r.name||"a file"}`)}return e}async function m(){x(!0);try{let t=await p(),a={...i};for(let e of t){let t=Array.isArray(a[e.key])?a[e.key]:a[e.key]?[a[e.key]]:[];a[e.key]=[...t,e.url]}let s=await fetch(`/api/task-boards/${e}/forms/${r._id}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({answers:a,fileAttachments:t})});if(!s.ok){let e=await s.json().catch(()=>({}));L.default.error(e.error||"Couldn't submit");return}let l=await s.json();L.default.success("Submitted"),n?.(l.submission),o(()=>{let e={};for(let t of r.fields||[])e[t.key]=aa(t);return e}),c({})}catch{L.default.error("Couldn't submit")}finally{x(!1)}}return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:6}
2,animate:{opacity:1,y:0},transition:{duration:.2},className:"rounded-2xl border p-5",style:{background:"var(--surface-frosted)",borderColor:"var(--border-subtle)"},children:[(0,t.jsx)("h3",{className:"text-base font-black tracking-tight text-gray-900 dark:text-zinc-100 mb-1",children:r.title}),r.description&&(0,t.jsx)("p",{className:"text-[13px] text-gray-600 dark:text-zinc-400 mb-4",children:r.description}),(0,t.jsx)("div",{className:"space-y-4",children:(r.fields||[]).map(e=>(0,t.jsx)(as,{field:e,value:i[e.key],onChange:t=>{var a;return a=e.key,void o(e=>({...e,[a]:t}))},pending:d[e.key]||[],onAttach:t=>{var a;let r;return a=e.key,void(0!==(r=Array.from(t||[])).length&&c(e=>({...e,[a]:[...e[a]||[],...r]})))},onRemovePending:t=>{var a;return a=e.key,void c(e=>({...e,[a]:(e[a]||[]).filter((e,a)=>a!==t)}))},teamMembers:s},e.key))}),(0,t.jsx)("div",{className:"mt-5 flex justify-end",children:(0,t.jsx)("button",{type:"button",onClick:m,disabled:u,className:"text-xs px-4 py-2 text-white rounded-xl font-semibold disabled:opacity-40",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 12px rgba(236,72,153,0.25)"},children:u?"Submittingâ¦":"Submit"})})]})}function as({field:e,value:a,onChange:r,pending:s,onAttach:n,onRemovePending:l,teamMembers:i}){let o={background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},d="w-full text-sm px-3 py-2 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300/40 text-gray-900 dark:text-zinc-100";function c(){return(0,t.jsxs)("label",{className:"block text-[12px] font-semibold text-gray-700 dark:text-zinc-300 mb-1.5",children:[e.label,e.required&&(0,t.jsx)("span",{className:"ml-1 text-pink-500","aria-label":"required",children:"*"})]})}if("textarea"===e.type)return(0,t.jsxs)("div",{children:[(0,t.jsx)(c,{}),(0,t.jsx)("textarea",{value:a||"",onChange:e=>r(e.target.value),placeholder:e.placeholder||"",rows:3,className:d,style:{...o,resize:"vertical"}})]});if("select"===e.type)return(0,t.jsxs)("div",{children:[(0,t.jsx)(c,{}),(0,t.jsxs)("select",{value:a||"",onChange:e=>r(e.target.value),className:d,style:o,children:[(0,t.jsx)("option",{value:"",children:"â pick one â"}),(e.options||[]).map(e=>(0,t.jsx)("option",{value:e.value,children:e.label},e.value))]})]});if("multi"===e.type){let s=Array.isArray(a)?a:[];return(0,t.jsxs)("div",{children:[(0,t.jsx)(c,{}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:(e.options||[]).map(e=>{let a=s.includes(e.value);return(0,t.jsx)("button",{type:"button",onClick:()=>r(a?s.filter(t=>t!==e.value):[...s,e.value]),className:"text-[12px] font-semibold px-2.5 py-1.5 rounded-lg transition-all",style:{background:a?"linear-gradient(135deg, #F97316, #EC4899)":"var(--surface-soft)",color:a?"white":"var(--text-secondary)",border:a?"1px solid transparent":"1px solid var(--border-subtle)"},children:e.label},e.value)})})]})}if("date"===e.type)return(0,t.jsxs)("div",{children:[(0,t.jsx)(c,{}),(0,t.jsx)("input",{type:"date",value:a||"",onChange:e=>r(e.target.value),className:d,style:o})]});if("number"===e.type)return(0,t.jsxs)("div",{children:[(0,t.jsx)(c,{}),(0,t.jsx)("input",{type:"number",value:a??"",onChange:e=>r(e.target.value),placeholder:e.placeholder||"",className:d,style:o})]});if("person"===e.type){let e=Array.isArray(a)?a:[];return(0,t.jsxs)("div",{children:[(0,t.jsx)(c,{}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:i.map(a=>{let s=e.includes(a._id);return(0,t.jsxs)("button",{type:"button",onClick:()=>r(s?e.filter(e=>e!==a._id):[...e,a._id]),className:"text-[12px] font-semibold inline-flex items-center gap-1.5 pl-0.5 pr-2.5 py-0.5 rounded-full transition-all",style:{background:s?"linear-gradient(135deg, rgba(236,72,153,0.15), rgba(249,115,22,0.12))":"var(--surface-soft)",color:"var(--text-primary)",border:s?"1px solid rgba(236,72,153,0.4)":"1px solid var(--border-subtle)"},children:[(0,t.jsx)("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[9px] font-bold text-white",style:{background:"linear-gradient(135deg, #ec4899, #f97316)"},children:(a.name||"?")[0]?.toUpperCase()}),a.name]},a._id)})})]})}return"file"===e.type?(0,t.jsxs)("div",{children:[(0,t.jsx)(c,{}),(0,t.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-[12px] font-semibold px-3 py-2 rounded-xl cursor-pointer",style:{background:"var(--surface-soft)",border:"1px dashed var(--border-default)",color:"var(--text-secondary)"},children:[(0,t.jsx)(f.PaperClipIcon,{className:"w-3.5 h-3.5"}),"Attach file",(0,t.jsx)("input",{type:"file",multiple:!0,accept:"image/*,video/*,application/pdf",className:"hidden",onChange:e=>n(e.target.files)})]}),s.length>0&&(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.map((e,a)=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px]",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("span",{className:"truncate max-w-[180px]",children:e.name}),(0,t.jsx)("button",{type:"button",onClick:()=>l(a),className:"text-gray-400 dark:text-zinc-500 hover:text-red-500",children:(0,t.jsx)(T.XMarkIcon,{className:"w-3 h-3"})})]},a))})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)(c,{}),(0,t.jsx)("input",{type:"text",value:a||"",onChange:e=>r(e.target.value),placeholder:e.placeholder||"",className:d,style:o})]})}var an=e.i(779529);function al({boardId:e,form:r,currentUserId:s,isManager:n}){let[i,o]=(0,a.useState)([]),[d,c]=(0,a.useState)(!0),[u,x]=(0,a.useState)(!1);async function p(){try{let t=await fetch(`/api/task-boards/${e}/forms/${r._id}/submissions`);if(t.ok){let e=await t.json();o(e.submissions||[])}}catch(e){console.error("Failed to load submissions:",e)}finally{c(!1),x(!1)}}async function h(t){if(confirm("Delete this submission? This can't be und
2one."))try{(await fetch(`/api/task-boards/${e}/forms/${r._id}/submissions/${t}`,{method:"DELETE"})).ok?(o(e=>e.filter(e=>e._id!==t)),L.default.success("Submission removed")):L.default.error("Couldn't delete")}catch{L.default.error("Couldn't delete")}}return((0,a.useEffect)(()=>{p()},[r._id]),d)?(0,t.jsx)("div",{className:"rounded-2xl border p-6 text-center",style:{background:"var(--surface-frosted)",borderColor:"var(--border-subtle)",color:"var(--text-tertiary)"},children:"Loading submissionsâ¦"}):(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2},className:"rounded-2xl border overflow-hidden",style:{background:"var(--surface-frosted)",borderColor:"var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b",style:{borderColor:"var(--border-subtle)"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-black tracking-tight text-gray-900 dark:text-zinc-100",children:"Submissions"}),(0,t.jsxs)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-0.5",children:[i.length," total · visibility:"," ",(0,t.jsx)("span",{className:"font-semibold capitalize",children:r.submissionVisibility})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{x(!0),p()},className:"w-7 h-7 rounded-lg flex items-center justify-center hover:bg-gray-100 dark:hover:bg-zinc-900",title:"Refresh",children:(0,t.jsx)(an.ArrowPathIcon,{className:`w-3.5 h-3.5 text-gray-500 dark:text-zinc-400 ${u?"animate-spin":""}`})})]}),0===i.length?(0,t.jsx)("div",{className:"px-4 py-8 text-center text-[13px]",style:{color:"var(--text-tertiary)"},children:"No submissions yet."}):(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"min-w-full text-[12.5px]",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"text-left",style:{background:"var(--surface-soft)",borderBottom:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("th",{className:"px-3 py-2 font-bold text-[10px] uppercase tracking-wider text-gray-500 dark:text-zinc-400",children:"Submitter"}),(0,t.jsx)("th",{className:"px-3 py-2 font-bold text-[10px] uppercase tracking-wider text-gray-500 dark:text-zinc-400",children:"When"}),(r.fields||[]).map(e=>(0,t.jsx)("th",{className:"px-3 py-2 font-bold text-[10px] uppercase tracking-wider text-gray-500 dark:text-zinc-400",children:e.label},e.key)),(0,t.jsx)("th",{className:"px-3 py-2 w-10"})]})}),(0,t.jsx)("tbody",{children:i.map(e=>{let a=e.submittedBy?._id?.toString?.()===s,l=e.answers instanceof Map?Object.fromEntries(e.answers
2):e.answers||{};return(0,t.jsxs)("tr",{className:"border-t",style:{borderColor:"var(--border-subtle)"},children:[(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"font-semibold text-gray-800 dark:text-zinc-100 truncate max-w-[180px]",children:e.submittedBy?.name||e.submittedByName||e.submittedByEmail||("public"===e.source?"Anonymous":"Someone")}),"public"===e.source&&(0,t.jsx)("span",{className:"text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"rgba(14,165,233,0.10)",color:"#0EA5E9",border:"1px solid rgba(14,165,233,0.25)"},title:"Submitted via public link",children:"Public"})]})}),(0,t.jsx)("td",{className:"px-3 py-2 text-gray-500 dark:text-zinc-400",children:new Date(e.createdAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}),(r.fields||[]).map(a=>(0,t.jsx)("td",{className:"px-3 py-2 text-gray-700 dark:text-zinc-300 max-w-[260px] truncate",title:String(l[a.key]??""),children:"file"===a.type&&l[a.key]?(0,t.jsx)(ai,{value:l[a.key],attachments:e.fileAttachments||[],fieldKey:a.key}):function(e,t,a){if(null==t||""===t)return"â";if("multi"===e.type)return(Array.isArray(t)?t:[]).map(t=>(e.options||[]).find(e=>e.value===t)?.label||t).join(", ")||"â";if("select"===e.type){let a=(e.options||[]).find(e=>e.value===t);return a?.label||t}if("date"===e.type)try{return new Date(t).toLocaleDateString()}catch{return t}if("person"===e.type){let e=Array.isArray(t)?t:[t];return`${e.length} person${1===e.length?"":"s"}`}if("file"===e.type){let e=Array.isArray(t)?t:[t];return e.length>0?`${e.length} file${1===e.length?"":"s"}`:"â"}return String(t)}(a,l[a.key],e.fileAttachments)},a.key)),(0,t.jsx)("td",{className:"px-3 py-2 text-right",children:(n||a)&&(0,t.jsx)("button",{type:"button",onClick:()=>h(e._id),className:"w-6 h-6 rounded-md flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10",title:"Delete submission",children:(0,t.jsx)(m.TrashIcon,{className:"w-3.5 h-3.5"})})})]},e._id)})})]})})]})}function ai({value:e,attachments:a,fieldKey:r}){let s=(Array.isArray(e)?e:[e]).map(e=>a.find(t=>t.url===e&&t.key===r)||{url:e,name:e}).filter(Boolean);return(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:s.map((e,a)=>(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] font-semibold text-indigo-500 hover:text-indigo-600",children:[(0,t.jsx)(j.ArrowTopRightOnSquareIcon,{className:"w-3 h-3"}),(0,t.jsx)("span",{className:"truncate max-w-[120px]",children:e.name||"file"})]},a))})}function ao({boardId:e,isManager:r,currentUserId:s,teamMembers:n=[],externalCreateNonce:o=0,initialFormId:d=null,onActiveFormChange:c}){let[u,x]=(0,a.useState)([]),[p,h]=(0,a.useState)(null),[g,b]=(0,a.useState)("fill"),[f,v]=(0,a.useState)(!0),[k,j]=(0,a.useState)(!1),[w,N]=(0,a.useState)(null);async function C(){try{let t=await fetch(`/api/task-boards/${e}/forms`);if(t.ok){let e=await t.json();if(x(e.forms||[]),!p&&e.forms?.length){let t=d&&e.forms.some(e=>e._id===d);h(t?d:e.forms[0]._id)}}}catch(e){console.error("Failed to load forms:",e)}finally{v(!1)}}async function S(t){if(confirm("Delete this form and all its submissions? This can't be undone."))try{(await fetch(`/api/task-boards/${e}/forms/${t}`,{method:"DELETE"})).ok?(x(e=>e.filter(e=>e._id!==t)),p===t&&h(null),L.default.success("Form deleted")):L.default.error("Couldn't delete the form")}catch{L.default.error("Couldn't delete the form")}}(0,a.useEffect)(()=>{o&&r&&(N(null),j(!0))},[o,r]),(0,a.useEffect)(()=>{C()},[e]),(0,a.useEffect)(()=>{p&&c?.(p)},[p]);let z=u.find(e=>e._id===p)||null;return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25},className:"grid grid-cols-1 md:grid-cols-[260px_1fr] gap-4",children:[(0,t.jsxs)("div",{className:"rounded-2xl border p-3",style:{background:"var(--surface-frosted)",borderColor:"var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.16em] text-gray-500 dark:text-zinc-400",children:"Forms"})}),r&&(0,t.jsxs)("button",{type:"button",onClick:()=>{N(null),j(!0)},className:"w-full inline-flex items-center justify-center gap-1.5 text-[12px] font-bold px-3 py-2 rounded-xl transition-all hover:-translate-y-0.5 hover:shadow-lg mb-2",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",color:"white",boxShadow:"0 4px 12px rgba(236,72,153,0.25)"},title:"Create a new form",children:[(0,t.jsx)($.PlusIcon,{className:"w-3.5 h-3.5"}),"Create form"]}),f?(0,t.jsx)("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:"Loadingâ¦"}):0===u.length?(0,t.jsx)("div",{className:"text-[12px] text-center py-6 px-2",style:{color:"var(--text-tertiary)"},children:r?'No forms yet. Click "New" to create one.':"No forms on this board."}):(0,t.jsx)("div",{className:"space-y-1",children:u.map(e=>{let a=p===e._id;return(0,t.jsxs)("div",{className:"group flex items-center gap-1.5 rounded-lg",children:[(0,t.jsx)("button",{type:"button",onClick:()=>
2{h(e._id),b("fill")},className:"flex-1 text-left px-2.5 py-2 rounded-lg transition-colors",style:{background:a?"linear-gradient(135deg, rgba(236,72,153,0.12), rgba(249,115,22,0.08))":"transparent",border:a?"1px solid rgba(236,72,153,0.3)":"1px solid transparent"},children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(t4.DocumentTextIcon,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:a?"#EC4899":"var(--text-tertiary)"}}),(0,t.jsx)("span",{className:"text-[12.5px] font-semibold text-gray-800 dark:text-zinc-100 truncate",children:e.title})]})}),e.publicShare?.enabled&&e.publicShare?.token&&(0,t.jsx)("button",{type:"button",onClick:async()=>{let t=`${window.location.origin}/forms/${e.publicShare.token}`;try{await navigator.clipboard.writeText(t),L.default.success("Public form link copied")}catch{L.default.error("Couldn't copy")}},className:"w-6 h-6 rounded-md flex-shrink-0 flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-emerald-500 hover:bg-emerald-50 dark:hover:bg-emerald-500/10 opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy public form link",children:(0,t.jsx)(y.LinkIcon,{className:"w-3 h-3"})}),r&&(0,t.jsxs)("div",{className:"flex items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{N(e),j(!0)},className:"w-6 h-6 rounded-md flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-emerald-500 hover:bg-emerald-50 dark:hover:bg-emerald-500/10",title:"Edit form",children:(0,t.jsx)(t2.PencilIcon,{className:"w-3 h-3"})}),(0,t.jsx)("button",{type:"button",onClick:()=>S(e._id),className:"w-6 h-6 rounded-md flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10",title:"Delete form",children:(0,t.jsx)(m.TrashIcon,{className:"w-3 h-3"})})]})]},e._id)})})]}),(0,t.jsx)("div",{children:z?(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"inline-flex items-center p-0.5 rounded-xl mb-3",style:{background:"var(--surface-frosted)",border:"1px solid var(--border-subtle)"},children:[{key:"fill",label:"Fill out"},{key:"submissions",label:"Submissions"}].map(e=>{let a=g===e.key;return(0,t.jsx)("button",{type:"button",onClick:()=>b(e.key),className:"text-[11px] font-bold px-3 py-1.5 rounded-lg transition-colors",style:{background:a?"linear-gradient(135deg, #F97316, #EC4899)":"transparent",color:a?"white":"var(--text-tertiary)",boxShadow:a?"0 2px 8px rgba(236,72,153,0.22)":"none"},children:e.label},e.key)})}),(0,t.jsx)(i.AnimatePresence,{mode:"wait",children:"fill"===g?(0,t.jsx)(ar,{boardId:e,form:z,teamMembers:n,onSubmitted:()=>b("submissions")},`fill-${z._id}`):(0,t.jsx)(al,{boardId:e,form:z,currentUserId:s,isManager:r},`subs-${z._id}`)})]}):(0,t.jsxs)("div",{className:"rounded-2xl border p-12 text-center",style:{background:"var(--surface-frosted)",borderColor:"var(--border-subtle)",color:"var(--text-tertiary)"},children:[(0,t.jsx)(t4.DocumentTextIcon,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),(0,t.jsx)("p",{className:"text-[13px] mb-4",children:0===u.length?"No forms on this board yet.":"Pick a form on the left to view or fill it."}),r&&0===u.length&&(0,t.jsxs)("button",{type:"button",onClick:()=>{N(null),j(!0)},className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold text-white transition-all duration-200 hover:-translate-y-0.5 hover:shadow-lg",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 16px rgba(236,72,153,0.25)"},children:[(0,t.jsx)($.PlusIcon,{className:"w-4 h-4"}),"Create your first form"]}),!r&&0===u.length&&(0,t.jsx)("p",{className:"text-[12px] mt-2",style:{color:"var(--text-tertiary)"},children:"Only the board creator can build forms here."})]})}),(0,t.jsx)(i.AnimatePresence,{children:k&&(0,t.jsx)(t8,{boardId:e,form:w,teamMembers:n,onClose:()=>{j(!1),N(null)},onSaved:e=>{x(t=>t.some(t=>t._id===e._id)?t.map(t=>t._id===e._id?e:t):[e,...t]),h(e._id),b("fill")}})})]})}var ad=e.i(437902),ac=e.i(346395);let au=a.forwardRef(function({title:e,titleId:t,...r},s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},r),e?a.createElement("title",{id:t},e):null,a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.25 7.5A2.25 2.25 0 0 1 7.5 5.25h9a2.25 2.25 0 0 1 2.25 2.25v9a2.25 2.25 0 0 1-2.25 2.25h-9a2.25 2.25 0 0 1-2.25-2.25v-9Z"}))}),ax=["low","medium","high","critical"];function ap({open:e,onClose:r,boardId:s,defaultGroup:n,teamMembers:o=[],onTaskCreated:d}){let[c,u]=(0,a.useState)("record"),[x,p]=(0,a.useState)(""),[m,h]=(0,a.useState)(!1),[g,b]=(0,a.useState)(null),f=(0,a.useRef)(null),y=(0,a.useRef)(""),[v,k]=(0,a.useState)(""),j=!!(window.webkitSpeechRecognition||window.SpeechRecognition);function w(){if(f.current){try{f.current.stop()}catch{}f.current=null}h(!1)}async function N(){let e=x.trim();if(!e)return void L.default.error("Say something first");w(),u("parsing");try{let t=await fetch("/api/tasks/ai/from-transcript",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({transcript:e,boardId:s})});if(!t.ok){let e=await t.json().catch(()=>({}));L.default.error(e.error||"Couldn't parse the transcript"),u("record");return}let a=await t.json();b({title:a.spec?.title||"",description:a.spec?.description||"",dueDate:a.spec?.dueDate||"",priority:a.spec?.priority||"medium",assignees:a.spec?.assignees||[],unresolvedNames:a.spec?.assigneeNames||[],subTasks:a.spec?.subTasks||[]}),u("review")}catch{L.default.error("Couldn't parse the transcript"),u("record")}}async function C(){if(!g?.title?.trim())return void L.default.error("Task needs a title");u("creating");try{let e={title:g.title.trim(),description:g.description?.trim()||"",priority:g.priority||"medium",assignees:g.assignees||[],dueDate:g.dueDate||null,subItems:(g.subTasks||[]).map(e=>({title:e.title?.trim()})).filter(e=>e.title)};s&&(e.board=s),n&&(e.group=n);let t=await fetch("/api/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));L.default.error(e.error||"Couldn't create the task"),u("review");return}let a=await t.json();L.default.success("Task created"),d?.(a.task||a),r()}catch{L.default.error("Couldn't create the task"),u("review")}}return(0,a.useEffect)(()=>{e?(u("record"),p(""),b(null),k(""),y.current=""):w()},[e]),e?(0,t.jsx)(l.motion.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-[110] flex items-center justify-center p-4 bg-black/30 backdrop-blur-sm",onClick:r,children:(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:16,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.96},transition:{duration:.25,ease:[.25,.46,.45,.94]},className:"relative w-full max-w-xl max-h-[92vh] flex flex-col rounded-2xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 20px 60px var(--shadow-ambient-2xl)",border:"1px solid var(--border-subtle)"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500 via-orange-400 to-violet-500"}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b",style:{borderColor:"var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(236,72,153,0.14), rgba(249,115,22,0.14))",border:"1px solid rgba(236,72,153,0.25)"},children:(0,t.jsx)(ac.MicrophoneIcon,{className:"w-3.5 h-3.5 text-pink-500"})}),(0,t.jsx)("h3",{className:"text-sm font-black tracking-tight text-gray-900 dark:text-zinc-100",children:"record"===c?"Dictate a task":"parsing"===c?"Parsing your transcriptâ¦":"review"===c?"Review the task":"Creatingâ¦"})]}),(0,t.jsx)("button",{onClick:r,className:"w-7 h-7 flex items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900",children:(0,t.jsx)(T.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})})]}),(0,t.jsx)("div",{className:"overflow-y-auto flex-1 p-5",children:(0,t.jsx)(i.AnimatePresence,{mode:"wait",children:"record"===c?(0,t.jsx)(am,{speechSupported:j,isListening:m,transcript:x,interim:v,onStart:function(){if(!j)return void L.default.error("This browser doesn't support voice input â type your task instead.");let e=new(window.SpeechRecognition||window.webkitSpeechRecognition);e.continuous=!0,e.interimResults=!0,e.lang="en-US",e.onresult=e=>{let t="";for(let a=e.resultIndex;a<e.results.length;a++){let r=e.results[a];r.isFinal?y.current+=(y.current?" ":"")+r[0].transcript.trim():t+=r[0].transcript}k(t),p(y.current+(t?` ${t}`:""))},e.onerror=e=>{e.error&&"no-speech"!==e.error&&L.default.error(`Voice input error: ${e.error}`),h(!1)},e.onend=()=>{h(!1)},f.current=e;try{e.start(),h(!0)}catch{}},onStop:w,onChangeTranscript:e=>{p(e),y.current=e,k("")},onContinue:N},"record"):"parsing"===c?(0,t.jsx)("div",{className:"py-12 text-center text-[13px]",style:{color:"var(--text-tertiary)"},children:(0,t.jsxs)(l.motion.div,{initial:{opacity:0,scale:.92},animate:{opacity:1,scale:1},className:"inline-flex items-center gap-2",children:[(0,t.jsx)("span",{className:"inline-block w-3 h-3 rounded-full bg-pink-500 animate-pulse"}),"Reading your transcript and pulling out the taskâ¦"]})},"parsing"):(0,t.jsx)(ah,{spec:g,setSpec:b,teamMembers:o},"review")})}),(0,t.jsxs)("div",{className:"px-5 py-3 border-t flex items-center justify-end gap-2",style:{borderColor:"var(--border-subtle)"},children:["review"===c&&(0,t.jsx)("button",{type:"button",onClick:()=>u("record"),className:"text-xs font-semibold px-3 py-2 rounded-xl",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:"Re-record"}),(0,t.jsx)("button",{type:"button",onClick:r,className:"text-xs font-semibold px-3 py-2 rounded-xl",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:"Cancel"}),"record"===c&&(0,t.jsx)("button",{type:"button",onClick:N,disabled:!x.trim(),className:"text-xs px-4 py-2 text-white rounded-xl font-semibold disabled:opacity-40",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 12px rgba(236,72,153,0.25)"},children:"Parse â"}),"review"===c&&(0,t.jsx)("button",{type:"button",onClick:C,className:"text-xs px-4 py-2 text-white rounded-xl font-semibold",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 12px rgba(236,72,153,0.25)"},children:"Create task"})]})]})}):null}function am({speechSupported:e,isListening:a,transcript:r,interim:s,onStart:n,onStop:i,onChangeTranscript:o,onContinue:d}){return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:6}
2,animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.2},className:"space-y-4",children:[e?(0,t.jsxs)("div",{className:"jsx-8a46e716d2ea1b5 text-center",children:[(0,t.jsx)("button",{type:"button",onClick:a?i:n,style:{background:a?"linear-gradient(135deg, #EF4444, #EC4899)":"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:a?"0 0 0 0 rgba(239,68,68,0.5)":"0 6px 16px rgba(236,72,153,0.35)",animation:a?"voicePulse 1.4s ease-in-out infinite":"none"},"aria-label":a?"Stop recording":"Start recording",className:"jsx-8a46e716d2ea1b5 relative inline-flex items-center justify-center w-16 h-16 rounded-full transition-all duration-300 hover:scale-105 active:scale-95",children:a?(0,t.jsx)(au,{className:"w-7 h-7 text-white"}):(0,t.jsx)(ac.MicrophoneIcon,{className:"w-7 h-7 text-white"})}),(0,t.jsx)("p",{style:{color:"var(--text-secondary)"},className:"jsx-8a46e716d2ea1b5 text-[12px] mt-3",children:a?"Listening⦠click stop when you're done.":"Tap the mic and describe the task. Mention sub-tasks, due dates, who you want to help."})]}):(0,t.jsx)("p",{style:{color:"var(--text-tertiary)"},className:"jsx-8a46e716d2ea1b5 text-[12px] text-center",children:"Voice input isn't supported in this browser. Type your task brief below and we'll still parse it."}),(0,t.jsx)("textarea",{value:r,onChange:e=>o(e.target.value),placeholder:"What's the task?",rows:6,style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",resize:"vertical"},className:"jsx-8a46e716d2ea1b5 w-full text-[13.5px] leading-relaxed text-gray-900 dark:text-zinc-100 placeholder-gray-300 dark:placeholder-zinc-500 rounded-xl p-3 focus:outline-none focus:ring-2 focus:ring-orange-300/40"}),s&&(0,t.jsxs)("p",{style:{color:"var(--text-tertiary)"},className:"jsx-8a46e716d2ea1b5 text-[11px] italic",children:["â¦",s]}),(0,t.jsx)("button",{type:"button",onClick:d,disabled:!r.trim(),"aria-hidden":"true",className:"jsx-8a46e716d2ea1b5 hidden"}),(0,t.jsx)(ad.default,{id:"8a46e716d2ea1b5",children:"@keyframes voicePulse{0%,to{box-shadow:0 0 #ef44448c}50%{box-shadow:0 0 0 12px #ef444400}}"})]})}function ah({spec:e,setSpec:a,teamMembers:r}){if(!e)return null;function s(e){a(t=>({...t,...e}))}return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.2},className:"space-y-4",children:[(0,t.jsx)(ag,{label:"Title",children:(0,t.jsx)("input",{type:"text",value:e.title,onChange:e=>s({title:e.target.value}),className:"w-full text-sm px-3 py-2 rounded-xl text-gray-900 dark:text-zinc-100 focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}})}),(0,t.jsx)(ag,{label:"Description",children:(0,t.jsx)("textarea",{value:e.description,onChange:e=>s({description:e.target.value}),rows:3,className:"w-full text-[13px] leading-relaxed px-3 py-2 rounded-xl text-gray-700 dark:text-zinc-300 focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",resize:"vertical"}})}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsx)(ag,{label:"Due date",children:(0,t.jsx)("input",{type:"date",value:e.dueDate||"",onChange:e=>s({dueDate:e.target.value}),className:"w-full text-sm px-3 py-2 rounded-xl text-gray-900 dark:text-zinc-100 focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}})}),(0,t.jsx)(ag,{label:"Priority",children:(0,t.jsx)("select",{value:e.priority,onChange:e=>s({priority:e.target.value}),className:"w-full text-sm px-3 py-2 rounded-xl text-gray-900 dark:text-zinc-100 focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:ax.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})})]}),r.length>0&&(0,t.jsxs)(ag,{label:"Assignees",children:[(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map(r=>{let s=e.assignees.includes(r._id);return(0,t.jsxs)("button",{type:"button",onClick:()=>{var e;return e=r._id,void a(t=>({...t,assignees:t.assignees.includes(e)?t.assignees.filter(t=>t!==e):[...t.assignees,e]}))},className:"text-[12px] font-semibold inline-flex items-center gap-1.5 pl-0.5 pr-2.5 py-0.5 rounded-full transition-all",style:{background:s?"linear-gradient(135deg, rgba(236,72,153,0.15), rgba(249,115,22,0.12))":"var(--surface-soft)",color:"var(--text-primary)",border:s?"1px solid rgba(236,72,153,0.4)":"1px solid var(--border-subtle)"},children:[(0,t.jsx)("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[9px] font-bold text-white",style:{background:"linear-gradient(135deg, #ec4899, #f97316)"},children:(r.name||"?")[0]?.toUpperCase()}),r.name]},r._id)})}),e.unresolvedNames?.length>0&&(0,t.jsxs)("p",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:["Couldn't auto-match: ",e.unresolvedNames.join(", "),". Pick them manually above."]})]}),(0,t.jsx)(ag,{label:`Sub-tasks (${e.subTasks.length})`,children:(0,t.jsxs)("div",{className:"space-y-1.5",children:[e.subTasks.map((e,r)=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(t2.PencilIcon,{className:"w-3 h-3 text-gray-400 dark:text-zinc-500 flex-shrink-0"}),(0,t.jsx)("input",{type:"text",value:e.title,onChange:e=>{var t;return t=e.target.value,void a(e=>({...e,subTasks:e.subTasks.map((e,a)=>a===r?{...e,title:t}:e)}))},className:"text-[12.5px] flex-1 px-2 py-1.5 rounded-lg text-gray-800 dark:text-zinc-100 focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),(0,t.jsx)("button",{type:"button",onClick:()=>{a(e=>({...e,subTasks:e.subTasks.filter((e,t)=>
2t!==r)}))},className:"w-7 h-7 rounded-md flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10",children:(0,t.jsx)(m.TrashIcon,{className:"w-3.5 h-3.5"})})]},r)),(0,t.jsxs)("button",{type:"button",onClick:function(){a(e=>({...e,subTasks:[...e.subTasks||[],{title:""}]}))},className:"inline-flex items-center gap-1.5 text-[11px] font-semibold px-2.5 py-1.5 rounded-lg",style:{background:"var(--surface-soft)",border:"1px dashed var(--border-default)",color:"var(--text-secondary)"},children:[(0,t.jsx)($.PlusIcon,{className:"w-3 h-3"}),"Add sub-task"]})]})})]})}function ag({label:e,children:a}){return(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 mb-1.5 block",children:e}),a]})}let ab=[.25,.46,.45,.94],af=["from-pink-500 to-rose-400","from-orange-500 to-amber-400","from-violet-500 to-purple-400","from-blue-500 to-cyan-400","from-emerald-500 to-teal-400"];function ay({agency:e,size:a=18,ringClass:r=""}){let s,n=e?.name||"?",l=`${a}px`;return e?.image?(0,t.jsx)("img",{src:e.image,alt:n,className:`rounded-full object-cover ${r}`,style:{width:l,height:l},title:n}):(0,t.jsx)("div",{className:`rounded-full bg-gradient-to-br ${(s=(n||"").charCodeAt(0)%af.length,af[s])} text-white flex items-center justify-center font-bold ${r}`,style:{width:l,height:l,fontSize:Math.max(8,.45*a)},title:n,children:n[0].toUpperCase()})}function av({agencies:e,size:a=18,ringClass:r="ring-2 ring-white dark:ring-zinc-950"}){if(!e||0===e.length)return null;let s=e.slice(0,3),n=e.length-s.length;return(0,t.jsxs)("span",{className:"inline-flex items-center",children:[s.map((e,s)=>(0,t.jsx)("span",{style:{marginLeft:0===s?0:-(.4*a)},children:(0,t.jsx)(ay,{agency:e,size:a,ringClass:r})},e._id||e.name||s)),n>0&&(0,t.jsxs)("span",{className:`rounded-full bg-gray-100 dark:bg-zinc-900 text-gray-600 dark:text-zinc-300 flex items-center justify-center font-bold ${r}`,style:{width:`${a}px`,height:`${a}px`,marginLeft:-(.4*a),fontSize:Math.max(8,.42*a)},children:["+",n]})]})}function ak(e){let t=[],a=new Set;for(let r of(e?.agency&&"object"==typeof e.agency&&(t.push(e.agency),a.add(e.agency._id?.toString?.())),e?.collaboratingAgencies||[])){if(!r||"object"!=typeof r)continue;let e=r._id?.toString?.();a.has(e)||(a.add(e),t.push(r))}return t}function aj({boards:e=[],activeBoardId:r,activeBoard:s,onChange:n,onCreate:o,includeArchived:d,onToggleArchived:c}){let[u,m]=(0,a.useState)(!1),h=(0,a.useRef)(null);(0,a.useEffect)(()=>{function e(e){h.current&&!h.current.contains(e.target)&&m(!1)}function t(e){"Escape"===e.key&&m(!1)}return u&&(document.addEventListener("mousedown",e),document.addEventListener("keydown",t)),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[u]);let g=(0,a.useMemo)(()=>e.filter(e=>!e.archived),[e]),b=(0,a.useMemo)(()=>e.filter(e=>e.archived),[e]),f=s||(r?e.find(e=>e._id?.toString()===r?.toString()):null),v=f?ak(f):[],k=v.length>1;return(0,t.jsxs)("div",{ref:h,className:"relative",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>m(e=>!e),"aria-expanded":u,className:"h-9 inline-flex items-center gap-2 text-sm font-semibold rounded-xl pl-3 pr-2.5 transition-all duration-300 max-w-[260px] sm:max-w-[320px] hover:shadow-md group",style:{background:"var(--surface-frosted)",backdropFilter:"blur(20px)",border:"1px solid var(--border-subtle)",boxShadow:"0 2px 12px var(--surface-softer)",color:"var(--text-primary, inherit)"},children:[f?(0,t.jsxs)(t.Fragment,{children:[v.length>0&&(0,t.jsx)(av,{agencies:v,size:18}),(0,t.jsx)("span",{className:"truncate",children:f.name}),k&&(0,t.jsxs)("span",{className:"hidden sm:inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-[0.12em] px-1.5 py-0.5 rounded shrink-0",style:{background:"linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.12))",color:"#4F46E5",border:"1px solid rgba(99,102,241,0.25)"},title:"This board is shared with another agency",children:[(0,t.jsx)(ew.GlobeAltIcon,{className:"w-2.5 h-2.5"}),"Cross-agency"]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"w-[18px] h-[18px] rounded-full flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(249,115,22,0.16), rgba(236,72,153,0.16))"},children:(0,t.jsx)(tH.ChatBubbleLeftRightIcon,{className:"w-3 h-3",style:{color:"#F97316"}})}),(0,t.jsx)("span",{children:"All Tasks"})]}),(0,t.jsx)(x.ChevronDownIcon,{className:`w-3.5 h-3.5 text-gray-400 dark:text-zinc-500 ml-auto transition-transform duration-300 ${u?"rotate-180":""}`})]}),(0,t.jsx)(i.AnimatePresence,{children:u&&(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:-6,scale:.98}
2,animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.18,ease:ab},className:"absolute z-50 left-0 mt-2 w-[320px] rounded-2xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(24px)",border:"1px solid var(--border-default)",boxShadow:"0 24px 64px var(--shadow-ambient-xl), 0 4px 16px var(--shadow-ambient)"},children:[(0,t.jsx)("div",{className:"h-[2px] bg-gradient-to-r from-pink-500/60 via-orange-400/60 to-violet-500/60"}),(0,t.jsxs)("div",{className:"py-1.5 max-h-[420px] overflow-y-auto",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{n?.(null),m(!1)},className:"w-full px-3 py-2 flex items-center gap-2.5 hover:bg-gray-50/80 dark:hover:bg-zinc-900/50 transition-colors text-left",children:[(0,t.jsx)("span",{className:"w-7 h-7 rounded-xl flex items-center justify-center shrink-0",style:{background:"linear-gradient(135deg, rgba(249,115,22,0.12), rgba(236,72,153,0.12))"},children:(0,t.jsx)(tH.ChatBubbleLeftRightIcon,{className:"w-3.5 h-3.5",style:{color:"#F97316"}})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100",children:"All Tasks"}),(0,t.jsx)("div",{className:"text-[11px] text-gray-400 dark:text-zinc-500",children:"Every board you have access to"})]}),!r&&(0,t.jsx)(E.CheckIcon,{className:"w-4 h-4 text-emerald-500 shrink-0"})]}),g.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"px-3 pt-2 pb-1 text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Boards"}),g.map(e=>(0,t.jsx)(aw,{board:e,active:e._id?.toString()===r?.toString(),onClick:()=>{n?.(e._id),m(!1)}},e._id))]}),d&&b.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"px-3 pt-2 pb-1 text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 flex items-center gap-1.5",children:[(0,t.jsx)(p.ArchiveBoxIcon,{className:"w-3 h-3"}),"Archived"]}),b.map(e=>(0,t.jsx)(aw,{board:e,active:e._id?.toString()===r?.toString(),muted:!0,onClick:()=>{n?.(e._id),m(!1)}},e._id))]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-2 py-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,t.jsx)("button",{type:"button",onClick:()=>c?.(),"aria-label":d?"Hide archived boards":"Show archived boards",title:d?"Hide archived boards":"Show archived boards",className:"w-8 h-8 inline-flex items-center justify-center rounded-lg transition-colors hover:bg-gray-100 dark:hover:bg-zinc-900",style:{color:"var(--text-tertiary)"},children:(0,t.jsx)(p.ArchiveBoxIcon,{className:"w-3.5 h-3.5"})}),f&&(0,t.jsx)("button",{type:"button",onClick:async()=>{try{let e=new URL(window.location.href);e.searchParams.set("board",f._id),e.searchParams.delete("taskId"),await navigator.clipboard.writeText(e.toString()),L.default.success("Board link copied")}catch{L.default.error("Couldn't copy link")}},"aria-label":"Copy link to this board",title:"Copy link to this board",className:"w-8 h-8 inline-flex items-center justify-center rounded-lg transition-colors hover:bg-gray-100 dark:hover:bg-zinc-900",style:{color:"var(--text-tertiary)"},children:(0,t.jsx)(y.LinkIcon,{className:"w-3.5 h-3.5"})})]}),o&&(0,t.jsx)("button",{type:"button",onClick:()=>{m(!1),o()},className:"inline-flex items-center gap-1 text-[11px] font-bold px-3 py-1.5 rounded-lg text-white transition-all hover:shadow-md",style:{background:"linear-gradient(135deg, #F97316, #EC4899)"},children:"+ New board"})]})]})})]})}function aw({board:e,active:a,muted:r,onClick:s}){let n=ak(e),l=n.length>1;return(0,t.jsxs)("button",{type:"button",onClick:s,className:`w-full px-3 py-2 flex items-center gap-2.5 hover:bg-gray-50/80 dark:hover:bg-zinc-900/50 transition-colors text-left ${r?"opacity-70":""}`,children:[n.length>0?(0,t.jsx)(av,{agencies:n,size:20,ringClass:"ring-2 ring-white dark:ring-zinc-950"}):(0,t.jsx)("span",{className:"w-7 h-7 rounded-xl flex items-center justify-center shrink-0",style:{background:"linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.12))"},children:(0,t.jsx)("span",{className:"text-[11px] font-bold text-indigo-600 dark:text-indigo-300",children:(e.name||"?")[0].toUpperCase()})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100 truncate",children:e.name}),l&&(0,t.jsx)("span",{className:"text-[8.5px] uppercase font-bold px-1.5 py-0.5 rounded shrink-0 tracking-wider",style:{background:"rgba(99,102,241,0.1)",color:"#4F46E5",border:"1px solid rgba(99,102,241,0.2)"},title:"Shared with another agency",children:"Cross"})]}),e.agency?.name&&(0,t.jsxs)("div",{className:"text-[10.5px] text-gray-400 dark:text-zinc-500 truncate",children:[e.agency.name,n.length>1?` \xb7 +${n.length-1} more`:""]})]}),a&&(0,t.jsx)(E.CheckIcon,{className:"w-4 h-4 text-emerald-500 shrink-0"})]})}var aN=e.i(343210),aC=e.i(896010),aS=e.i(302292),az=e.i(967969),a_=e.i(730049);function aD(e){let t=e?.milestone;return t?String(t._id||t):null}function aI(e,t){let a=e.dueDate?new Date(e.dueDate).getTime():1/0,r=t.dueDate?new Date(t.dueDate).getTime():1/0;return a!==r?a-r:new Date(e.createdAt||0)-new Date(t.createdAt||0)}let aE=new Set([320,520,680]),a$=[{key:"status",label:"Status",type:"status",position:0,width:140},{key:"person",label:"Owner",type:"person",position:1,width:140},{key:"collaborators",label:"Collaborators",type:"collaborators",position:2,width:140},{key:"assigner",label:"Assigner",type:"assigner",position:3,width:140},{key:"dueDate",label:"Due Date",type:"date",position:4,width:140},{key:"priority",label:"Priority",type:"priority",position:5,width:130}],aT=[{name:"To Do",color:"#6366F1",position:0},{name:"In Progress",color:"#F59E0B",position:1},{name:"Stuck",color:"#df2f4a",position:2},{name:"Done",color:"#10B981",position:3}],aF=[{label:"To Do",color:"#c4c4c4"},{label:"In Progress",color:"#fdab3d"},{label:"Review",color:"#e2445c"},{label:"Done",color:"#00c875"},{label:"Stuck",color:"#df2f4a"}],aM={hidden:{},visible:{transition:{staggerChildren:.06,delayChildren:.1}}}
2,aA={hidden:{opacity:0,y:16,scale:.98},visible:{opacity:1,y:0,scale:1,transition:{duration:.4,ease:[.25,.46,.45,.94]}}};function aL({icon:e,label:a,accent:r,onClick:s,active:n}){return(0,t.jsxs)("button",{onClick:s,className:"w-full flex items-center gap-3 px-3 py-3 rounded-xl active:scale-[0.99] transition-transform",style:{background:n?`${r}10`:"transparent",border:n?`1px solid ${r}25`:"1px solid transparent"},children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:`${r}14`},children:(0,t.jsx)(e,{className:"w-4 h-4",style:{color:r}})}),(0,t.jsx)("span",{className:"text-sm font-semibold flex-1 text-left",style:{color:n?r:"var(--text-secondary)"},children:a})]})}function aP({board:e}){let a={agency:{Icon:ew.GlobeAltIcon,label:"Agency",color:"#6366F1"},team:{Icon:eN.UserGroupIcon,label:"Team",color:"#F59E0B"},private:{Icon:b.LockClosedIcon,label:"Private",color:"#EF4444"}},r=a[e.visibility]||a.team,s=r.Icon,n=(e.members||[]).length;return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 pl-1.5 pr-2 py-1 rounded-lg text-[10px] font-bold tracking-wide",style:{background:`${r.color}10`,border:`1px solid ${r.color}25`,color:r.color},title:"agency"===e.visibility?"All agency members can see this board":`${n} invited member${1===n?"":"s"}`,children:[(0,t.jsx)(s,{className:"w-3 h-3"}),r.label,n>0&&"agency"!==e.visibility&&(0,t.jsx)("span",{className:"ml-0.5 px-1 rounded text-[9px]",style:{background:`${r.color}20`},children:n})]})}function aB({label:e,width:r,isFirst:s=!1,onResize:n}){let l=(0,a.useRef)(null),i=(0,a.useRef)(null),[o,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(!1);return(0,t.jsxs)("div",{className:`relative flex-shrink-0 flex items-center${s?"":" border-l border-gray-200/30 dark:border-zinc-800/30"}`,style:{width:r,minWidth:r},children:[(0,t.jsx)("div",{className:"flex-1 px-5 py-3 overflow-hidden",children:(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-400 dark:text-zinc-500 uppercase tracking-[0.14em] truncate block",children:e})}),(0,t.jsx)("div",{ref:i,onMouseDown:function(e){function t(e){if(!l.current)return;let{startX:t,startWidth:a}=l.current;n(Math.max(80,Math.min(800,a+(e.clientX-t))))}e.preventDefault(),l.current={startX:e.clientX,startWidth:r},d(!0),document.body.classList.add("cursor-col-resize-active"),window.addEventListener("mousemove",t),window.addEventListener("mouseup",function e(){l.current=null,d(!1),document.body.classList.remove("cursor-col-resize-active"),window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",e)})},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),className:`absolute right-0 top-0 bottom-0 w-1 flex-shrink-0 z-10 transition-colors duration-150${o?"":c?" bg-gray-200 dark:bg-zinc-700":""}`,style:{cursor:"col-resize",...o?{background:"linear-gradient(180deg, #ec4899, #f97316)"}:{}},"aria-hidden":"true",title:"Drag to resize column"})]})}function aR({groupName:e,children:a}){let{setNodeRef:r,isOver:s}=(0,o.useDroppable)({id:e});return(0,t.jsx)("div",{ref:r,className:"transition-colors duration-150",style:{background:s?"rgba(249,115,22,0.06)":"transparent",outline:s?"2px dashed rgba(249,115,22,0.4)":"none",outlineOffset:-2,borderRadius:4},children:a})}function aO({task:e,children:a}){let{attributes:r,listeners:s,setNodeRef:n,transform:l,transition:i,isDragging:o}=(0,d.useSortable)({id:e._id}),u={transform:c.CSS.Transform.toString(l),transition:i,opacity:o?.4:1,cursor:o?"grabbing":"grab",zIndex:o?10:"auto"};return(0,t.jsx)("div",{ref:n,...r,...s,style:u,children:a})}function aU({viewMode:e,onChange:r,showMilestones:s=!1}){let n=[...s?[{key:"milestones",label:"Milestones",Icon:ea.FlagIcon,gradient:"linear-gradient(135deg, #EC4899, #8B5CF6)"}]:[],{key:"board",label:"List",Icon:aS.TableCellsIcon,gradient:"linear-gradient(135deg, #F97316, #EC4899)"},{key:"kanban",label:"Kanban",Icon:a_.Squares2X2Icon,gradient:"linear-gradient(135deg, #14B8A6, #6366F1)"},{key:"gantt",label:"Gantt",Icon:tw.CalendarDaysIcon,gradient:"linear-gradient(135deg, #F59E0B, #EF4444)"},{key:"calendar",label:"Calendar",Icon:tw.CalendarDaysIcon,gradient:"linear-gradient(135deg, #10B981, #14B8A6)"},{key:"forms",label:"Forms",Icon:eB.ClipboardDocumentListIcon,gradient:"linear-gradient(135deg, #EC4899, #F59
2E0B)"},{key:"insights",label:"Insights",Icon:e8.ChartBarIcon,gradient:"linear-gradient(135deg, #6366F1, #A855F7)"}],[o,d]=(0,a.useState)(!1),c=(0,a.useRef)(null),u=n.find(t=>t.key===e)||n[0],x=u.Icon;return(0,a.useEffect)(()=>{function e(e){c.current&&!c.current.contains(e.target)&&d(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.jsxs)("div",{ref:c,className:"relative",children:[(0,t.jsxs)("button",{onClick:()=>d(e=>!e),"aria-haspopup":"listbox","aria-expanded":o,"aria-label":"Switch view",className:"relative flex items-center gap-1.5 pl-2.5 pr-2 sm:pl-3 sm:pr-2.5 py-1.5 text-[11px] font-bold rounded-xl transition-all duration-200",style:{background:u.gradient,color:"white",boxShadow:"0 2px 8px rgba(99,102,241,0.18)"},children:[(0,t.jsx)(x,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:u.label}),(0,t.jsx)("svg",{className:"w-3 h-3 -mr-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M19 9l-7 7-7-7"})})]}),(0,t.jsx)(i.AnimatePresence,{children:o&&(0,t.jsx)(l.motion.div,{initial:{opacity:0,y:-4,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.96},transition:{duration:.15,ease:[.25,.46,.45,.94]},className:"absolute z-[60] right-0 mt-1.5 rounded-xl py-1 w-44",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 12px 40px var(--shadow-ambient-lg), 0 2px 8px var(--border-subtle)",border:"1px solid var(--border-default)"},role:"listbox",children:n.map(a=>{let s=a.Icon,n=a.key===e;return(0,t.jsxs)("button",{role:"option","aria-selected":n,onClick:()=>{r(a.key),d(!1)},className:"w-full px-2.5 py-2 flex items-center gap-2.5 text-[12px] font-semibold transition-colors duration-150 hover:bg-gray-50/80 dark:hover:bg-zinc-900/80",style:{color:n?"var(--text-primary)":"var(--text-secondary)"},children:[(0,t.jsx)("span",{className:"w-6 h-6 rounded-md flex items-center justify-center flex-shrink-0",style:{background:n?a.gradient:"transparent",border:n?"none":"1px solid var(--border-subtle)"},children:(0,t.jsx)(s,{className:"w-3 h-3",style:{color:n?"white":"var(--text-tertiary)"}})}),(0,t.jsx)("span",{className:"flex-1 text-left",children:a.label}),n&&(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 flex-shrink-0"})]},a.key)})})})]})}e.s(["default",0,function({filter:e={},boardId:c=null,showBoardSelector:u=!1,context:m="global",defaultPrivate:h=!1,autoAssignOwnerIfEmpty:g=!1,refreshKey:b=0,milestonesScope:f=null}){let y,v,k,{data:j}=(0,r.useSession)(),w=(0,s.useSearchParams)(),N=(0,s.useRouter)(),C=(0,s.usePathname)(),{params:S,setParams:z}=(0,n.useHomeQuery)();function _(e){if("home"===m)return void z(e);let t=new URLSearchParams(w.toString());for(let[a,r]of Object.entries(e))null==r?t.delete(a):t.set(a,String(r));let a=t.toString();N.replace(a?`${C}?${a}`:C,{scroll:!1})}let{openOrCreateDM:D}=(0,tK.useConversation)(),[I,E]=(0,a.useState)([]),[F,A]=(0,a.useState)(null),[P,B]=(0,a.useState)([]),[R,O]=(0,a.useState)(c),[U,W]=(0,a.useState)(new Set),[q,X]=(0,a.useState)(new Set),[G,H]=(0,a.useState)(null),[K,J]=(0,a.useState)(null),[V,Y]=(0,a.useState)(!1),[Z,et]=(0,a.useState)(null),[ea,er]=(0,a.useState)(!1),[es,en]=(0,a.useState)([]),[ei,ec]=(0,a.useState)(!0),[eu,ex]=(0,a.useState)(!1),[ep,em]=(0,a.useState)(!1),[eh,ef]=(0,a.useState)(new Set),[ey,ev]=(0,a.useState)(null),[ek,ew]=(0,a.useState)(null),[eN,eS]=(0,a.useState)({}),[ez,e_]=(0,a.useState)(new Set),[eD,eI]=(0,a.useState)(null),[eE,e$]=(0,a.useState)(!1),[eT,eM]=(0,a.useState)(null),[eA,eL]=(0,a.useState)(!1),[eP,eR]=(0,a.useState)(!1),[eO,eU]=(0,a.useState)(0),eW=[...f?["milestones"]:[],"board","kanban","gantt","calendar","forms","insights"],eX=f?"milestones":"board",eH="home"===m?S.get("view"):w.get("view"),[eK,eJ]=(0,a.useState)(eW.includes(eH)?eH:eX),eV="home"===m?S.get("form"):w.get("form");(0,a.useEffect)(()=>{let e=("home"===m?S.get("view"):w.get("view"))||null,t=eK===eX?null:eK;e!==t&&_("forms"===eK?{view:t}:{view:t,form:null})},[eK]);let[eY,eZ]=(0,a.useState)(e0());(0,a.useEffect)(()=>{let e=j?.user?._id?.toString?.();if(e)try{let t=localStorage.getItem(`task-view-type:${e}`);t&&["all","my","assigned","collaborator"].includes(t)&&eZ(e=>({...e,viewType:t}))}catch{}},[j?.user?._id]),(0,a.useEffect)(()=>{let e=j?.user?._id?.toString?.();if(!e)return;let t=eY.viewType||"all";try{"all"===t?localStorage.removeItem(`task-view-type:${e}`):localStorage.setItem(`task-view-type:${e}`,t)}catch{}},[eY.viewType,j?.user?._id]),(0,a.useEffect)(()=>{let e=j?.user?._id?.toString?.();if(e&&R)try{localStorage.setItem(`task-board:lastActive:${e}`,R)}catch{}},[R,j?.user?._id]);let[eQ,e1]=(0,a.useState)(null),[e2,e4]=(0,a.useState)(!1),[e3,e6]=(0,a.useState)(a$),[e9,e8]=(0,a.useState)(null),[e7,te]=(0,a.useState)(null),[tt,ta]=(0,a.useState)({}),[ts,tn]=(0,a.useState)(0),tl=(0,a.useRef)(null),ti=(0,a.useCallback)(e=>{if(tl.current&&(tl.current.disconnect(),tl.current=null),!e||"u"<typeof ResizeObserver)return;tn(e.clientWidth);let t=new ResizeObserver(()=>tn(e.clientWidth));t.observe(e),tl.current=t},[]),to=(0,a.useRef)(null),td=(0,a.useCallback)(e=>
2{R&&(to.current&&clearTimeout(to.current),to.current=setTimeout(()=>{fetch(`/api/task-boards/${R}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})},500))},[R]),tc=(0,o.useSensors)((0,o.useSensor)(o.MouseSensor,{activationConstraint:{distance:8}}),(0,o.useSensor)(o.TouchSensor,{activationConstraint:{delay:250,tolerance:8}})),tu=e.linkedCampaign||null,tx=e.linkedCreator||null,tp=e.linkedPost||null,tm=e.assignee||null,th=e.taskType||null,tg=e.parentDeal||null,tf=(0,a.useMemo)(()=>"deal"===m&&tg?["campaigns","organizations","creators"]:"campaign"===m&&tu?["campaigns"]:"organization"===m&&e.organization?["organizations"]:"creator"===m&&tx?["creators"]:[],[m,tg,tu,tx,e.organization]);function ty(e){if(!e)return;let t=Array.isArray(e.milestones)?e.milestones:[];if(t.length>0){let e=new Map(t.map(e=>[String(e._id),e]));E(t=>t.map(t=>{let a=aD(t),r=a?e.get(a):null;if(!r)return t;let s=t.milestone&&"object"==typeof t.milestone?t.milestone:{};return{...t,milestone:{...s,...r}}}))}Array.isArray(e.shiftedTaskIds)&&e.shiftedTaskIds.length>0&&t_()}let tv=(y=F?.columns?.length>0?[...F.columns].sort((e,t)=>e.position-t.position):e3,0===Object.keys(tt).length?y:y.map(e=>{let t=e._id?.toString?.()||e.key,a=t?tt[t]:void 0;return void 0!==a?{...e,width:a}:e})),tk=e9&&e9.length>0?e9.map(e=>tv.find(t=>t.key===e)).filter(Boolean):tv,tj=tk.reduce((e,t)=>e+(t.width||150),0),tw=e7??(ts>0?Math.max(360,Math.min(680,ts-tj)):680),tN=(v=F?.groups?.length>0?[...F.groups].sort((e,t)=>e.position-t.position):aT).some(e=>"stuck"===String(e.name||"").toLowerCase())?v:[...v,{name:"Stuck",color:"#df2f4a",position:v.length}],tC=(k=F?.statusDefinitions?.length>0?F.statusDefinitions:aF).some(e=>"stuck"===String(e.label||"").toLowerCase())?k:[...k,{label:"Stuck",color:"#df2f4a",isDefault:!1,isDone:!1}],tS=(0,a.useCallback)(async()=>{if(j?.user)try{if(R){let e=await fetch(`/api/task-boards/${R}/members`);if(e.ok){let t=await e.json();en(t.members||[]);return}}let e=await fetch("/api/agency-team");if(e.ok){let t=await e.json();en(t.users||t.team||[])}}catch{}},[j,R]),tz=(0,a.useRef)(0),t_=(0,a.useCallback)(async()=>{if(!j?.user)return;let e=++tz.current;try{let t=new URLSearchParams;t.set("limit","2000"),tu&&t.set("campaign",tu),tx&&t.set("creator",tx),tp&&t.set("post",tp),tm&&t.set("assignee",tm),th&&t.set("taskType",th),R&&t.set("board",R),eu&&t.set("archived","true"),tg?t.set("parentDeal",tg):eY.parentDeal&&t.set("parentDeal",eY.parentDeal),eY.milestone&&t.set("milestone",eY.milestone),eY.assignees?.length&&t.set("assignees",eY.assignees.join(",")),eY.collaborators?.length&&t.set("collaborators",eY.collaborators.join(",")),eY.campaigns?.length&&t.set("campaigns",eY.campaigns.join(",")),eY.creators?.length&&t.set("creators",eY.creators.join(",")),eY.organizations?.length&&t.set("organizations",eY.organizations.join(",")),eY.statuses?.length&&t.set("statuses",eY.statuses.join(",")),eY.priorities?.length&&t.set("priorities",eY.priorities.join(",")),eY.dueRange&&"all"!==eY.dueRange&&t.set("dueRange",eY.dueRange),eY.query?.trim()&&t.set("query",eY.query.trim());let a=await fetch(`/api/tasks?${t.toString()}`);if(e!==tz.current)return;if(a.ok){let t=await a.json();if(e!==tz.current)return;E(t.tasks||[])}}catch(e){console.error("Error fetching tasks:",e)}finally{e===tz.current&&ec(!1)}},[j,tu,tx,tp,tm,th,tg,R,eu,eY,b]),tI=(0,a.useCallback)(async()=>{if(R)try{let e=await fetch(`/api/task-boards/${R}`);if(e.ok){let t=await e.json();A(t.board)}}catch(e){console.error("Error fetching board:",e)}},[R]),tE=(0,a.useCallback)(async()=>{if(u)try{let e=new URLSearchParams;ep&&e.set("includeArchived","true");let t=e.toString(),a=await fetch(t?`/api/task-boards?${t}`:"/api/task-boards");if(a.ok){let e=await a.json();B(e.boards||[])}}catch{}},[u,ep]),t$=(0,a.useCallback)(async e=>{if(e&&j?.user)try{let t=await fetch(`/api/tasks/${e}/unread-summary`);if(!t.ok)return;let a=await t.json();eS(t=>({...t,[e.toString()]:a}))}catch{}},[j?.user]);(0,a.useEffect)(()=>{function e(){for(let e of eh)t$(e)}return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[eh,t$]),(0,a.useEffect)(()=>{function e(){let e=window.location.hash,t=e.match(/^#task-([^-]+(?:-[^-]+)*)-subitem-(.+)$/);if(t){let[,e,a]=t;ef(t=>{if(t.has(e))return t;let a=new Set(t);return a.add(e),t$(e),a}),ev(e),ew(a),window.history.replaceState(null,"",window.location.pathname+window.location.search);return}let a=e.match(/^#subitem-(.+)$/);if(a){let e=a[1],t=I.find(t=>(t.subItems||[]).some(t=>t._id?.toString?.()===e));if(t){let a=t._id.toString();ef(e=>{if(e.has(a))return e;let t=new Set(e);return t.add(a),t$(a),t}),ev(a),ew(e),window.history.replaceState(null,"",window.location.pathname+window.location.search)}}}return e(),window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[I]),(0,a.useEffect)(()=>{t_(),tS(),R&&tI(),u&&tE()},[t_,tS,tI,tE]),(0,a.useEffect)(()=>{E([]),ec(!0),e8(null),R||A(null)},[R]),(0,a.useEffect)(()=>
2{if(F){var e;if(te("number"!=typeof(e=F.taskColumnWidth)||!Number.isFinite(e)||aE.has(e)?null:e),F.columns?.length>0){let e={};for(let t of F.columns){let a=t._id?.toString?.()||t.key;a&&(e[a]=t.width||150)}ta(e)}}},[F?._id]),(0,a.useEffect)(()=>{"home"===m&&W(e=>{let t=new Set(e);for(let e of tN){let a=String(e?.name||"").toLowerCase();("done"===a||"complete"===a)&&t.add(e.name)}return t})},[m,F?._id]),(0,a.useEffect)(()=>{if(j?.user)return window.addEventListener("ss-task-event",e),()=>window.removeEventListener("ss-task-event",e);function e(e){let{taskId:t,type:a}=e.detail||{};t&&fetch(`/api/tasks/${t}`).then(e=>e.ok?e.json():null).then(e=>{e?.task&&E(r=>{if(r.some(e=>e._id===t))return r.map(a=>a._id===t?e.task:a);if("task_assigned"!==a)return r;let s=e.task.board?._id?.toString?.()||e.task.board?.toString?.()||null,n=R?R.toString?.()||R:null;return n&&s!==n?r:[e.task,...r]})}).catch(()=>{})}},[j?.user,R]);let tT="home"===m?S.get("taskId"):w.get("taskId");function tF(e){J(null),Y(!1),H(e),e?._id&&t$(e._id),e?._id&&_({taskId:e._id})}function tM(e,t,{draft:a=!1}={}){J(t||null),Y(!!a),et(null),H(e),e?._id&&_({taskId:e._id})}function tA(e,t,a){et({subItemId:t,title:(a||"").slice(0,200)}),J(null),Y(!1),H(e),e?._id&&_({taskId:e._id})}function tL(){H(null),J(null),Y(!1),et(null),_({taskId:null,taskTab:null})}async function tP(t,a,r={}){let s="object"==typeof t&&null!==t,n=s?t.title:t,l=s?{assignees:t.assignees||[],linkedCreator:t.linkedCreator||e.linkedCreator,linkedCampaign:t.linkedCampaign||e.linkedCampaign,parentDeal:t.parentDeal||e.parentDeal||void 0,isPrivate:"boolean"==typeof t.isPrivate?t.isPrivate:h,media:Array.isArray(t.media)?t.media:[]}:{isPrivate:h},i=(tC||[]).find(e=>String(e.label||"").toLowerCase()===String(a||"").toLowerCase()),o=!Array.isArray(l.assignees)||0===l.assignees.length,d="my"===(eY.viewType||"all");try{let t=await fetch("/api/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,group:a||"Default",board:R||void 0,...i?{status:i.label,statusColor:i.color}:{},...e,...l,...r,autoAssignOwnerIfEmpty:g||d&&o})});if(t.ok){let e=await t.json();E(t=>[...t,e.task]),ty(e.milestoneSync),L.default.success("Task created")}else L.default.error("Failed to create task")}catch{L.default.error("Failed to create task")}}async function tB(e,t){let a=t;if(t.status){let e=tN.find(e=>e.name?.toLowerCase()===t.status.toLowerCase());e&&(a={...t,group:e.name})}if("critical"===t.priority){let t=I.find(t=>t._id===e);if(t&&!t.dueDate){let e=new Date;e.setDate(e.getDate()+1),a={...a,dueDate:e.toISOString()},(0,L.default)("Critical priority â due date set to 24h from now",{icon:"â°"})}}E(t=>t.map(t=>t._id===e?{...t,...a}:t)),("Done"===a.status||"Complete"===a.status)&&G?._id===e&&setTimeout(()=>tL(),350);try{let t=await fetch(`/api/tasks/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(t.ok){let a=await t.json(),r=Array.isArray(a.cascadeRestoredTasks)?a.cascadeRestoredTasks:[],s=new Map(r.map(e=>[e._id?.toString?.()||e._id,e]));E(t=>t.map(t=>{if(t._id===e)return a.task;let r=t._id?.toString?.()||t._id;return s.get(r)||t})),ty(a.milestoneSync)}else t_(),L.default.error("Failed to update task")}catch{t_(),L.default.error("Failed to update task")}}async function tR(e){E(t=>t.filter(t=>t._id!==e));try{await fetch(`/api/tasks/${e}`,{method:"DELETE"}),L.default.success("Task deleted")}catch{t_(),L.default.error("Failed to delete task")}}async function tO(e,t=!0){eu?E(a=>a.map(a=>a._id===e?{...a,archived:t}:a)):E(t=>t.filter(t=>t._id!==e));try{await fetch(`/api/tasks/${e}/archive`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({archived:t})}),L.default.success(t?"Task archived":"Task restored")}catch{t_(),L.default.error("Failed to archive task")}}function tW(){eL(!0)}(0,a.useEffect)(()=>{if(!tT||!j?.user||G?._id===tT)return;let e=I.find(e=>e._id===tT);if(e)return void H(e);let t=!1;return fetch(`/api/tasks/${tT}`).then(e=>e.ok?e.json():null).then(e=>{!t&&e?.task&&H(e.task)}).catch(()=>{}),()=>{t=!0}},[tT,j?.user]);let tq={critical:4,high:3,medium:2,low:1},tG=j?.user?._id?.toString?.();function tH(e){let t=eY.viewType||"all";if("all"===t||!tG)return!0;let a=(e.assignees||[]).some(e=>(e?._id||e)?.toString?.()===tG),r=(e.collaborators||[]).some(e=>(e?._id||e)?.toString?.()===tG),s=(e.createdBy?._id||e.createdBy)?.toString?.()===tG;return"my"===t?a:"assigned"===t?s&&!a:"collaborator"!==t||r}function tJ(e){return I.filter(t=>(t.group||"Default")===e).filter(tH).sort((e,t)=>
2{let a=e.position||0,r=t.position||0,s=0!==a,n=0!==r;if(s&&n)return a-r;if(s)return -1;if(n)return 1;let l=tq[e.priority]||0,i=tq[t.priority]||0;return l!==i?i-l:(e.dueDate?new Date(e.dueDate).getTime():1/0)-(t.dueDate?new Date(t.dueDate).getTime():1/0)})}async function tV(e,t,a={}){E(r=>{let s=new Map(r.map(e=>[e._id,e])),n=new Map(t.map((t,r)=>{let n=s.get(t);return n?{...n,group:e,position:(r+1)*1024,...a.statusForGroup?{status:a.statusForGroup.label,statusColor:a.statusForGroup.color}:{}}:null}).filter(Boolean).map(e=>[e._id,e]));return r.map(e=>n.get(e._id)||e)});try{let r=t.map((t,a)=>({taskId:t,position:(a+1)*1024,group:e}));await fetch("/api/tasks/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:r})}),a.statusForGroup&&a.movedTaskId&&await fetch(`/api/tasks/${a.movedTaskId}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:a.statusForGroup.label,statusColor:a.statusForGroup.color})})}catch{L.default.error("Couldn't save the new order"),t_()}}function tY(e,t,a){let r=e._id?.toString?.();return{task:e,columns:tk,onUpdate:tB,onClick:tF,onOpenWithSubItem:tM,onCommentOnSubItem:tA,onArchive:tO,onDelete:tR,onRequestDelete:e=>e1(e),teamMembers:es,statusOptions:tC,groupColor:a,index:t,context:m,dueDateMode:F?.dueDateMode||"single",isExpanded:eh.has(e._id),onToggleSubItems:e=>{ef(t=>{let a=new Set(t);return a.has(e)?a.delete(e):(a.add(e),t$(e)),a})},onSubItemRefresh:t_,taskColumnWidth:tw,unreadSummary:eN[r]?.subItemUnread||{},totalSummary:eN[r]?.subItemTotal||{},onUnreadRefresh:()=>t$(e._id),autoExpandSubItemId:ey===r?ek:null}}function tZ(){let e=new Set(tN.map(e=>e.name));return I.filter(t=>!e.has(t.group||"Default")).filter(tH)}return ei?(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200/40 dark:border-zinc-800/40 p-8",style:{background:"var(--surface-frosted)",backdropFilter:"blur(20px)"},children:[(0,t.jsx)("div",{className:"absolute -top-16 -right-16 w-48 h-48 rounded-full opacity-20 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, #F59E0B, #EC4899)"}}),(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 gap-4",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"w-10 h-10 border-3 border-orange-400/30 border-t-orange-500 rounded-full animate-spin"}),(0,t.jsx)("div",{className:"absolute inset-0 w-10 h-10 border-3 border-pink-400/20 border-b-pink-500 rounded-full animate-spin",style:{animationDirection:"reverse",animationDuration:"1.5s"}})]}),(0,t.jsx)("p",{className:"text-xs font-semibold text-gray-400 dark:text-zinc-500 tracking-wide uppercase",children:"Loading tasks"})]})]}):(0,t.jsxs)(l.motion.div,{initial:"hidden",animate:"visible",variants:aM,className:"w-full",children:[(0,t.jsxs)(l.motion.div,{variants:aA,className:"flex items-center justify-between gap-2 mb-4 px-1",children:[(0,t.jsx)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:u&&(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[(0,t.jsx)(aj,{boards:P,activeBoardId:R,activeBoard:F,onChange:e=>{O(e),_({board:e||null,taskId:null})},onCreate:tW,includeArchived:ep,onToggleArchived:()=>em(e=>!e),onOpenDmCompose:function(e){e?.kind==="user"&&e.user?._id?D({otherUserId:e.user._id}).catch(()=>{}):e?.kind==="agency"&&((0,L.default)(`Opening messages â search ${e.agency?.name||"the agency"} to start a DM`,{icon:"ð¬"}),N.push("/dashboard/messages"))}}),F&&(0,t.jsx)(aP,{board:F})]})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2 sm:px-2.5 py-1.5 rounded-lg",style:{background:"rgba(16,185,129,0.06)",border:"1px solid rgba(16,185,129,0.18)"},title:"Real-time updates active",children:[(0,t.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-emerald-500"})]}),(0,t.jsx)("span",{className:"hidden sm:inline text-[10px] font-bold uppercase tracking-[0.12em] text-emerald-700",children:"Live"})]}),(0,t.jsx)(aU,{viewMode:eK,onChange:eJ,showMilestones:!!f}),"insights"!==eK&&(0,t.jsxs)("button",{onClick:()=>eR(!0),className:"group flex items-center gap-1.5 text-xs font-semibold px-2.5 sm:px-3 py-2 rounded-xl transition-all duration-300 hover:shadow-md",style:{background:"linear-gradient(135deg, rgba(236,72,153,0.10), rgba(249,115,22,0.10))",border:"1px solid rgba(236,72,153,0.25)",color:"#EC4899"},title:"Dictate a task with your voice","aria-label":"Dictate a task",children:[(0,t.jsx)(ac.MicrophoneIcon,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{className:"hidden md:inline",children:"Dictate"})]}),"insights"!==eK&&R&&(0,t.jsxs)("button",{onClick:()=>{eJ("forms"),eU(e=>e+1)},className:"group flex items-center gap-1.5 text-xs font-semibold px-2.5 sm:px-3 py-2 rounded-xl transition-all duration-300 hover:shadow-md",style:{background:"linear-gradient(135deg, rgba(245,158,11,0.10), rgba(236,72,153,0.10))",border:"1px solid rgba(245,158,11,0.30)",color:"#F59E0B"},title:"Build a form on this board","aria-label":"Create a form",children:[(0,t.jsx)(eB.ClipboardDocumentListIcon,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{className:"hidden md:inline",children:"+ Form"})]}),F&&(0,t.jsxs)("button",{onClick:()=>e$(!0),className:"hidden md:flex group items-center gap-1.5 text-xs font-semibold px-3 py-2 rounded-xl transition-all duration-300 hover:shadow-md",style:{background:"rgba(99,102,241,0.06)",border:"1px solid rgba(99,102,241,0.12)",color:"#6366F1"},title:"Board settings",children:[(0,t.jsx)(eC.Cog6ToothIcon,{className:"w-3.5 h-3.5 group-hover:rotate-45 transition-transform duration-300"}),"Settings"]}),(0,t.jsxs)("button",{onClick:()=>ex(e=>!e),className:"hidden md:flex group items-center gap-1.5 text-xs font-semibold px-3 py-2 rounded-xl transition-all duration-300 hover:shadow-md",style:{background:eu?"rgba(245,158,11,0.1)":"var(--surface-soft)",border:eu?"1px solid rgba(245,158,11,0.2)":"1px solid var(--border-subtle)",color:eu?"#D97706":"var(--text-tertiary)"},children:[(0,t.jsx)(p.ArchiveBoxIcon,{className:"w-3.5 h-3.5"}),eu?"Showing archived":"Archive hidden"]}),(0,t.jsxs)("button",{onClick:()=>er(!0),className:"hidden md:flex group items-center gap-1.5 text-xs font-semibold px-3 py-2 rounded-xl transition-all duration-300 hover:shadow-md",style:{background:"rgba(99,102,241,0.06)",border:"1px solid rgba(99,102,241,0.12)",color:"#6366F1"},children:[(0,t.jsx)(aC.ViewColumnsIcon,{className:"w-4 h-4 group-hover:scale-110 transition-transform duration-200"}),"Columns"]}),(0,t.jsx)("button",{onClick:()=>e4(!0),className:"md:hidden w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-200 active:scale-95",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)"},title:"More actions","aria-label":"More board actions",children:(0,t.jsx)(az.EllipsisHorizontalIcon,{className:"w-5 h-5 text-gray-600 dark:text-zinc-400"})})]})]}),(0,t.jsx)(i.AnimatePresence,{children:e2&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.motion.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"md:hidden fixed inset-0 z-[90] bg-black/30 backdrop-blur-sm",onClick:()=>e4(!1)}),(0,t.jsxs)(l.motion.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{duration:.35,ease:[.25,.46,.45,.94]},className:"md:hidden fixed bottom-0 left-0 right-0 z-[91] rounded-t-3xl overflow-hidden safe-area-pb",style:{background:"var(--panel-95)",backdropFilter:"blur(40px)",boxShadow:"0 -20px 60px var(--shadow-ambient-lg), 0 -4px 20px var(--surface-softer)"},children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500/60 via-orange-400/60 to-violet-500/60"}),(0,t.jsx)("div",{className:"flex justify-center pt-2.5",children:(0,t.jsx)("div",{className:"w-10 h-1 rounded-full bg-gray-200 dark:bg-zinc-800"})}),(0,t.jsxs)("div",{className:"px-5 pt-3 pb-2 flex items-center justify-between",children:[(0,t.jsx)("h3",{className:"text-base font-bold text-gray-900 dark:text-zinc-100 tracking-tight",children:"Board actions"}),(0,t.jsx)("button",{onClick:()=>e4(!1),className:"w-9 h-9 flex items-center justify-center rounded-xl active:scale-95 transition-transform",style:{background:"var(--border-subtle)"},"aria-label":"Close menu",children:(0,t.jsx)(T.XMarkIcon,{className:"w-5 h-5 text-gray-500 dark:text-zinc-400"})})]}),(0,t.jsxs)("div",{className:"px-3 pb-4 pt-1 space-y-1",children:[u&&(0,t.jsx)(aL,{icon:$.PlusIcon,label:"New Board",accent:"#F97316",onClick:()=>{e4(!1),tW()}}),F&&(0,t.jsx)(aL,{icon:eC.Cog6ToothIcon,label:"Board settings",accent:"#6366F1",onClick:()=>{e4(!1),e$(!0)}}),(0,t.jsx)(aL,{icon:aC.ViewColumnsIcon,label:"Configure columns",accent:"#6366F1",onClick:()=>{e4(!1),er(!0)}}),(0,t.jsx)(aL,{icon:p.ArchiveBoxIcon,label:eu?"Hide archived":"Show archived",accent:eu?"#D97706":"var(--text-tertiary)",active:eu,onClick:()=>{ex(e=>!e),e4(!1)}})]})]})]})}),"milestones"===eK&&f?(0,t.jsx)(l.motion.div,{variants:aA,initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3},children:(0,t.jsx)(aN.default,{embedded:!0,campaignId:"campaign"===f.type?f.id:null,dealId:"deal"===f.type?f.id:null,onChange:()=>t_()})},"milestones"):"forms"===eK?(0,t.jsx)(l.motion.div,{variants:aA,initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3},children:R?(0,t.jsx)(ao,{boardId:R,isManager:j?.user?.role==="super_admin"||(F?.createdBy?._id||F?.createdBy)?.toString?.()===j?.user?._id?.toString?.(),currentUserId:j?.user?._id?.toString?.(),teamMembers:es,externalCreateNonce:eO,initialFormId:eV,onActiveFormChange:e=>{(e||null)!==(("home"===m?S.get("form"):w.get("form"))||null)&&_({form:e||null})}}):(0,t.jsxs)("div",{className:"rounded-2xl border p-10 text-center",style:{background:"var(--surface-frosted)",borderColor:"var(--border-subtle)"},children:[(0,t.jsx)(eB.ClipboardDocumentListIcon,{className:"w-10 h-10 mx-auto mb-3 opacity-40",style:{color:"var(--text-tertiary)"}}),(0,t.jsx)("h3",{className:"text-[15px] font-bold text-gray-800 dark:text-zinc-100 mb-1",children:"Forms live on a specific board"}),(0,t.jsx)("p",{className:"text-[13px] mb-5 max-w-sm mx-auto",style:{color:"var(--text-tertiary)"},children:"Pick a board from the dropdown above, or create a new one to start collecting submissions."}),(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[(0,t.jsxs)("button",{type:"button",onClick:tW,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-xl text-sm font-semibold text-white transition-all duration-200 hover:-translate-y-0.5 hover:shadow-lg",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 16px rgba(236,72,153,0.25)"},children:[(0,t.jsx)($.PlusIcon,{className:"w-3.5 h-3.5"}),"Create a board"]}),P.length>0&&(0,t.jsx)("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"or pick one from the board dropdown"})]})]})},"forms"):"insights"===eK?(0,t.jsx)(l.motion.div,{variants:aA,initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3},children:(0,t.jsx)(tr,{scopeParams:{...R?{board:R}:{},...tu?{campaign:tu}:{},...tx?{creator:tx}:{},...tp?{post:tp}:{},...e.organization?{organization:e.organization}:{}}})},"insights"):(0,t.jsxs)(t.Fragment,{children:[F&&(0,t.jsx)(t0,{board:F,currentUser:j?.user}),F&&(0,t.jsx)(tX,{board:F,onOpenAutomations:()=>{eM("automations"),e$(!0)}}),(0,t.jsx)(l.motion.div,{variants:aA,children:(0,t.jsx)(e5,{filters:eY,onChange:eZ,teamMembers:es,statusOptions:tC,availableColumns:tv,activeColumnKeys:e9||tv.map(e=>e.key),onColumnKeysChange:e8,filterCampaignId:tu,filterParentDealId:tg,hiddenChips:tf,scope:R?{type:"board",id:R}:"campaign"===m&&tu?{type:"campaign",id:tu}:"creator"===m&&tx?{type:"creator",id:tx}
2:"organization"===m&&e.organization?{type:"organization",id:e.organization}:{type:"global"}})}),"kanban"===eK?(0,t.jsx)(tb,{tasks:I,statusOptions:tC,teamMembers:es,onUpdate:tB,onClick:tF,onAddTask:e=>tP("New Task",e)}):"calendar"===eK?(0,t.jsx)(tU,{tasks:I.filter(tH),onClick:tF,dueDateMode:F?.dueDateMode||"single"}):"gantt"===eK?(0,t.jsx)(tD,{tasks:I,onUpdate:tB,onClick:tF}):(0,t.jsxs)(o.DndContext,{sensors:tc,onDragStart:e=>{eI(e.active.id)},collisionDetection:o.closestCorners,onDragEnd:e=>{eI(null);let{active:t,over:a}=e;if(!a)return;let r=t.id,s=a.id;if(r===s)return;let n=I.find(e=>e._id===r);if(!n)return;let l=n.group||"Default";if("string"==typeof s&&s.startsWith("ms:")){let e=s.indexOf("::");if(-1===e)return;let t=s.slice(3,e),a=s.slice(e+2);if(aD(n)===a&&l===t)return;!function(e,t,a){let r=I.find(e=>aD(e)===String(t)&&e.milestone&&"object"==typeof e.milestone)?.milestone||null,s=String(r?.campaign?._id||r?.campaign||""),n=String(e.linkedCampaign?._id||e.linkedCampaign||"");if(n&&s&&n!==s)return L.default.error("That task is on a different campaign than the milestone");let l=(tC||[]).find(e=>String(e.label||"").toLowerCase()===String(a||"").toLowerCase()),i=e.group||"Default";X(e=>{let r=new Set(e);return r.add(`${a}::${t}`),r}),tB(e._id,{milestone:t,...n||!s?{}:{linkedCampaign:s},...a&&a!==i?l?{status:l.label,statusColor:l.color,group:a}:{group:a}:{}})}(n,a,t);return}let i=new Set(tN.map(e=>e.name)),o=l,c=-1;if(i.has(s))o=s;else{let e=I.find(e=>e._id===s);if(!e)return;{let t=tJ(o=e.group||"Default");-1===(c=t.findIndex(e=>e._id===s))&&(c=t.length)}}let u=(tC||[]).find(e=>e.label.toLowerCase()===o.toLowerCase());if(l===o){let e=tJ(o).map(e=>e._id),t=e.indexOf(r);if(-1===t)return;let a=-1===c?e.length-1:c;if(t===a)return;let s=(0,d.arrayMove)(e,t,a);tV(o,s)}else{let e=tJ(o).filter(e=>e._id!==r).map(e=>e._id),t=-1===c?e.length:Math.min(c,e.length);e.splice(t,0,r),tV(o,e,{statusForGroup:u||null,movedTaskId:r});let a=tJ(l).filter(e=>e._id!==r).map(e=>e._id);a.length&&tV(l,a)}},children:[(0,t.jsxs)(l.motion.div,{variants:aA,className:"relative overflow-hidden rounded-2xl border border-gray-200/40 dark:border-zinc-800/40",style:{background:"var(--surface-frosted)",backdropFilter:"blur(20px)",boxShadow:"0 8px 40px var(--surface-softer), 0 1px 3px var(--surface-soft)"},children:[(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500/60 via-orange-400/60 to-violet-500/60"}),(0,t.jsx)("div",{className:"absolute -top-12 -right-12 w-40 h-40 rounded-full opacity-15 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, #F59E0B, #EC4899)"}}),(0,t.jsx)("div",{className:"absolute -bottom-12 -left-12 w-40 h-40 rounded-full opacity-10 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, #6366F1, #8B5CF6)"}}),(0,t.jsx)("div",{ref:ti,className:"overflow-x-auto relative z-10",children:(0,t.jsxs)("div",{style:{minWidth:tw+tj},children:[(0,t.jsxs)("div",{className:"flex items-center border-b border-gray-200/5 dark:border-zinc-800/50",style:{background:"var(--surface-frosted)",backdropFilter:"blur(8px)"},children:[(0,t.jsx)(aB,{label:"Task",width:tw,isFirst:!0,onResize:e=>{te(e),td({taskColumnWidth:e})}}),tk.map(e=>(0,t.jsx)(aB,{label:e.label,width:e.width||150,onResize:t=>{let a=e._id?.toString?.()||e.key;ta(e=>({...e,[a]:t})),td({columns:tv.map(e=>(e._id?.toString?.()||e.key)===a?{...e,width:t}:e)})}},e._id||e.key))]}),(()=>{let e=I.filter(e=>!tH(e)).length;if(0===e)return null;let a={my:"My Tasks",assigned:"Assigned by me",collaborator:"Collaborating"}[eY.viewType]||eY.viewType;return(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b",style:{background:"rgba(245,158,11,0.08)",borderColor:"rgba(245,158,11,0.2)"},children:[(0,t.jsxs)("span",{className:"text-[11.5px] font-semibold text-amber-700 dark:text-amber-400",children:[e," task",1===e?" is":"s are",' hidden by the "',a,'" view']}),(0,t.jsx)("button",{type:"button",onClick:()=>eZ(e=>({...e,viewType:"all"})),className:"text-[11px] font-bold px-2.5 py-1 rounded-full text-amber-700 dark:text-amber-400 hover:bg-amber-100 dar
2k:hover:bg-amber-500/10",style:{border:"1px solid rgba(245,158,11,0.35)"},children:"Show all"})]})})(),(0,t.jsx)(i.AnimatePresence,{children:tN.map((e,a)=>{let r,s,n=tJ(e.name),o=U.has(e.name),c="done"===(r=String(e.name||"").toLowerCase())||"complete"===r,{visible:u,hidden:p}=c?{visible:(s=[...n].sort((e,t)=>new Date(t.completedAt||t.updatedAt||0)-new Date(e.completedAt||e.updatedAt||0))).slice(0,10),hidden:s.slice(10)}:{visible:n,hidden:[]},m=ez.has(e.name),g=m?n:u;return(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.05*a,duration:.35,ease:[.25,.46,.45,.94]},children:[(0,t.jsx)(ee,{group:e,taskCount:g.length,collapsed:o,onToggle:()=>W(t=>{let a=new Set(t);return a.has(e.name)?a.delete(e.name):a.add(e.name),a}),onRename:e=>{}}),(0,t.jsx)(i.AnimatePresence,{children:!o&&(0,t.jsx)(l.motion.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.25,ease:[.25,.46,.45,.94]},children:(0,t.jsxs)(aR,{groupName:e.name,children:[(0,t.jsx)(d.SortableContext,{items:g.map(e=>e._id),strategy:d.verticalListSortingStrategy,children:function(e,a){let r=new Map,s=[];for(let e of a){let t=aD(e);if(!t){s.push(e);continue}r.has(t)||r.set(t,[]),r.get(t).push(e)}let n=Array.from(r.entries()).map(([e,t])=>{let a=t.find(e=>e.milestone&&"object"==typeof e.milestone)?.milestone||{_id:e,title:"Milestone"},r=t.find(e=>e.linkedCampaign);return{id:e,milestone:a,rows:[...t].sort(aI),campaignId:String(a?.campaign?._id||a?.campaign||r?.linkedCampaign?._id||r?.linkedCampaign||""),campaignName:a?.campaign?.name||t.find(e=>e.linkedCampaign?.name)?.linkedCampaign?.name||null,dealId:a?.campaign?null:String(a?.deal?._id||a?.deal||"")||null}}).sort((e,t)=>{let a=(e.campaignName||"").localeCompare(t.campaignName||"");return 0!==a?a:e.campaignId!==t.campaignId?e.campaignId.localeCompare(t.campaignId):(e.milestone?.position??0)-(t.milestone?.position??0)});return(0,t.jsxs)(t.Fragment,{children:[n.map(a=>{let r=`${e.name}::${a.id}`,s=q.has(r),n=a.milestone?.color||"#F97316";return(0,t.jsxs)("div",{children:[(0,t.jsx)(aR,{groupName:`ms:${r}`,children:(0,t.jsx)(el,{compact:!0,milestone:a.milestone,campaignName:a.campaignName,campaignId:a.campaignId||null,dealId:a.dealId||null,taskCount:a.rows.length,collapsed:!s,onToggle:()=>X(e=>{let t=new Set(e);return t.has(r)?t.delete(r):t.add(r),t})})}),(0,t.jsx)(i.AnimatePresence,{children:s&&(0,t.jsx)(l.motion.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.22,ease:[.25,.46,.45,.94]},style:{background:`${n}06`,boxShadow:`inset 3px 0 0 ${n}55`},children:a.rows.map((e,a)=>(0,t.jsx)(aO,{task:e,children:(0,t.jsx)(Q,{...tY(e,a,n)})},e._id))})})]},r)}),s.map((a,r)=>(0,t.jsx)(aO,{task:a,children:(0,t.jsx)(Q,{...tY(a,r,e.color)})},a._id))]})}(e,g)}),c&&p.length>0&&(0,t.jsx)("div",{className:"flex items-center justify-center py-2",children:(0,t.jsx)("button",{type:"button",onClick:()=>e_(t=>{let a=new Set(t);return a.has(e.name)?a.delete(e.name):a.add(e.name),a}),className:"inline-flex items-center gap-1.5 text-[11px] font-semibold px-3 py-1.5 rounded-lg transition-colors hover:bg-gray-50 dark:hover:bg-zinc-900",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-tertiary)"},title:m?"Hide tasks done a while ago":`Show ${p.length} older done task${1===p.length?"":"s"}`,children:m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(M.ChevronUpIcon,{className:"w-3 h-3"}),"Hide aged-out"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x.ChevronDownIcon,{className:"w-3 h-3"}),"Show ",p.length," hidden"]})})}),(0,t.jsx)(eo,{group:e.name,groupColor:e.color,teamMembers:es,defaultPrivate:h,onAdd:t=>tP(t,e.name)})]})})})]},e.name)})}),tZ().length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)(ee,{group:{name:"Other",color:"var(--text-label)"},taskCount:tZ().length,collapsed:U.has("Other"),onToggle:()=>W(e=>{let t=new Set(e);return t.has("Other")?t.delete("Other"):t.add("Other"),t}),onRename:()=>{}}),!U.has("Other")&&tZ().map((e,a)=>(0,t.jsx)(Q,{task:e,columns:tk,onUpdate:tB,onClick:tF,onOpenWithSubItem:tM,onCommentOnSubItem:tA,onArchive:tO,onDelete:tR,onRequestDelete:e=>e1(e),teamMembers:es,statusOptions:tC,groupColor:"var(--text-label)",index:a,context:m,dueDateMode:F?.dueDateMode||"single",isExpanded:eh.has(e._id
2),onToggleSubItems:e=>{ef(t=>{let a=new Set(t);return a.has(e)?a.delete(e):(a.add(e),t$(e)),a})},onSubItemRefresh:t_,taskColumnWidth:tw,unreadSummary:eN[e._id?.toString?.()]?.subItemUnread||{},totalSummary:eN[e._id?.toString?.()]?.subItemTotal||{},onUnreadRefresh:()=>t$(e._id),autoExpandSubItemId:ey===e._id?.toString?.()?ek:null},e._id))]}),0===I.length&&(0,t.jsxs)(l.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2,duration:.5},className:"py-16 text-center relative",children:[(0,t.jsx)("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-48 h-48 rounded-full opacity-20 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, #F59E0B, #EC4899, #6366F1)"}}),(0,t.jsxs)("div",{className:"relative z-10",children:[(0,t.jsx)("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(249,115,22,0.1), rgba(236,72,153,0.1))"},children:(0,t.jsx)(eB.ClipboardDocumentListIcon,{className:"w-8 h-8 text-orange-400"})}),(0,t.jsx)("p",{className:"text-sm font-semibold text-gray-500 dark:text-zinc-400 mb-1",children:"No tasks yet"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 mb-5",children:"Create your first task to get started"}),(0,t.jsxs)("button",{onClick:()=>tP("New Task",tN[0]?.name||"Default"),className:"group inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-semibold text-white transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5",style:{background:"linear-gradient(135deg, #F97316, #EC4899)",boxShadow:"0 4px 16px rgba(236,72,153,0.25)"},children:[(0,t.jsx)(eb.SparklesIcon,{className:"w-4 h-4 group-hover:rotate-12 transition-transform"}),"Create first task"]})]})]})]})})]}),(0,t.jsx)(o.DragOverlay,{dropAnimation:{duration:200},children:eD?(()=>{let e=I.find(e=>e._id===eD);if(!e)return null;let a=e.statusColor||"#F97316";return(0,t.jsxs)("div",{className:"pointer-events-none flex items-center gap-2.5 pl-3 pr-4 py-2.5 rounded-xl",style:{background:"var(--surface-panel)",backdropFilter:"blur(24px)",border:"1px solid var(--border-default)",boxShadow:"0 18px 40px -10px rgba(236,72,153,0.32), 0 8px 18px -6px rgba(249,115,22,0.18), 0 0 0 1px rgba(249,115,22,0.08)",transform:"rotate(-1.5deg)",maxWidth:360},children:[(0,t.jsx)("span",{className:"block w-1 self-stretch rounded-full flex-shrink-0",style:{background:`linear-gradient(180deg, ${a}, ${a}AA)`}}),(0,t.jsx)("span",{className:"text-[10px] font-black tracking-[0.14em] uppercase px-2 py-0.5 rounded-md flex-shrink-0",style:{background:`${a}20`,color:a,border:`1px solid ${a}30`},children:e.status||"Task"}),(0,t.jsx)("span",{className:"text-[13px] font-semibold text-gray-900 dark:text-zinc-100 truncate",children:e.title})]})})():null})]})]}),(0,t.jsx)(i.AnimatePresence,{children:G&&(0,t.jsx)(ed.default,{task:G,initialSubItemId:K,initialSubItemDraft:V,initialQuoteSubItem:Z,onClose:tL,onUpdate:e=>{tB(G._id,e),H(t=>t?{...t,...e}:null)},onDelete:()=>{tR(G._id),tL()},onRequestDelete:e=>e1(e),onRefresh:t_,teamMembers:es,statusOptions:tC,subItemUnread:eN[G._id?.toString?.()]?.subItemUnread||{},subItemTotal:eN[G._id?.toString?.()]?.subItemTotal||{},onUnreadRefresh:()=>t$(G._id),onNavigateToSubitem:e=>(function(e,t){if(tL(),!e||!t)return;let a=e.toString(),r=t.toString();ef(e=>{if(e.has(a))return e;let t=new Set(e);return t.add(a),t$(a),t}),ev(a),ew(r)})(G._id,e)})}),(0,t.jsx)(ej,{}),(0,t.jsx)(i.AnimatePresence,{children:eQ&&(0,t.jsx)(eG,{task:eQ,onClose:()=>e1(null),onDelete:async()=>{await tR(eQ._id),G?._id===eQ._id&&tL(),e1(null)},onArchive:async()=>{await tO(eQ._id,!0),G?._id===eQ._id&&tL(),e1(null)}})}),(0,t.jsx)(i.AnimatePresence,{children:eP&&(0,t.jsx)(ap,{open:eP,onClose:()=>eR(!1),boardId:R,defaultGroup:tN?.[0]?.name,teamMembers:es,onTaskCreated:()=>
2t_()})}),(0,t.jsx)(i.AnimatePresence,{children:eA&&(0,t.jsx)(eq,{teamMembers:es,currentUser:j?.user,onClose:()=>eL(!1),onCreated:e=>{B(t=>[e,...t]),O(e._id),A(e)}})}),(0,t.jsx)(i.AnimatePresence,{children:eE&&F&&(0,t.jsx)(eF,{board:F,boards:P,teamMembers:es,currentUser:j?.user,initialTab:eT,onClose:()=>{e$(!1),eM(null)},onSaved:e=>{A(e),B(t=>t.map(t=>t._id===e._id?e:t))},onArchived:e=>{B(t=>t.map(t=>t._id===e._id?e:t)),O(null),A(null),e$(!1),eM(null),t_(),tE()},onDelete:()=>{B(e=>e.filter(e=>e._id!==F._id)),O(null),A(null),e$(!1),eM(null),t_(),tE()}})}),ea&&(0,t.jsx)(eg,{columns:tk,boardId:R,onClose:()=>er(!1),onSave:e=>{F?A(t=>t?{...t,columns:e}:null):e6(e),er(!1)}})]})}],700109)},865654,283564,723994,615737,300058,597730,539156,743607,465509,960590,e=>{"use strict";var t=e.i(271645),a=e.i(618566);e.s(["useHomeQuery",0,function(){let e=(0,a.useSearchParams)(),r=e?.toString()||"",[s,n]=(0,t.useState)(()=>r?`?${r}`:window.location.search);return(0,t.useEffect)(()=>{n(r?`?${r}`:"")},[r]),{params:(0,t.useMemo)(()=>new URLSearchParams(s),[s]),setParams:(0,t.useCallback)((e,{replace:t=!0}={})=>{let a=new URLSearchParams(window.location.search);for(let[t,r]of Object.entries(e))null==r?a.delete(t):a.set(t,String(r));let r=a.toString(),s=r?`/?${r}`:"/";t?window.history.replaceState(null,"",s):window.history.pushState(null,"",s),n(r?`?${r}`:"")},[])}}],865654);var r=e.i(843476),s=e.i(846932),n=e.i(88653),l=e.i(787906),i=e.i(879945),o=e.i(618969);let d=[{label:"To Do",color:"#c4c4c4"},{label:"In Progress",color:"#fdab3d"},{label:"Review",color:"#e2445c"},{label:"Done",color:"#00c875"},{label:"Stuck",color:"#df2f4a"}];function c({value:e,onChange:a,statusOptions:l,compact:u=!1}){let[x,p]=(0,t.useState)(!1),m=(0,t.useRef)(null),{resolvedTheme:h}=(0,i.useTheme)(),g=l?.length>0?l:d,b=g.find(t=>t.label===e)||g[0],f=(0,o.adjustStatusColor)(b.color,h);return(0,t.useEffect)(()=>{function e(e){m.current&&!m.current.contains(e.target)&&p(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,r.jsxs)("div",{ref:m,className:"relative",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:[(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),p(!x)},className:`${u?"px-2 py-0.5 rounded-md text-[10px] font-bold tracking-wide max-w-full truncate":"w-full h-9 rounded-lg text-[11px] font-bold tracking-wide flex items-center justify-center"} text-white transition-all duration-300 hover:shadow-md hover:scale-[1.02] active:scale-[0.98]`,style:{background:`linear-gradient(135deg, ${f}, ${f}CC)`,boxShadow:`0 2px 8px ${f}25`},title:b.label,children:b.label}),(0,r.jsx)(n.AnimatePresence,{children:x&&(0,r.jsx)(s.motion.div,{initial:{opacity:0,y:-4,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.96},transition:{duration:.15,ease:[.25,.46,.45,.94]},className:"absolute z-50 mt-1.5 left-0 rounded-xl py-1.5 min-w-[160px]",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 12px 40px var(--shadow-ambient-lg), 0 2px 8px var(--border-subtle)",border:"1px solid var(--border-subtle)"},children:g.map(e=>{let t=(0,o.adjustStatusColor)(e.color,h);return(0,r.jsxs)("button",{onClick:t=>{t.stopPropagation(),a(e.label,e.color),p(!1)},className:"w-full px-3 py-2 flex items-center gap-2.5 hover:bg-gray-50/80 dark:hover:bg-zinc-900/80 text-xs transition-colors duration-150",children:[(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full flex-shrink-0 ring-2 ring-offset-1",style:{backgroundColor:t,ringColor:`${t}30`}}),(0,r.jsx)("span",{className:"text-gray-700 dark:text-zinc-300 font-medium",children:e.label}),e.label===b.label&&(0,r.jsx)("svg",{className:"w-3.5 h-3.5 ml-auto text-emerald-500",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})]},e.label)})})})]})}e.s(["default",0,c],283564);var u=e.i(825367);function x({value:e=[],externalValue:t=[],onChange:a,onAddExternal:s,onRemoveExternal:n,teamMembers:l=[],compact:i=!1}){return(0,r.jsx)(u.default,{value:e,externalValue:t,onChange:a,onAddExternal:s,onRemoveExternal:n,teamMembers:l,compact:i})}var p=e.i(833786);
2function m({value:e,onChange:a,teamMembers:l=[],compact:i=!1}){let[o,d]=(0,t.useState)(!1),[c,u]=(0,t.useState)(""),x=(0,t.useRef)(null);(0,t.useEffect)(()=>{function e(e){x.current&&!x.current.contains(e.target)&&d(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let h=e&&"object"==typeof e?e:e?l.find(t=>t._id?.toString()===e?.toString()):null,g=l.filter(e=>e.name?.toLowerCase().includes(c.toLowerCase())||e.email?.toLowerCase().includes(c.toLowerCase()));return(0,r.jsxs)("div",{ref:x,className:"relative",children:[(0,r.jsx)("button",{onClick:()=>d(e=>!e),className:`${i?"h-7":"h-9 w-full"} flex items-center justify-center gap-1.5 group/assigner`,children:h?(0,r.jsx)(p.default,{user:h,size:i?20:24}):(0,r.jsx)("div",{className:"rounded-full flex items-center justify-center transition-all duration-300 group-hover/assigner:scale-110",style:{width:i?20:24,height:i?20:24,background:"var(--surface-soft)",border:"1.5px dashed var(--border-default)"},children:(0,r.jsx)("svg",{className:"text-gray-300 dark:text-zinc-700",style:{width:i?10:12,height:i?10:12},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})})}),(0,r.jsx)(n.AnimatePresence,{children:o&&(0,r.jsxs)(s.motion.div,{initial:{opacity:0,y:-4,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.96},transition:{duration:.15,ease:[.25,.46,.45,.94]},className:"absolute z-50 mt-1.5 left-0 rounded-xl py-2 w-72",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 12px 40px var(--shadow-ambient-lg), 0 2px 8px var(--border-subtle)",border:"1px solid var(--border-default)"},children:[(0,r.jsx)("div",{className:"px-3 pb-2",children:(0,r.jsx)("input",{type:"text",placeholder:"Find a teammateâ¦",value:c,onChange:e=>u(e.target.value),className:"w-full text-xs px-3 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-orange-300/50 transition-all text-gray-900 dark:text-zinc-100 placeholder-gray-400 dark:placeholder-zinc-500",style:{background:"var(--surface-soft)",border:"1px solid var(--border-default)"},autoFocus:!0})}),(0,r.jsxs)("div",{className:"max-h-56 overflow-y-auto",children:[g.map(e=>{let t=h?._id?.toString?.()===e._id?.toString?.();return(0,r.jsxs)("button",{onClick:()=>{a(e),d(!1)},className:"w-full px-3 py-2 flex items-center gap-2.5 hover:bg-gray-50/80 dark:hover:bg-zinc-900/80 text-xs transition-colors duration-150",children:[(0,r.jsx)(p.default,{user:e,size:28}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 text-left",children:[(0,r.jsx)("div",{className:"text-gray-700 dark:text-zinc-300 font-medium truncate",children:e.name}),e.email&&(0,r.jsx)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500 truncate",children:e.email})]}),t&&(0,r.jsx)("div",{className:"ml-auto flex-shrink-0 w-5 h-5 rounded-full bg-emerald-500 flex items-center justify-center shadow-sm",children:(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})]},e._id)}),0===g.length&&(0,r.jsx)("p",{className:"px-3 py-3 text-xs text-gray-400 dark:text-zinc-500 text-center",children:c?"No teammates match":"No teammates"})]})]})})]})}var h=e.i(389472),g=e.i(83663);function b({value:e,startValue:a=null,onChange:s,mode:n="single",compact:l=!1}){let[i,o]=(0,t.useState)(!1),d=(0,t.useRef)(null);(0,t.useEffect)(()=>{i&&"single"===n&&d.current&&(d.current.focus(),d.current.showPicker?.())},[i,n]);let c="range"===n?((e,t)=>{if(!e&&!t)return null;let a=e=>new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"});return e&&t?`${a(e)} â ${a(t)}`:t?a(t):`${a(e)} â ?`})(a,e):e?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"}):null,u=e&&new Date(e)<new Date&&new Date(e).toDateString()!==new Date().toDateString(),x=e&&new Date(e).toDateString()===new Date().toDateString();return i&&"range"===n?(0,r.jsxs)("div",{className:"flex items-center gap-1 px-1.5",style:{background:"var(--surface-soft)",border:"1px solid var(--border-default)",borderRadius:8,height:36},children:[(0,r.jsx)("input",{type:"date",defaultValue:(0,g.toInputDate)(a),onChange:t=>s(e,{startDate:(0,g.fromInputDate)(t.target.value)}),onBlur:()=>o(!1),className:"text-[11px] bg-transparent focus:outline-none text-gray-900 dark:text-zinc-100 w-[88px]","aria-label":"Start date"}),(0,r.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-zinc-500",children:"â"}),(0,r.jsx)("input",{type:"date",defaultValue:(0,g.toInputDate)(e),onChange:e=>s((0,g.fromInputDate)(e.target.value)),onBlur:()=>o(!1),className:"text-[11px] bg-transparent focus:outline-none text-gray-900 dark:text-zinc-100 w-[88px]","aria-label":"End date"})]}):i?(0,r.jsx)("input",{ref:d,type:"date",defaultValue:(0,g.toInputDate)(e),onChange:e=>{s((0,g.fromInputDate)(e.target.value)),o(!1)},onBlur:()=>o(!1),className:"w-full h-9 text-xs px-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-orange-300/50 transition-all",style:{background:"var(--surface-soft)",border:"1px solid var(--border-default)"}}):(0,r.jsxs)("button",{onClick:()=>o(!0),className:l?"px-2 py-0.5 rounded-md text-[10px] font-bold tracking-wide flex items-center gap-1 max-w-full whitespace-nowrap transition-all duration-300 hover:shadow-sm hover:scale-[1.02] active:scale-[0.98]":"w-full h-9 flex items-center justify-center gap-1.5 text-xs font-medium rounded-lg transition-all duration-200 hover:shadow-sm",style:u?{background:"rgba(239,68,68,0.08)",color:"#DC2626",border:"1px solid rgba(239,68,68,0.15)"}:x?{background:"rgba(245,158,11,0.08)",color:"#D97706",border:"1px solid rgba(245,158,11,0.15)"}:c?{background:"var(--surface-soft)",color:"var(--text-tertiary)",border:"1px solid transparent"}:{background:"transparent",color:"var(--text-disabled)",border:"1px solid transparent"},children:[u&&(0,r.jsxs)("span",{className:"flex h-1.5 w-1.5",children:[(0,r.jsx)("span",{className:"animate-ping absolute inline-flex h-1.5 w-1.5 rounded-full bg-red-400 opacity-75"}),(0,r.jsx)("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-red-500"})]}),!c&&(0,r.jsx)(h.CalendarDaysIcon,{className:l?"w-3 h-3":"w-3.5 h-3.5"}),(0,r.jsx)("span",{className:"truncate",children:c||("range"===n?"Set range":"Set date")})]})}e.s(["default",0,b],723994);let f=[{value:"critical",label:"Critical",color:"#EF4444",bg:"rgba(239,68,68,0.1)",border:"rgba(239,68,68,0.2)",icon:"!!!"},{value:"high",label:"High",color:"#F59E0B",bg:"rgba(245,158,11,0.1)",border:"rgba(245,158,11,0.2)",icon:"!!"},{value:"medium",label:"Medium",color:"#6366F1",bg:"rgba(99,102,241,0.1)",border:"rgba(99,102,241,0.2)",icon:"!"},{value:"low",label:"Low",color:"var(--text-label)",bg:"rgba(156,163,175,0.1)",border:"rgba(156,163,175,0.2)",icon:"â"}];
2function y({value:e,onChange:a,compact:l=!1}){let[i,o]=(0,t.useState)(!1),d=(0,t.useRef)(null),c=f.find(t=>t.value===e)||f[2];return(0,t.useEffect)(()=>{function e(e){d.current&&!d.current.contains(e.target)&&o(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,r.jsxs)("div",{ref:d,className:"relative",children:[(0,r.jsxs)("button",{onClick:()=>o(!i),className:`${l?"px-2 py-0.5 rounded-md text-[10px] font-bold tracking-wide flex items-center gap-1 max-w-full":"w-full h-9 rounded-lg text-[11px] font-bold tracking-wide flex items-center justify-center gap-1.5"} transition-all duration-300 hover:shadow-sm hover:scale-[1.02] active:scale-[0.98]`,style:{background:c.bg,color:c.color,border:`1px solid ${c.border}`},title:c.label,children:[(0,r.jsx)("span",{className:"opacity-60",children:c.icon}),(0,r.jsx)("span",{className:"truncate",children:c.label})]}),(0,r.jsx)(n.AnimatePresence,{children:i&&(0,r.jsx)(s.motion.div,{initial:{opacity:0,y:-4,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.96},transition:{duration:.15,ease:[.25,.46,.45,.94]},className:"absolute z-50 mt-1.5 left-0 rounded-xl py-1.5 min-w-[150px]",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 12px 40px var(--shadow-ambient-lg), 0 2px 8px var(--border-subtle)",border:"1px solid var(--border-subtle)"},children:f.map(e=>(0,r.jsxs)("button",{onClick:()=>{a(e.value),o(!1)},className:"w-full px-3 py-2 flex items-center gap-2.5 hover:bg-gray-50/80 dark:hover:bg-zinc-900/80 text-xs transition-colors duration-150",children:[(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-md flex items-center justify-center text-[8px] font-black flex-shrink-0",style:{background:e.bg,color:e.color,border:`1px solid ${e.border}`},children:e.icon}),(0,r.jsx)("span",{className:"text-gray-700 dark:text-zinc-300 font-medium",children:e.label}),e.value===c.value&&(0,r.jsx)("svg",{className:"w-3.5 h-3.5 ml-auto text-emerald-500",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})]},e.value))})})]})}function v({value:e,onChange:a,placeholder:s="â"}){let[n,l]=(0,t.useState)(!1),[i,o]=(0,t.useState)(e||""),d=(0,t.useRef)(null);function c(){let t=i.trim();t!==(e||"")&&a(t),l(!1)}return((0,t.useEffect)(()=>{n&&d.current&&(d.current.focus(),d.current.select())},[n]),(0,t.useEffect)(()=>{o(e||"")},[e]),n)?(0,r.jsx)("input",{ref:d,type:"text",value:i,onChange:e=>o(e.target.value),onBlur:c,onKeyDown:t=>{"Enter"===t.key&&c(),"Escape"===t.key&&(o(e||""),l(!1))},className:"w-full h-9 text-xs px-3 rounded-lg focus:outline-none focus:ring-2 focus:ring-orange-300/50 transition-all",style:{background:"var(--surface-soft)",border:"1px solid var(--border-default)"}}):(0,r.jsx)("button",{onClick:()=>l(!0),className:"w-full h-9 flex items-center justify-center text-xs font-medium rounded-lg truncate px-2 transition-all duration-200 hover:bg-gray-50/60 dark:hover:bg-zinc-900/60",style:{color:e?"var(--text-secondary)":"var(--text-disabled)"},children:e||s})}e.s(["default",0,y],615737),e.s(["default",0,v],300058);var k=e.i(803884);function j({value:e=[],onChange:a}){let[l,i]=(0,t.useState)(!1),[o,d]=(0,t.useState)(""),[c,u]=(0,t.useState)(""),x=(0,t.useRef)(null);function p(){o.trim()&&(a([...e,{label:c.trim()||o.trim(),url:o.trim()}]),d(""),u(""),i(!1))}return((0,t.useEffect)(()=>{function e(e){x.current&&!x.current.contains(e.target)&&i(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),e.length>0&&!l)?(0,r.jsxs)("div",{className:"flex items-center gap-1.5 justify-center h-9",children:[(0,r.jsx)("a",{href:e[0].url,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-medium truncate max-w-[80px] transition-colors duration-200",style:{color:"#6366F1"},onClick:e=>e.stopPropagation(),children:(0,r.jsx)("span",{className:"hover:underline",children:e[0].label||"Link"})}),e.length>1&&(0,r.jsxs)("span",{className:"text-[9px] font-bold px-1.5 py-0.5 rounded-full",style:{background:"rgba(99,102,241,0.08)",color:"#6366F1"},children:["+",e.length-1]}),(0,r.jsx)("button",{onClick:()=>i(!0),className:"text-gray-300 dark:text-zinc-700 hover:text-violet-500 transition-colors duration-200",children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):l?(0,r.jsx)(n.AnimatePresence,{children:(0,r.jsxs)(s.motion.div,{ref:x,initial:{opacity:0,y:-4,scale:.96}
2,animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.96},transition:{duration:.15},className:"absolute z-50 rounded-xl p-3 w-60",style:{background:"var(--panel-95)",backdropFilter:"blur(20px)",boxShadow:"0 12px 40px var(--shadow-ambient-lg), 0 2px 8px var(--border-subtle)",border:"1px solid var(--border-subtle)"},children:[(0,r.jsx)("input",{type:"text",placeholder:"Label",value:c,onChange:e=>u(e.target.value),className:"w-full text-xs px-3 py-2 rounded-lg mb-2 focus:outline-none focus:ring-2 focus:ring-violet-300/50 transition-all",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},autoFocus:!0}),(0,r.jsx)("input",{type:"url",placeholder:"https://...",value:o,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&p(),className:"w-full text-xs px-3 py-2 rounded-lg mb-2.5 focus:outline-none focus:ring-2 focus:ring-violet-300/50 transition-all",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),(0,r.jsx)("button",{onClick:p,className:"w-full text-xs py-2 text-white rounded-lg font-semibold transition-all duration-300 hover:shadow-md",style:{background:"linear-gradient(135deg, #6366F1, #8B5CF6)",boxShadow:"0 2px 8px rgba(99,102,241,0.25)"},children:"Add Link"})]})}):(0,r.jsx)("button",{onClick:()=>i(!0),className:"w-full h-9 flex items-center justify-center transition-all duration-200 hover:bg-gray-50/60 dark:hover:bg-zinc-900/60 rounded-lg group",children:(0,r.jsx)(k.LinkIcon,{className:"w-3.5 h-3.5 text-gray-300 dark:text-zinc-700 group-hover:text-violet-400 transition-colors duration-200"})})}function w(e){let t=e.replace("#",""),a=parseInt(3===t.length?t.split("").map(e=>e+e).join(""):t,16);return[a>>16&255,a>>8&255,255&a]}function N(e,t){try{let[a,r,s]=w(e);return`rgba(${a},${r},${s},${t})`}catch{return`rgba(0,0,0,${t})`}}function C({value:e,onChange:a,column:o={},options:d=[]}){let[c,u]=(0,t.useState)(!1),[x,p]=(0,t.useState)(e||""),m=(0,t.useRef)(null),{resolvedTheme:h}=(0,i.useTheme)(),g=o?.options,b=Array.isArray(g)&&g.length>0,f=b?g:d,y=Array.isArray(f)&&f.length>0,v=!y&&!b,k=y?f.find(t=>t.value===e):null,j=!v&&e&&!k;if((0,t.useEffect)(()=>{function e(e){m.current&&!m.current.contains(e.target)&&u(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),v)return(0,r.jsx)("div",{className:"w-full h-9 flex items-center px-2",children:(0,r.jsx)("input",{type:"text",value:x,onChange:e=>p(e.target.value),onBlur:()=>a(x),onKeyDown:e=>{"Enter"===e.key&&(e.currentTarget.blur(),a(x))},placeholder:"â",className:"w-full text-xs text-gray-700 dark:text-zinc-300 bg-transparent focus:outline-none placeholder-gray-300 dark:placeholder-zinc-700"})});let S=e=>"dark"===h?{background:N(e,.18),border:`1px solid ${N(e,.38)}`,color:e}:{background:N(e,.1),border:`1px solid ${N(e,.25)}`,color:function(e){try{let t=w(e);if(.35>function([e,t,a]){let r=e=>{let t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)};return .2126*r(e)+.7152*r(t)+.0722*r(a)}(t))return e;let a=t.map(e=>Math.round(.55*e));return`#${a.map(e=>e.toString(16).padStart(2,"0")).join("")}`}catch{return e}}(e)};return(0,r.jsxs)("div",{ref:m,className:"relative w-full",children:[(0,r.jsx)("button",{onClick:()=>u(!c),className:"w-full h-9 flex items-center justify-center px-2 transition-all duration-150 hover:bg-gray-50/60 dark:hover:bg-zinc-900/60 rounded-lg group",children:k?(0,r.jsx)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-semibold tracking-wide max-w-full truncate",style:S(k.color||"#6b7280"),children:k.label}):j?(0,r.jsx)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-semibold tracking-wide max-w-full truncate",style:{background:"rgba(107,114,128,0.10)",border:"1px solid rgba(107,114,128,0.22)",color:"#6b7280"},children:e}):(0,r.jsx)("span",{className:"text-[11px] text-gray-300 dark:text-zinc-700",children:"Select"})}),(0,r.jsx)(n.AnimatePresence,{children:c&&(0,r.jsxs)(s.motion.div,{initial:{opacity:0,y:-4,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.96},transition:{duration:.15,ease:[.25,.46,.45,.94]},className:"absolute z-50 mt-1 left-0 rounded-xl py-1.5 min-w-[160px] max-w-[220px]",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",boxShadow:"0 12px 40px var(--shadow-ambient-lg), 0 2px 8px var(--border-subtle)",border:"1px solid var(--border-subtle)"},children:[e&&(0,r.jsxs)("button",{onClick:()=>{a(""),u(!1)},className:"w-full px-3 py-2 flex items-center gap-2.5 hover:bg-gray-50/80 dark:hover:bg-zinc-900/80 text-xs transition-colors duration-100 text-gray-400 dark:text-zinc-500",children:[(0,r.jsx)("span",{className:"w-3 h-3 rounded-full flex-shrink-0 border border-dashed border-gray-300 dark:border-zinc-700"}),(0,r.jsx)("span",{className:"font-medium",children:"Clear"})]}),f.map(t=>{let s=t.value===e,n=t.color||"#6b7280";return(0,r.jsxs)("button",{onClick:()=>{a(t.value),u(!1)},className:"w-full px-3 py-2 flex items-center gap-2.5 hover:bg-gray-50/80 dark:hover:bg-zinc-900/80 text-xs transition-colors duration-100",children:[(0,r.jsx)("span",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:n}}),(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-semibold flex-1 min-w-0 truncate",style:S(n),children:t.label}),s&&(0,r.jsx)(l.CheckIcon,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:n}})]},t.value)})]})})]})}
2function S({value:e,onChange:a}){let[s,n]=(0,t.useState)(!1),[l,i]=(0,t.useState)(e??""),o=(0,t.useRef)(null);function d(){let t=""===l?null:Number(l);t!==e&&a(t),n(!1)}return((0,t.useEffect)(()=>{s&&o.current&&(o.current.focus(),o.current.select())},[s]),(0,t.useEffect)(()=>{i(e??"")},[e]),s)?(0,r.jsx)("input",{ref:o,type:"number",value:l,onChange:e=>i(e.target.value),onBlur:d,onKeyDown:t=>{"Enter"===t.key&&d(),"Escape"===t.key&&(i(e??""),n(!1))},className:"w-full h-9 text-xs px-3 rounded-lg focus:outline-none focus:ring-2 focus:ring-orange-300/50 text-center transition-all",style:{background:"var(--surface-soft)",border:"1px solid var(--border-default)"}}):(0,r.jsx)("button",{onClick:()=>n(!0),className:"w-full h-9 flex items-center justify-center text-xs font-medium rounded-lg transition-all duration-200 hover:bg-gray-50/60 dark:hover:bg-zinc-900/60",style:{color:null!=e?"var(--text-secondary)":"var(--text-disabled)"},children:null!=e?e.toLocaleString():"â"})}e.s(["default",0,j],597730),e.s(["default",0,C],539156),e.s(["default",0,S],743607);var z=e.i(928950);function _({value:e,onChange:a}){let[l,i]=(0,t.useState)(!1),[o,d]=(0,t.useState)(""),[c,u]=(0,t.useState)([]),[x,p]=(0,t.useState)(!1),m=(0,t.useRef)(null),h=(0,t.useRef)(null);(0,t.useEffect)(()=>{function e(e){m.current&&!m.current.contains(e.target)&&i(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.useEffect)(()=>o.trim()&&l?(h.current&&clearTimeout(h.current),h.current=setTimeout(async()=>{p(!0);try{let e=await fetch(`/api/searchAutoCompleteCreators?query=${encodeURIComponent(o.trim())}`);if(e.ok){let t=await e.json();u(Array.isArray(t)?t:[])}}catch{u([])}finally{p(!1)}},220),()=>clearTimeout(h.current)):void u([]),[o,l]);let g=e&&"object"==typeof e?e:null;return(0,r.jsxs)("div",{ref:m,className:"relative",children:[(0,r.jsx)("button",{onClick:()=>i(!l),className:"w-full h-9 flex items-center justify-center gap-1.5 transition-all duration-200 hover:bg-gray-50/60 dark:hover:bg-zinc-900/60 rounded-lg group",children:g?(0,r.jsxs)(r.Fragment,{children:[g.image?(0,r.jsx)("img",{src:g.image,alt:g.name,className:"w-6 h-6 rounded-full object-cover ring-1 ring-purple-200/60"}):(0,r.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{background:"rgba(168,85,247,0.12)"},children:(0,r.jsx)(z.UserCircleIcon,{className:"w-4 h-4 text-purple-400"})}),(0,r.jsx)("span",{className:"text-[11px] text-gray-700 dark:text-zinc-300 font-medium truncate max-w-[80px]",children:g.name})]}):(0,r.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center transition-all duration-200 group-hover:scale-110",style:{background:"rgba(168,85,247,0.05)",border:"1.5px dashed rgba(168,85,247,0.25)"},children:(0,r.jsx)(z.UserCircleIcon,{className:"w-3.5 h-3.5 text-purple-300"})})}),(0,r.jsx)(n.AnimatePresence,{children:l&&(0,r.jsxs)(s.motion.div,{initial:{opacity:0,y:-4,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.96},transition:{duration:.15,ease:[.25,.46,.45,.94]},className:"absolute z-50 mt-1.5 left-0 rounded-xl py-2 w-72",style:{background:"var(--panel-95)",backdropFilter:"blur(20px)",boxShadow:"0 12px 40px var(--shadow-ambient-lg), 0 2px 8px var(--border-subtle)",border:"1px solid var(--border-subtle)"},children:[(0,r.jsx)("div",{className:"px-3 pb-2",children:(0,r.jsx)("input",{autoFocus:!0,t
2ype:"text",value:o,onChange:e=>d(e.target.value),placeholder:"Search creatorsâ¦",className:"w-full text-xs px-3 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-300/50 transition-all",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}})}),(0,r.jsxs)("div",{className:"max-h-56 overflow-y-auto",children:[g&&(0,r.jsx)("button",{onClick:()=>{a(null),i(!1)},className:"w-full px-3 py-1.5 text-[11px] text-gray-400 dark:text-zinc-500 text-left hover:bg-gray-50/80 dark:hover:bg-zinc-900/80 transition-colors",children:"Clear selection"}),x&&(0,r.jsx)("p",{className:"px-3 py-3 text-xs text-gray-400 dark:text-zinc-500 text-center",children:"Searchingâ¦"}),!x&&c.map(e=>(0,r.jsxs)("button",{onClick:()=>{a(e),i(!1),d("")},className:"w-full px-3 py-2 flex items-center gap-2.5 hover:bg-gray-50/80 dark:hover:bg-zinc-900/80 text-xs transition-colors duration-150",children:[e.image?(0,r.jsx)("img",{src:e.image,alt:e.name,className:"w-7 h-7 rounded-full object-cover flex-shrink-0 ring-1 ring-purple-200/60"}):(0,r.jsx)("div",{className:"w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 bg-purple-100",children:(0,r.jsx)(z.UserCircleIcon,{className:"w-4 h-4 text-purple-500"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 text-left",children:[(0,r.jsx)("div",{className:"text-gray-700 dark:text-zinc-300 font-medium truncate",children:e.name}),e.category&&(0,r.jsx)("div",{className:"text-[10px] text-purple-500 truncate",children:e.category})]})]},e._id)),!x&&o&&0===c.length&&(0,r.jsx)("p",{className:"px-3 py-3 text-xs text-gray-400 dark:text-zinc-500 text-center",children:"No creators found"})]})]})})]})}e.s(["default",0,_],465509);var D=e.i(754863),I=e.i(427217),E=e.i(39875),$=e.i(171387),T=e.i(307163),F=e.i(705766);let M=[.25,.46,.45,.94],A=[{value:"status",label:"Status"},{value:"priority",label:"Priority"},{value:"dueDate",label:"Due date"},{value:"title",label:"Title"},{value:"description",label:"Description"}];function L(e){return e?"string"==typeof e?e:e._id?.toString?.()||e.toString?.()||null:null}function P({taskId:e,ownBoardId:a,value:l=[],onChange:i,compact:o=!1}){let[d,c]=(0,t.useState)(!1),[u,x]=(0,t.useState)(""),[p,m]=(0,t.useState)([]),[h,g]=(0,t.useState)(!1),[b,f]=(0,t.useState)(!1),[y,v]=(0,t.useState)(null),[k,j]=(0,t.useState)([]),w=(0,t.useRef)(null);async function N(){if(y&&!b){f(!0);try{let t={taskId:y._id};k.length>0&&(t.mirrorFields=k);let a=await fetch(`/api/tasks/${e}/linked-tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||"Failed to link")}let r=await a.json();i?.(r.linkedTasks||[]),F.default.success("Linked"),x(""),v(null),j([]),c(!1)}catch(e){F.default.error(e.message||"Couldn't link")}finally{f(!1)}}}async function C(t){if(!b){f(!0);try{let a=await fetch(`/api/tasks/${e}/linked-tasks`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:t})});if(!a.ok)throw Error("Failed to unlink");let r=await a.json();i?.(r.linkedTasks||[])}catch(e){F.default.error(e.message||"Couldn't unlink")}finally{f(!1)}}}return(0,t.useEffect)(()=>{if(d)return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)};function e(e){w.current&&!w.current.contains(e.target)&&(c(!1),v(null),j([]))}function t(e){"Escape"===e.key&&(y?(v(null),j([])):c(!1))}},[d]),(0,t.useEffect)(()=>{if(!d)return;let t=u.trim(),a=!1;g(!0);let r=setTimeout(async()=>{try{let r=t.length>=2?`/api/tasks?query=${encodeURIComponent(t)}&limit=20`:"/api/tasks?limit=30",s=await fetch(r);if(!s.ok)throw Error("search_failed");let n=await s.json();if(a)return;let i=new Set((l||[]).map(e=>L(e.task)).filter(Boolean)),o=(n?.tasks||[]).filter(t=>{let a=L(t._id);return a&&a!==L(e)&&!i.has(a)});m(o)}catch{a||m([])}finally{a||g(!1)}},180);return()=>{a=!0,clearTimeout(r)}},[d,u,e,l]),(0,r.jsxs)("div",{ref:w,className:"relative",children:[(0,r.jsx)("button",{type:"button",onClick:()=>c(e=>!e),className:`${o?"h-7":"h-9 w-full"} flex items-center justify-start gap-1 px-1.5 rounded-md hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors`,title:"Link to tasks on other boards",children:0===l.length?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:[(0,r.jsx)(D.ArrowsRightLeftIcon,{className:"w-3 h-3"}),"Link"]}):(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1 min-w-0",children:[l.slice(0,o?2:4).map((e,t)=>(function(e,t){let s=e.task;if(!s||"object"!=typeof s)return null;let n=L(e.board)||L(s.board),l="object"==typeof e.board?e.board?.name:null,i=n&&a&&n!==a,d=function(e){let t=[{bg:"rgba(99,102,241,0.10)",color:"#4F46E5",border:"rgba(99,102,241,0.25)"},{bg:"rgba(236,72,153,0.10)",color:"#BE185D",border:"rgba(236,72,153,0.25)"},{bg:"rgba(16,185,129,0.10)",color:"#047857",border:"rgba(16,185,129,0.25)"},{bg:"rgba(245,158,11,0.10)",color:"#B45309",border:"rgba(245,158,11,0.25)"},{bg:"rgba(14,165,233,0.10)",color:"#0369A1",border:"rgba(14,165,233,0.25)"}],a=String(e||"?"),r=0;for(let e=0;e<a.length;
2e+=1)r=31*r+a.charCodeAt(e)|0;return t[Math.abs(r)%t.length]}(n),c="Done"===s.status||"Complete"===s.status,u=`/dashboard/user/tasks?${n?`board=${n}&`:""}taskId=${s._id}`;return(0,r.jsxs)("span",{className:"group/link inline-flex items-center gap-1 pl-1.5 pr-1 py-0.5 rounded-md text-[11px] font-semibold transition-all hover:shadow-sm hover:-translate-y-0.5",style:{background:d.bg,color:d.color,border:`1px solid ${d.border}`,maxWidth:o?160:220},title:l?`${s.title} \xb7 on ${l}`:s.title,children:[(0,r.jsxs)("a",{href:u,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)(D.ArrowsRightLeftIcon,{className:"w-2.5 h-2.5 flex-shrink-0"}),(0,r.jsx)("span",{className:`truncate ${c?"line-through opacity-70":""}`,children:s.title||"(untitled)"}),i&&l&&(0,r.jsx)("span",{className:"text-[8px] uppercase tracking-wider px-1 py-0.5 rounded shrink-0 opacity-80",style:{background:"var(--surface-softer)",border:"1px solid var(--shadow-ambient)"},children:l}),(0,r.jsx)($.ArrowTopRightOnSquareIcon,{className:"w-2.5 h-2.5 opacity-50 flex-shrink-0"})]}),(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),C(s._id)},className:"opacity-0 group-hover/link:opacity-100 w-3.5 h-3.5 rounded-sm flex items-center justify-center transition-opacity",style:{background:"var(--surface-softer)"},title:"Unlink","aria-label":"Unlink",children:(0,r.jsx)(I.XMarkIcon,{className:"w-2.5 h-2.5"})})]},`${s._id}-${t}`)})(e,t)),l.length>(o?2:4)&&(0,r.jsxs)("span",{className:"text-[9px] font-bold text-gray-400 dark:text-zinc-500 px-1",children:["+",l.length-(o?2:4)]})]})}),(0,r.jsx)(n.AnimatePresence,{children:d&&(0,r.jsxs)(s.motion.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.16,ease:M},className:"absolute z-50 left-0 top-full mt-1 w-[320px] rounded-xl overflow-hidden",style:{background:"var(--surface-panel)",backdropFilter:"blur(20px)",border:"1px solid var(--border-default)",boxShadow:"0 18px 42px var(--shadow-ambient-xl), 0 4px 12px var(--shadow-ambient)"},children:[(0,r.jsx)("div",{className:"h-[2px] bg-gradient-to-r from-indigo-500/60 via-pink-500/60 to-orange-500/60"}),y?(0,r.jsxs)("div",{className:"p-2.5 space-y-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{v(null),j([])},className:"w-5 h-5 flex items-center justify-center rounded-md hover:bg-gray-100 dark:hover:bg-zinc-800 text-gray-400 dark:text-zinc-500",children:(0,r.jsx)(T.ChevronLeftIcon,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("span",{className:"text-[11px] font-semibold text-gray-700 dark:text-zinc-300 truncate flex-1",children:y.title||"(untitled)"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500 mb-1.5",children:"Keep connected (mirror)"}),(0,r.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mb-2",children:"Changes to these fields will sync between both tasks automatically."}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:A.map(e=>{let t=k.includes(e.value);return(0,r.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.value,void j(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"text-[10px] font-semibold px-2 py-0.5 rounded-full transition-all",style:t?{background:"rgba(99,102,241,0.15)",color:"#4F46E5",border:"1px solid rgba(99,102,241,0.35)"}:{background:"var(--surface-soft)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:e.label},e.value)})}),0===k.length&&(0,r.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 italic mt-1.5",children:"None selected â tasks will be linked but not mirrored."})]}),(0,r.jsx)("button",{type:"button",onClick:N,disabled:b,className:"w-full py-1.5 rounded-lg text-[11px] font-semibold text-white disabled:opacity-40 transition-all hover:shadow-sm",style:{background:"linear-gradient(135deg, #6366F1, #8B5CF6)"},children:b?"Linkingâ¦":"Link task"})]}):(0,r.jsxs)("div",{className:"p-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg mb-2",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,r.jsx)(E.MagnifyingGlassIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"}
2),(0,r.jsx)("input",{autoFocus:!0,type:"text",value:u,onChange:e=>x(e.target.value),placeholder:"Search any board for a task to linkâ¦",className:"flex-1 bg-transparent border-0 outline-none text-[12px] text-gray-900 dark:text-zinc-100 placeholder:text-gray-400 dark:placeholder:text-zinc-600"})]}),(0,r.jsx)("div",{className:"max-h-[260px] overflow-y-auto",children:h&&0===p.length?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)("div",{className:"w-4 h-4 border-2 border-indigo-300 border-t-indigo-500 rounded-full animate-spin"})}):0===p.length?(0,r.jsx)("div",{className:"px-2 py-4 text-[11px] text-gray-400 dark:text-zinc-500 text-center",children:u.trim().length>=2?"No matches across your boards":"Type to find a task on any board"}):p.map(e=>{let t="Done"===e.status||"Complete"===e.status,s=L(e.board),n="object"==typeof e.board?e.board?.name:null,l=s&&a&&s!==a&&n;return(0,r.jsxs)("button",{onClick:()=>{v(e),j([])},disabled:b,className:"w-full px-2 py-1.5 text-[12px] text-left rounded-md hover:bg-gray-50 dark:hover:bg-zinc-900 text-gray-700 dark:text-zinc-300 flex items-center gap-2 disabled:opacity-50",children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:e.statusColor||(t?"#10B981":"var(--text-label)")}}),(0,r.jsx)("span",{className:"truncate flex-1",children:e.title}),l&&(0,r.jsx)("span",{className:"text-[9px] uppercase tracking-wider px-1 py-0.5 rounded shrink-0",style:{background:"rgba(99,102,241,0.10)",color:"#4F46E5",border:"1px solid rgba(99,102,241,0.20)"},children:n})]},e._id)})})]})]})})]})}e.s(["default",0,function({column:e,task:a,onUpdate:i,teamMembers:o=[],statusOptions:d=[],dueDateMode:p="single"}){let h,[g,f]=(0,t.useState)(null),k=(0,t.useRef)(null);function w(e){i(e),f(Date.now()),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{},1200)}(0,t.useEffect)(()=>()=>{k.current&&clearTimeout(k.current)},[]);let{key:N,type:z,options:D}=e;function I(e,t){switch(N){case"status":w({status:e,statusColor:t||void 0});break;case"person":w({assignees:e.map(e=>e._id||e)});break;case"collaborators":w({collaborators:e.map(e=>e._id||e)});break;case"assigner":case"createdBy":w({createdBy:e?._id||e||null});break;case"dueDate":{let a={dueDate:e};t&&"startDate"in t&&(a.startDate=t.startDate),w(a);break}case"priority":w({priority:e});break;case"linkedCreator":w({linkedCreator:e?._id||e||null});break;default:"creator"===z&&e&&"object"==typeof e?w({customFields:{...a.customFields||{},[N]:e._id,[`${N}__display`]:{_id:e._id,name:e.name,image:e.image}}}):w({customFields:{...a.customFields||{},[N]:e}})}}let E=function(){switch(N){case"status":return a.status;case"person":return a.assignees;case"collaborators":return a.collaborators;case"assigner":case"createdBy":return a.createdBy;case"dueDate":return a.dueDate;case"priority":return a.priority;case"linkedCreator":return a.linkedCreator;case"linkedTasks":return a.linkedTasks||[];default:return a.customFields?.[N]??null}}();switch(z){case"status":h=(0,r.jsx)(c,{value:E,onChange:I,statusOptions:d});break;case"person":h=(0,r.jsx)(u.default,{value:E,externalValue:a.externalAssignees||[],onChange:I,teamMembers:o,onAddExternal:async e=>{try{let t=await fetch(`/api/tasks/${a._id}/external-assignees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(t.ok){let e=await t.json();w({externalAssignees:e.task.externalAssignees})}}catch(e){console.error("Failed to add external assignee:",e)}},onRemoveExternal:async e=>{try{let t=await fetch(`/api/tasks/${a._id}/external-assignees`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(t.ok){let e=await t.json();w({externalAssignees:e.task.externalAssignees})}}catch(e){console.error("Failed to remove external assignee:",e)}}});break;case"collaborators":h=(0,r.jsx)(x,{value:E,externalValue:a.externalCollaborators||[],onChange:I,teamMembers:o,onAddExternal:async e=>{try{let t=await fetch(`/api/tasks/${a._id}/external-collaborators`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(t.ok){let e=await t.json();w({externalCollaborators:e.task.externalCollaborators})}}
2catch(e){console.error("Failed to add external collaborator:",e)}},onRemoveExternal:async e=>{try{let t=await fetch(`/api/tasks/${a._id}/external-collaborators`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(t.ok){let e=await t.json();w({externalCollaborators:e.task.externalCollaborators})}}catch(e){console.error("Failed to remove external collaborator:",e)}}});break;case"assigner":h=(0,r.jsx)(m,{value:E,onChange:I,teamMembers:o});break;case"date":h=(0,r.jsx)(b,{value:E,startValue:"dueDate"===N?a.startDate:null,onChange:I,mode:"dueDate"===N?p:"single"});break;case"priority":h=(0,r.jsx)(y,{value:E,onChange:I});break;case"text":default:h=(0,r.jsx)(v,{value:E,onChange:I});break;case"link":h=(0,r.jsx)(j,{value:"links"===N?a.links:E,onChange:e=>"links"===N?w({links:e}):I(e)});break;case"dropdown":h=(0,r.jsx)(C,{value:E,onChange:I,column:e,options:D||[]});break;case"number":h=(0,r.jsx)(S,{value:E,onChange:I});break;case"creator":{let e="linkedCreator"===N?E:a.customFields?.[`${N}__display`]||null;h=(0,r.jsx)(_,{value:e,onChange:I});break}case"linked_tasks":h=(0,r.jsx)(P,{taskId:a._id,ownBoardId:"object"==typeof a.board?a.board?._id?.toString?.():a.board?.toString?.(),value:a.linkedTasks||[],onChange:e=>w({linkedTasks:e}),compact:!0})}let $=g?`Saved ${new Date(g).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}`:void 0;return(0,r.jsxs)("div",{className:"relative",title:$,children:[h,(0,r.jsx)(n.AnimatePresence,{children:g&&Date.now()-g<1100&&(0,r.jsx)(s.motion.div,{initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6},transition:{duration:.18},className:"absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full flex items-center justify-center pointer-events-none z-10",style:{background:"#10B981",boxShadow:"0 0 8px rgba(16,185,129,0.5)"},children:(0,r.jsx)(l.CheckIcon,{className:"w-2 h-2 text-white",strokeWidth:3})},`flash-${g}`)})]})}],960590)}]);
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.