knowns 0.10.5 → 0.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -311,7 +311,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
311
311
  To pick up a draggable item, press the space bar.
312
312
  While dragging, use the arrow keys to move the item.
313
313
  Press space again to drop the item in its new position, or press escape to cancel.
314
- `},gdt={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function bdt(e){let{announcements:t=gdt,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=mdt}=e;const{announce:i,announcement:s}=fdt(),a=m1("DndLiveRegion"),[l,c]=x.useState(!1);if(x.useEffect(()=>{c(!0)},[]),pdt(x.useMemo(()=>({onDragStart(f){let{active:m}=f;i(t.onDragStart({active:m}))},onDragMove(f){let{active:m,over:g}=f;t.onDragMove&&i(t.onDragMove({active:m,over:g}))},onDragOver(f){let{active:m,over:g}=f;i(t.onDragOver({active:m,over:g}))},onDragEnd(f){let{active:m,over:g}=f;i(t.onDragEnd({active:m,over:g}))},onDragCancel(f){let{active:m,over:g}=f;i(t.onDragCancel({active:m,over:g}))}}),[i,t])),!l)return null;const u=ue.createElement(ue.Fragment,null,ue.createElement(udt,{id:r,value:o.draggable}),ue.createElement(ddt,{id:a,announcement:s}));return n?Kr.createPortal(u,n):u}var qr;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(qr||(qr={}));function IS(){}function Y_(e,t){return x.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function ydt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Na=Object.freeze({x:0,y:0});function MB(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xdt(e,t){const n=DS(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function LB(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function vdt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function YI(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function Edt(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function VY(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const wdt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=VY(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=MB(VY(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(LB)},GY=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=YI(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=YI(l),u=o.reduce((m,g,y)=>m+MB(c[y],g),0),f=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:f}})}}return i.sort(LB)};function Sdt(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),s=o-r,a=i-n;if(r<o&&n<i){const l=t.width*t.height,c=e.width*e.height,u=s*a,f=u/(l+c-u);return Number(f.toFixed(4))}return 0}const bfe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=Sdt(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(vdt)};function Cdt(e,t){const{top:n,left:r,bottom:o,right:i}=t;return n<=e.y&&e.y<=o&&r<=e.x&&e.x<=i}const Tdt=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];const o=[];for(const i of t){const{id:s}=i,a=n.get(s);if(a&&Cdt(r,a)){const c=YI(a).reduce((f,m)=>f+MB(r,m),0),u=Number((c/4).toFixed(4));o.push({id:s,data:{droppableContainer:i,value:u}})}}return o.sort(LB)};function kdt(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function yfe(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Na}function Adt(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+e*a.y,bottom:s.bottom+e*a.y,left:s.left+e*a.x,right:s.right+e*a.x}),{...n})}}const Ndt=Adt(1);function xfe(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function _dt(e,t,n){const r=xfe(t);if(!r)return e;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=e.left-s-(1-o)*parseFloat(n),c=e.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?e.width/o:e.width,f=i?e.height/i:e.height;return{width:u,height:f,top:c,right:l+u,bottom:c+f,left:l}}const Rdt={ignoreTransform:!1};function Wm(e,t){t===void 0&&(t=Rdt);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=hi(e).getComputedStyle(e);c&&(n=_dt(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function WY(e){return Wm(e,{ignoreTransform:!0})}function Ddt(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Idt(e,t){return t===void 0&&(t=hi(e).getComputedStyle(e)),t.position==="fixed"}function Odt(e,t){t===void 0&&(t=hi(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function PB(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(OB(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!p1(o)||hfe(o)||n.includes(o))return n;const i=hi(e).getComputedStyle(o);return o!==e&&Odt(o,i)&&n.push(o),Idt(o,i)?n:r(o.parentNode)}return e?r(e):n}function vfe(e){const[t]=PB(e,1);return t??null}function K_(e){return!KT||!e?null:Vm(e)?e:IB(e)?OB(e)||e===Gm(e).scrollingElement?window:p1(e)?e:null:null}function Efe(e){return Vm(e)?e.scrollX:e.scrollLeft}function wfe(e){return Vm(e)?e.scrollY:e.scrollTop}function KI(e){return{x:Efe(e),y:wfe(e)}}var io;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(io||(io={}));function Sfe(e){return!KT||!e?!1:e===document.scrollingElement}function Cfe(e){const t={x:0,y:0},n=Sfe(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const Mdt={x:.2,y:.2};function Ldt(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=Mdt);const{isTop:c,isBottom:u,isLeft:f,isRight:m}=Cfe(e),g={x:0,y:0},y={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!c&&i<=t.top+v.height?(g.y=io.Backward,y.y=r*Math.abs((t.top+v.height-i)/v.height)):!u&&l>=t.bottom-v.height&&(g.y=io.Forward,y.y=r*Math.abs((t.bottom-v.height-l)/v.height)),!m&&a>=t.right-v.width?(g.x=io.Forward,y.x=r*Math.abs((t.right-v.width-a)/v.width)):!f&&s<=t.left+v.width&&(g.x=io.Backward,y.x=r*Math.abs((t.left+v.width-s)/v.width)),{direction:g,speed:y}}function Pdt(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Tfe(e){return e.reduce((t,n)=>Ch(t,KI(n)),Na)}function Fdt(e){return e.reduce((t,n)=>t+Efe(n),0)}function Bdt(e){return e.reduce((t,n)=>t+wfe(n),0)}function kfe(e,t){if(t===void 0&&(t=Wm),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);vfe(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const jdt=[["x",["left","right"],Fdt],["y",["top","bottom"],Bdt]];class FB{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=PB(n),o=Tfe(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of jdt)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Kb{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function $dt(e){const{EventTarget:t}=hi(e);return e instanceof t?e:Gm(e)}function X_(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Is;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Is||(Is={}));function qY(e){e.preventDefault()}function Udt(e){e.stopPropagation()}var vn;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(vn||(vn={}));const Afe={start:[vn.Space,vn.Enter],cancel:[vn.Esc],end:[vn.Space,vn.Enter,vn.Tab]},Hdt=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case vn.Right:return{...n,x:n.x+25};case vn.Left:return{...n,x:n.x-25};case vn.Down:return{...n,y:n.y+25};case vn.Up:return{...n,y:n.y-25}}};class BB{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Kb(Gm(n)),this.windowListeners=new Kb(hi(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Is.Resize,this.handleCancel),this.windowListeners.add(Is.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Is.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&kfe(r),n(Na)}handleKeyDown(t){if(ZT(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=Afe,coordinateGetter:s=Hdt,scrollBehavior:a="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Na;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(t,{active:n,context:r.current,currentCoordinates:u});if(f){const m=RS(f,u),g={x:0,y:0},{scrollableAncestors:y}=r.current;for(const v of y){const w=t.code,{isTop:S,isRight:T,isLeft:k,isBottom:I,maxScroll:_,minScroll:R}=Cfe(v),D=Pdt(v),M={x:Math.min(w===vn.Right?D.right-D.width/2:D.right,Math.max(w===vn.Right?D.left:D.left+D.width/2,f.x)),y:Math.min(w===vn.Down?D.bottom-D.height/2:D.bottom,Math.max(w===vn.Down?D.top:D.top+D.height/2,f.y))},$=w===vn.Right&&!T||w===vn.Left&&!k,O=w===vn.Down&&!I||w===vn.Up&&!S;if($&&M.x!==f.x){const F=v.scrollLeft+m.x,U=w===vn.Right&&F<=_.x||w===vn.Left&&F>=R.x;if(U&&!m.y){v.scrollTo({left:F,behavior:a});return}U?g.x=v.scrollLeft-F:g.x=w===vn.Right?v.scrollLeft-_.x:v.scrollLeft-R.x,g.x&&v.scrollBy({left:-g.x,behavior:a});break}else if(O&&M.y!==f.y){const F=v.scrollTop+m.y,U=w===vn.Down&&F<=_.y||w===vn.Up&&F>=R.y;if(U&&!m.x){v.scrollTo({top:F,behavior:a});return}U?g.y=v.scrollTop-F:g.y=w===vn.Down?v.scrollTop-_.y:v.scrollTop-R.y,g.y&&v.scrollBy({top:-g.y,behavior:a});break}}this.handleMove(t,Ch(RS(f,this.referenceCoordinates),g))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}BB.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Afe,onActivation:o}=t,{active:i}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function YY(e){return!!(e&&"distance"in e)}function KY(e){return!!(e&&"delay"in e)}class jB{constructor(t,n,r){var o;r===void 0&&(r=$dt(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:s}=i;this.props=t,this.events=n,this.document=Gm(s),this.documentListeners=new Kb(this.document),this.listeners=new Kb(r),this.windowListeners=new Kb(hi(s)),this.initialCoordinates=(o=DS(i))!=null?o:Na,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Is.Resize,this.handleCancel),this.windowListeners.add(Is.DragStart,qY),this.windowListeners.add(Is.VisibilityChange,this.handleCancel),this.windowListeners.add(Is.ContextMenu,qY),this.documentListeners.add(Is.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(KY(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(YY(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Is.Click,Udt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Is.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=DS(t))!=null?n:Na,c=RS(o,l);if(!r&&a){if(YY(a)){if(a.tolerance!=null&&X_(c,a.tolerance))return this.handleCancel();if(X_(c,a.distance))return this.handleStart()}if(KY(a)&&X_(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),s(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===vn.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const zdt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Nfe extends jB{constructor(t){const{event:n}=t,r=Gm(n.target);super(t,zdt,r)}}Nfe.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const Vdt={move:{name:"mousemove"},end:{name:"mouseup"}};var XI;(function(e){e[e.RightClick=2]="RightClick"})(XI||(XI={}));class _fe extends jB{constructor(t){super(t,Vdt,Gm(t.event.target))}}_fe.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===XI.RightClick?!1:(r?.({event:n}),!0)}}];const Z_={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Rfe extends jB{constructor(t){super(t,Z_)}static setup(){return window.addEventListener(Z_.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Z_.move.name,t)};function t(){}}}Rfe.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Xb;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Xb||(Xb={}));var OS;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(OS||(OS={}));function Gdt(e){let{acceleration:t,activator:n=Xb.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=OS.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:m}=e;const g=qdt({delta:f,disabled:!i}),[y,v]=idt(),w=x.useRef({x:0,y:0}),S=x.useRef({x:0,y:0}),T=x.useMemo(()=>{switch(n){case Xb.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Xb.DraggableRect:return o}},[n,o,l]),k=x.useRef(null),I=x.useCallback(()=>{const R=k.current;if(!R)return;const D=w.current.x*S.current.x,M=w.current.y*S.current.y;R.scrollBy(D,M)},[]),_=x.useMemo(()=>a===OS.TreeOrder?[...c].reverse():c,[a,c]);x.useEffect(()=>{if(!i||!c.length||!T){v();return}for(const R of _){if(r?.(R)===!1)continue;const D=c.indexOf(R),M=u[D];if(!M)continue;const{direction:$,speed:O}=Ldt(R,M,T,t,m);for(const F of["x","y"])g[F][$[F]]||(O[F]=0,$[F]=0);if(O.x>0||O.y>0){v(),k.current=R,y(I,s),w.current=O,S.current=$;return}}w.current={x:0,y:0},S.current={x:0,y:0},v()},[t,I,r,v,i,s,JSON.stringify(T),JSON.stringify(g),y,c,_,u,JSON.stringify(m)])}const Wdt={x:{[io.Backward]:!1,[io.Forward]:!1},y:{[io.Backward]:!1,[io.Forward]:!1}};function qdt(e){let{delta:t,disabled:n}=e;const r=_S(t);return h1(o=>{if(n||!r||!o)return Wdt;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[io.Backward]:o.x[io.Backward]||i.x===-1,[io.Forward]:o.x[io.Forward]||i.x===1},y:{[io.Backward]:o.y[io.Backward]||i.y===-1,[io.Forward]:o.y[io.Forward]||i.y===1}}},[n,t,r])}function Ydt(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return h1(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function Kdt(e,t){return x.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...i]},[]),[e,t])}var ay;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ay||(ay={}));var ZI;(function(e){e.Optimized="optimized"})(ZI||(ZI={}));const XY=new Map;function Xdt(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,s]=x.useState(null),{frequency:a,measure:l,strategy:c}=o,u=x.useRef(e),f=w(),m=sy(f),g=x.useCallback(function(S){S===void 0&&(S=[]),!m.current&&s(T=>T===null?S:T.concat(S.filter(k=>!T.includes(k))))},[m]),y=x.useRef(null),v=h1(S=>{if(f&&!n)return XY;if(!S||S===XY||u.current!==e||i!=null){const T=new Map;for(let k of e){if(!k)continue;if(i&&i.length>0&&!i.includes(k.id)&&k.rect.current){T.set(k.id,k.rect.current);continue}const I=k.node.current,_=I?new FB(l(I),I):null;k.rect.current=_,_&&T.set(k.id,_)}return T}return S},[e,i,n,f,l]);return x.useEffect(()=>{u.current=e},[e]),x.useEffect(()=>{f||g()},[n,f]),x.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),x.useEffect(()=>{f||typeof a!="number"||y.current!==null||(y.current=setTimeout(()=>{g(),y.current=null},a))},[a,f,g,...r]),{droppableRects:v,measureDroppableContainers:g,measuringScheduled:i!=null};function w(){switch(c){case ay.Always:return!1;case ay.BeforeDragging:return n;default:return!n}}}function $B(e,t){return h1(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Zdt(e,t){return $B(e,t)}function Qdt(e){let{callback:t,disabled:n}=e;const r=XT(t),o=x.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return x.useEffect(()=>()=>o?.disconnect(),[o]),o}function QT(e){let{callback:t,disabled:n}=e;const r=XT(t),o=x.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return x.useEffect(()=>()=>o?.disconnect(),[o]),o}function Jdt(e){return new FB(Wm(e),e)}function ZY(e,t,n){t===void 0&&(t=Jdt);const[r,o]=x.useState(null);function i(){o(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=t(e);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=Qdt({callback(l){if(e)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(e)){i();break}}}}),a=QT({callback:i});return Aa(()=>{i(),e?(a?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[e]),r}function eft(e){const t=$B(e);return yfe(e,t)}const QY=[];function tft(e){const t=x.useRef(e),n=h1(r=>e?r&&r!==QY&&e&&t.current&&e.parentNode===t.current.parentNode?r:PB(e):QY,[e]);return x.useEffect(()=>{t.current=e},[e]),n}function nft(e){const[t,n]=x.useState(null),r=x.useRef(e),o=x.useCallback(i=>{const s=K_(i.target);s&&n(a=>a?(a.set(s,KI(s)),new Map(a)):null)},[]);return x.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=K_(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,KI(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(i)};function s(a){a.forEach(l=>{const c=K_(l);c?.removeEventListener("scroll",o)})}},[o,e]),x.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>Ch(i,s),Na):Tfe(e):Na,[e,t])}function JY(e,t){t===void 0&&(t=[]);const n=x.useRef(null);return x.useEffect(()=>{n.current=null},t),x.useEffect(()=>{const r=e!==Na;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?RS(e,n.current):Na}function rft(e){x.useEffect(()=>{if(!KT)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function oft(e,t){return x.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,t)},n},{}),[e,t])}function Dfe(e){return x.useMemo(()=>e?Ddt(e):null,[e])}const eK=[];function ift(e,t){t===void 0&&(t=Wm);const[n]=e,r=Dfe(n?hi(n):null),[o,i]=x.useState(eK);function s(){i(()=>e.length?e.map(l=>Sfe(l)?r:new FB(t(l),l)):eK)}const a=QT({callback:s});return Aa(()=>{a?.disconnect(),s(),e.forEach(l=>a?.observe(l))},[e]),o}function Ife(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return p1(t)?t:e}function sft(e){let{measure:t}=e;const[n,r]=x.useState(null),o=x.useCallback(c=>{for(const{target:u}of c)if(p1(u)){r(f=>{const m=t(u);return f?{...f,width:m.width,height:m.height}:m});break}},[t]),i=QT({callback:o}),s=x.useCallback(c=>{const u=Ife(c);i?.disconnect(),u&&i?.observe(u),r(u?t(u):null)},[t,i]),[a,l]=NS(s);return x.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const aft=[{sensor:Nfe,options:{}},{sensor:BB,options:{}}],lft={current:{}},vE={draggable:{measure:WY},droppable:{measure:WY,strategy:ay.WhileDragging,frequency:ZI.Optimized},dragOverlay:{measure:Wm}};class Zb extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const cft={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Zb,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:IS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:vE,measureDroppableContainers:IS,windowRect:null,measuringScheduled:!1},Ofe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:IS,draggableNodes:new Map,over:null,measureDroppableContainers:IS},g1=x.createContext(Ofe),Mfe=x.createContext(cft);function uft(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Zb}}}function dft(e,t){switch(t.type){case qr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case qr.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case qr.DragEnd:case qr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case qr.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Zb(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case qr.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new Zb(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case qr.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Zb(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function fft(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=x.useContext(g1),i=_S(r),s=_S(n?.id);return x.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!ZT(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const f=ldt(u);if(f){f.focus();break}}})}},[r,t,o,s,i]),null}function Lfe(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function pft(e){return x.useMemo(()=>({draggable:{...vE.draggable,...e?.draggable},droppable:{...vE.droppable,...e?.droppable},dragOverlay:{...vE.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function hft(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=x.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Aa(()=>{if(!s&&!a||!t){i.current=!1;return}if(i.current||!r)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),f=yfe(u,r);if(s||(f.x=0),a||(f.y=0),i.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=vfe(c);m&&m.scrollBy({top:f.y,left:f.x})}},[t,s,a,r,n])}const JT=x.createContext({...Na,scaleX:1,scaleY:1});var ou;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ou||(ou={}));const mft=x.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=aft,collisionDetection:f=bfe,measuring:m,modifiers:g,...y}=t;const v=x.useReducer(dft,void 0,uft),[w,S]=v,[T,k]=hdt(),[I,_]=x.useState(ou.Uninitialized),R=I===ou.Initialized,{draggable:{active:D,nodes:M,translate:$},droppable:{containers:O}}=w,F=D!=null?M.get(D):null,U=x.useRef({initial:null,translated:null}),G=x.useMemo(()=>{var nn;return D!=null?{id:D,data:(nn=F?.data)!=null?nn:lft,rect:U}:null},[D,F]),j=x.useRef(null),[Q,V]=x.useState(null),[K,X]=x.useState(null),J=sy(y,Object.values(y)),B=m1("DndDescribedBy",s),q=x.useMemo(()=>O.getEnabled(),[O]),Y=pft(m),{droppableRects:P,measureDroppableContainers:le,measuringScheduled:ae}=Xdt(q,{dragging:R,dependencies:[$.x,$.y],config:Y.droppable}),ie=Ydt(M,D),ne=x.useMemo(()=>K?DS(K):null,[K]),se=bo(),pe=Zdt(ie,Y.draggable.measure);hft({activeNode:D!=null?M.get(D):null,config:se.layoutShiftCompensation,initialRect:pe,measure:Y.draggable.measure});const ke=ZY(ie,Y.draggable.measure,pe),Me=ZY(ie?ie.parentElement:null),Ce=x.useRef({activatorEvent:null,active:null,activeNode:ie,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:M,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Re=O.getNodeFor((n=Ce.current.over)==null?void 0:n.id),de=sft({measure:Y.dragOverlay.measure}),Te=(r=de.nodeRef.current)!=null?r:ie,Ge=R?(o=de.rect)!=null?o:ke:null,Ie=!!(de.nodeRef.current&&de.rect),cn=eft(Ie?null:ke),bt=Dfe(Te?hi(Te):null),it=tft(R?Re??ie:null),te=ift(it),fe=Lfe(g,{transform:{x:$.x-cn.x,y:$.y-cn.y,scaleX:1,scaleY:1},activatorEvent:K,active:G,activeNodeRect:ke,containerNodeRect:Me,draggingNodeRect:Ge,over:Ce.current.over,overlayNodeRect:de.rect,scrollableAncestors:it,scrollableAncestorRects:te,windowRect:bt}),ge=ne?Ch(ne,$):null,Pe=nft(it),je=JY(Pe),W=JY(Pe,[ke]),ye=Ch(fe,je),Be=Ge?Ndt(Ge,fe):null,qe=G&&Be?f({active:G,collisionRect:Be,droppableRects:P,droppableContainers:q,pointerCoordinates:ge}):null,at=Edt(qe,"id"),[un,mn]=x.useState(null),Mn=Ie?fe:Ch(fe,W),wn=kdt(Mn,(i=un?.rect)!=null?i:null,ke),Sn=x.useRef(null),_e=x.useCallback((nn,rn)=>{let{sensor:Ke,options:qt}=rn;if(j.current==null)return;const Et=M.get(j.current);if(!Et)return;const Pt=nn.nativeEvent,Yn=new Ke({active:j.current,activeNode:Et,event:Pt,options:qt,context:Ce,onAbort(Jt){if(!M.get(Jt))return;const{onDragAbort:_n}=J.current,nr={id:Jt};_n?.(nr),T({type:"onDragAbort",event:nr})},onPending(Jt,tr,_n,nr){if(!M.get(Jt))return;const{onDragPending:yo}=J.current,ms={id:Jt,constraint:tr,initialCoordinates:_n,offset:nr};yo?.(ms),T({type:"onDragPending",event:ms})},onStart(Jt){const tr=j.current;if(tr==null)return;const _n=M.get(tr);if(!_n)return;const{onDragStart:nr}=J.current,hs={activatorEvent:Pt,active:{id:tr,data:_n.data,rect:U}};Kr.unstable_batchedUpdates(()=>{nr?.(hs),_(ou.Initializing),S({type:qr.DragStart,initialCoordinates:Jt,active:tr}),T({type:"onDragStart",event:hs}),V(Sn.current),X(Pt)})},onMove(Jt){S({type:qr.DragMove,coordinates:Jt})},onEnd:Qt(qr.DragEnd),onCancel:Qt(qr.DragCancel)});Sn.current=Yn;function Qt(Jt){return async function(){const{active:_n,collisions:nr,over:hs,scrollAdjustedTranslate:yo}=Ce.current;let ms=null;if(_n&&yo){const{cancelDrop:xc}=J.current;ms={activatorEvent:Pt,active:_n,collisions:nr,delta:yo,over:hs},Jt===qr.DragEnd&&typeof xc=="function"&&await Promise.resolve(xc(ms))&&(Jt=qr.DragCancel)}j.current=null,Kr.unstable_batchedUpdates(()=>{S({type:Jt}),_(ou.Uninitialized),mn(null),V(null),X(null),Sn.current=null;const xc=Jt===qr.DragEnd?"onDragEnd":"onDragCancel";if(ms){const gs=J.current[xc];gs?.(ms),T({type:xc,event:ms})}})}}},[M]),Xe=x.useCallback((nn,rn)=>(Ke,qt)=>{const Et=Ke.nativeEvent,Pt=M.get(qt);if(j.current!==null||!Pt||Et.dndKit||Et.defaultPrevented)return;const Yn={active:Pt};nn(Ke,rn.options,Yn)===!0&&(Et.dndKit={capturedBy:rn.sensor},j.current=qt,_e(Ke,rn))},[M,_e]),xt=Kdt(u,Xe);rft(u),Aa(()=>{ke&&I===ou.Initializing&&_(ou.Initialized)},[ke,I]),x.useEffect(()=>{const{onDragMove:nn}=J.current,{active:rn,activatorEvent:Ke,collisions:qt,over:Et}=Ce.current;if(!rn||!Ke)return;const Pt={active:rn,activatorEvent:Ke,collisions:qt,delta:{x:ye.x,y:ye.y},over:Et};Kr.unstable_batchedUpdates(()=>{nn?.(Pt),T({type:"onDragMove",event:Pt})})},[ye.x,ye.y]),x.useEffect(()=>{const{active:nn,activatorEvent:rn,collisions:Ke,droppableContainers:qt,scrollAdjustedTranslate:Et}=Ce.current;if(!nn||j.current==null||!rn||!Et)return;const{onDragOver:Pt}=J.current,Yn=qt.get(at),Qt=Yn&&Yn.rect.current?{id:Yn.id,rect:Yn.rect.current,data:Yn.data,disabled:Yn.disabled}:null,Jt={active:nn,activatorEvent:rn,collisions:Ke,delta:{x:Et.x,y:Et.y},over:Qt};Kr.unstable_batchedUpdates(()=>{mn(Qt),Pt?.(Jt),T({type:"onDragOver",event:Jt})})},[at]),Aa(()=>{Ce.current={activatorEvent:K,active:G,activeNode:ie,collisionRect:Be,collisions:qe,droppableRects:P,draggableNodes:M,draggingNode:Te,draggingNodeRect:Ge,droppableContainers:O,over:un,scrollableAncestors:it,scrollAdjustedTranslate:ye},U.current={initial:Ge,translated:Be}},[G,ie,qe,Be,M,Te,Ge,P,O,un,it,ye]),Gdt({...se,delta:$,draggingRect:Be,pointerCoordinates:ge,scrollableAncestors:it,scrollableAncestorRects:te});const ut=x.useMemo(()=>({active:G,activeNode:ie,activeNodeRect:ke,activatorEvent:K,collisions:qe,containerNodeRect:Me,dragOverlay:de,draggableNodes:M,droppableContainers:O,droppableRects:P,over:un,measureDroppableContainers:le,scrollableAncestors:it,scrollableAncestorRects:te,measuringConfiguration:Y,measuringScheduled:ae,windowRect:bt}),[G,ie,ke,K,qe,Me,de,M,O,P,un,le,it,te,Y,ae,bt]),lr=x.useMemo(()=>({activatorEvent:K,activators:xt,active:G,activeNodeRect:ke,ariaDescribedById:{draggable:B},dispatch:S,draggableNodes:M,over:un,measureDroppableContainers:le}),[K,xt,G,ke,S,B,M,un,le]);return ue.createElement(gfe.Provider,{value:k},ue.createElement(g1.Provider,{value:lr},ue.createElement(Mfe.Provider,{value:ut},ue.createElement(JT.Provider,{value:wn},c)),ue.createElement(fft,{disabled:a?.restoreFocus===!1})),ue.createElement(bdt,{...a,hiddenTextDescribedById:B}));function bo(){const nn=Q?.autoScrollEnabled===!1,rn=typeof l=="object"?l.enabled===!1:l===!1,Ke=R&&!nn&&!rn;return typeof l=="object"?{...l,enabled:Ke}:{enabled:Ke}}}),gft=x.createContext(null),tK="button",bft="Draggable";function yft(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=m1(bft),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:m}=x.useContext(g1),{role:g=tK,roleDescription:y="draggable",tabIndex:v=0}=o??{},w=l?.id===t,S=x.useContext(w?JT:gft),[T,k]=NS(),[I,_]=NS(),R=oft(s,t),D=sy(n);Aa(()=>(f.set(t,{id:t,key:i,node:T,activatorNode:I,data:D}),()=>{const $=f.get(t);$&&$.key===i&&f.delete(t)}),[f,t]);const M=x.useMemo(()=>({role:g,tabIndex:v,"aria-disabled":r,"aria-pressed":w&&g===tK?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[r,g,v,w,y,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:M,isDragging:w,listeners:r?void 0:R,node:T,over:m,setNodeRef:k,setActivatorNodeRef:_,transform:S}}function Pfe(){return x.useContext(Mfe)}const xft="Droppable",vft={timeout:25};function Ffe(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=m1(xft),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=x.useContext(g1),u=x.useRef({disabled:n}),f=x.useRef(!1),m=x.useRef(null),g=x.useRef(null),{disabled:y,updateMeasurementsFor:v,timeout:w}={...vft,...o},S=sy(v??r),T=x.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(S.current)?S.current:[S.current]),g.current=null},w)},[w]),k=QT({callback:T,disabled:y||!s}),I=x.useCallback((M,$)=>{k&&($&&(k.unobserve($),f.current=!1),M&&k.observe(M))},[k]),[_,R]=NS(I),D=sy(t);return x.useEffect(()=>{!k||!_.current||(k.disconnect(),f.current=!1,k.observe(_.current))},[_,k]),x.useEffect(()=>(a({type:qr.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:m,data:D}}),()=>a({type:qr.UnregisterDroppable,key:i,id:r})),[r]),x.useEffect(()=>{n!==u.current.disabled&&(a({type:qr.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:m,isOver:l?.id===r,node:_,over:l,setNodeRef:R}}function Eft(e){let{animation:t,children:n}=e;const[r,o]=x.useState(null),[i,s]=x.useState(null),a=_S(n);return!n&&!r&&a&&o(a),Aa(()=>{if(!i)return;const l=r?.key,c=r?.props.id;if(l==null||c==null){o(null);return}Promise.resolve(t(c,i)).then(()=>{o(null)})},[t,r,i]),ue.createElement(ue.Fragment,null,n,r?x.cloneElement(r,{ref:s}):null)}const wft={x:0,y:0,scaleX:1,scaleY:1};function Sft(e){let{children:t}=e;return ue.createElement(g1.Provider,{value:Ofe},ue.createElement(JT.Provider,{value:wft},t))}const Cft={position:"fixed",touchAction:"none"},Tft=e=>ZT(e)?"transform 250ms ease":void 0,kft=x.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Tft}=e;if(!a)return null;const f=o?c:{...c,scaleX:1,scaleY:1},m={...Cft,width:a.width,height:a.height,top:a.top,left:a.left,transform:Wu.Transform.toString(f),transformOrigin:o&&r?xdt(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return ue.createElement(n,{className:s,style:m,ref:t},i)}),Aft=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:s}=e;if(i!=null&&i.active)for(const[a,l]of Object.entries(i.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(i!=null&&i.dragOverlay)for(const[a,l]of Object.entries(i.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return s!=null&&s.active&&n.node.classList.add(s.active),s!=null&&s.dragOverlay&&r.node.classList.add(s.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);s!=null&&s.active&&n.node.classList.remove(s.active)}},Nft=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Wu.Transform.toString(t)},{transform:Wu.Transform.toString(n)}]},_ft={duration:250,easing:"ease",keyframes:Nft,sideEffects:Aft({styles:{active:{opacity:"0"}}})};function Rft(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return XT((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=Ife(s);if(!c)return;const{transform:u}=hi(s).getComputedStyle(s),f=xfe(u);if(!f)return;const m=typeof t=="function"?t:Dft(t);return kfe(l,o.draggable.measure),m({active:{id:i,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:s,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:f})})}function Dft(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={..._ft,...e};return i=>{let{active:s,dragOverlay:a,transform:l,...c}=i;if(!t)return;const u={x:a.rect.left-s.rect.left,y:a.rect.top-s.rect.top},f={scaleX:l.scaleX!==1?s.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?s.rect.height*l.scaleY/a.rect.height:1},m={x:l.x-u.x,y:l.y-u.y,...f},g=o({...c,active:s,dragOverlay:a,transform:{initial:l,final:m}}),[y]=g,v=g[g.length-1];if(JSON.stringify(y)===JSON.stringify(v))return;const w=r?.({active:s,dragOverlay:a,...c}),S=a.node.animate(g,{duration:t,easing:n,fill:"forwards"});return new Promise(T=>{S.onfinish=()=>{w?.(),T()}})}}let nK=0;function Ift(e){return x.useMemo(()=>{if(e!=null)return nK++,nK},[e])}const Oft=ue.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:s,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:u,active:f,activeNodeRect:m,containerNodeRect:g,draggableNodes:y,droppableContainers:v,dragOverlay:w,over:S,measuringConfiguration:T,scrollableAncestors:k,scrollableAncestorRects:I,windowRect:_}=Pfe(),R=x.useContext(JT),D=Ift(f?.id),M=Lfe(s,{activatorEvent:u,active:f,activeNodeRect:m,containerNodeRect:g,draggingNodeRect:w.rect,over:S,overlayNodeRect:w.rect,scrollableAncestors:k,scrollableAncestorRects:I,transform:R,windowRect:_}),$=$B(m),O=Rft({config:r,draggableNodes:y,droppableContainers:v,measuringConfiguration:T}),F=$?w.setRef:void 0;return ue.createElement(Sft,null,ue.createElement(Eft,{animation:O},f&&D?ue.createElement(kft,{key:D,id:f.id,ref:F,as:a,activatorEvent:u,adjustScale:t,className:l,transition:i,rect:$,style:{zIndex:c,...o},transform:M},n):null))});function MS(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Mft(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Ov(e){return e!==null&&e>=0}function Lft(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Pft(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Bfe=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=MS(t,r,n),s=t[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},jfe="Sortable",$fe=ue.createContext({activeIndex:-1,containerId:jfe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Bfe,disabled:{draggable:!1,droppable:!1}});function Fft(e){let{children:t,id:n,items:r,strategy:o=Bfe,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=Pfe(),f=m1(jfe,n),m=a.rect!==null,g=x.useMemo(()=>r.map(R=>typeof R=="object"&&"id"in R?R.id:R),[r]),y=s!=null,v=s?g.indexOf(s.id):-1,w=c?g.indexOf(c.id):-1,S=x.useRef(g),T=!Lft(g,S.current),k=w!==-1&&v===-1||T,I=Pft(i);Aa(()=>{T&&y&&u(g)},[T,g,y,u]),x.useEffect(()=>{S.current=g},[g]);const _=x.useMemo(()=>({activeIndex:v,containerId:f,disabled:I,disableTransforms:k,items:g,overIndex:w,useDragOverlay:m,sortedRects:Mft(g,l),strategy:o}),[v,f,I.draggable,I.droppable,k,g,w,l,m,o]);return ue.createElement($fe.Provider,{value:_},t)}const Bft=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return MS(n,r,o).indexOf(t)},jft=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&t===l},$ft={duration:200,easing:"ease"},Ufe="transform",Uft=Wu.Transition.toString({property:Ufe,duration:0,easing:"linear"}),Hft={roleDescription:"sortable"};function zft(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=x.useState(null),a=x.useRef(n);return Aa(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=Wm(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[t,n,r,o]),x.useEffect(()=>{i&&s(null)},[i]),i}function Vft(e){let{animateLayoutChanges:t=jft,attributes:n,disabled:r,data:o,getNewIndex:i=Bft,id:s,strategy:a,resizeObserverConfig:l,transition:c=$ft}=e;const{items:u,containerId:f,activeIndex:m,disabled:g,disableTransforms:y,sortedRects:v,overIndex:w,useDragOverlay:S,strategy:T}=x.useContext($fe),k=Gft(r,g),I=u.indexOf(s),_=x.useMemo(()=>({sortable:{containerId:f,index:I,items:u},...o}),[f,o,I,u]),R=x.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:D,node:M,isOver:$,setNodeRef:O}=Ffe({id:s,data:_,disabled:k.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...l}}),{active:F,activatorEvent:U,activeNodeRect:G,attributes:j,setNodeRef:Q,listeners:V,isDragging:K,over:X,setActivatorNodeRef:J,transform:B}=yft({id:s,data:_,attributes:{...Hft,...n},disabled:k.draggable}),q=odt(O,Q),Y=!!F,P=Y&&!y&&Ov(m)&&Ov(w),le=!S&&K,ae=le&&P?B:null,ne=P?ae??(a??T)({rects:v,activeNodeRect:G,activeIndex:m,overIndex:w,index:I}):null,se=Ov(m)&&Ov(w)?i({id:s,items:u,activeIndex:m,overIndex:w}):I,pe=F?.id,ke=x.useRef({activeId:pe,items:u,newIndex:se,containerId:f}),Me=u!==ke.current.items,Ce=t({active:F,containerId:f,isDragging:K,isSorting:Y,id:s,index:I,items:u,newIndex:ke.current.newIndex,previousItems:ke.current.items,previousContainerId:ke.current.containerId,transition:c,wasDragging:ke.current.activeId!=null}),Re=zft({disabled:!Ce,index:I,node:M,rect:D});return x.useEffect(()=>{Y&&ke.current.newIndex!==se&&(ke.current.newIndex=se),f!==ke.current.containerId&&(ke.current.containerId=f),u!==ke.current.items&&(ke.current.items=u)},[Y,se,f,u]),x.useEffect(()=>{if(pe===ke.current.activeId)return;if(pe!=null&&ke.current.activeId==null){ke.current.activeId=pe;return}const Te=setTimeout(()=>{ke.current.activeId=pe},50);return()=>clearTimeout(Te)},[pe]),{active:F,activeIndex:m,attributes:j,data:_,rect:D,index:I,newIndex:se,items:u,isOver:$,isSorting:Y,isDragging:K,listeners:V,node:M,overIndex:w,over:X,setNodeRef:q,setActivatorNodeRef:J,setDroppableNodeRef:O,setDraggableNodeRef:Q,transform:Re??ne,transition:de()};function de(){if(Re||Me&&ke.current.newIndex===I)return Uft;if(!(le&&!ZT(U)||!c)&&(Y||Ce))return Wu.Transition.toString({...c,property:Ufe})}}function Gft(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}vn.Down,vn.Right,vn.Up,vn.Left;const Wft={},rK=e=>{let t;const n=new Set,r=(u,f)=>{const m=typeof u=="function"?u(t):u;if(!Object.is(m,t)){const g=t;t=f??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,g))}},o=()=>t,l={setState:r,getState:o,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Wft?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(r,o,l);return l},qft=e=>e?rK(e):rK,Hfe={},{useDebugValue:Yft}=ue,{useSyncExternalStoreWithSelector:Kft}=UXe;let oK=!1;const Xft=e=>e;function Zft(e,t=Xft,n){(Hfe?"production":void 0)!=="production"&&n&&!oK&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),oK=!0);const r=Kft(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Yft(r),r}const iK=e=>{(Hfe?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?qft(e):e,n=(r,o)=>Zft(t,r,o);return Object.assign(n,t),n},Qft=e=>e?iK(e):iK;var sK,aK;const lK=typeof window<"u"&&((sK=window.document)!=null&&sK.createElement||((aK=window.navigator)==null?void 0:aK.product)==="ReactNative")?ue.useLayoutEffect:ue.useEffect;function Jft(){const e=Qft(t=>({current:new Array,version:0,set:t}));return{In:({children:t})=>{const n=e(o=>o.set),r=e(o=>o.version);return lK(()=>{n(o=>({version:o.version+1}))},[]),lK(()=>(n(({current:o})=>({current:[...o,t]})),()=>n(({current:o})=>({current:o.filter(i=>i!==t)}))),[t,r]),null},Out:()=>{const t=e(n=>n.current);return ue.createElement(ue.Fragment,null,t)}}}const Q_=768;function ek(){const[e,t]=x.useState(void 0);return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Q_-1}px)`),r=()=>{t(window.innerWidth<Q_)};return n.addEventListener("change",r),t(window.innerWidth<Q_),()=>n.removeEventListener("change",r)},[]),!!e}const zfe=Jft(),UB=x.createContext({columns:[],data:[],activeCardId:null}),ept=({id:e,children:t,className:n})=>{const{isOver:r,setNodeRef:o}=Ffe({id:e});return h.jsx("div",{className:Ee("flex min-h-40 flex-col divide-y overflow-hidden rounded-md border bg-secondary text-xs shadow-sm ring-2 transition-all shrink-0",r?"ring-primary":"ring-transparent",n),ref:o,children:t})},tpt=({id:e,name:t,children:n,className:r})=>{const{attributes:o,listeners:i,setNodeRef:s,transition:a,transform:l,isDragging:c}=Vft({id:e}),{activeCardId:u}=x.useContext(UB),f={transition:a,transform:Wu.Transform.toString(l)};return h.jsxs(h.Fragment,{children:[h.jsx("div",{style:f,...i,...o,ref:s,children:h.jsx(nf,{className:Ee("cursor-grab gap-4 rounded-md p-3 shadow-sm",c&&"pointer-events-none cursor-grabbing opacity-30",r),children:n??h.jsx("p",{className:"m-0 font-medium text-sm",children:t})})}),u===e&&h.jsx(zfe.In,{children:h.jsx(nf,{className:Ee("cursor-grab gap-4 rounded-md p-3 shadow-sm ring-2 ring-primary",c&&"cursor-grabbing",r),children:n??h.jsx("p",{className:"m-0 font-medium text-sm",children:t})})})]})},npt=({children:e,className:t,...n})=>{const{data:r}=x.useContext(UB),o=r.filter(s=>s.column===n.id),i=o.map(s=>s.id);return h.jsxs(Xr,{className:"overflow-hidden flex-1",children:[h.jsx(Fft,{items:i,children:h.jsx("div",{className:Ee("flex flex-grow flex-col gap-2 p-2",t),...n,children:o.map(e)})}),h.jsx(ZS,{orientation:"vertical"})]})},rpt=({className:e,...t})=>h.jsx("div",{className:Ee("m-0 p-2 font-semibold text-sm",e),...t}),opt=e=>t=>{const{droppableRects:n,droppableContainers:r,pointerCoordinates:o}=t,i=y=>!e.includes(y),s=y=>e.includes(y),a=Tdt(t),l=a.filter(y=>i(y.id)),c=a.filter(y=>s(y.id));if(l.length>0){const v=GY(t).filter(w=>i(w.id));return v.length>0?[v[0]]:[l[0]]}if(c.length>0)return[c[0]];const u=bfe(t),f=u.filter(y=>i(y.id)),m=u.filter(y=>s(y.id));if(f.length>0){const v=wdt(t).filter(w=>i(w.id));return v.length>0?[v[0]]:[f[0]]}if(m.length>0)return[m[0]];if(o){let y=null;for(const v of e){const w=n.get(v);if(!w)continue;const S=w.left+w.width/2,T=w.top+w.height/2,k=Math.sqrt(Math.pow(o.x-S,2)+Math.pow(o.y-T,2)),I={left:w.left-150,right:w.right+150,top:w.top-50,bottom:w.bottom+50};o.x>=I.left&&o.x<=I.right&&o.y>=I.top&&o.y<=I.bottom&&(!y||k<y.distance)&&(y={id:v,distance:k})}if(y)return[{id:y.id}]}const g=GY(t);if(g.length>0){const y=g.find(v=>s(v.id));return y?[y]:[g[0]]}return[]},ipt=({children:e,onDragStart:t,onDragEnd:n,onDragOver:r,className:o,columns:i,data:s,onDataChange:a,...l})=>{const[c,u]=x.useState(null),f=ek(),m=x.useMemo(()=>i.map(k=>k.id),[i]),g=x.useMemo(()=>opt(m),[m]),y=ydt(Y_(_fe,{activationConstraint:{distance:8}}),Y_(Rfe,{activationConstraint:{delay:150,tolerance:8}}),Y_(BB)),v=k=>{s.find(_=>_.id===k.active.id)&&u(k.active.id),t?.(k)},w=k=>{const{active:I,over:_}=k;if(!_)return;const R=s.find(F=>F.id===I.id),D=s.find(F=>F.id===_.id);if(!R)return;const M=R.column,O=i.some(F=>F.id===_.id)?_.id:D?.column||M;if(M!==O){let F=[...s];const U=F.findIndex(G=>G.id===I.id);if(F[U]={...F[U],column:O},D){const G=F.findIndex(j=>j.id===_.id);F=MS(F,U,G)}a?.(F)}r?.(k)},S=k=>{u(null),n?.(k);const{active:I,over:_}=k;if(!_||I.id===_.id)return;if(i.some(O=>O.id===_.id)){const O=s.find(F=>F.id===I.id);if(O&&O.column!==_.id){let F=[...s];const U=F.findIndex(G=>G.id===I.id);F[U]={...F[U],column:_.id},a?.(F)}return}let D=[...s];const M=D.findIndex(O=>O.id===I.id),$=D.findIndex(O=>O.id===_.id);M!==-1&&$!==-1&&(D=MS(D,M,$),a?.(D))},T={onDragStart({active:k}){const{name:I,column:_}=s.find(R=>R.id===k.id)??{};return`Picked up the card "${I}" from the "${_}" column`},onDragOver({active:k,over:I}){const{name:_}=s.find(D=>D.id===k.id)??{},R=i.find(D=>D.id===I?.id)?.name;return`Dragged the card "${_}" over the "${R}" column`},onDragEnd({active:k,over:I}){const{name:_}=s.find(D=>D.id===k.id)??{},R=i.find(D=>D.id===I?.id)?.name;return`Dropped the card "${_}" into the "${R}" column`},onDragCancel({active:k}){const{name:I}=s.find(_=>_.id===k.id)??{};return`Cancelled dragging the card "${I}"`}};return h.jsx(UB.Provider,{value:{columns:i,data:s,activeCardId:c},children:h.jsxs(mft,{accessibility:{announcements:T},collisionDetection:g,onDragEnd:S,onDragOver:w,onDragStart:v,sensors:y,...l,children:[h.jsx("div",{className:Ee("flex gap-4",f&&"flex-col",o),children:i.map(k=>e(k))}),typeof window<"u"&&Kr.createPortal(h.jsx(Oft,{children:h.jsx(zfe.Out,{})}),document.body)]})})},cK={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold"};function xb(e){return cK[e]?cK[e]:e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function spt({tasks:e,loading:t,onTasksUpdate:n}){const{config:r,updateConfig:o}=Sf(),[i,s]=x.useState(new Set),[a,l]=x.useState(!1),c=ek(),u=r?.statuses||["todo","in-progress","in-review","done","blocked"],f=r?.statusColors||iM,m=x.useMemo(()=>u.filter(O=>i.has(O)).map(O=>({id:O,name:xb(O),color:f[O]||"gray"})),[u,i,f]),g={high:0,medium:1,low:2},y=x.useMemo(()=>[...e].sort((F,U)=>{const G=g[F.priority]??2,j=g[U.priority]??2;return G!==j?G-j:new Date(U.updatedAt).getTime()-new Date(F.updatedAt).getTime()}).map(F=>({id:F.id,name:F.title,column:F.status,task:F})),[e]),v=()=>{const F=window.location.hash.slice(1).match(/^\/kanban\/([^?]+)/);if(!F)return null;const U=F[1];return e.find(G=>G.id===U)||null},[w,S]=x.useState(v());x.useEffect(()=>{const O=()=>{S(v())};return S(v()),window.addEventListener("hashchange",O),()=>window.removeEventListener("hashchange",O)},[e]),x.useEffect(()=>{r?.visibleColumns?s(new Set(r.visibleColumns)):s(new Set(u))},[r?.visibleColumns,u.join(",")]);const T=async O=>{try{await o({visibleColumns:[...O]})}catch(F){console.error("Failed to save config:",F)}},k=O=>{s(F=>{const U=new Set(F);return U.has(O)?U.delete(O):U.add(O),T(U),U})},I=async O=>{const F=O.filter(G=>{const j=e.find(Q=>Q.id===G.id);return j&&j.status!==G.column}),U=e.map(G=>{const j=O.find(Q=>Q.id===G.id);return j&&j.column!==G.status?{...G,status:j.column}:G});n(U);for(const G of F)try{await ma.updateTask(G.id,{status:G.column}),so.success("Status updated",{description:`#${G.id} moved to ${xb(G.column)}`})}catch(j){console.error("Failed to update task:",j),so.error("Failed to update status",{description:j instanceof Error?j.message:"Unknown error"}),ma.getTasks().then(n).catch(console.error);break}};if(t)return h.jsx("div",{className:"flex items-center justify-center h-64",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),h.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading tasks..."})]})});const _=O=>{window.location.hash=`/kanban/${O.id}`},R=()=>{window.location.hash="/"},D=O=>{n(e.map(F=>F.id===O.id?O:F))},M=O=>{window.location.hash=`/kanban/${O}`},$=async O=>{try{await ma.archiveTask(O),n(e.filter(F=>F.id!==O)),R()}catch(F){console.error("Failed to archive task:",F)}};return h.jsxs("div",{className:"flex flex-col h-full",children:[c?h.jsxs(Yde,{open:a,onOpenChange:l,className:"shrink-0 bg-card rounded-lg mb-4 border border-border",children:[h.jsxs(Kde,{className:"flex items-center justify-between w-full p-3",children:[h.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Show Columns (",i.size,"/",u.length,")"]}),a?h.jsx(IK,{className:"w-4 h-4 text-muted-foreground"}):h.jsx(cc,{className:"w-4 h-4 text-muted-foreground"})]}),h.jsx(Xde,{children:h.jsx("div",{className:"flex flex-wrap gap-2 px-3 pb-3",children:u.map(O=>{const F=i.has(O),U=e.filter(G=>G.status===O).length;return h.jsxs("button",{type:"button",onClick:()=>k(O),className:Ee("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg transition-colors text-xs",F?"bg-primary/10 text-primary dark:bg-primary/20":"bg-muted text-muted-foreground"),children:[F?h.jsx(e0,{className:"w-3.5 h-3.5"}):h.jsx(fR,{className:"w-3.5 h-3.5"}),h.jsxs("span",{className:"font-medium",children:[xb(O)," (",U,")"]})]},O)})})})]}):h.jsx("div",{className:"shrink-0 bg-card rounded-lg p-4 mb-4 border border-border",children:h.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[h.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Show Columns:"}),u.map(O=>{const F=i.has(O),U=e.filter(G=>G.status===O).length;return h.jsxs("button",{type:"button",onClick:()=>k(O),className:Ee("flex items-center gap-2 px-3 py-1.5 rounded-lg transition-colors",F?"bg-primary/10 text-primary dark:bg-primary/20":"bg-muted text-muted-foreground"),children:[F?h.jsx(e0,{className:"w-4 h-4"}):h.jsx(fR,{className:"w-4 h-4"}),h.jsxs("span",{className:"text-sm font-medium",children:[xb(O)," (",U,")"]})]},O)})]})}),h.jsxs(Xr,{className:"flex-1",children:[i.size>0?h.jsx(ipt,{columns:m,data:y,onDataChange:I,className:"min-h-full pb-4",children:O=>{const F=nTe(O.id,f),U=y.filter(G=>G.column===O.id).length;return h.jsxs(ept,{id:O.id,className:Ee("min-w-[320px] max-w-[380px]",c&&"min-w-0 max-w-none w-full",F.bg,F.border),children:[h.jsxs(rpt,{className:"flex items-center justify-between",children:[h.jsx("span",{className:"font-bold text-sm uppercase tracking-wide text-foreground",children:O.name}),h.jsx("span",{className:"text-xs rounded-full px-2 py-1 font-medium text-muted-foreground bg-background",children:U})]}),h.jsx(npt,{id:O.id,children:G=>h.jsx(apt,{item:G,statusColors:f,onClick:()=>_(G.task)},G.id)})]},O.id)}}):h.jsx("div",{className:"text-center py-12",children:h.jsx("p",{className:"text-lg text-muted-foreground",children:"No columns visible. Please select at least one column to display."})}),h.jsx(ZS,{orientation:"horizontal"})]}),h.jsx(pfe,{task:w,allTasks:e,onClose:R,onUpdate:D,onArchive:$,onNavigateToTask:M})]})}function apt({item:e,statusColors:t,onClick:n}){const{task:r}=e,o=Dh(r.status,t),i=r.acceptanceCriteria.filter(a=>a.completed).length,s=r.acceptanceCriteria.length;return h.jsx(tpt,{id:e.id,name:e.name,column:e.column,className:"w-full",children:h.jsxs("div",{onClick:n,onKeyDown:a=>a.key==="Enter"&&n(),role:"button",tabIndex:0,className:"cursor-pointer",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[h.jsxs("span",{className:"text-xs font-mono shrink-0 text-muted-foreground",children:["#",r.id]}),h.jsxs("div",{className:"flex items-center gap-1 flex-wrap justify-end",children:[h.jsx("span",{className:Ee("text-xs px-1.5 py-0.5 rounded font-medium",o),children:xb(r.status)}),r.priority==="high"&&h.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-destructive/10 text-destructive dark:bg-destructive/20",children:"HIGH"}),r.priority==="medium"&&h.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",children:"MED"})]})]}),h.jsx("h3",{className:"font-medium text-sm mb-2 line-clamp-2 text-foreground",children:r.title}),s>0&&h.jsxs("div",{className:"flex items-center gap-2 text-xs mb-2 text-muted-foreground",children:[h.jsx(MK,{className:"w-3 h-3","aria-hidden":"true"}),h.jsxs("span",{children:[i,"/",s]})]}),r.labels.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:r.labels.map(a=>h.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-secondary text-secondary-foreground",children:a},a))}),r.assignee&&h.jsxs("div",{className:"flex items-center gap-1.5 text-xs mt-2 text-muted-foreground",children:[h.jsx(ry,{name:r.assignee,size:"sm"}),h.jsx("span",{children:r.assignee})]})]})})}const uK=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],dK={low:"bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400",medium:"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300",high:"bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-300"};function lpt({isOpen:e,allTasks:t,onClose:n,onCreated:r}){const{currentUser:o}=DQ(),{config:i}=Sf(),s=x.useRef(null),a=x.useRef(null),l=x.useMemo(()=>{const W=i.statuses||["todo","in-progress","in-review","done","blocked"];return PQ(W)},[i.statuses]),c=i.statusColors||{},[u,f]=x.useState(""),[m,g]=x.useState(""),[y,v]=x.useState("todo"),[w,S]=x.useState("medium"),[T,k]=x.useState(""),[I,_]=x.useState([]),[R,D]=x.useState(""),[M,$]=x.useState([]),[O,F]=x.useState(""),[U,G]=x.useState(""),[j,Q]=x.useState(!1),[V,K]=x.useState(null),[X,J]=x.useState(!1),[B,q]=x.useState(""),[Y,P]=x.useState(!1),[le,ae]=x.useState(""),[ie,ne]=x.useState(!1),[se,pe]=x.useState(!1),{preferences:ke,toggleTaskCreateLayout:Me}=MQ(),Ce=ke.taskCreateLayout==="maximized",Re=x.useRef(null),de={hidden:{opacity:0,y:20,scale:.98},visible:{opacity:1,y:0,scale:1,transition:{duration:.2,ease:"easeOut"}},exit:{opacity:0,y:10,scale:.98,transition:{duration:.15,ease:"easeIn"}}};x.useEffect(()=>{e||(f(""),g(""),v("todo"),S("medium"),k(""),_([]),D(""),$([]),F(""),G(""),K(null),J(!1),q(""),P(!1),ae(""),ne(!1),pe(!1))},[e]),x.useEffect(()=>{e&&setTimeout(()=>s.current?.focus(),100)},[e,Ce]),x.useEffect(()=>{Y&&Re.current&&Re.current.focus()},[Y]);const Te=x.useCallback(()=>{B.trim()&&($(W=>[...W,{id:crypto.randomUUID(),text:B.trim()}]),q(""),P(!1))},[B]),Ge=x.useCallback(W=>{$(ye=>ye.filter(Be=>Be.id!==W))},[]),Ie=x.useCallback(()=>{le.trim()&&(I.includes(le.trim())||_(W=>[...W,le.trim()]),ae(""),ne(!1))},[le,I]),cn=x.useCallback(W=>{_(ye=>ye.filter(Be=>Be!==W))},[]),bt=async W=>{if(W.preventDefault(),K(null),!u.trim()){K("Title is required");return}Q(!0);try{const ye={title:u.trim(),description:m.trim()||void 0,status:y,priority:w,labels:I,assignee:T.trim()||void 0,parent:R||void 0,acceptanceCriteria:M.map(Be=>({text:Be.text,completed:!1})),implementationPlan:O.trim()||void 0,implementationNotes:U.trim()||void 0};await pge(ye),J(!0),so.success("Task created successfully",{description:u.trim()}),setTimeout(()=>{r(),n()},800)}catch(ye){const Be=ye instanceof Error?ye.message:"Failed to create task";K(Be),so.error("Failed to create task",{description:Be})}finally{Q(!1)}},it=R?t.find(W=>W.id===R):null,te=h.jsxs("div",{className:"flex items-center justify-between gap-2 p-4 border-b bg-green-700",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:"text-green-100 text-xs font-medium uppercase tracking-wide",children:"New Task"}),h.jsx("input",{ref:s,type:"text",value:u,onChange:W=>f(W.target.value),placeholder:"Enter task title...",className:"w-full text-lg font-semibold bg-white/20 text-white placeholder-white/60 border-0 rounded px-2 py-1 mt-1 focus:outline-none focus:ring-2 focus:ring-white/50",disabled:j})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(Le,{variant:"ghost",size:"icon",onClick:Me,className:"h-8 w-8 text-foreground hover:text-foreground",title:Ce?"Minimize":"Maximize",children:Ce?h.jsx(jK,{className:"w-4 h-4"}):h.jsx(BK,{className:"w-4 h-4"})}),h.jsx(Le,{variant:"ghost",size:"icon",onClick:n,className:"h-8 w-8 text-foreground hover:text-foreground",title:"Close",children:h.jsx(ti,{className:"w-4 h-4"})})]})]}),fe=(X||V)&&h.jsxs("div",{className:"px-4 pt-4",children:[X&&h.jsx("div",{className:"bg-green-50 dark:bg-green-900/50 border border-green-200 dark:border-green-700 text-green-700 dark:text-green-300 px-4 py-2 rounded-lg text-sm",children:"Task created successfully!"}),V&&h.jsx("div",{className:"bg-red-50 dark:bg-red-900/50 border border-red-200 dark:border-red-700 text-red-700 dark:text-red-300 px-4 py-2 rounded-lg text-sm",children:V})]}),ge=h.jsxs("div",{className:"p-6 space-y-6",children:[h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(HK,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Description"})]}),h.jsx(Tu,{markdown:m,onChange:g,placeholder:"Add a more detailed description...",readOnly:j})]}),h.jsxs("section",{children:[h.jsx("div",{className:"flex items-center justify-between mb-3",children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(am,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Acceptance Criteria"}),M.length>0&&h.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",M.length,")"]})]})}),h.jsx("div",{className:"space-y-2",children:M.map(W=>h.jsxs("div",{className:"flex items-start gap-2 bg-muted/50 rounded-lg px-3 py-2 group hover:shadow-sm transition-shadow",children:[h.jsx("input",{type:"checkbox",checked:!1,disabled:!0,className:"mt-1 w-4 h-4 rounded cursor-not-allowed opacity-50"}),h.jsx("span",{className:"flex-1 text-sm",children:W.text}),h.jsx("button",{type:"button",onClick:()=>Ge(W.id),className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-red-500 p-1 transition-all",title:"Delete",children:h.jsx(Nu,{className:"w-4 h-4"})})]},W.id))}),Y?h.jsxs("div",{className:"mt-2 bg-muted/50 rounded-lg px-3 py-2",children:[h.jsx("input",{ref:Re,type:"text",value:B,onChange:W=>q(W.target.value),onKeyDown:W=>{W.key==="Enter"&&B.trim()&&(W.preventDefault(),Te()),W.key==="Escape"&&(q(""),P(!1))},placeholder:"Add an item...",className:"w-full border border-input rounded px-2 py-1.5 text-sm bg-background focus:outline-none focus:ring-2 focus:ring-green-500",disabled:j}),h.jsxs("div",{className:"flex gap-2 mt-2",children:[h.jsx(Le,{type:"button",size:"sm",onClick:Te,disabled:!B.trim()||j,className:"bg-green-700 hover:bg-green-800 text-white",children:"Add"}),h.jsx(Le,{type:"button",variant:"ghost",size:"sm",onClick:()=>{q(""),P(!1)},children:"Cancel"})]})]}):h.jsxs("button",{type:"button",onClick:()=>P(!0),className:"mt-2 flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground hover:bg-muted px-3 py-2 rounded-lg transition-colors w-full",disabled:j,children:[h.jsx(Go,{className:"w-4 h-4"}),h.jsx("span",{children:"Add an item"})]})]}),h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(Br,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Implementation Plan"}),h.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),h.jsx(Tu,{markdown:O,onChange:F,placeholder:"Describe how you plan to implement this task...",readOnly:j})]}),h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(F0e,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Implementation Notes"}),h.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),h.jsx(Tu,{markdown:U,onChange:G,placeholder:"Add notes, observations, or any other relevant information...",readOnly:j})]})]}),Pe=h.jsxs("div",{className:"p-4 space-y-6",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Status"}),h.jsxs(ri,{value:y,onValueChange:W=>v(W),disabled:j,children:[h.jsx(zo,{className:Ee("w-full",Dh(y,c)),children:h.jsx(oi,{})}),h.jsx(Vo,{children:l.map(W=>h.jsx(En,{value:W.value,children:W.label},W.value))})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Priority"}),h.jsxs(ri,{value:w,onValueChange:W=>S(W),disabled:j,children:[h.jsx(zo,{className:Ee("w-full",dK[w]),children:h.jsx(oi,{})}),h.jsx(Vo,{children:uK.map(W=>h.jsx(En,{value:W.value,children:W.label},W.value))})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Assignee"}),h.jsx(SS,{value:T,onChange:k,showGrabButton:!1,currentUser:o,container:a.current})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Labels"}),h.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(W=>h.jsxs(fc,{variant:"secondary",className:"gap-1 pr-1",children:[W,h.jsx("button",{type:"button",onClick:()=>cn(W),className:"ml-1 hover:text-destructive",children:h.jsx(ti,{className:"w-3 h-3"})})]},W))}),ie?h.jsxs("div",{className:"space-y-2",children:[h.jsx(Gn,{value:le,onChange:W=>ae(W.target.value),onKeyDown:W=>{W.key==="Enter"&&le.trim()&&(W.preventDefault(),Ie()),W.key==="Escape"&&(ae(""),ne(!1))},placeholder:"Label name",disabled:j,autoFocus:!0}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Le,{size:"sm",onClick:Ie,disabled:!le.trim()||j,children:"Add"}),h.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>{ae(""),ne(!1)},children:"Cancel"})]})]}):h.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground",onClick:()=>ne(!0),disabled:j,children:[h.jsx(Go,{className:"w-4 h-4 mr-2"}),"Add label"]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Parent Task"}),h.jsxs(Q0,{open:se,onOpenChange:pe,children:[h.jsx(J0,{asChild:!0,children:h.jsxs(Le,{variant:"outline",role:"combobox","aria-expanded":se,className:"w-full justify-between h-auto min-h-10 py-2",disabled:j,title:it?`#${it.id} - ${it.title}`:void 0,children:[it?h.jsxs("div",{className:"flex items-center gap-2 text-left overflow-hidden min-w-0 flex-1",children:[h.jsx(kh,{className:"w-4 h-4 shrink-0 text-muted-foreground"}),h.jsxs("div",{className:"overflow-hidden min-w-0 flex-1",children:[h.jsxs("span",{className:"text-xs text-muted-foreground font-mono block",children:["#",it.id]}),h.jsx("p",{className:"truncate text-sm",children:it.title})]})]}):h.jsx("span",{className:"text-muted-foreground",children:"Select parent task..."}),h.jsx(TE,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),h.jsx(Qh,{className:"w-[400px] p-0",align:"start",children:h.jsxs(Jh,{children:[h.jsx(em,{placeholder:"Search tasks..."}),h.jsxs(tm,{children:[h.jsx(nm,{children:"No task found."}),h.jsxs(sl,{children:[h.jsxs(ns,{value:"none",onSelect:()=>{D(""),pe(!1)},children:[h.jsx(lo,{className:Ee("mr-2 h-4 w-4 shrink-0",R?"opacity-0":"opacity-100")}),h.jsx("span",{className:"text-muted-foreground",children:"None"})]}),t.map(W=>h.jsxs(ns,{value:`${W.id} ${W.title}`,onSelect:()=>{D(W.id),pe(!1)},title:`#${W.id} - ${W.title}`,children:[h.jsx(lo,{className:Ee("mr-2 h-4 w-4 shrink-0",R===W.id?"opacity-100":"opacity-0")}),h.jsxs("div",{className:"overflow-hidden min-w-0 flex-1",children:[h.jsxs("span",{className:"text-xs text-muted-foreground font-mono block",children:["#",W.id]}),h.jsx("p",{className:"truncate text-sm",children:W.title})]})]},W.id))]})]})]})})]})]})]}),je=h.jsxs("div",{className:"border-t px-6 py-4 bg-muted/30 flex justify-end gap-3",children:[h.jsx(Le,{type:"button",variant:"ghost",onClick:n,disabled:j,children:"Cancel"}),h.jsx(Le,{type:"button",onClick:bt,className:"bg-green-700 hover:bg-green-800 text-white",disabled:j||X||!u.trim(),children:j?"Creating...":"Create Task"})]});return Ce?h.jsx(_E,{children:e&&h.jsx(JO,{open:e,onOpenChange:W=>!W&&n(),children:h.jsxs(YS,{className:"max-w-6xl w-[95vw] h-[90vh] p-0 gap-0 overflow-hidden flex flex-col",hideCloseButton:!0,children:[h.jsx(eM,{className:"sr-only",children:"Create New Task"}),h.jsxs(OE.div,{ref:a,className:"flex flex-col h-full overflow-hidden",variants:de,initial:"hidden",animate:"visible",exit:"exit",children:[te,fe,h.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[h.jsx(Xr,{className:"flex-1",children:ge}),h.jsx("div",{className:"shrink-0 w-72 border-l bg-muted/20",children:h.jsx(Xr,{className:"h-full",children:Pe})})]}),je]})]})})}):h.jsx(_E,{children:e&&h.jsx(XO,{open:e,onOpenChange:W=>!W&&n(),children:h.jsx(qS,{side:"right",className:"w-full sm:max-w-2xl lg:max-w-3xl xl:max-w-4xl p-0 flex flex-col gap-0",hideCloseButton:!0,children:h.jsxs(OE.div,{ref:a,className:"flex flex-col h-full overflow-hidden",variants:de,initial:"hidden",animate:"visible",exit:"exit",children:[te,fe,h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[h.jsx("div",{className:"shrink-0 border-b bg-muted/20",children:h.jsxs("div",{className:"p-4 space-y-3",children:[h.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Status"}),h.jsxs(ri,{value:y,onValueChange:W=>v(W),disabled:j,children:[h.jsx(zo,{className:Ee("w-full h-9",Dh(y,c)),children:h.jsx(oi,{})}),h.jsx(Vo,{children:l.map(W=>h.jsx(En,{value:W.value,children:W.label},W.value))})]})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Priority"}),h.jsxs(ri,{value:w,onValueChange:W=>S(W),disabled:j,children:[h.jsx(zo,{className:Ee("w-full h-9",dK[w]),children:h.jsx(oi,{})}),h.jsx(Vo,{children:uK.map(W=>h.jsx(En,{value:W.value,children:W.label},W.value))})]})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Assignee"}),h.jsx(SS,{value:T,onChange:k,showGrabButton:!1,currentUser:o,container:a.current})]})]}),h.jsxs("div",{className:"flex items-start gap-4 flex-wrap",children:[h.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground shrink-0",children:"Labels:"}),h.jsxs("div",{className:"flex flex-wrap gap-1 flex-1",children:[I.map(W=>h.jsxs(fc,{variant:"secondary",className:"gap-1 pr-1 text-xs",children:[W,h.jsx("button",{type:"button",onClick:()=>cn(W),className:"ml-0.5 hover:text-destructive",children:h.jsx(ti,{className:"w-3 h-3"})})]},W)),!ie&&h.jsxs(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground",onClick:()=>ne(!0),children:[h.jsx(Go,{className:"w-3 h-3 mr-1"}),"Add"]})]}),ie&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{value:le,onChange:W=>ae(W.target.value),onKeyDown:W=>{W.key==="Enter"&&le.trim()&&Ie(),W.key==="Escape"&&(ae(""),ne(!1))},placeholder:"Label",className:"h-7 w-24 text-xs",autoFocus:!0}),h.jsx(Le,{size:"sm",className:"h-7 px-2",onClick:Ie,disabled:!le.trim(),children:"Add"}),h.jsx(Le,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>{ae(""),ne(!1)},children:h.jsx(ti,{className:"w-3 h-3"})})]})]}),h.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground shrink-0",children:"Parent:"}),h.jsxs(Q0,{open:se,onOpenChange:pe,children:[h.jsx(J0,{asChild:!0,children:h.jsxs(Le,{variant:"outline",role:"combobox",size:"sm",className:"h-7 justify-between min-w-[120px] max-w-[250px]",disabled:j,title:it?`#${it.id} - ${it.title}`:void 0,children:[it?h.jsxs("span",{className:"truncate text-xs",children:["#",it.id," - ",it.title]}):h.jsx("span",{className:"text-muted-foreground text-xs",children:"None"}),h.jsx(TE,{className:"ml-1 h-3 w-3 shrink-0 opacity-50"})]})}),h.jsx(Qh,{className:"w-[400px] p-0",align:"end",children:h.jsxs(Jh,{children:[h.jsx(em,{placeholder:"Search tasks..."}),h.jsxs(tm,{children:[h.jsx(nm,{children:"No task found."}),h.jsxs(sl,{children:[h.jsxs(ns,{value:"none",onSelect:()=>{D(""),pe(!1)},children:[h.jsx(lo,{className:Ee("mr-2 h-4 w-4 shrink-0",R?"opacity-0":"opacity-100")}),h.jsx("span",{className:"text-muted-foreground",children:"None"})]}),t.map(W=>h.jsxs(ns,{value:`${W.id} ${W.title}`,onSelect:()=>{D(W.id),pe(!1)},title:`#${W.id} - ${W.title}`,children:[h.jsx(lo,{className:Ee("mr-2 h-4 w-4 shrink-0",R===W.id?"opacity-100":"opacity-0")}),h.jsxs("div",{className:"overflow-hidden min-w-0 flex-1",children:[h.jsxs("span",{className:"text-xs text-muted-foreground font-mono block",children:["#",W.id]}),h.jsx("p",{className:"truncate text-sm",children:W.title})]})]},W.id))]})]})]})})]})]})]})]})}),h.jsx(Xr,{className:"flex-1",children:ge})]}),je]})})})})}const cpt="/assets/logo-BkDQ9x4a.png",upt="sidebar_state",dpt=3600*24*7,fpt="16rem",ppt="18rem",hpt="3rem",mpt="b",Vfe=x.createContext(null);function b1(){const e=x.useContext(Vfe);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Gfe=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:i,...s},a)=>{const l=ek(),[c,u]=x.useState(!1),[f,m]=x.useState(e),g=t??f,y=x.useCallback(T=>{const k=typeof T=="function"?T(g):T;n?n(k):m(k),document.cookie=`${upt}=${k}; path=/; max-age=${dpt}`},[n,g]),v=x.useCallback(()=>l?u(T=>!T):y(T=>!T),[l,y,u]);x.useEffect(()=>{const T=k=>{k.key===mpt&&(k.metaKey||k.ctrlKey)&&(k.preventDefault(),v())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[v]);const w=g?"expanded":"collapsed",S=x.useMemo(()=>({state:w,open:g,setOpen:y,isMobile:l,openMobile:c,setOpenMobile:u,toggleSidebar:v}),[w,g,y,l,c,u,v]);return h.jsx(Vfe.Provider,{value:S,children:h.jsx(Fde,{delayDuration:0,children:h.jsx("div",{style:{"--sidebar-width":fpt,"--sidebar-width-icon":hpt,...o},className:Ee("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:a,...s,children:i})})})});Gfe.displayName="SidebarProvider";const Wfe=x.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:o,...i},s)=>{const{isMobile:a,state:l,openMobile:c,setOpenMobile:u}=b1();return n==="none"?h.jsx("div",{className:Ee("flex h-full w-[var(--sidebar-width)] flex-col bg-sidebar text-sidebar-foreground",r),ref:s,...i,children:o}):a?h.jsx(XO,{open:c,onOpenChange:u,...i,children:h.jsxs(qS,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[var(--sidebar-width)] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":ppt},side:e,children:[h.jsxs(ZO,{className:"sr-only",children:[h.jsx(QO,{children:"Sidebar"}),h.jsx(pQ,{children:"Displays the mobile sidebar."})]}),h.jsx("div",{className:"flex h-full w-full flex-col",children:o})]})}):h.jsxs("div",{ref:s,className:"group peer hidden text-sidebar-foreground md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,children:[h.jsx("div",{className:Ee("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),h.jsx("div",{className:Ee("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...i,children:h.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});Wfe.displayName="Sidebar";const qfe=x.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=b1();return h.jsxs(Le,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Ee("h-7 w-7",e),onClick:i=>{t?.(i),o()},...n,children:[h.jsx(v0e,{}),h.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});qfe.displayName="SidebarTrigger";const Yfe=x.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=b1();return h.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Ee("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});Yfe.displayName="SidebarRail";const gpt=x.forwardRef(({className:e,...t},n)=>h.jsx("main",{ref:n,className:Ee("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));gpt.displayName="SidebarInset";const bpt=x.forwardRef(({className:e,...t},n)=>h.jsx(Gn,{ref:n,"data-sidebar":"input",className:Ee("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));bpt.displayName="SidebarInput";const Kfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"header",className:Ee("flex flex-col gap-2 p-2",e),...t}));Kfe.displayName="SidebarHeader";const Xfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"footer",className:Ee("flex flex-col gap-2 p-2",e),...t}));Xfe.displayName="SidebarFooter";const ypt=x.forwardRef(({className:e,...t},n)=>h.jsx(ny,{ref:n,"data-sidebar":"separator",className:Ee("mx-2 w-auto bg-sidebar-border",e),...t}));ypt.displayName="SidebarSeparator";const Zfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"content",className:Ee("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Zfe.displayName="SidebarContent";const Qfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"group",className:Ee("relative flex w-full min-w-0 flex-col p-2",e),...t}));Qfe.displayName="SidebarGroup";const Jfe=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Ku:"div";return h.jsx(o,{ref:r,"data-sidebar":"group-label",className:Ee("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});Jfe.displayName="SidebarGroupLabel";const xpt=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Ku:"button";return h.jsx(o,{ref:r,"data-sidebar":"group-action",className:Ee("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});xpt.displayName="SidebarGroupAction";const epe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"group-content",className:Ee("w-full text-sm",e),...t}));epe.displayName="SidebarGroupContent";const EE=x.forwardRef(({className:e,...t},n)=>h.jsx("ul",{ref:n,"data-sidebar":"menu",className:Ee("flex w-full min-w-0 flex-col gap-1",e),...t}));EE.displayName="SidebarMenu";const wE=x.forwardRef(({className:e,...t},n)=>h.jsx("li",{ref:n,"data-sidebar":"menu-item",className:Ee("group/menu-item relative",e),...t}));wE.displayName="SidebarMenuItem";const vpt=Xs("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),SE=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:i,...s},a)=>{const l=e?Ku:"button",{isMobile:c,state:u}=b1(),f=h.jsx(l,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:Ee(vpt({variant:n,size:r}),i),...s});return o?(typeof o=="string"&&(o={children:o}),h.jsxs(Bde,{children:[h.jsx(jde,{asChild:!0,children:f}),h.jsx(mB,{side:"right",align:"center",hidden:u!=="collapsed"||c,...o})]})):f});SE.displayName="SidebarMenuButton";const Ept=x.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const i=t?Ku:"button";return h.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Ee("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});Ept.displayName="SidebarMenuAction";const wpt=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:Ee("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));wpt.displayName="SidebarMenuBadge";const Spt=x.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const o=x.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return h.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Ee("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&h.jsx(fY,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),h.jsx(fY,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});Spt.displayName="SidebarMenuSkeleton";const Cpt=x.forwardRef(({className:e,...t},n)=>h.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:Ee("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Cpt.displayName="SidebarMenuSub";const Tpt=x.forwardRef(({...e},t)=>h.jsx("li",{ref:t,...e}));Tpt.displayName="SidebarMenuSubItem";const kpt=x.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},i)=>{const s=e?Ku:"a";return h.jsx(s,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:Ee("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...o})});kpt.displayName="SidebarMenuSubButton";const Apt=[{id:"kanban",label:"Kanban",icon:r0e,href:"#/"},{id:"tasks",label:"Tasks",icon:FK,href:"#/tasks"},{id:"docs",label:"Docs",icon:Br,href:"#/docs"},{id:"templates",label:"Templates",icon:Md,href:"#/templates"},{id:"imports",label:"Imports",icon:Ah,href:"#/imports"}];function Npt({currentPage:e,onSearchClick:t}){const{state:n}=b1(),r=ek(),o=n==="expanded";return h.jsxs(Wfe,{collapsible:"icon",variant:r?"floating":"sidebar",children:[h.jsxs(Kfe,{children:[h.jsx(EE,{children:h.jsx(wE,{children:h.jsx(SE,{size:"lg",asChild:!0,children:h.jsxs("a",{href:"#/",children:[h.jsx("img",{src:cpt,alt:"Knowns",className:"size-8 rounded-lg object-contain"}),h.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[h.jsx("span",{className:"truncate font-semibold",children:"Knowns"}),h.jsx("span",{className:"truncate text-xs",children:"AI-ready task management"})]})]})})})}),o&&h.jsx("div",{className:"px-2 pb-2",children:h.jsxs("button",{type:"button",onClick:t,className:"flex w-full items-center gap-2 rounded-lg border bg-background px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",children:[h.jsx(PS,{className:"h-4 w-4"}),h.jsx("span",{children:"Search..."}),h.jsxs("kbd",{className:"ml-auto pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100",children:[h.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]})})]}),h.jsx(Zfe,{children:h.jsxs(Qfe,{children:[h.jsx(Jfe,{children:"Navigation"}),h.jsx(epe,{children:h.jsx(EE,{children:Apt.map(i=>{const s=e===i.id;return h.jsx(wE,{children:h.jsx(SE,{asChild:!0,isActive:s,tooltip:i.label,children:h.jsxs("a",{href:i.href,children:[h.jsx(i.icon,{}),h.jsx("span",{children:i.label})]})})},i.id)})})})]})}),h.jsxs(Xfe,{children:[h.jsx(EE,{children:h.jsx(wE,{children:h.jsx(SE,{asChild:!0,isActive:e==="config",tooltip:"Settings",children:h.jsxs("a",{href:"#/config",children:[h.jsx(cO,{}),h.jsx("span",{children:"Settings"})]})})})}),o&&h.jsx("div",{className:"px-3 py-2 text-xs text-sidebar-foreground/50",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("a",{href:"https://github.com/knowns-dev/knowns",target:"_blank",rel:"noopener noreferrer",className:"hover:text-sidebar-foreground transition-colors",children:"Knowns"}),h.jsx("span",{className:"font-mono",children:"0.10.5"})]})})]}),h.jsx(Yfe,{})]})}const _pt=[{value:"all",label:"All"},{value:"status",label:"Status"},{value:"assignee",label:"Assignee"},{value:"content",label:"Content"}];function Rpt(e){const t=e.changes;if(t.length===0)return"Updated";const n=t.find(s=>s.field==="status");if(n){const s=String(n.newValue);return s==="done"?"Completed":s==="in-progress"?"Started working on":s==="in-review"?"Submitted for review":s==="blocked"?"Blocked":`Changed status to ${s}`}const r=t.find(s=>s.field==="assignee");if(r){const s=r.newValue;return s?`Assigned to ${s}`:"Unassigned"}if(t.find(s=>s.field==="title"))return"Updated title";const i=t.find(s=>s.field==="priority");return i?`Set priority to ${i.newValue}`:t.some(s=>s.field==="description")?"Updated description":t.some(s=>s.field==="acceptanceCriteria")?"Updated acceptance criteria":t.some(s=>s.field==="implementationPlan")?"Updated plan":t.some(s=>s.field==="implementationNotes")?"Updated notes":t.some(s=>s.field==="labels")?"Updated labels":`Updated ${t.length} field(s)`}function Dpt(e){const n=new Date().getTime()-e.getTime(),r=Math.floor(n/6e4),o=Math.floor(n/36e5),i=Math.floor(n/864e5);return r<1?"just now":r<60?`${r}m ago`:o<24?`${o}h ago`:i<7?`${i}d ago`:e.toLocaleDateString()}function Ipt(e){return e.some(t=>t.field==="status"&&t.newValue==="done")?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":e.some(t=>t.field==="status"&&t.newValue==="in-progress")?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":e.some(t=>t.field==="status"&&t.newValue==="blocked")?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":e.some(t=>t.field==="assignee")?"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400":"bg-muted text-muted-foreground"}function Opt({limit:e=20,showFilter:t=!0,onTaskClick:n}){const[r,o]=x.useState([]),[i,s]=x.useState(!0),[a,l]=x.useState("all"),[c,u]=x.useState(!1),f=x.useCallback(async()=>{try{const y=a==="all"?void 0:a,v=await ma.getActivities({limit:e,type:y});o(v)}catch(y){console.error("Failed to load activities:",y)}finally{s(!1),u(!1)}},[e,a]);x.useEffect(()=>{f()},[f]),rs("tasks:updated",()=>{f()},[f]);const m=()=>{u(!0),f()},g=y=>{n?n(y):window.location.hash=`/kanban/${y}`};return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(J9,{className:"w-5 h-5"}),h.jsx("h3",{className:"font-semibold",children:"Recent Activity"})]}),h.jsx(Le,{variant:"ghost",size:"icon",onClick:m,disabled:c,className:"h-8 w-8",children:h.jsx(n0,{className:`w-4 h-4 ${c?"animate-spin":""}`})})]}),t&&h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(lO,{className:"w-4 h-4 text-muted-foreground"}),h.jsx("select",{value:a,onChange:y=>l(y.target.value),className:"text-sm rounded px-2 py-1 bg-card border flex-1",children:_pt.map(y=>h.jsx("option",{value:y.value,children:y.label},y.value))})]}),h.jsx(Xr,{className:"flex-1",children:h.jsx("div",{className:"space-y-1.5 pr-3",children:i?h.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"Loading activities..."}):r.length===0?h.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"No recent activity"}):r.map((y,v)=>h.jsx("div",{role:"button",tabIndex:0,onClick:w=>{w.preventDefault(),w.stopPropagation(),g(y.taskId)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),g(y.taskId))},className:"w-full bg-card rounded p-2 text-left hover:bg-accent transition-colors border cursor-pointer select-none",children:h.jsxs("div",{className:"flex items-center gap-2",children:[y.author?h.jsx(ry,{name:y.author,size:"xs"}):h.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${Ipt(y.changes)}`,children:h.jsx(J9,{className:"w-2.5 h-2.5"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"text-xs font-medium truncate",children:Rpt(y)}),h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Dpt(y.timestamp)})]}),h.jsxs("div",{className:"text-[11px] text-muted-foreground truncate",children:[h.jsxs("span",{className:"font-medium",children:["#",y.taskId]})," ",y.taskTitle]})]})]})},`${y.taskId}-${y.version}-${v}`))})})]})}function Mpt(){const[e,t]=x.useState(!1),[n,r]=x.useState(!1),[o,i]=x.useState(()=>{const l=localStorage.getItem("knowns-last-activity-check");return l?new Date(l):new Date}),s=x.useCallback(async()=>{try{const l=await ma.getActivities({limit:1});l.length>0&&new Date(l[0].timestamp)>o&&t(!0)}catch(l){console.error("Failed to check activities:",l)}},[o]);x.useEffect(()=>{s()},[s]),rs("tasks:updated",()=>{n||t(!0)},[n]);const a=l=>{if(r(l),l){t(!1);const c=new Date;i(c),localStorage.setItem("knowns-last-activity-check",c.toISOString())}};return h.jsxs(Q0,{open:n,onOpenChange:a,children:[h.jsx(J0,{asChild:!0,children:h.jsxs(Le,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Notifications",children:[h.jsx(lbe,{className:"h-4 w-4"}),e&&h.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-blue-500 animate-pulse"})]})}),h.jsx(Qh,{className:"w-80 p-0",align:"end",sideOffset:8,children:h.jsxs("div",{className:"flex flex-col h-[400px]",children:[h.jsx("div",{className:"px-4 py-3 border-b",children:h.jsx("h3",{className:"font-semibold text-sm",children:"Recent Activity"})}),h.jsx("div",{className:"flex-1 overflow-hidden p-2",children:h.jsx(Opt,{limit:20,showFilter:!1,onTaskClick:l=>{r(!1),window.location.hash=`/kanban/${l}`}})})]})})]})}const fK={todo:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300","in-progress":"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300","in-review":"bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-300",done:"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300",blocked:"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300","on-hold":"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300"},Lpt={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold"};function Ppt({open:e,onOpenChange:t,onTaskSelect:n,onDocSelect:r}){const[o,i]=x.useState(""),[s,a]=x.useState({tasks:[],docs:[]}),[l,c]=x.useState(!1);x.useEffect(()=>{if(!e){i(""),a({tasks:[],docs:[]});return}if(!o.trim()){a({tasks:[],docs:[]});return}c(!0);const m=setTimeout(()=>{fetch(`/api/search?q=${encodeURIComponent(o)}`).then(g=>g.json()).then(g=>{a({tasks:g.tasks||[],docs:g.docs||[]})}).catch(g=>{console.error("Search failed:",g),a({tasks:[],docs:[]})}).finally(()=>{c(!1)})},300);return()=>clearTimeout(m)},[o,e]);const u=m=>{n(m),t(!1),i("")},f=m=>{r(m),t(!1),i("")};return h.jsx(JO,{open:e,onOpenChange:t,children:h.jsx(YS,{className:"overflow-hidden p-0 max-w-2xl",hideClose:!0,children:h.jsxs(Jh,{shouldFilter:!1,children:[h.jsx(em,{placeholder:"Search tasks and docs...",value:o,onValueChange:i}),h.jsxs(tm,{children:[h.jsx(nm,{children:l?"Searching...":o?"No results found.":"Type to search..."}),s.tasks.length>0&&h.jsx(sl,{heading:"Tasks",children:s.tasks.slice(0,8).map(m=>{const g=fK[m.status]||fK.todo,y=Lpt[m.status]||m.status;return h.jsxs(ns,{value:`task-${m.id}`,onSelect:()=>u(m),children:[h.jsx(FK,{className:"mr-2 h-4 w-4 shrink-0"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["#",m.id]}),h.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${g}`,children:y})]}),h.jsx("div",{className:"font-medium truncate",children:m.title})]})]},m.id)})}),s.tasks.length>0&&s.docs.length>0&&h.jsx(vS,{}),s.docs.length>0&&h.jsx(sl,{heading:"Documentation",children:s.docs.slice(0,8).map(m=>{const g=m.metadata?.title||m.filename;return h.jsxs(ns,{value:`doc-${m.path}`,onSelect:()=>f(m),children:[h.jsx(Br,{className:"mr-2 h-4 w-4 shrink-0"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"font-medium truncate mb-1",children:g}),h.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:h.jsx("span",{className:"truncate",children:m.path})})]})]},m.path)})})]})]})})})}function vu(e,t){return typeof e=="function"?e(t):e}function ds(e,t){return n=>{t.setState(r=>({...r,[e]:vu(n,r[e])}))}}function tk(e){return e instanceof Function}function Fpt(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function Bpt(e,t){const n=[],r=o=>{o.forEach(i=>{n.push(i);const s=t(i);s!=null&&s.length&&r(s)})};return r(e),n}function ft(e,t,n){let r=[],o;return i=>{let s;n.key&&n.debug&&(s=Date.now());const a=e(i);if(!(a.length!==r.length||a.some((u,f)=>r[f]!==u)))return o;r=a;let c;if(n.key&&n.debug&&(c=Date.now()),o=t(...a),n==null||n.onChange==null||n.onChange(o),n.key&&n.debug&&n!=null&&n.debug()){const u=Math.round((Date.now()-s)*100)/100,f=Math.round((Date.now()-c)*100)/100,m=f/16,g=(y,v)=>{for(y=String(y);y.length<v;)y=" "+y;return y};console.info(`%c⏱ ${g(f,5)} /${g(u,5)} ms`,`
314
+ `},gdt={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function bdt(e){let{announcements:t=gdt,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=mdt}=e;const{announce:i,announcement:s}=fdt(),a=m1("DndLiveRegion"),[l,c]=x.useState(!1);if(x.useEffect(()=>{c(!0)},[]),pdt(x.useMemo(()=>({onDragStart(f){let{active:m}=f;i(t.onDragStart({active:m}))},onDragMove(f){let{active:m,over:g}=f;t.onDragMove&&i(t.onDragMove({active:m,over:g}))},onDragOver(f){let{active:m,over:g}=f;i(t.onDragOver({active:m,over:g}))},onDragEnd(f){let{active:m,over:g}=f;i(t.onDragEnd({active:m,over:g}))},onDragCancel(f){let{active:m,over:g}=f;i(t.onDragCancel({active:m,over:g}))}}),[i,t])),!l)return null;const u=ue.createElement(ue.Fragment,null,ue.createElement(udt,{id:r,value:o.draggable}),ue.createElement(ddt,{id:a,announcement:s}));return n?Kr.createPortal(u,n):u}var qr;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(qr||(qr={}));function IS(){}function Y_(e,t){return x.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function ydt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Na=Object.freeze({x:0,y:0});function MB(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xdt(e,t){const n=DS(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function LB(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function vdt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function YI(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function Edt(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function VY(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const wdt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=VY(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=MB(VY(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(LB)},GY=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=YI(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=YI(l),u=o.reduce((m,g,y)=>m+MB(c[y],g),0),f=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:f}})}}return i.sort(LB)};function Sdt(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),s=o-r,a=i-n;if(r<o&&n<i){const l=t.width*t.height,c=e.width*e.height,u=s*a,f=u/(l+c-u);return Number(f.toFixed(4))}return 0}const bfe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=Sdt(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(vdt)};function Cdt(e,t){const{top:n,left:r,bottom:o,right:i}=t;return n<=e.y&&e.y<=o&&r<=e.x&&e.x<=i}const Tdt=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];const o=[];for(const i of t){const{id:s}=i,a=n.get(s);if(a&&Cdt(r,a)){const c=YI(a).reduce((f,m)=>f+MB(r,m),0),u=Number((c/4).toFixed(4));o.push({id:s,data:{droppableContainer:i,value:u}})}}return o.sort(LB)};function kdt(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function yfe(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Na}function Adt(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+e*a.y,bottom:s.bottom+e*a.y,left:s.left+e*a.x,right:s.right+e*a.x}),{...n})}}const Ndt=Adt(1);function xfe(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function _dt(e,t,n){const r=xfe(t);if(!r)return e;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=e.left-s-(1-o)*parseFloat(n),c=e.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?e.width/o:e.width,f=i?e.height/i:e.height;return{width:u,height:f,top:c,right:l+u,bottom:c+f,left:l}}const Rdt={ignoreTransform:!1};function Wm(e,t){t===void 0&&(t=Rdt);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=hi(e).getComputedStyle(e);c&&(n=_dt(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function WY(e){return Wm(e,{ignoreTransform:!0})}function Ddt(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Idt(e,t){return t===void 0&&(t=hi(e).getComputedStyle(e)),t.position==="fixed"}function Odt(e,t){t===void 0&&(t=hi(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function PB(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(OB(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!p1(o)||hfe(o)||n.includes(o))return n;const i=hi(e).getComputedStyle(o);return o!==e&&Odt(o,i)&&n.push(o),Idt(o,i)?n:r(o.parentNode)}return e?r(e):n}function vfe(e){const[t]=PB(e,1);return t??null}function K_(e){return!KT||!e?null:Vm(e)?e:IB(e)?OB(e)||e===Gm(e).scrollingElement?window:p1(e)?e:null:null}function Efe(e){return Vm(e)?e.scrollX:e.scrollLeft}function wfe(e){return Vm(e)?e.scrollY:e.scrollTop}function KI(e){return{x:Efe(e),y:wfe(e)}}var io;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(io||(io={}));function Sfe(e){return!KT||!e?!1:e===document.scrollingElement}function Cfe(e){const t={x:0,y:0},n=Sfe(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const Mdt={x:.2,y:.2};function Ldt(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=Mdt);const{isTop:c,isBottom:u,isLeft:f,isRight:m}=Cfe(e),g={x:0,y:0},y={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!c&&i<=t.top+v.height?(g.y=io.Backward,y.y=r*Math.abs((t.top+v.height-i)/v.height)):!u&&l>=t.bottom-v.height&&(g.y=io.Forward,y.y=r*Math.abs((t.bottom-v.height-l)/v.height)),!m&&a>=t.right-v.width?(g.x=io.Forward,y.x=r*Math.abs((t.right-v.width-a)/v.width)):!f&&s<=t.left+v.width&&(g.x=io.Backward,y.x=r*Math.abs((t.left+v.width-s)/v.width)),{direction:g,speed:y}}function Pdt(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Tfe(e){return e.reduce((t,n)=>Ch(t,KI(n)),Na)}function Fdt(e){return e.reduce((t,n)=>t+Efe(n),0)}function Bdt(e){return e.reduce((t,n)=>t+wfe(n),0)}function kfe(e,t){if(t===void 0&&(t=Wm),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);vfe(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const jdt=[["x",["left","right"],Fdt],["y",["top","bottom"],Bdt]];class FB{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=PB(n),o=Tfe(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of jdt)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Kb{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function $dt(e){const{EventTarget:t}=hi(e);return e instanceof t?e:Gm(e)}function X_(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Is;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Is||(Is={}));function qY(e){e.preventDefault()}function Udt(e){e.stopPropagation()}var vn;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(vn||(vn={}));const Afe={start:[vn.Space,vn.Enter],cancel:[vn.Esc],end:[vn.Space,vn.Enter,vn.Tab]},Hdt=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case vn.Right:return{...n,x:n.x+25};case vn.Left:return{...n,x:n.x-25};case vn.Down:return{...n,y:n.y+25};case vn.Up:return{...n,y:n.y-25}}};class BB{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Kb(Gm(n)),this.windowListeners=new Kb(hi(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Is.Resize,this.handleCancel),this.windowListeners.add(Is.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Is.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&kfe(r),n(Na)}handleKeyDown(t){if(ZT(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=Afe,coordinateGetter:s=Hdt,scrollBehavior:a="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Na;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(t,{active:n,context:r.current,currentCoordinates:u});if(f){const m=RS(f,u),g={x:0,y:0},{scrollableAncestors:y}=r.current;for(const v of y){const w=t.code,{isTop:S,isRight:T,isLeft:k,isBottom:I,maxScroll:_,minScroll:R}=Cfe(v),D=Pdt(v),M={x:Math.min(w===vn.Right?D.right-D.width/2:D.right,Math.max(w===vn.Right?D.left:D.left+D.width/2,f.x)),y:Math.min(w===vn.Down?D.bottom-D.height/2:D.bottom,Math.max(w===vn.Down?D.top:D.top+D.height/2,f.y))},$=w===vn.Right&&!T||w===vn.Left&&!k,O=w===vn.Down&&!I||w===vn.Up&&!S;if($&&M.x!==f.x){const F=v.scrollLeft+m.x,U=w===vn.Right&&F<=_.x||w===vn.Left&&F>=R.x;if(U&&!m.y){v.scrollTo({left:F,behavior:a});return}U?g.x=v.scrollLeft-F:g.x=w===vn.Right?v.scrollLeft-_.x:v.scrollLeft-R.x,g.x&&v.scrollBy({left:-g.x,behavior:a});break}else if(O&&M.y!==f.y){const F=v.scrollTop+m.y,U=w===vn.Down&&F<=_.y||w===vn.Up&&F>=R.y;if(U&&!m.x){v.scrollTo({top:F,behavior:a});return}U?g.y=v.scrollTop-F:g.y=w===vn.Down?v.scrollTop-_.y:v.scrollTop-R.y,g.y&&v.scrollBy({top:-g.y,behavior:a});break}}this.handleMove(t,Ch(RS(f,this.referenceCoordinates),g))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}BB.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Afe,onActivation:o}=t,{active:i}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function YY(e){return!!(e&&"distance"in e)}function KY(e){return!!(e&&"delay"in e)}class jB{constructor(t,n,r){var o;r===void 0&&(r=$dt(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:s}=i;this.props=t,this.events=n,this.document=Gm(s),this.documentListeners=new Kb(this.document),this.listeners=new Kb(r),this.windowListeners=new Kb(hi(s)),this.initialCoordinates=(o=DS(i))!=null?o:Na,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Is.Resize,this.handleCancel),this.windowListeners.add(Is.DragStart,qY),this.windowListeners.add(Is.VisibilityChange,this.handleCancel),this.windowListeners.add(Is.ContextMenu,qY),this.documentListeners.add(Is.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(KY(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(YY(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Is.Click,Udt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Is.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=DS(t))!=null?n:Na,c=RS(o,l);if(!r&&a){if(YY(a)){if(a.tolerance!=null&&X_(c,a.tolerance))return this.handleCancel();if(X_(c,a.distance))return this.handleStart()}if(KY(a)&&X_(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),s(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===vn.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const zdt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Nfe extends jB{constructor(t){const{event:n}=t,r=Gm(n.target);super(t,zdt,r)}}Nfe.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const Vdt={move:{name:"mousemove"},end:{name:"mouseup"}};var XI;(function(e){e[e.RightClick=2]="RightClick"})(XI||(XI={}));class _fe extends jB{constructor(t){super(t,Vdt,Gm(t.event.target))}}_fe.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===XI.RightClick?!1:(r?.({event:n}),!0)}}];const Z_={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Rfe extends jB{constructor(t){super(t,Z_)}static setup(){return window.addEventListener(Z_.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Z_.move.name,t)};function t(){}}}Rfe.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Xb;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Xb||(Xb={}));var OS;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(OS||(OS={}));function Gdt(e){let{acceleration:t,activator:n=Xb.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=OS.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:m}=e;const g=qdt({delta:f,disabled:!i}),[y,v]=idt(),w=x.useRef({x:0,y:0}),S=x.useRef({x:0,y:0}),T=x.useMemo(()=>{switch(n){case Xb.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Xb.DraggableRect:return o}},[n,o,l]),k=x.useRef(null),I=x.useCallback(()=>{const R=k.current;if(!R)return;const D=w.current.x*S.current.x,M=w.current.y*S.current.y;R.scrollBy(D,M)},[]),_=x.useMemo(()=>a===OS.TreeOrder?[...c].reverse():c,[a,c]);x.useEffect(()=>{if(!i||!c.length||!T){v();return}for(const R of _){if(r?.(R)===!1)continue;const D=c.indexOf(R),M=u[D];if(!M)continue;const{direction:$,speed:O}=Ldt(R,M,T,t,m);for(const F of["x","y"])g[F][$[F]]||(O[F]=0,$[F]=0);if(O.x>0||O.y>0){v(),k.current=R,y(I,s),w.current=O,S.current=$;return}}w.current={x:0,y:0},S.current={x:0,y:0},v()},[t,I,r,v,i,s,JSON.stringify(T),JSON.stringify(g),y,c,_,u,JSON.stringify(m)])}const Wdt={x:{[io.Backward]:!1,[io.Forward]:!1},y:{[io.Backward]:!1,[io.Forward]:!1}};function qdt(e){let{delta:t,disabled:n}=e;const r=_S(t);return h1(o=>{if(n||!r||!o)return Wdt;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[io.Backward]:o.x[io.Backward]||i.x===-1,[io.Forward]:o.x[io.Forward]||i.x===1},y:{[io.Backward]:o.y[io.Backward]||i.y===-1,[io.Forward]:o.y[io.Forward]||i.y===1}}},[n,t,r])}function Ydt(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return h1(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function Kdt(e,t){return x.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...i]},[]),[e,t])}var ay;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ay||(ay={}));var ZI;(function(e){e.Optimized="optimized"})(ZI||(ZI={}));const XY=new Map;function Xdt(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,s]=x.useState(null),{frequency:a,measure:l,strategy:c}=o,u=x.useRef(e),f=w(),m=sy(f),g=x.useCallback(function(S){S===void 0&&(S=[]),!m.current&&s(T=>T===null?S:T.concat(S.filter(k=>!T.includes(k))))},[m]),y=x.useRef(null),v=h1(S=>{if(f&&!n)return XY;if(!S||S===XY||u.current!==e||i!=null){const T=new Map;for(let k of e){if(!k)continue;if(i&&i.length>0&&!i.includes(k.id)&&k.rect.current){T.set(k.id,k.rect.current);continue}const I=k.node.current,_=I?new FB(l(I),I):null;k.rect.current=_,_&&T.set(k.id,_)}return T}return S},[e,i,n,f,l]);return x.useEffect(()=>{u.current=e},[e]),x.useEffect(()=>{f||g()},[n,f]),x.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),x.useEffect(()=>{f||typeof a!="number"||y.current!==null||(y.current=setTimeout(()=>{g(),y.current=null},a))},[a,f,g,...r]),{droppableRects:v,measureDroppableContainers:g,measuringScheduled:i!=null};function w(){switch(c){case ay.Always:return!1;case ay.BeforeDragging:return n;default:return!n}}}function $B(e,t){return h1(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Zdt(e,t){return $B(e,t)}function Qdt(e){let{callback:t,disabled:n}=e;const r=XT(t),o=x.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return x.useEffect(()=>()=>o?.disconnect(),[o]),o}function QT(e){let{callback:t,disabled:n}=e;const r=XT(t),o=x.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return x.useEffect(()=>()=>o?.disconnect(),[o]),o}function Jdt(e){return new FB(Wm(e),e)}function ZY(e,t,n){t===void 0&&(t=Jdt);const[r,o]=x.useState(null);function i(){o(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=t(e);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=Qdt({callback(l){if(e)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(e)){i();break}}}}),a=QT({callback:i});return Aa(()=>{i(),e?(a?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[e]),r}function eft(e){const t=$B(e);return yfe(e,t)}const QY=[];function tft(e){const t=x.useRef(e),n=h1(r=>e?r&&r!==QY&&e&&t.current&&e.parentNode===t.current.parentNode?r:PB(e):QY,[e]);return x.useEffect(()=>{t.current=e},[e]),n}function nft(e){const[t,n]=x.useState(null),r=x.useRef(e),o=x.useCallback(i=>{const s=K_(i.target);s&&n(a=>a?(a.set(s,KI(s)),new Map(a)):null)},[]);return x.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=K_(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,KI(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(i)};function s(a){a.forEach(l=>{const c=K_(l);c?.removeEventListener("scroll",o)})}},[o,e]),x.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>Ch(i,s),Na):Tfe(e):Na,[e,t])}function JY(e,t){t===void 0&&(t=[]);const n=x.useRef(null);return x.useEffect(()=>{n.current=null},t),x.useEffect(()=>{const r=e!==Na;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?RS(e,n.current):Na}function rft(e){x.useEffect(()=>{if(!KT)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function oft(e,t){return x.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,t)},n},{}),[e,t])}function Dfe(e){return x.useMemo(()=>e?Ddt(e):null,[e])}const eK=[];function ift(e,t){t===void 0&&(t=Wm);const[n]=e,r=Dfe(n?hi(n):null),[o,i]=x.useState(eK);function s(){i(()=>e.length?e.map(l=>Sfe(l)?r:new FB(t(l),l)):eK)}const a=QT({callback:s});return Aa(()=>{a?.disconnect(),s(),e.forEach(l=>a?.observe(l))},[e]),o}function Ife(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return p1(t)?t:e}function sft(e){let{measure:t}=e;const[n,r]=x.useState(null),o=x.useCallback(c=>{for(const{target:u}of c)if(p1(u)){r(f=>{const m=t(u);return f?{...f,width:m.width,height:m.height}:m});break}},[t]),i=QT({callback:o}),s=x.useCallback(c=>{const u=Ife(c);i?.disconnect(),u&&i?.observe(u),r(u?t(u):null)},[t,i]),[a,l]=NS(s);return x.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const aft=[{sensor:Nfe,options:{}},{sensor:BB,options:{}}],lft={current:{}},vE={draggable:{measure:WY},droppable:{measure:WY,strategy:ay.WhileDragging,frequency:ZI.Optimized},dragOverlay:{measure:Wm}};class Zb extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const cft={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Zb,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:IS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:vE,measureDroppableContainers:IS,windowRect:null,measuringScheduled:!1},Ofe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:IS,draggableNodes:new Map,over:null,measureDroppableContainers:IS},g1=x.createContext(Ofe),Mfe=x.createContext(cft);function uft(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Zb}}}function dft(e,t){switch(t.type){case qr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case qr.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case qr.DragEnd:case qr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case qr.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Zb(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case qr.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new Zb(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case qr.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Zb(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function fft(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=x.useContext(g1),i=_S(r),s=_S(n?.id);return x.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!ZT(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const f=ldt(u);if(f){f.focus();break}}})}},[r,t,o,s,i]),null}function Lfe(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function pft(e){return x.useMemo(()=>({draggable:{...vE.draggable,...e?.draggable},droppable:{...vE.droppable,...e?.droppable},dragOverlay:{...vE.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function hft(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=x.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Aa(()=>{if(!s&&!a||!t){i.current=!1;return}if(i.current||!r)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),f=yfe(u,r);if(s||(f.x=0),a||(f.y=0),i.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=vfe(c);m&&m.scrollBy({top:f.y,left:f.x})}},[t,s,a,r,n])}const JT=x.createContext({...Na,scaleX:1,scaleY:1});var ou;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ou||(ou={}));const mft=x.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=aft,collisionDetection:f=bfe,measuring:m,modifiers:g,...y}=t;const v=x.useReducer(dft,void 0,uft),[w,S]=v,[T,k]=hdt(),[I,_]=x.useState(ou.Uninitialized),R=I===ou.Initialized,{draggable:{active:D,nodes:M,translate:$},droppable:{containers:O}}=w,F=D!=null?M.get(D):null,U=x.useRef({initial:null,translated:null}),G=x.useMemo(()=>{var nn;return D!=null?{id:D,data:(nn=F?.data)!=null?nn:lft,rect:U}:null},[D,F]),j=x.useRef(null),[Q,V]=x.useState(null),[K,X]=x.useState(null),J=sy(y,Object.values(y)),B=m1("DndDescribedBy",s),q=x.useMemo(()=>O.getEnabled(),[O]),Y=pft(m),{droppableRects:P,measureDroppableContainers:le,measuringScheduled:ae}=Xdt(q,{dragging:R,dependencies:[$.x,$.y],config:Y.droppable}),ie=Ydt(M,D),ne=x.useMemo(()=>K?DS(K):null,[K]),se=bo(),pe=Zdt(ie,Y.draggable.measure);hft({activeNode:D!=null?M.get(D):null,config:se.layoutShiftCompensation,initialRect:pe,measure:Y.draggable.measure});const ke=ZY(ie,Y.draggable.measure,pe),Me=ZY(ie?ie.parentElement:null),Ce=x.useRef({activatorEvent:null,active:null,activeNode:ie,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:M,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Re=O.getNodeFor((n=Ce.current.over)==null?void 0:n.id),de=sft({measure:Y.dragOverlay.measure}),Te=(r=de.nodeRef.current)!=null?r:ie,Ge=R?(o=de.rect)!=null?o:ke:null,Ie=!!(de.nodeRef.current&&de.rect),cn=eft(Ie?null:ke),bt=Dfe(Te?hi(Te):null),it=tft(R?Re??ie:null),te=ift(it),fe=Lfe(g,{transform:{x:$.x-cn.x,y:$.y-cn.y,scaleX:1,scaleY:1},activatorEvent:K,active:G,activeNodeRect:ke,containerNodeRect:Me,draggingNodeRect:Ge,over:Ce.current.over,overlayNodeRect:de.rect,scrollableAncestors:it,scrollableAncestorRects:te,windowRect:bt}),ge=ne?Ch(ne,$):null,Pe=nft(it),je=JY(Pe),W=JY(Pe,[ke]),ye=Ch(fe,je),Be=Ge?Ndt(Ge,fe):null,qe=G&&Be?f({active:G,collisionRect:Be,droppableRects:P,droppableContainers:q,pointerCoordinates:ge}):null,at=Edt(qe,"id"),[un,mn]=x.useState(null),Mn=Ie?fe:Ch(fe,W),wn=kdt(Mn,(i=un?.rect)!=null?i:null,ke),Sn=x.useRef(null),_e=x.useCallback((nn,rn)=>{let{sensor:Ke,options:qt}=rn;if(j.current==null)return;const Et=M.get(j.current);if(!Et)return;const Pt=nn.nativeEvent,Yn=new Ke({active:j.current,activeNode:Et,event:Pt,options:qt,context:Ce,onAbort(Jt){if(!M.get(Jt))return;const{onDragAbort:_n}=J.current,nr={id:Jt};_n?.(nr),T({type:"onDragAbort",event:nr})},onPending(Jt,tr,_n,nr){if(!M.get(Jt))return;const{onDragPending:yo}=J.current,ms={id:Jt,constraint:tr,initialCoordinates:_n,offset:nr};yo?.(ms),T({type:"onDragPending",event:ms})},onStart(Jt){const tr=j.current;if(tr==null)return;const _n=M.get(tr);if(!_n)return;const{onDragStart:nr}=J.current,hs={activatorEvent:Pt,active:{id:tr,data:_n.data,rect:U}};Kr.unstable_batchedUpdates(()=>{nr?.(hs),_(ou.Initializing),S({type:qr.DragStart,initialCoordinates:Jt,active:tr}),T({type:"onDragStart",event:hs}),V(Sn.current),X(Pt)})},onMove(Jt){S({type:qr.DragMove,coordinates:Jt})},onEnd:Qt(qr.DragEnd),onCancel:Qt(qr.DragCancel)});Sn.current=Yn;function Qt(Jt){return async function(){const{active:_n,collisions:nr,over:hs,scrollAdjustedTranslate:yo}=Ce.current;let ms=null;if(_n&&yo){const{cancelDrop:xc}=J.current;ms={activatorEvent:Pt,active:_n,collisions:nr,delta:yo,over:hs},Jt===qr.DragEnd&&typeof xc=="function"&&await Promise.resolve(xc(ms))&&(Jt=qr.DragCancel)}j.current=null,Kr.unstable_batchedUpdates(()=>{S({type:Jt}),_(ou.Uninitialized),mn(null),V(null),X(null),Sn.current=null;const xc=Jt===qr.DragEnd?"onDragEnd":"onDragCancel";if(ms){const gs=J.current[xc];gs?.(ms),T({type:xc,event:ms})}})}}},[M]),Xe=x.useCallback((nn,rn)=>(Ke,qt)=>{const Et=Ke.nativeEvent,Pt=M.get(qt);if(j.current!==null||!Pt||Et.dndKit||Et.defaultPrevented)return;const Yn={active:Pt};nn(Ke,rn.options,Yn)===!0&&(Et.dndKit={capturedBy:rn.sensor},j.current=qt,_e(Ke,rn))},[M,_e]),xt=Kdt(u,Xe);rft(u),Aa(()=>{ke&&I===ou.Initializing&&_(ou.Initialized)},[ke,I]),x.useEffect(()=>{const{onDragMove:nn}=J.current,{active:rn,activatorEvent:Ke,collisions:qt,over:Et}=Ce.current;if(!rn||!Ke)return;const Pt={active:rn,activatorEvent:Ke,collisions:qt,delta:{x:ye.x,y:ye.y},over:Et};Kr.unstable_batchedUpdates(()=>{nn?.(Pt),T({type:"onDragMove",event:Pt})})},[ye.x,ye.y]),x.useEffect(()=>{const{active:nn,activatorEvent:rn,collisions:Ke,droppableContainers:qt,scrollAdjustedTranslate:Et}=Ce.current;if(!nn||j.current==null||!rn||!Et)return;const{onDragOver:Pt}=J.current,Yn=qt.get(at),Qt=Yn&&Yn.rect.current?{id:Yn.id,rect:Yn.rect.current,data:Yn.data,disabled:Yn.disabled}:null,Jt={active:nn,activatorEvent:rn,collisions:Ke,delta:{x:Et.x,y:Et.y},over:Qt};Kr.unstable_batchedUpdates(()=>{mn(Qt),Pt?.(Jt),T({type:"onDragOver",event:Jt})})},[at]),Aa(()=>{Ce.current={activatorEvent:K,active:G,activeNode:ie,collisionRect:Be,collisions:qe,droppableRects:P,draggableNodes:M,draggingNode:Te,draggingNodeRect:Ge,droppableContainers:O,over:un,scrollableAncestors:it,scrollAdjustedTranslate:ye},U.current={initial:Ge,translated:Be}},[G,ie,qe,Be,M,Te,Ge,P,O,un,it,ye]),Gdt({...se,delta:$,draggingRect:Be,pointerCoordinates:ge,scrollableAncestors:it,scrollableAncestorRects:te});const ut=x.useMemo(()=>({active:G,activeNode:ie,activeNodeRect:ke,activatorEvent:K,collisions:qe,containerNodeRect:Me,dragOverlay:de,draggableNodes:M,droppableContainers:O,droppableRects:P,over:un,measureDroppableContainers:le,scrollableAncestors:it,scrollableAncestorRects:te,measuringConfiguration:Y,measuringScheduled:ae,windowRect:bt}),[G,ie,ke,K,qe,Me,de,M,O,P,un,le,it,te,Y,ae,bt]),lr=x.useMemo(()=>({activatorEvent:K,activators:xt,active:G,activeNodeRect:ke,ariaDescribedById:{draggable:B},dispatch:S,draggableNodes:M,over:un,measureDroppableContainers:le}),[K,xt,G,ke,S,B,M,un,le]);return ue.createElement(gfe.Provider,{value:k},ue.createElement(g1.Provider,{value:lr},ue.createElement(Mfe.Provider,{value:ut},ue.createElement(JT.Provider,{value:wn},c)),ue.createElement(fft,{disabled:a?.restoreFocus===!1})),ue.createElement(bdt,{...a,hiddenTextDescribedById:B}));function bo(){const nn=Q?.autoScrollEnabled===!1,rn=typeof l=="object"?l.enabled===!1:l===!1,Ke=R&&!nn&&!rn;return typeof l=="object"?{...l,enabled:Ke}:{enabled:Ke}}}),gft=x.createContext(null),tK="button",bft="Draggable";function yft(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=m1(bft),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:m}=x.useContext(g1),{role:g=tK,roleDescription:y="draggable",tabIndex:v=0}=o??{},w=l?.id===t,S=x.useContext(w?JT:gft),[T,k]=NS(),[I,_]=NS(),R=oft(s,t),D=sy(n);Aa(()=>(f.set(t,{id:t,key:i,node:T,activatorNode:I,data:D}),()=>{const $=f.get(t);$&&$.key===i&&f.delete(t)}),[f,t]);const M=x.useMemo(()=>({role:g,tabIndex:v,"aria-disabled":r,"aria-pressed":w&&g===tK?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[r,g,v,w,y,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:M,isDragging:w,listeners:r?void 0:R,node:T,over:m,setNodeRef:k,setActivatorNodeRef:_,transform:S}}function Pfe(){return x.useContext(Mfe)}const xft="Droppable",vft={timeout:25};function Ffe(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=m1(xft),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=x.useContext(g1),u=x.useRef({disabled:n}),f=x.useRef(!1),m=x.useRef(null),g=x.useRef(null),{disabled:y,updateMeasurementsFor:v,timeout:w}={...vft,...o},S=sy(v??r),T=x.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(S.current)?S.current:[S.current]),g.current=null},w)},[w]),k=QT({callback:T,disabled:y||!s}),I=x.useCallback((M,$)=>{k&&($&&(k.unobserve($),f.current=!1),M&&k.observe(M))},[k]),[_,R]=NS(I),D=sy(t);return x.useEffect(()=>{!k||!_.current||(k.disconnect(),f.current=!1,k.observe(_.current))},[_,k]),x.useEffect(()=>(a({type:qr.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:m,data:D}}),()=>a({type:qr.UnregisterDroppable,key:i,id:r})),[r]),x.useEffect(()=>{n!==u.current.disabled&&(a({type:qr.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:m,isOver:l?.id===r,node:_,over:l,setNodeRef:R}}function Eft(e){let{animation:t,children:n}=e;const[r,o]=x.useState(null),[i,s]=x.useState(null),a=_S(n);return!n&&!r&&a&&o(a),Aa(()=>{if(!i)return;const l=r?.key,c=r?.props.id;if(l==null||c==null){o(null);return}Promise.resolve(t(c,i)).then(()=>{o(null)})},[t,r,i]),ue.createElement(ue.Fragment,null,n,r?x.cloneElement(r,{ref:s}):null)}const wft={x:0,y:0,scaleX:1,scaleY:1};function Sft(e){let{children:t}=e;return ue.createElement(g1.Provider,{value:Ofe},ue.createElement(JT.Provider,{value:wft},t))}const Cft={position:"fixed",touchAction:"none"},Tft=e=>ZT(e)?"transform 250ms ease":void 0,kft=x.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Tft}=e;if(!a)return null;const f=o?c:{...c,scaleX:1,scaleY:1},m={...Cft,width:a.width,height:a.height,top:a.top,left:a.left,transform:Wu.Transform.toString(f),transformOrigin:o&&r?xdt(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return ue.createElement(n,{className:s,style:m,ref:t},i)}),Aft=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:s}=e;if(i!=null&&i.active)for(const[a,l]of Object.entries(i.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(i!=null&&i.dragOverlay)for(const[a,l]of Object.entries(i.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return s!=null&&s.active&&n.node.classList.add(s.active),s!=null&&s.dragOverlay&&r.node.classList.add(s.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);s!=null&&s.active&&n.node.classList.remove(s.active)}},Nft=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Wu.Transform.toString(t)},{transform:Wu.Transform.toString(n)}]},_ft={duration:250,easing:"ease",keyframes:Nft,sideEffects:Aft({styles:{active:{opacity:"0"}}})};function Rft(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return XT((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=Ife(s);if(!c)return;const{transform:u}=hi(s).getComputedStyle(s),f=xfe(u);if(!f)return;const m=typeof t=="function"?t:Dft(t);return kfe(l,o.draggable.measure),m({active:{id:i,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:s,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:f})})}function Dft(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={..._ft,...e};return i=>{let{active:s,dragOverlay:a,transform:l,...c}=i;if(!t)return;const u={x:a.rect.left-s.rect.left,y:a.rect.top-s.rect.top},f={scaleX:l.scaleX!==1?s.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?s.rect.height*l.scaleY/a.rect.height:1},m={x:l.x-u.x,y:l.y-u.y,...f},g=o({...c,active:s,dragOverlay:a,transform:{initial:l,final:m}}),[y]=g,v=g[g.length-1];if(JSON.stringify(y)===JSON.stringify(v))return;const w=r?.({active:s,dragOverlay:a,...c}),S=a.node.animate(g,{duration:t,easing:n,fill:"forwards"});return new Promise(T=>{S.onfinish=()=>{w?.(),T()}})}}let nK=0;function Ift(e){return x.useMemo(()=>{if(e!=null)return nK++,nK},[e])}const Oft=ue.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:s,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:u,active:f,activeNodeRect:m,containerNodeRect:g,draggableNodes:y,droppableContainers:v,dragOverlay:w,over:S,measuringConfiguration:T,scrollableAncestors:k,scrollableAncestorRects:I,windowRect:_}=Pfe(),R=x.useContext(JT),D=Ift(f?.id),M=Lfe(s,{activatorEvent:u,active:f,activeNodeRect:m,containerNodeRect:g,draggingNodeRect:w.rect,over:S,overlayNodeRect:w.rect,scrollableAncestors:k,scrollableAncestorRects:I,transform:R,windowRect:_}),$=$B(m),O=Rft({config:r,draggableNodes:y,droppableContainers:v,measuringConfiguration:T}),F=$?w.setRef:void 0;return ue.createElement(Sft,null,ue.createElement(Eft,{animation:O},f&&D?ue.createElement(kft,{key:D,id:f.id,ref:F,as:a,activatorEvent:u,adjustScale:t,className:l,transition:i,rect:$,style:{zIndex:c,...o},transform:M},n):null))});function MS(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Mft(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Ov(e){return e!==null&&e>=0}function Lft(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Pft(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Bfe=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=MS(t,r,n),s=t[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},jfe="Sortable",$fe=ue.createContext({activeIndex:-1,containerId:jfe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Bfe,disabled:{draggable:!1,droppable:!1}});function Fft(e){let{children:t,id:n,items:r,strategy:o=Bfe,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=Pfe(),f=m1(jfe,n),m=a.rect!==null,g=x.useMemo(()=>r.map(R=>typeof R=="object"&&"id"in R?R.id:R),[r]),y=s!=null,v=s?g.indexOf(s.id):-1,w=c?g.indexOf(c.id):-1,S=x.useRef(g),T=!Lft(g,S.current),k=w!==-1&&v===-1||T,I=Pft(i);Aa(()=>{T&&y&&u(g)},[T,g,y,u]),x.useEffect(()=>{S.current=g},[g]);const _=x.useMemo(()=>({activeIndex:v,containerId:f,disabled:I,disableTransforms:k,items:g,overIndex:w,useDragOverlay:m,sortedRects:Mft(g,l),strategy:o}),[v,f,I.draggable,I.droppable,k,g,w,l,m,o]);return ue.createElement($fe.Provider,{value:_},t)}const Bft=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return MS(n,r,o).indexOf(t)},jft=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&t===l},$ft={duration:200,easing:"ease"},Ufe="transform",Uft=Wu.Transition.toString({property:Ufe,duration:0,easing:"linear"}),Hft={roleDescription:"sortable"};function zft(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=x.useState(null),a=x.useRef(n);return Aa(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=Wm(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[t,n,r,o]),x.useEffect(()=>{i&&s(null)},[i]),i}function Vft(e){let{animateLayoutChanges:t=jft,attributes:n,disabled:r,data:o,getNewIndex:i=Bft,id:s,strategy:a,resizeObserverConfig:l,transition:c=$ft}=e;const{items:u,containerId:f,activeIndex:m,disabled:g,disableTransforms:y,sortedRects:v,overIndex:w,useDragOverlay:S,strategy:T}=x.useContext($fe),k=Gft(r,g),I=u.indexOf(s),_=x.useMemo(()=>({sortable:{containerId:f,index:I,items:u},...o}),[f,o,I,u]),R=x.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:D,node:M,isOver:$,setNodeRef:O}=Ffe({id:s,data:_,disabled:k.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...l}}),{active:F,activatorEvent:U,activeNodeRect:G,attributes:j,setNodeRef:Q,listeners:V,isDragging:K,over:X,setActivatorNodeRef:J,transform:B}=yft({id:s,data:_,attributes:{...Hft,...n},disabled:k.draggable}),q=odt(O,Q),Y=!!F,P=Y&&!y&&Ov(m)&&Ov(w),le=!S&&K,ae=le&&P?B:null,ne=P?ae??(a??T)({rects:v,activeNodeRect:G,activeIndex:m,overIndex:w,index:I}):null,se=Ov(m)&&Ov(w)?i({id:s,items:u,activeIndex:m,overIndex:w}):I,pe=F?.id,ke=x.useRef({activeId:pe,items:u,newIndex:se,containerId:f}),Me=u!==ke.current.items,Ce=t({active:F,containerId:f,isDragging:K,isSorting:Y,id:s,index:I,items:u,newIndex:ke.current.newIndex,previousItems:ke.current.items,previousContainerId:ke.current.containerId,transition:c,wasDragging:ke.current.activeId!=null}),Re=zft({disabled:!Ce,index:I,node:M,rect:D});return x.useEffect(()=>{Y&&ke.current.newIndex!==se&&(ke.current.newIndex=se),f!==ke.current.containerId&&(ke.current.containerId=f),u!==ke.current.items&&(ke.current.items=u)},[Y,se,f,u]),x.useEffect(()=>{if(pe===ke.current.activeId)return;if(pe!=null&&ke.current.activeId==null){ke.current.activeId=pe;return}const Te=setTimeout(()=>{ke.current.activeId=pe},50);return()=>clearTimeout(Te)},[pe]),{active:F,activeIndex:m,attributes:j,data:_,rect:D,index:I,newIndex:se,items:u,isOver:$,isSorting:Y,isDragging:K,listeners:V,node:M,overIndex:w,over:X,setNodeRef:q,setActivatorNodeRef:J,setDroppableNodeRef:O,setDraggableNodeRef:Q,transform:Re??ne,transition:de()};function de(){if(Re||Me&&ke.current.newIndex===I)return Uft;if(!(le&&!ZT(U)||!c)&&(Y||Ce))return Wu.Transition.toString({...c,property:Ufe})}}function Gft(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}vn.Down,vn.Right,vn.Up,vn.Left;const Wft={},rK=e=>{let t;const n=new Set,r=(u,f)=>{const m=typeof u=="function"?u(t):u;if(!Object.is(m,t)){const g=t;t=f??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,g))}},o=()=>t,l={setState:r,getState:o,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Wft?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(r,o,l);return l},qft=e=>e?rK(e):rK,Hfe={},{useDebugValue:Yft}=ue,{useSyncExternalStoreWithSelector:Kft}=UXe;let oK=!1;const Xft=e=>e;function Zft(e,t=Xft,n){(Hfe?"production":void 0)!=="production"&&n&&!oK&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),oK=!0);const r=Kft(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Yft(r),r}const iK=e=>{(Hfe?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?qft(e):e,n=(r,o)=>Zft(t,r,o);return Object.assign(n,t),n},Qft=e=>e?iK(e):iK;var sK,aK;const lK=typeof window<"u"&&((sK=window.document)!=null&&sK.createElement||((aK=window.navigator)==null?void 0:aK.product)==="ReactNative")?ue.useLayoutEffect:ue.useEffect;function Jft(){const e=Qft(t=>({current:new Array,version:0,set:t}));return{In:({children:t})=>{const n=e(o=>o.set),r=e(o=>o.version);return lK(()=>{n(o=>({version:o.version+1}))},[]),lK(()=>(n(({current:o})=>({current:[...o,t]})),()=>n(({current:o})=>({current:o.filter(i=>i!==t)}))),[t,r]),null},Out:()=>{const t=e(n=>n.current);return ue.createElement(ue.Fragment,null,t)}}}const Q_=768;function ek(){const[e,t]=x.useState(void 0);return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Q_-1}px)`),r=()=>{t(window.innerWidth<Q_)};return n.addEventListener("change",r),t(window.innerWidth<Q_),()=>n.removeEventListener("change",r)},[]),!!e}const zfe=Jft(),UB=x.createContext({columns:[],data:[],activeCardId:null}),ept=({id:e,children:t,className:n})=>{const{isOver:r,setNodeRef:o}=Ffe({id:e});return h.jsx("div",{className:Ee("flex min-h-40 flex-col divide-y overflow-hidden rounded-md border bg-secondary text-xs shadow-sm ring-2 transition-all shrink-0",r?"ring-primary":"ring-transparent",n),ref:o,children:t})},tpt=({id:e,name:t,children:n,className:r})=>{const{attributes:o,listeners:i,setNodeRef:s,transition:a,transform:l,isDragging:c}=Vft({id:e}),{activeCardId:u}=x.useContext(UB),f={transition:a,transform:Wu.Transform.toString(l)};return h.jsxs(h.Fragment,{children:[h.jsx("div",{style:f,...i,...o,ref:s,children:h.jsx(nf,{className:Ee("cursor-grab gap-4 rounded-md p-3 shadow-sm",c&&"pointer-events-none cursor-grabbing opacity-30",r),children:n??h.jsx("p",{className:"m-0 font-medium text-sm",children:t})})}),u===e&&h.jsx(zfe.In,{children:h.jsx(nf,{className:Ee("cursor-grab gap-4 rounded-md p-3 shadow-sm ring-2 ring-primary",c&&"cursor-grabbing",r),children:n??h.jsx("p",{className:"m-0 font-medium text-sm",children:t})})})]})},npt=({children:e,className:t,...n})=>{const{data:r}=x.useContext(UB),o=r.filter(s=>s.column===n.id),i=o.map(s=>s.id);return h.jsxs(Xr,{className:"overflow-hidden flex-1",children:[h.jsx(Fft,{items:i,children:h.jsx("div",{className:Ee("flex flex-grow flex-col gap-2 p-2",t),...n,children:o.map(e)})}),h.jsx(ZS,{orientation:"vertical"})]})},rpt=({className:e,...t})=>h.jsx("div",{className:Ee("m-0 p-2 font-semibold text-sm",e),...t}),opt=e=>t=>{const{droppableRects:n,droppableContainers:r,pointerCoordinates:o}=t,i=y=>!e.includes(y),s=y=>e.includes(y),a=Tdt(t),l=a.filter(y=>i(y.id)),c=a.filter(y=>s(y.id));if(l.length>0){const v=GY(t).filter(w=>i(w.id));return v.length>0?[v[0]]:[l[0]]}if(c.length>0)return[c[0]];const u=bfe(t),f=u.filter(y=>i(y.id)),m=u.filter(y=>s(y.id));if(f.length>0){const v=wdt(t).filter(w=>i(w.id));return v.length>0?[v[0]]:[f[0]]}if(m.length>0)return[m[0]];if(o){let y=null;for(const v of e){const w=n.get(v);if(!w)continue;const S=w.left+w.width/2,T=w.top+w.height/2,k=Math.sqrt(Math.pow(o.x-S,2)+Math.pow(o.y-T,2)),I={left:w.left-150,right:w.right+150,top:w.top-50,bottom:w.bottom+50};o.x>=I.left&&o.x<=I.right&&o.y>=I.top&&o.y<=I.bottom&&(!y||k<y.distance)&&(y={id:v,distance:k})}if(y)return[{id:y.id}]}const g=GY(t);if(g.length>0){const y=g.find(v=>s(v.id));return y?[y]:[g[0]]}return[]},ipt=({children:e,onDragStart:t,onDragEnd:n,onDragOver:r,className:o,columns:i,data:s,onDataChange:a,...l})=>{const[c,u]=x.useState(null),f=ek(),m=x.useMemo(()=>i.map(k=>k.id),[i]),g=x.useMemo(()=>opt(m),[m]),y=ydt(Y_(_fe,{activationConstraint:{distance:8}}),Y_(Rfe,{activationConstraint:{delay:150,tolerance:8}}),Y_(BB)),v=k=>{s.find(_=>_.id===k.active.id)&&u(k.active.id),t?.(k)},w=k=>{const{active:I,over:_}=k;if(!_)return;const R=s.find(F=>F.id===I.id),D=s.find(F=>F.id===_.id);if(!R)return;const M=R.column,O=i.some(F=>F.id===_.id)?_.id:D?.column||M;if(M!==O){let F=[...s];const U=F.findIndex(G=>G.id===I.id);if(F[U]={...F[U],column:O},D){const G=F.findIndex(j=>j.id===_.id);F=MS(F,U,G)}a?.(F)}r?.(k)},S=k=>{u(null),n?.(k);const{active:I,over:_}=k;if(!_||I.id===_.id)return;if(i.some(O=>O.id===_.id)){const O=s.find(F=>F.id===I.id);if(O&&O.column!==_.id){let F=[...s];const U=F.findIndex(G=>G.id===I.id);F[U]={...F[U],column:_.id},a?.(F)}return}let D=[...s];const M=D.findIndex(O=>O.id===I.id),$=D.findIndex(O=>O.id===_.id);M!==-1&&$!==-1&&(D=MS(D,M,$),a?.(D))},T={onDragStart({active:k}){const{name:I,column:_}=s.find(R=>R.id===k.id)??{};return`Picked up the card "${I}" from the "${_}" column`},onDragOver({active:k,over:I}){const{name:_}=s.find(D=>D.id===k.id)??{},R=i.find(D=>D.id===I?.id)?.name;return`Dragged the card "${_}" over the "${R}" column`},onDragEnd({active:k,over:I}){const{name:_}=s.find(D=>D.id===k.id)??{},R=i.find(D=>D.id===I?.id)?.name;return`Dropped the card "${_}" into the "${R}" column`},onDragCancel({active:k}){const{name:I}=s.find(_=>_.id===k.id)??{};return`Cancelled dragging the card "${I}"`}};return h.jsx(UB.Provider,{value:{columns:i,data:s,activeCardId:c},children:h.jsxs(mft,{accessibility:{announcements:T},collisionDetection:g,onDragEnd:S,onDragOver:w,onDragStart:v,sensors:y,...l,children:[h.jsx("div",{className:Ee("flex gap-4",f&&"flex-col",o),children:i.map(k=>e(k))}),typeof window<"u"&&Kr.createPortal(h.jsx(Oft,{children:h.jsx(zfe.Out,{})}),document.body)]})})},cK={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold"};function xb(e){return cK[e]?cK[e]:e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function spt({tasks:e,loading:t,onTasksUpdate:n}){const{config:r,updateConfig:o}=Sf(),[i,s]=x.useState(new Set),[a,l]=x.useState(!1),c=ek(),u=r?.statuses||["todo","in-progress","in-review","done","blocked"],f=r?.statusColors||iM,m=x.useMemo(()=>u.filter(O=>i.has(O)).map(O=>({id:O,name:xb(O),color:f[O]||"gray"})),[u,i,f]),g={high:0,medium:1,low:2},y=x.useMemo(()=>[...e].sort((F,U)=>{const G=g[F.priority]??2,j=g[U.priority]??2;return G!==j?G-j:new Date(U.updatedAt).getTime()-new Date(F.updatedAt).getTime()}).map(F=>({id:F.id,name:F.title,column:F.status,task:F})),[e]),v=()=>{const F=window.location.hash.slice(1).match(/^\/kanban\/([^?]+)/);if(!F)return null;const U=F[1];return e.find(G=>G.id===U)||null},[w,S]=x.useState(v());x.useEffect(()=>{const O=()=>{S(v())};return S(v()),window.addEventListener("hashchange",O),()=>window.removeEventListener("hashchange",O)},[e]),x.useEffect(()=>{r?.visibleColumns?s(new Set(r.visibleColumns)):s(new Set(u))},[r?.visibleColumns,u.join(",")]);const T=async O=>{try{await o({visibleColumns:[...O]})}catch(F){console.error("Failed to save config:",F)}},k=O=>{s(F=>{const U=new Set(F);return U.has(O)?U.delete(O):U.add(O),T(U),U})},I=async O=>{const F=O.filter(G=>{const j=e.find(Q=>Q.id===G.id);return j&&j.status!==G.column}),U=e.map(G=>{const j=O.find(Q=>Q.id===G.id);return j&&j.column!==G.status?{...G,status:j.column}:G});n(U);for(const G of F)try{await ma.updateTask(G.id,{status:G.column}),so.success("Status updated",{description:`#${G.id} moved to ${xb(G.column)}`})}catch(j){console.error("Failed to update task:",j),so.error("Failed to update status",{description:j instanceof Error?j.message:"Unknown error"}),ma.getTasks().then(n).catch(console.error);break}};if(t)return h.jsx("div",{className:"flex items-center justify-center h-64",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),h.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading tasks..."})]})});const _=O=>{window.location.hash=`/kanban/${O.id}`},R=()=>{window.location.hash="/"},D=O=>{n(e.map(F=>F.id===O.id?O:F))},M=O=>{window.location.hash=`/kanban/${O}`},$=async O=>{try{await ma.archiveTask(O),n(e.filter(F=>F.id!==O)),R()}catch(F){console.error("Failed to archive task:",F)}};return h.jsxs("div",{className:"flex flex-col h-full",children:[c?h.jsxs(Yde,{open:a,onOpenChange:l,className:"shrink-0 bg-card rounded-lg mb-4 border border-border",children:[h.jsxs(Kde,{className:"flex items-center justify-between w-full p-3",children:[h.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Show Columns (",i.size,"/",u.length,")"]}),a?h.jsx(IK,{className:"w-4 h-4 text-muted-foreground"}):h.jsx(cc,{className:"w-4 h-4 text-muted-foreground"})]}),h.jsx(Xde,{children:h.jsx("div",{className:"flex flex-wrap gap-2 px-3 pb-3",children:u.map(O=>{const F=i.has(O),U=e.filter(G=>G.status===O).length;return h.jsxs("button",{type:"button",onClick:()=>k(O),className:Ee("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg transition-colors text-xs",F?"bg-primary/10 text-primary dark:bg-primary/20":"bg-muted text-muted-foreground"),children:[F?h.jsx(e0,{className:"w-3.5 h-3.5"}):h.jsx(fR,{className:"w-3.5 h-3.5"}),h.jsxs("span",{className:"font-medium",children:[xb(O)," (",U,")"]})]},O)})})})]}):h.jsx("div",{className:"shrink-0 bg-card rounded-lg p-4 mb-4 border border-border",children:h.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[h.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Show Columns:"}),u.map(O=>{const F=i.has(O),U=e.filter(G=>G.status===O).length;return h.jsxs("button",{type:"button",onClick:()=>k(O),className:Ee("flex items-center gap-2 px-3 py-1.5 rounded-lg transition-colors",F?"bg-primary/10 text-primary dark:bg-primary/20":"bg-muted text-muted-foreground"),children:[F?h.jsx(e0,{className:"w-4 h-4"}):h.jsx(fR,{className:"w-4 h-4"}),h.jsxs("span",{className:"text-sm font-medium",children:[xb(O)," (",U,")"]})]},O)})]})}),h.jsxs(Xr,{className:"flex-1",children:[i.size>0?h.jsx(ipt,{columns:m,data:y,onDataChange:I,className:"min-h-full pb-4",children:O=>{const F=nTe(O.id,f),U=y.filter(G=>G.column===O.id).length;return h.jsxs(ept,{id:O.id,className:Ee("min-w-[320px] max-w-[380px]",c&&"min-w-0 max-w-none w-full",F.bg,F.border),children:[h.jsxs(rpt,{className:"flex items-center justify-between",children:[h.jsx("span",{className:"font-bold text-sm uppercase tracking-wide text-foreground",children:O.name}),h.jsx("span",{className:"text-xs rounded-full px-2 py-1 font-medium text-muted-foreground bg-background",children:U})]}),h.jsx(npt,{id:O.id,children:G=>h.jsx(apt,{item:G,statusColors:f,onClick:()=>_(G.task)},G.id)})]},O.id)}}):h.jsx("div",{className:"text-center py-12",children:h.jsx("p",{className:"text-lg text-muted-foreground",children:"No columns visible. Please select at least one column to display."})}),h.jsx(ZS,{orientation:"horizontal"})]}),h.jsx(pfe,{task:w,allTasks:e,onClose:R,onUpdate:D,onArchive:$,onNavigateToTask:M})]})}function apt({item:e,statusColors:t,onClick:n}){const{task:r}=e,o=Dh(r.status,t),i=r.acceptanceCriteria.filter(a=>a.completed).length,s=r.acceptanceCriteria.length;return h.jsx(tpt,{id:e.id,name:e.name,column:e.column,className:"w-full",children:h.jsxs("div",{onClick:n,onKeyDown:a=>a.key==="Enter"&&n(),role:"button",tabIndex:0,className:"cursor-pointer",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[h.jsxs("span",{className:"text-xs font-mono shrink-0 text-muted-foreground",children:["#",r.id]}),h.jsxs("div",{className:"flex items-center gap-1 flex-wrap justify-end",children:[h.jsx("span",{className:Ee("text-xs px-1.5 py-0.5 rounded font-medium",o),children:xb(r.status)}),r.priority==="high"&&h.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-destructive/10 text-destructive dark:bg-destructive/20",children:"HIGH"}),r.priority==="medium"&&h.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",children:"MED"})]})]}),h.jsx("h3",{className:"font-medium text-sm mb-2 line-clamp-2 text-foreground",children:r.title}),s>0&&h.jsxs("div",{className:"flex items-center gap-2 text-xs mb-2 text-muted-foreground",children:[h.jsx(MK,{className:"w-3 h-3","aria-hidden":"true"}),h.jsxs("span",{children:[i,"/",s]})]}),r.labels.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:r.labels.map(a=>h.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-secondary text-secondary-foreground",children:a},a))}),r.assignee&&h.jsxs("div",{className:"flex items-center gap-1.5 text-xs mt-2 text-muted-foreground",children:[h.jsx(ry,{name:r.assignee,size:"sm"}),h.jsx("span",{children:r.assignee})]})]})})}const uK=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],dK={low:"bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400",medium:"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300",high:"bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-300"};function lpt({isOpen:e,allTasks:t,onClose:n,onCreated:r}){const{currentUser:o}=DQ(),{config:i}=Sf(),s=x.useRef(null),a=x.useRef(null),l=x.useMemo(()=>{const W=i.statuses||["todo","in-progress","in-review","done","blocked"];return PQ(W)},[i.statuses]),c=i.statusColors||{},[u,f]=x.useState(""),[m,g]=x.useState(""),[y,v]=x.useState("todo"),[w,S]=x.useState("medium"),[T,k]=x.useState(""),[I,_]=x.useState([]),[R,D]=x.useState(""),[M,$]=x.useState([]),[O,F]=x.useState(""),[U,G]=x.useState(""),[j,Q]=x.useState(!1),[V,K]=x.useState(null),[X,J]=x.useState(!1),[B,q]=x.useState(""),[Y,P]=x.useState(!1),[le,ae]=x.useState(""),[ie,ne]=x.useState(!1),[se,pe]=x.useState(!1),{preferences:ke,toggleTaskCreateLayout:Me}=MQ(),Ce=ke.taskCreateLayout==="maximized",Re=x.useRef(null),de={hidden:{opacity:0,y:20,scale:.98},visible:{opacity:1,y:0,scale:1,transition:{duration:.2,ease:"easeOut"}},exit:{opacity:0,y:10,scale:.98,transition:{duration:.15,ease:"easeIn"}}};x.useEffect(()=>{e||(f(""),g(""),v("todo"),S("medium"),k(""),_([]),D(""),$([]),F(""),G(""),K(null),J(!1),q(""),P(!1),ae(""),ne(!1),pe(!1))},[e]),x.useEffect(()=>{e&&setTimeout(()=>s.current?.focus(),100)},[e,Ce]),x.useEffect(()=>{Y&&Re.current&&Re.current.focus()},[Y]);const Te=x.useCallback(()=>{B.trim()&&($(W=>[...W,{id:crypto.randomUUID(),text:B.trim()}]),q(""),P(!1))},[B]),Ge=x.useCallback(W=>{$(ye=>ye.filter(Be=>Be.id!==W))},[]),Ie=x.useCallback(()=>{le.trim()&&(I.includes(le.trim())||_(W=>[...W,le.trim()]),ae(""),ne(!1))},[le,I]),cn=x.useCallback(W=>{_(ye=>ye.filter(Be=>Be!==W))},[]),bt=async W=>{if(W.preventDefault(),K(null),!u.trim()){K("Title is required");return}Q(!0);try{const ye={title:u.trim(),description:m.trim()||void 0,status:y,priority:w,labels:I,assignee:T.trim()||void 0,parent:R||void 0,acceptanceCriteria:M.map(Be=>({text:Be.text,completed:!1})),implementationPlan:O.trim()||void 0,implementationNotes:U.trim()||void 0};await pge(ye),J(!0),so.success("Task created successfully",{description:u.trim()}),setTimeout(()=>{r(),n()},800)}catch(ye){const Be=ye instanceof Error?ye.message:"Failed to create task";K(Be),so.error("Failed to create task",{description:Be})}finally{Q(!1)}},it=R?t.find(W=>W.id===R):null,te=h.jsxs("div",{className:"flex items-center justify-between gap-2 p-4 border-b bg-green-700",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:"text-green-100 text-xs font-medium uppercase tracking-wide",children:"New Task"}),h.jsx("input",{ref:s,type:"text",value:u,onChange:W=>f(W.target.value),placeholder:"Enter task title...",className:"w-full text-lg font-semibold bg-white/20 text-white placeholder-white/60 border-0 rounded px-2 py-1 mt-1 focus:outline-none focus:ring-2 focus:ring-white/50",disabled:j})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(Le,{variant:"ghost",size:"icon",onClick:Me,className:"h-8 w-8 text-foreground hover:text-foreground",title:Ce?"Minimize":"Maximize",children:Ce?h.jsx(jK,{className:"w-4 h-4"}):h.jsx(BK,{className:"w-4 h-4"})}),h.jsx(Le,{variant:"ghost",size:"icon",onClick:n,className:"h-8 w-8 text-foreground hover:text-foreground",title:"Close",children:h.jsx(ti,{className:"w-4 h-4"})})]})]}),fe=(X||V)&&h.jsxs("div",{className:"px-4 pt-4",children:[X&&h.jsx("div",{className:"bg-green-50 dark:bg-green-900/50 border border-green-200 dark:border-green-700 text-green-700 dark:text-green-300 px-4 py-2 rounded-lg text-sm",children:"Task created successfully!"}),V&&h.jsx("div",{className:"bg-red-50 dark:bg-red-900/50 border border-red-200 dark:border-red-700 text-red-700 dark:text-red-300 px-4 py-2 rounded-lg text-sm",children:V})]}),ge=h.jsxs("div",{className:"p-6 space-y-6",children:[h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(HK,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Description"})]}),h.jsx(Tu,{markdown:m,onChange:g,placeholder:"Add a more detailed description...",readOnly:j})]}),h.jsxs("section",{children:[h.jsx("div",{className:"flex items-center justify-between mb-3",children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(am,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Acceptance Criteria"}),M.length>0&&h.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",M.length,")"]})]})}),h.jsx("div",{className:"space-y-2",children:M.map(W=>h.jsxs("div",{className:"flex items-start gap-2 bg-muted/50 rounded-lg px-3 py-2 group hover:shadow-sm transition-shadow",children:[h.jsx("input",{type:"checkbox",checked:!1,disabled:!0,className:"mt-1 w-4 h-4 rounded cursor-not-allowed opacity-50"}),h.jsx("span",{className:"flex-1 text-sm",children:W.text}),h.jsx("button",{type:"button",onClick:()=>Ge(W.id),className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-red-500 p-1 transition-all",title:"Delete",children:h.jsx(Nu,{className:"w-4 h-4"})})]},W.id))}),Y?h.jsxs("div",{className:"mt-2 bg-muted/50 rounded-lg px-3 py-2",children:[h.jsx("input",{ref:Re,type:"text",value:B,onChange:W=>q(W.target.value),onKeyDown:W=>{W.key==="Enter"&&B.trim()&&(W.preventDefault(),Te()),W.key==="Escape"&&(q(""),P(!1))},placeholder:"Add an item...",className:"w-full border border-input rounded px-2 py-1.5 text-sm bg-background focus:outline-none focus:ring-2 focus:ring-green-500",disabled:j}),h.jsxs("div",{className:"flex gap-2 mt-2",children:[h.jsx(Le,{type:"button",size:"sm",onClick:Te,disabled:!B.trim()||j,className:"bg-green-700 hover:bg-green-800 text-white",children:"Add"}),h.jsx(Le,{type:"button",variant:"ghost",size:"sm",onClick:()=>{q(""),P(!1)},children:"Cancel"})]})]}):h.jsxs("button",{type:"button",onClick:()=>P(!0),className:"mt-2 flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground hover:bg-muted px-3 py-2 rounded-lg transition-colors w-full",disabled:j,children:[h.jsx(Go,{className:"w-4 h-4"}),h.jsx("span",{children:"Add an item"})]})]}),h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(Br,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Implementation Plan"}),h.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),h.jsx(Tu,{markdown:O,onChange:F,placeholder:"Describe how you plan to implement this task...",readOnly:j})]}),h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(F0e,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Implementation Notes"}),h.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),h.jsx(Tu,{markdown:U,onChange:G,placeholder:"Add notes, observations, or any other relevant information...",readOnly:j})]})]}),Pe=h.jsxs("div",{className:"p-4 space-y-6",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Status"}),h.jsxs(ri,{value:y,onValueChange:W=>v(W),disabled:j,children:[h.jsx(zo,{className:Ee("w-full",Dh(y,c)),children:h.jsx(oi,{})}),h.jsx(Vo,{children:l.map(W=>h.jsx(En,{value:W.value,children:W.label},W.value))})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Priority"}),h.jsxs(ri,{value:w,onValueChange:W=>S(W),disabled:j,children:[h.jsx(zo,{className:Ee("w-full",dK[w]),children:h.jsx(oi,{})}),h.jsx(Vo,{children:uK.map(W=>h.jsx(En,{value:W.value,children:W.label},W.value))})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Assignee"}),h.jsx(SS,{value:T,onChange:k,showGrabButton:!1,currentUser:o,container:a.current})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Labels"}),h.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(W=>h.jsxs(fc,{variant:"secondary",className:"gap-1 pr-1",children:[W,h.jsx("button",{type:"button",onClick:()=>cn(W),className:"ml-1 hover:text-destructive",children:h.jsx(ti,{className:"w-3 h-3"})})]},W))}),ie?h.jsxs("div",{className:"space-y-2",children:[h.jsx(Gn,{value:le,onChange:W=>ae(W.target.value),onKeyDown:W=>{W.key==="Enter"&&le.trim()&&(W.preventDefault(),Ie()),W.key==="Escape"&&(ae(""),ne(!1))},placeholder:"Label name",disabled:j,autoFocus:!0}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Le,{size:"sm",onClick:Ie,disabled:!le.trim()||j,children:"Add"}),h.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>{ae(""),ne(!1)},children:"Cancel"})]})]}):h.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground",onClick:()=>ne(!0),disabled:j,children:[h.jsx(Go,{className:"w-4 h-4 mr-2"}),"Add label"]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Parent Task"}),h.jsxs(Q0,{open:se,onOpenChange:pe,children:[h.jsx(J0,{asChild:!0,children:h.jsxs(Le,{variant:"outline",role:"combobox","aria-expanded":se,className:"w-full justify-between h-auto min-h-10 py-2",disabled:j,title:it?`#${it.id} - ${it.title}`:void 0,children:[it?h.jsxs("div",{className:"flex items-center gap-2 text-left overflow-hidden min-w-0 flex-1",children:[h.jsx(kh,{className:"w-4 h-4 shrink-0 text-muted-foreground"}),h.jsxs("div",{className:"overflow-hidden min-w-0 flex-1",children:[h.jsxs("span",{className:"text-xs text-muted-foreground font-mono block",children:["#",it.id]}),h.jsx("p",{className:"truncate text-sm",children:it.title})]})]}):h.jsx("span",{className:"text-muted-foreground",children:"Select parent task..."}),h.jsx(TE,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),h.jsx(Qh,{className:"w-[400px] p-0",align:"start",children:h.jsxs(Jh,{children:[h.jsx(em,{placeholder:"Search tasks..."}),h.jsxs(tm,{children:[h.jsx(nm,{children:"No task found."}),h.jsxs(sl,{children:[h.jsxs(ns,{value:"none",onSelect:()=>{D(""),pe(!1)},children:[h.jsx(lo,{className:Ee("mr-2 h-4 w-4 shrink-0",R?"opacity-0":"opacity-100")}),h.jsx("span",{className:"text-muted-foreground",children:"None"})]}),t.map(W=>h.jsxs(ns,{value:`${W.id} ${W.title}`,onSelect:()=>{D(W.id),pe(!1)},title:`#${W.id} - ${W.title}`,children:[h.jsx(lo,{className:Ee("mr-2 h-4 w-4 shrink-0",R===W.id?"opacity-100":"opacity-0")}),h.jsxs("div",{className:"overflow-hidden min-w-0 flex-1",children:[h.jsxs("span",{className:"text-xs text-muted-foreground font-mono block",children:["#",W.id]}),h.jsx("p",{className:"truncate text-sm",children:W.title})]})]},W.id))]})]})]})})]})]})]}),je=h.jsxs("div",{className:"border-t px-6 py-4 bg-muted/30 flex justify-end gap-3",children:[h.jsx(Le,{type:"button",variant:"ghost",onClick:n,disabled:j,children:"Cancel"}),h.jsx(Le,{type:"button",onClick:bt,className:"bg-green-700 hover:bg-green-800 text-white",disabled:j||X||!u.trim(),children:j?"Creating...":"Create Task"})]});return Ce?h.jsx(_E,{children:e&&h.jsx(JO,{open:e,onOpenChange:W=>!W&&n(),children:h.jsxs(YS,{className:"max-w-6xl w-[95vw] h-[90vh] p-0 gap-0 overflow-hidden flex flex-col",hideCloseButton:!0,children:[h.jsx(eM,{className:"sr-only",children:"Create New Task"}),h.jsxs(OE.div,{ref:a,className:"flex flex-col h-full overflow-hidden",variants:de,initial:"hidden",animate:"visible",exit:"exit",children:[te,fe,h.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[h.jsx(Xr,{className:"flex-1",children:ge}),h.jsx("div",{className:"shrink-0 w-72 border-l bg-muted/20",children:h.jsx(Xr,{className:"h-full",children:Pe})})]}),je]})]})})}):h.jsx(_E,{children:e&&h.jsx(XO,{open:e,onOpenChange:W=>!W&&n(),children:h.jsx(qS,{side:"right",className:"w-full sm:max-w-2xl lg:max-w-3xl xl:max-w-4xl p-0 flex flex-col gap-0",hideCloseButton:!0,children:h.jsxs(OE.div,{ref:a,className:"flex flex-col h-full overflow-hidden",variants:de,initial:"hidden",animate:"visible",exit:"exit",children:[te,fe,h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[h.jsx("div",{className:"shrink-0 border-b bg-muted/20",children:h.jsxs("div",{className:"p-4 space-y-3",children:[h.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Status"}),h.jsxs(ri,{value:y,onValueChange:W=>v(W),disabled:j,children:[h.jsx(zo,{className:Ee("w-full h-9",Dh(y,c)),children:h.jsx(oi,{})}),h.jsx(Vo,{children:l.map(W=>h.jsx(En,{value:W.value,children:W.label},W.value))})]})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Priority"}),h.jsxs(ri,{value:w,onValueChange:W=>S(W),disabled:j,children:[h.jsx(zo,{className:Ee("w-full h-9",dK[w]),children:h.jsx(oi,{})}),h.jsx(Vo,{children:uK.map(W=>h.jsx(En,{value:W.value,children:W.label},W.value))})]})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Assignee"}),h.jsx(SS,{value:T,onChange:k,showGrabButton:!1,currentUser:o,container:a.current})]})]}),h.jsxs("div",{className:"flex items-start gap-4 flex-wrap",children:[h.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground shrink-0",children:"Labels:"}),h.jsxs("div",{className:"flex flex-wrap gap-1 flex-1",children:[I.map(W=>h.jsxs(fc,{variant:"secondary",className:"gap-1 pr-1 text-xs",children:[W,h.jsx("button",{type:"button",onClick:()=>cn(W),className:"ml-0.5 hover:text-destructive",children:h.jsx(ti,{className:"w-3 h-3"})})]},W)),!ie&&h.jsxs(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground",onClick:()=>ne(!0),children:[h.jsx(Go,{className:"w-3 h-3 mr-1"}),"Add"]})]}),ie&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{value:le,onChange:W=>ae(W.target.value),onKeyDown:W=>{W.key==="Enter"&&le.trim()&&Ie(),W.key==="Escape"&&(ae(""),ne(!1))},placeholder:"Label",className:"h-7 w-24 text-xs",autoFocus:!0}),h.jsx(Le,{size:"sm",className:"h-7 px-2",onClick:Ie,disabled:!le.trim(),children:"Add"}),h.jsx(Le,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>{ae(""),ne(!1)},children:h.jsx(ti,{className:"w-3 h-3"})})]})]}),h.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[h.jsx(Xt,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground shrink-0",children:"Parent:"}),h.jsxs(Q0,{open:se,onOpenChange:pe,children:[h.jsx(J0,{asChild:!0,children:h.jsxs(Le,{variant:"outline",role:"combobox",size:"sm",className:"h-7 justify-between min-w-[120px] max-w-[250px]",disabled:j,title:it?`#${it.id} - ${it.title}`:void 0,children:[it?h.jsxs("span",{className:"truncate text-xs",children:["#",it.id," - ",it.title]}):h.jsx("span",{className:"text-muted-foreground text-xs",children:"None"}),h.jsx(TE,{className:"ml-1 h-3 w-3 shrink-0 opacity-50"})]})}),h.jsx(Qh,{className:"w-[400px] p-0",align:"end",children:h.jsxs(Jh,{children:[h.jsx(em,{placeholder:"Search tasks..."}),h.jsxs(tm,{children:[h.jsx(nm,{children:"No task found."}),h.jsxs(sl,{children:[h.jsxs(ns,{value:"none",onSelect:()=>{D(""),pe(!1)},children:[h.jsx(lo,{className:Ee("mr-2 h-4 w-4 shrink-0",R?"opacity-0":"opacity-100")}),h.jsx("span",{className:"text-muted-foreground",children:"None"})]}),t.map(W=>h.jsxs(ns,{value:`${W.id} ${W.title}`,onSelect:()=>{D(W.id),pe(!1)},title:`#${W.id} - ${W.title}`,children:[h.jsx(lo,{className:Ee("mr-2 h-4 w-4 shrink-0",R===W.id?"opacity-100":"opacity-0")}),h.jsxs("div",{className:"overflow-hidden min-w-0 flex-1",children:[h.jsxs("span",{className:"text-xs text-muted-foreground font-mono block",children:["#",W.id]}),h.jsx("p",{className:"truncate text-sm",children:W.title})]})]},W.id))]})]})]})})]})]})]})]})}),h.jsx(Xr,{className:"flex-1",children:ge})]}),je]})})})})}const cpt="/assets/logo-BkDQ9x4a.png",upt="sidebar_state",dpt=3600*24*7,fpt="16rem",ppt="18rem",hpt="3rem",mpt="b",Vfe=x.createContext(null);function b1(){const e=x.useContext(Vfe);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Gfe=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:i,...s},a)=>{const l=ek(),[c,u]=x.useState(!1),[f,m]=x.useState(e),g=t??f,y=x.useCallback(T=>{const k=typeof T=="function"?T(g):T;n?n(k):m(k),document.cookie=`${upt}=${k}; path=/; max-age=${dpt}`},[n,g]),v=x.useCallback(()=>l?u(T=>!T):y(T=>!T),[l,y,u]);x.useEffect(()=>{const T=k=>{k.key===mpt&&(k.metaKey||k.ctrlKey)&&(k.preventDefault(),v())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[v]);const w=g?"expanded":"collapsed",S=x.useMemo(()=>({state:w,open:g,setOpen:y,isMobile:l,openMobile:c,setOpenMobile:u,toggleSidebar:v}),[w,g,y,l,c,u,v]);return h.jsx(Vfe.Provider,{value:S,children:h.jsx(Fde,{delayDuration:0,children:h.jsx("div",{style:{"--sidebar-width":fpt,"--sidebar-width-icon":hpt,...o},className:Ee("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:a,...s,children:i})})})});Gfe.displayName="SidebarProvider";const Wfe=x.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:o,...i},s)=>{const{isMobile:a,state:l,openMobile:c,setOpenMobile:u}=b1();return n==="none"?h.jsx("div",{className:Ee("flex h-full w-[var(--sidebar-width)] flex-col bg-sidebar text-sidebar-foreground",r),ref:s,...i,children:o}):a?h.jsx(XO,{open:c,onOpenChange:u,...i,children:h.jsxs(qS,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[var(--sidebar-width)] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":ppt},side:e,children:[h.jsxs(ZO,{className:"sr-only",children:[h.jsx(QO,{children:"Sidebar"}),h.jsx(pQ,{children:"Displays the mobile sidebar."})]}),h.jsx("div",{className:"flex h-full w-full flex-col",children:o})]})}):h.jsxs("div",{ref:s,className:"group peer hidden text-sidebar-foreground md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,children:[h.jsx("div",{className:Ee("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),h.jsx("div",{className:Ee("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...i,children:h.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});Wfe.displayName="Sidebar";const qfe=x.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=b1();return h.jsxs(Le,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Ee("h-7 w-7",e),onClick:i=>{t?.(i),o()},...n,children:[h.jsx(v0e,{}),h.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});qfe.displayName="SidebarTrigger";const Yfe=x.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=b1();return h.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Ee("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});Yfe.displayName="SidebarRail";const gpt=x.forwardRef(({className:e,...t},n)=>h.jsx("main",{ref:n,className:Ee("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));gpt.displayName="SidebarInset";const bpt=x.forwardRef(({className:e,...t},n)=>h.jsx(Gn,{ref:n,"data-sidebar":"input",className:Ee("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));bpt.displayName="SidebarInput";const Kfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"header",className:Ee("flex flex-col gap-2 p-2",e),...t}));Kfe.displayName="SidebarHeader";const Xfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"footer",className:Ee("flex flex-col gap-2 p-2",e),...t}));Xfe.displayName="SidebarFooter";const ypt=x.forwardRef(({className:e,...t},n)=>h.jsx(ny,{ref:n,"data-sidebar":"separator",className:Ee("mx-2 w-auto bg-sidebar-border",e),...t}));ypt.displayName="SidebarSeparator";const Zfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"content",className:Ee("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Zfe.displayName="SidebarContent";const Qfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"group",className:Ee("relative flex w-full min-w-0 flex-col p-2",e),...t}));Qfe.displayName="SidebarGroup";const Jfe=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Ku:"div";return h.jsx(o,{ref:r,"data-sidebar":"group-label",className:Ee("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});Jfe.displayName="SidebarGroupLabel";const xpt=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Ku:"button";return h.jsx(o,{ref:r,"data-sidebar":"group-action",className:Ee("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});xpt.displayName="SidebarGroupAction";const epe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"group-content",className:Ee("w-full text-sm",e),...t}));epe.displayName="SidebarGroupContent";const EE=x.forwardRef(({className:e,...t},n)=>h.jsx("ul",{ref:n,"data-sidebar":"menu",className:Ee("flex w-full min-w-0 flex-col gap-1",e),...t}));EE.displayName="SidebarMenu";const wE=x.forwardRef(({className:e,...t},n)=>h.jsx("li",{ref:n,"data-sidebar":"menu-item",className:Ee("group/menu-item relative",e),...t}));wE.displayName="SidebarMenuItem";const vpt=Xs("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),SE=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:i,...s},a)=>{const l=e?Ku:"button",{isMobile:c,state:u}=b1(),f=h.jsx(l,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:Ee(vpt({variant:n,size:r}),i),...s});return o?(typeof o=="string"&&(o={children:o}),h.jsxs(Bde,{children:[h.jsx(jde,{asChild:!0,children:f}),h.jsx(mB,{side:"right",align:"center",hidden:u!=="collapsed"||c,...o})]})):f});SE.displayName="SidebarMenuButton";const Ept=x.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const i=t?Ku:"button";return h.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Ee("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});Ept.displayName="SidebarMenuAction";const wpt=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:Ee("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));wpt.displayName="SidebarMenuBadge";const Spt=x.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const o=x.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return h.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Ee("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&h.jsx(fY,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),h.jsx(fY,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});Spt.displayName="SidebarMenuSkeleton";const Cpt=x.forwardRef(({className:e,...t},n)=>h.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:Ee("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Cpt.displayName="SidebarMenuSub";const Tpt=x.forwardRef(({...e},t)=>h.jsx("li",{ref:t,...e}));Tpt.displayName="SidebarMenuSubItem";const kpt=x.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},i)=>{const s=e?Ku:"a";return h.jsx(s,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:Ee("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...o})});kpt.displayName="SidebarMenuSubButton";const Apt=[{id:"kanban",label:"Kanban",icon:r0e,href:"#/"},{id:"tasks",label:"Tasks",icon:FK,href:"#/tasks"},{id:"docs",label:"Docs",icon:Br,href:"#/docs"},{id:"templates",label:"Templates",icon:Md,href:"#/templates"},{id:"imports",label:"Imports",icon:Ah,href:"#/imports"}];function Npt({currentPage:e,onSearchClick:t}){const{state:n}=b1(),r=ek(),o=n==="expanded";return h.jsxs(Wfe,{collapsible:"icon",variant:r?"floating":"sidebar",children:[h.jsxs(Kfe,{children:[h.jsx(EE,{children:h.jsx(wE,{children:h.jsx(SE,{size:"lg",asChild:!0,children:h.jsxs("a",{href:"#/",children:[h.jsx("img",{src:cpt,alt:"Knowns",className:"size-8 rounded-lg object-contain"}),h.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[h.jsx("span",{className:"truncate font-semibold",children:"Knowns"}),h.jsx("span",{className:"truncate text-xs",children:"AI-ready task management"})]})]})})})}),o&&h.jsx("div",{className:"px-2 pb-2",children:h.jsxs("button",{type:"button",onClick:t,className:"flex w-full items-center gap-2 rounded-lg border bg-background px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",children:[h.jsx(PS,{className:"h-4 w-4"}),h.jsx("span",{children:"Search..."}),h.jsxs("kbd",{className:"ml-auto pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100",children:[h.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]})})]}),h.jsx(Zfe,{children:h.jsxs(Qfe,{children:[h.jsx(Jfe,{children:"Navigation"}),h.jsx(epe,{children:h.jsx(EE,{children:Apt.map(i=>{const s=e===i.id;return h.jsx(wE,{children:h.jsx(SE,{asChild:!0,isActive:s,tooltip:i.label,children:h.jsxs("a",{href:i.href,children:[h.jsx(i.icon,{}),h.jsx("span",{children:i.label})]})})},i.id)})})})]})}),h.jsxs(Xfe,{children:[h.jsx(EE,{children:h.jsx(wE,{children:h.jsx(SE,{asChild:!0,isActive:e==="config",tooltip:"Settings",children:h.jsxs("a",{href:"#/config",children:[h.jsx(cO,{}),h.jsx("span",{children:"Settings"})]})})})}),o&&h.jsx("div",{className:"px-3 py-2 text-xs text-sidebar-foreground/50",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("a",{href:"https://github.com/knowns-dev/knowns",target:"_blank",rel:"noopener noreferrer",className:"hover:text-sidebar-foreground transition-colors",children:"Knowns"}),h.jsx("span",{className:"font-mono",children:"0.10.6"})]})})]}),h.jsx(Yfe,{})]})}const _pt=[{value:"all",label:"All"},{value:"status",label:"Status"},{value:"assignee",label:"Assignee"},{value:"content",label:"Content"}];function Rpt(e){const t=e.changes;if(t.length===0)return"Updated";const n=t.find(s=>s.field==="status");if(n){const s=String(n.newValue);return s==="done"?"Completed":s==="in-progress"?"Started working on":s==="in-review"?"Submitted for review":s==="blocked"?"Blocked":`Changed status to ${s}`}const r=t.find(s=>s.field==="assignee");if(r){const s=r.newValue;return s?`Assigned to ${s}`:"Unassigned"}if(t.find(s=>s.field==="title"))return"Updated title";const i=t.find(s=>s.field==="priority");return i?`Set priority to ${i.newValue}`:t.some(s=>s.field==="description")?"Updated description":t.some(s=>s.field==="acceptanceCriteria")?"Updated acceptance criteria":t.some(s=>s.field==="implementationPlan")?"Updated plan":t.some(s=>s.field==="implementationNotes")?"Updated notes":t.some(s=>s.field==="labels")?"Updated labels":`Updated ${t.length} field(s)`}function Dpt(e){const n=new Date().getTime()-e.getTime(),r=Math.floor(n/6e4),o=Math.floor(n/36e5),i=Math.floor(n/864e5);return r<1?"just now":r<60?`${r}m ago`:o<24?`${o}h ago`:i<7?`${i}d ago`:e.toLocaleDateString()}function Ipt(e){return e.some(t=>t.field==="status"&&t.newValue==="done")?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":e.some(t=>t.field==="status"&&t.newValue==="in-progress")?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":e.some(t=>t.field==="status"&&t.newValue==="blocked")?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":e.some(t=>t.field==="assignee")?"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400":"bg-muted text-muted-foreground"}function Opt({limit:e=20,showFilter:t=!0,onTaskClick:n}){const[r,o]=x.useState([]),[i,s]=x.useState(!0),[a,l]=x.useState("all"),[c,u]=x.useState(!1),f=x.useCallback(async()=>{try{const y=a==="all"?void 0:a,v=await ma.getActivities({limit:e,type:y});o(v)}catch(y){console.error("Failed to load activities:",y)}finally{s(!1),u(!1)}},[e,a]);x.useEffect(()=>{f()},[f]),rs("tasks:updated",()=>{f()},[f]);const m=()=>{u(!0),f()},g=y=>{n?n(y):window.location.hash=`/kanban/${y}`};return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(J9,{className:"w-5 h-5"}),h.jsx("h3",{className:"font-semibold",children:"Recent Activity"})]}),h.jsx(Le,{variant:"ghost",size:"icon",onClick:m,disabled:c,className:"h-8 w-8",children:h.jsx(n0,{className:`w-4 h-4 ${c?"animate-spin":""}`})})]}),t&&h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(lO,{className:"w-4 h-4 text-muted-foreground"}),h.jsx("select",{value:a,onChange:y=>l(y.target.value),className:"text-sm rounded px-2 py-1 bg-card border flex-1",children:_pt.map(y=>h.jsx("option",{value:y.value,children:y.label},y.value))})]}),h.jsx(Xr,{className:"flex-1",children:h.jsx("div",{className:"space-y-1.5 pr-3",children:i?h.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"Loading activities..."}):r.length===0?h.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"No recent activity"}):r.map((y,v)=>h.jsx("div",{role:"button",tabIndex:0,onClick:w=>{w.preventDefault(),w.stopPropagation(),g(y.taskId)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),g(y.taskId))},className:"w-full bg-card rounded p-2 text-left hover:bg-accent transition-colors border cursor-pointer select-none",children:h.jsxs("div",{className:"flex items-center gap-2",children:[y.author?h.jsx(ry,{name:y.author,size:"xs"}):h.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${Ipt(y.changes)}`,children:h.jsx(J9,{className:"w-2.5 h-2.5"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"text-xs font-medium truncate",children:Rpt(y)}),h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Dpt(y.timestamp)})]}),h.jsxs("div",{className:"text-[11px] text-muted-foreground truncate",children:[h.jsxs("span",{className:"font-medium",children:["#",y.taskId]})," ",y.taskTitle]})]})]})},`${y.taskId}-${y.version}-${v}`))})})]})}function Mpt(){const[e,t]=x.useState(!1),[n,r]=x.useState(!1),[o,i]=x.useState(()=>{const l=localStorage.getItem("knowns-last-activity-check");return l?new Date(l):new Date}),s=x.useCallback(async()=>{try{const l=await ma.getActivities({limit:1});l.length>0&&new Date(l[0].timestamp)>o&&t(!0)}catch(l){console.error("Failed to check activities:",l)}},[o]);x.useEffect(()=>{s()},[s]),rs("tasks:updated",()=>{n||t(!0)},[n]);const a=l=>{if(r(l),l){t(!1);const c=new Date;i(c),localStorage.setItem("knowns-last-activity-check",c.toISOString())}};return h.jsxs(Q0,{open:n,onOpenChange:a,children:[h.jsx(J0,{asChild:!0,children:h.jsxs(Le,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Notifications",children:[h.jsx(lbe,{className:"h-4 w-4"}),e&&h.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-blue-500 animate-pulse"})]})}),h.jsx(Qh,{className:"w-80 p-0",align:"end",sideOffset:8,children:h.jsxs("div",{className:"flex flex-col h-[400px]",children:[h.jsx("div",{className:"px-4 py-3 border-b",children:h.jsx("h3",{className:"font-semibold text-sm",children:"Recent Activity"})}),h.jsx("div",{className:"flex-1 overflow-hidden p-2",children:h.jsx(Opt,{limit:20,showFilter:!1,onTaskClick:l=>{r(!1),window.location.hash=`/kanban/${l}`}})})]})})]})}const fK={todo:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300","in-progress":"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300","in-review":"bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-300",done:"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300",blocked:"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300","on-hold":"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300"},Lpt={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold"};function Ppt({open:e,onOpenChange:t,onTaskSelect:n,onDocSelect:r}){const[o,i]=x.useState(""),[s,a]=x.useState({tasks:[],docs:[]}),[l,c]=x.useState(!1);x.useEffect(()=>{if(!e){i(""),a({tasks:[],docs:[]});return}if(!o.trim()){a({tasks:[],docs:[]});return}c(!0);const m=setTimeout(()=>{fetch(`/api/search?q=${encodeURIComponent(o)}`).then(g=>g.json()).then(g=>{a({tasks:g.tasks||[],docs:g.docs||[]})}).catch(g=>{console.error("Search failed:",g),a({tasks:[],docs:[]})}).finally(()=>{c(!1)})},300);return()=>clearTimeout(m)},[o,e]);const u=m=>{n(m),t(!1),i("")},f=m=>{r(m),t(!1),i("")};return h.jsx(JO,{open:e,onOpenChange:t,children:h.jsx(YS,{className:"overflow-hidden p-0 max-w-2xl",hideClose:!0,children:h.jsxs(Jh,{shouldFilter:!1,children:[h.jsx(em,{placeholder:"Search tasks and docs...",value:o,onValueChange:i}),h.jsxs(tm,{children:[h.jsx(nm,{children:l?"Searching...":o?"No results found.":"Type to search..."}),s.tasks.length>0&&h.jsx(sl,{heading:"Tasks",children:s.tasks.slice(0,8).map(m=>{const g=fK[m.status]||fK.todo,y=Lpt[m.status]||m.status;return h.jsxs(ns,{value:`task-${m.id}`,onSelect:()=>u(m),children:[h.jsx(FK,{className:"mr-2 h-4 w-4 shrink-0"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["#",m.id]}),h.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${g}`,children:y})]}),h.jsx("div",{className:"font-medium truncate",children:m.title})]})]},m.id)})}),s.tasks.length>0&&s.docs.length>0&&h.jsx(vS,{}),s.docs.length>0&&h.jsx(sl,{heading:"Documentation",children:s.docs.slice(0,8).map(m=>{const g=m.metadata?.title||m.filename;return h.jsxs(ns,{value:`doc-${m.path}`,onSelect:()=>f(m),children:[h.jsx(Br,{className:"mr-2 h-4 w-4 shrink-0"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"font-medium truncate mb-1",children:g}),h.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:h.jsx("span",{className:"truncate",children:m.path})})]})]},m.path)})})]})]})})})}function vu(e,t){return typeof e=="function"?e(t):e}function ds(e,t){return n=>{t.setState(r=>({...r,[e]:vu(n,r[e])}))}}function tk(e){return e instanceof Function}function Fpt(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function Bpt(e,t){const n=[],r=o=>{o.forEach(i=>{n.push(i);const s=t(i);s!=null&&s.length&&r(s)})};return r(e),n}function ft(e,t,n){let r=[],o;return i=>{let s;n.key&&n.debug&&(s=Date.now());const a=e(i);if(!(a.length!==r.length||a.some((u,f)=>r[f]!==u)))return o;r=a;let c;if(n.key&&n.debug&&(c=Date.now()),o=t(...a),n==null||n.onChange==null||n.onChange(o),n.key&&n.debug&&n!=null&&n.debug()){const u=Math.round((Date.now()-s)*100)/100,f=Math.round((Date.now()-c)*100)/100,m=f/16,g=(y,v)=>{for(y=String(y);y.length<v;)y=" "+y;return y};console.info(`%c⏱ ${g(f,5)} /${g(u,5)} ms`,`
315
315
  font-size: .6rem;
316
316
  font-weight: bold;
317
317
  color: hsl(${Math.max(0,Math.min(120-120*m,120))}deg 100% 31%);`,n?.key)}return o}}function pt(e,t,n,r){return{debug:()=>{var o;return(o=e?.debugAll)!=null?o:e[t]},key:!1,onChange:r}}function jpt(e,t,n,r){const o=()=>{var s;return(s=i.getValue())!=null?s:e.options.renderFallbackValue},i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:o,getContext:ft(()=>[e,n,t,i],(s,a,l,c)=>({table:s,column:a,row:l,cell:c,getValue:c.getValue,renderValue:c.renderValue}),pt(e.options,"debugCells"))};return e._features.forEach(s=>{s.createCell==null||s.createCell(i,n,t,e)},{}),i}function $pt(e,t,n,r){var o,i;const a={...e._getDefaultColumnDef(),...t},l=a.accessorKey;let c=(o=(i=a.id)!=null?i:l?typeof String.prototype.replaceAll=="function"?l.replaceAll(".","_"):l.replace(/\./g,"_"):void 0)!=null?o:typeof a.header=="string"?a.header:void 0,u;if(a.accessorFn?u=a.accessorFn:l&&(l.includes(".")?u=m=>{let g=m;for(const v of l.split(".")){var y;g=(y=g)==null?void 0:y[v]}return g}:u=m=>m[a.accessorKey]),!c)throw new Error;let f={id:`${String(c)}`,accessorFn:u,parent:r,depth:n,columnDef:a,columns:[],getFlatColumns:ft(()=>[!0],()=>{var m;return[f,...(m=f.columns)==null?void 0:m.flatMap(g=>g.getFlatColumns())]},pt(e.options,"debugColumns")),getLeafColumns:ft(()=>[e._getOrderColumnsFn()],m=>{var g;if((g=f.columns)!=null&&g.length){let y=f.columns.flatMap(v=>v.getLeafColumns());return m(y)}return[f]},pt(e.options,"debugColumns"))};for(const m of e._features)m.createColumn==null||m.createColumn(f,e);return f}const Bo="debugHeaders";function pK(e,t,n){var r;let i={id:(r=n.id)!=null?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const s=[],a=l=>{l.subHeaders&&l.subHeaders.length&&l.subHeaders.map(a),s.push(l)};return a(i),s},getContext:()=>({table:e,header:i,column:t})};return e._features.forEach(s=>{s.createHeader==null||s.createHeader(i,e)}),i}const Upt={createTable:e=>{e.getHeaderGroups=ft(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,o)=>{var i,s;const a=(i=r?.map(f=>n.find(m=>m.id===f)).filter(Boolean))!=null?i:[],l=(s=o?.map(f=>n.find(m=>m.id===f)).filter(Boolean))!=null?s:[],c=n.filter(f=>!(r!=null&&r.includes(f.id))&&!(o!=null&&o.includes(f.id)));return Mv(t,[...a,...c,...l],e)},pt(e.options,Bo)),e.getCenterHeaderGroups=ft(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,o)=>(n=n.filter(i=>!(r!=null&&r.includes(i.id))&&!(o!=null&&o.includes(i.id))),Mv(t,n,e,"center")),pt(e.options,Bo)),e.getLeftHeaderGroups=ft(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var o;const i=(o=r?.map(s=>n.find(a=>a.id===s)).filter(Boolean))!=null?o:[];return Mv(t,i,e,"left")},pt(e.options,Bo)),e.getRightHeaderGroups=ft(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var o;const i=(o=r?.map(s=>n.find(a=>a.id===s)).filter(Boolean))!=null?o:[];return Mv(t,i,e,"right")},pt(e.options,Bo)),e.getFooterGroups=ft(()=>[e.getHeaderGroups()],t=>[...t].reverse(),pt(e.options,Bo)),e.getLeftFooterGroups=ft(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),pt(e.options,Bo)),e.getCenterFooterGroups=ft(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),pt(e.options,Bo)),e.getRightFooterGroups=ft(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),pt(e.options,Bo)),e.getFlatHeaders=ft(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,Bo)),e.getLeftFlatHeaders=ft(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,Bo)),e.getCenterFlatHeaders=ft(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,Bo)),e.getRightFlatHeaders=ft(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,Bo)),e.getCenterLeafHeaders=ft(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),pt(e.options,Bo)),e.getLeftLeafHeaders=ft(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),pt(e.options,Bo)),e.getRightLeafHeaders=ft(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),pt(e.options,Bo)),e.getLeafHeaders=ft(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,r)=>{var o,i,s,a,l,c;return[...(o=(i=t[0])==null?void 0:i.headers)!=null?o:[],...(s=(a=n[0])==null?void 0:a.headers)!=null?s:[],...(l=(c=r[0])==null?void 0:c.headers)!=null?l:[]].map(u=>u.getLeafHeaders()).flat()},pt(e.options,Bo))}};function Mv(e,t,n,r){var o,i;let s=0;const a=function(m,g){g===void 0&&(g=1),s=Math.max(s,g),m.filter(y=>y.getIsVisible()).forEach(y=>{var v;(v=y.columns)!=null&&v.length&&a(y.columns,g+1)},0)};a(e);let l=[];const c=(m,g)=>{const y={depth:g,id:[r,`${g}`].filter(Boolean).join("_"),headers:[]},v=[];m.forEach(w=>{const S=[...v].reverse()[0],T=w.column.depth===y.depth;let k,I=!1;if(T&&w.column.parent?k=w.column.parent:(k=w.column,I=!0),S&&S?.column===k)S.subHeaders.push(w);else{const _=pK(n,k,{id:[r,g,k.id,w?.id].filter(Boolean).join("_"),isPlaceholder:I,placeholderId:I?`${v.filter(R=>R.column===k).length}`:void 0,depth:g,index:v.length});_.subHeaders.push(w),v.push(_)}y.headers.push(w),w.headerGroup=y}),l.push(y),g>0&&c(v,g-1)},u=t.map((m,g)=>pK(n,m,{depth:s,index:g}));c(u,s-1),l.reverse();const f=m=>m.filter(y=>y.column.getIsVisible()).map(y=>{let v=0,w=0,S=[0];y.subHeaders&&y.subHeaders.length?(S=[],f(y.subHeaders).forEach(k=>{let{colSpan:I,rowSpan:_}=k;v+=I,S.push(_)})):v=1;const T=Math.min(...S);return w=w+T,y.colSpan=v,y.rowSpan=w,{colSpan:v,rowSpan:w}});return f((o=(i=l[0])==null?void 0:i.headers)!=null?o:[]),l}const HB=(e,t,n,r,o,i,s)=>{let a={id:t,index:r,original:n,depth:o,parentId:s,_valuesCache:{},_uniqueValuesCache:{},getValue:l=>{if(a._valuesCache.hasOwnProperty(l))return a._valuesCache[l];const c=e.getColumn(l);if(c!=null&&c.accessorFn)return a._valuesCache[l]=c.accessorFn(a.original,r),a._valuesCache[l]},getUniqueValues:l=>{if(a._uniqueValuesCache.hasOwnProperty(l))return a._uniqueValuesCache[l];const c=e.getColumn(l);if(c!=null&&c.accessorFn)return c.columnDef.getUniqueValues?(a._uniqueValuesCache[l]=c.columnDef.getUniqueValues(a.original,r),a._uniqueValuesCache[l]):(a._uniqueValuesCache[l]=[a.getValue(l)],a._uniqueValuesCache[l])},renderValue:l=>{var c;return(c=a.getValue(l))!=null?c:e.options.renderFallbackValue},subRows:[],getLeafRows:()=>Bpt(a.subRows,l=>l.subRows),getParentRow:()=>a.parentId?e.getRow(a.parentId,!0):void 0,getParentRows:()=>{let l=[],c=a;for(;;){const u=c.getParentRow();if(!u)break;l.push(u),c=u}return l.reverse()},getAllCells:ft(()=>[e.getAllLeafColumns()],l=>l.map(c=>jpt(e,a,c,c.id)),pt(e.options,"debugRows")),_getAllCellsByColumnId:ft(()=>[a.getAllCells()],l=>l.reduce((c,u)=>(c[u.column.id]=u,c),{}),pt(e.options,"debugRows"))};for(let l=0;l<e._features.length;l++){const c=e._features[l];c==null||c.createRow==null||c.createRow(a,e)}return a},Hpt={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},tpe=(e,t,n)=>{var r,o;const i=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((o=e.getValue(t))==null||(o=o.toString())==null||(o=o.toLowerCase())==null)&&o.includes(i))};tpe.autoRemove=e=>va(e);const npe=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};npe.autoRemove=e=>va(e);const rpe=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};rpe.autoRemove=e=>va(e);const ope=(e,t,n)=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(n)};ope.autoRemove=e=>va(e);const ipe=(e,t,n)=>!n.some(r=>{var o;return!((o=e.getValue(t))!=null&&o.includes(r))});ipe.autoRemove=e=>va(e)||!(e!=null&&e.length);const spe=(e,t,n)=>n.some(r=>{var o;return(o=e.getValue(t))==null?void 0:o.includes(r)});spe.autoRemove=e=>va(e)||!(e!=null&&e.length);const ape=(e,t,n)=>e.getValue(t)===n;ape.autoRemove=e=>va(e);const lpe=(e,t,n)=>e.getValue(t)==n;lpe.autoRemove=e=>va(e);const zB=(e,t,n)=>{let[r,o]=n;const i=e.getValue(t);return i>=r&&i<=o};zB.resolveFilterValue=e=>{let[t,n]=e,r=typeof t!="number"?parseFloat(t):t,o=typeof n!="number"?parseFloat(n):n,i=t===null||Number.isNaN(r)?-1/0:r,s=n===null||Number.isNaN(o)?1/0:o;if(i>s){const a=i;i=s,s=a}return[i,s]};zB.autoRemove=e=>va(e)||va(e[0])&&va(e[1]);const Ql={includesString:tpe,includesStringSensitive:npe,equalsString:rpe,arrIncludes:ope,arrIncludesAll:ipe,arrIncludesSome:spe,equals:ape,weakEquals:lpe,inNumberRange:zB};function va(e){return e==null||e===""}const zpt={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:ds("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{const n=t.getCoreRowModel().flatRows[0],r=n?.getValue(e.id);return typeof r=="string"?Ql.includesString:typeof r=="number"?Ql.inNumberRange:typeof r=="boolean"||r!==null&&typeof r=="object"?Ql.equals:Array.isArray(r)?Ql.arrIncludes:Ql.weakEquals},e.getFilterFn=()=>{var n,r;return tk(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(r=t.options.filterFns)==null?void 0:r[e.columnDef.filterFn])!=null?n:Ql[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,r,o;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((r=t.options.enableColumnFilters)!=null?r:!0)&&((o=t.options.enableFilters)!=null?o:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(r=>r.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>{var n,r;return(n=(r=t.getState().columnFilters)==null?void 0:r.findIndex(o=>o.id===e.id))!=null?n:-1},e.setFilterValue=n=>{t.setColumnFilters(r=>{const o=e.getFilterFn(),i=r?.find(u=>u.id===e.id),s=vu(n,i?i.value:void 0);if(hK(o,s,e)){var a;return(a=r?.filter(u=>u.id!==e.id))!=null?a:[]}const l={id:e.id,value:s};if(i){var c;return(c=r?.map(u=>u.id===e.id?l:u))!=null?c:[]}return r!=null&&r.length?[...r,l]:[l]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{const n=e.getAllLeafColumns(),r=o=>{var i;return(i=vu(t,o))==null?void 0:i.filter(s=>{const a=n.find(l=>l.id===s.id);if(a){const l=a.getFilterFn();if(hK(l,s.value,a))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(r)},e.resetColumnFilters=t=>{var n,r;e.setColumnFilters(t?[]:(n=(r=e.initialState)==null?void 0:r.columnFilters)!=null?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function hK(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const Vpt=(e,t,n)=>n.reduce((r,o)=>{const i=o.getValue(e);return r+(typeof i=="number"?i:0)},0),Gpt=(e,t,n)=>{let r;return n.forEach(o=>{const i=o.getValue(e);i!=null&&(r>i||r===void 0&&i>=i)&&(r=i)}),r},Wpt=(e,t,n)=>{let r;return n.forEach(o=>{const i=o.getValue(e);i!=null&&(r<i||r===void 0&&i>=i)&&(r=i)}),r},qpt=(e,t,n)=>{let r,o;return n.forEach(i=>{const s=i.getValue(e);s!=null&&(r===void 0?s>=s&&(r=o=s):(r>s&&(r=s),o<s&&(o=s)))}),[r,o]},Ypt=(e,t)=>{let n=0,r=0;if(t.forEach(o=>{let i=o.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},Kpt=(e,t)=>{if(!t.length)return;const n=t.map(i=>i.getValue(e));if(!Fpt(n))return;if(n.length===1)return n[0];const r=Math.floor(n.length/2),o=n.sort((i,s)=>i-s);return n.length%2!==0?o[r]:(o[r-1]+o[r])/2},Xpt=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),Zpt=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,Qpt=(e,t)=>t.length,J_={sum:Vpt,min:Gpt,max:Wpt,extent:qpt,mean:Ypt,median:Kpt,unique:Xpt,uniqueCount:Zpt,count:Qpt},Jpt={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:ds("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(r=>r!==e.id):[...n??[],e.id])},e.getCanGroup=()=>{var n,r;return((n=e.columnDef.enableGrouping)!=null?n:!0)&&((r=t.options.enableGrouping)!=null?r:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const n=t.getCoreRowModel().flatRows[0],r=n?.getValue(e.id);if(typeof r=="number")return J_.sum;if(Object.prototype.toString.call(r)==="[object Date]")return J_.extent},e.getAggregationFn=()=>{var n,r;if(!e)throw new Error;return tk(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(r=t.options.aggregationFns)==null?void 0:r[e.columnDef.aggregationFn])!=null?n:J_[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,r;e.setGrouping(t?[]:(n=(r=e.initialState)==null?void 0:r.grouping)!=null?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];const r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var o;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((o=n.subRows)!=null&&o.length)}}};function eht(e,t,n){if(!(t!=null&&t.length)||!n)return e;const r=e.filter(i=>!t.includes(i.id));return n==="remove"?r:[...t.map(i=>e.find(s=>s.id===i)).filter(Boolean),...r]}const tht={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:ds("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=ft(n=>[Qb(t,n)],n=>n.findIndex(r=>r.id===e.id),pt(t.options,"debugColumns")),e.getIsFirstColumn=n=>{var r;return((r=Qb(t,n)[0])==null?void 0:r.id)===e.id},e.getIsLastColumn=n=>{var r;const o=Qb(t,n);return((r=o[o.length-1])==null?void 0:r.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},e._getOrderColumnsFn=ft(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,r)=>o=>{let i=[];if(!(t!=null&&t.length))i=o;else{const s=[...t],a=[...o];for(;a.length&&s.length;){const l=s.shift(),c=a.findIndex(u=>u.id===l);c>-1&&i.push(a.splice(c,1)[0])}i=[...i,...a]}return eht(i,n,r)},pt(e.options,"debugTable"))}},eR=()=>({left:[],right:[]}),nht={getInitialState:e=>({columnPinning:eR(),...e}),getDefaultOptions:e=>({onColumnPinningChange:ds("columnPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{const r=e.getLeafColumns().map(o=>o.id).filter(Boolean);t.setColumnPinning(o=>{var i,s;if(n==="right"){var a,l;return{left:((a=o?.left)!=null?a:[]).filter(f=>!(r!=null&&r.includes(f))),right:[...((l=o?.right)!=null?l:[]).filter(f=>!(r!=null&&r.includes(f))),...r]}}if(n==="left"){var c,u;return{left:[...((c=o?.left)!=null?c:[]).filter(f=>!(r!=null&&r.includes(f))),...r],right:((u=o?.right)!=null?u:[]).filter(f=>!(r!=null&&r.includes(f)))}}return{left:((i=o?.left)!=null?i:[]).filter(f=>!(r!=null&&r.includes(f))),right:((s=o?.right)!=null?s:[]).filter(f=>!(r!=null&&r.includes(f)))}})},e.getCanPin=()=>e.getLeafColumns().some(r=>{var o,i,s;return((o=r.columnDef.enablePinning)!=null?o:!0)&&((i=(s=t.options.enableColumnPinning)!=null?s:t.options.enablePinning)!=null?i:!0)}),e.getIsPinned=()=>{const n=e.getLeafColumns().map(a=>a.id),{left:r,right:o}=t.getState().columnPinning,i=n.some(a=>r?.includes(a)),s=n.some(a=>o?.includes(a));return i?"left":s?"right":!1},e.getPinnedIndex=()=>{var n,r;const o=e.getIsPinned();return o?(n=(r=t.getState().columnPinning)==null||(r=r[o])==null?void 0:r.indexOf(e.id))!=null?n:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=ft(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,r,o)=>{const i=[...r??[],...o??[]];return n.filter(s=>!i.includes(s.column.id))},pt(t.options,"debugRows")),e.getLeftVisibleCells=ft(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(n,r)=>(r??[]).map(i=>n.find(s=>s.column.id===i)).filter(Boolean).map(i=>({...i,position:"left"})),pt(t.options,"debugRows")),e.getRightVisibleCells=ft(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,r)=>(r??[]).map(i=>n.find(s=>s.column.id===i)).filter(Boolean).map(i=>({...i,position:"right"})),pt(t.options,"debugRows"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,r;return e.setColumnPinning(t?eR():(n=(r=e.initialState)==null?void 0:r.columnPinning)!=null?n:eR())},e.getIsSomeColumnsPinned=t=>{var n;const r=e.getState().columnPinning;if(!t){var o,i;return!!((o=r.left)!=null&&o.length||(i=r.right)!=null&&i.length)}return!!((n=r[t])!=null&&n.length)},e.getLeftLeafColumns=ft(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(r=>t.find(o=>o.id===r)).filter(Boolean),pt(e.options,"debugColumns")),e.getRightLeafColumns=ft(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(r=>t.find(o=>o.id===r)).filter(Boolean),pt(e.options,"debugColumns")),e.getCenterLeafColumns=ft(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r)=>{const o=[...n??[],...r??[]];return t.filter(i=>!o.includes(i.id))},pt(e.options,"debugColumns"))}};function rht(e){return e||(typeof document<"u"?document:null)}const Lv={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},tR=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),oht={getDefaultColumnDef:()=>Lv,getInitialState:e=>({columnSizing:{},columnSizingInfo:tR(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:ds("columnSizing",e),onColumnSizingInfoChange:ds("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,r,o;const i=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:Lv.minSize,(r=i??e.columnDef.size)!=null?r:Lv.size),(o=e.columnDef.maxSize)!=null?o:Lv.maxSize)},e.getStart=ft(n=>[n,Qb(t,n),t.getState().columnSizing],(n,r)=>r.slice(0,e.getIndex(n)).reduce((o,i)=>o+i.getSize(),0),pt(t.options,"debugColumns")),e.getAfter=ft(n=>[n,Qb(t,n),t.getState().columnSizing],(n,r)=>r.slice(e.getIndex(n)+1).reduce((o,i)=>o+i.getSize(),0),pt(t.options,"debugColumns")),e.resetSize=()=>{t.setColumnSizing(n=>{let{[e.id]:r,...o}=n;return o})},e.getCanResize=()=>{var n,r;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((r=t.options.enableColumnResizing)!=null?r:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let n=0;const r=o=>{if(o.subHeaders.length)o.subHeaders.forEach(r);else{var i;n+=(i=o.column.getSize())!=null?i:0}};return r(e),n},e.getStart=()=>{if(e.index>0){const n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},e.getResizeHandler=n=>{const r=t.getColumn(e.column.id),o=r?.getCanResize();return i=>{if(!r||!o||(i.persist==null||i.persist(),nR(i)&&i.touches&&i.touches.length>1))return;const s=e.getSize(),a=e?e.getLeafHeaders().map(S=>[S.column.id,S.column.getSize()]):[[r.id,r.getSize()]],l=nR(i)?Math.round(i.touches[0].clientX):i.clientX,c={},u=(S,T)=>{typeof T=="number"&&(t.setColumnSizingInfo(k=>{var I,_;const R=t.options.columnResizeDirection==="rtl"?-1:1,D=(T-((I=k?.startOffset)!=null?I:0))*R,M=Math.max(D/((_=k?.startSize)!=null?_:0),-.999999);return k.columnSizingStart.forEach($=>{let[O,F]=$;c[O]=Math.round(Math.max(F+F*M,0)*100)/100}),{...k,deltaOffset:D,deltaPercentage:M}}),(t.options.columnResizeMode==="onChange"||S==="end")&&t.setColumnSizing(k=>({...k,...c})))},f=S=>u("move",S),m=S=>{u("end",S),t.setColumnSizingInfo(T=>({...T,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},g=rht(n),y={moveHandler:S=>f(S.clientX),upHandler:S=>{g?.removeEventListener("mousemove",y.moveHandler),g?.removeEventListener("mouseup",y.upHandler),m(S.clientX)}},v={moveHandler:S=>(S.cancelable&&(S.preventDefault(),S.stopPropagation()),f(S.touches[0].clientX),!1),upHandler:S=>{var T;g?.removeEventListener("touchmove",v.moveHandler),g?.removeEventListener("touchend",v.upHandler),S.cancelable&&(S.preventDefault(),S.stopPropagation()),m((T=S.touches[0])==null?void 0:T.clientX)}},w=iht()?{passive:!1}:!1;nR(i)?(g?.addEventListener("touchmove",v.moveHandler,w),g?.addEventListener("touchend",v.upHandler,w)):(g?.addEventListener("mousemove",y.moveHandler,w),g?.addEventListener("mouseup",y.upHandler,w)),t.setColumnSizingInfo(S=>({...S,startOffset:l,startSize:s,deltaOffset:0,deltaPercentage:0,columnSizingStart:a,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?tR():(n=e.initialState.columnSizingInfo)!=null?n:tR())},e.getTotalSize=()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((r,o)=>r+o.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((r,o)=>r+o.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((r,o)=>r+o.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((r,o)=>r+o.getSize(),0))!=null?t:0}}};let Pv=null;function iht(){if(typeof Pv=="boolean")return Pv;let e=!1;try{const t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return Pv=e,Pv}function nR(e){return e.type==="touchstart"}const sht={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:ds("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(r=>({...r,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{var n,r;const o=e.columns;return(n=o.length?o.some(i=>i.getIsVisible()):(r=t.getState().columnVisibility)==null?void 0:r[e.id])!=null?n:!0},e.getCanHide=()=>{var n,r;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((r=t.options.enableHiding)!=null?r:!0)},e.getToggleVisibilityHandler=()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=ft(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(r=>r.column.getIsVisible()),pt(t.options,"debugRows")),e.getVisibleCells=ft(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,r,o)=>[...n,...r,...o],pt(t.options,"debugRows"))},createTable:e=>{const t=(n,r)=>ft(()=>[r(),r().filter(o=>o.getIsVisible()).map(o=>o.id).join("_")],o=>o.filter(i=>i.getIsVisible==null?void 0:i.getIsVisible()),pt(e.options,"debugColumns"));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),e.resetColumnVisibility=n=>{var r;e.setColumnVisibility(n?{}:(r=e.initialState.columnVisibility)!=null?r:{})},e.toggleAllColumnsVisible=n=>{var r;n=(r=n)!=null?r:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((o,i)=>({...o,[i.id]:n||!(i.getCanHide!=null&&i.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>n=>{var r;e.toggleAllColumnsVisible((r=n.target)==null?void 0:r.checked)}}};function Qb(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const aht={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},lht={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:ds("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;const r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r=="string"||typeof r=="number"}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var n,r,o,i;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((r=t.options.enableGlobalFilter)!=null?r:!0)&&((o=t.options.enableFilters)!=null?o:!0)&&((i=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?i:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>Ql.includesString,e.getGlobalFilterFn=()=>{var t,n;const{globalFilterFn:r}=e.options;return tk(r)?r:r==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[r])!=null?t:Ql[r]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},cht={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:ds("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var r,o;if(!t){e._queue(()=>{t=!0});return}if((r=(o=e.options.autoResetAll)!=null?o:e.options.autoResetExpanded)!=null?r:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=r=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(r),e.toggleAllRowsExpanded=r=>{r??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=r=>{var o,i;e.setExpanded(r?{}:(o=(i=e.initialState)==null?void 0:i.expanded)!=null?o:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(r=>r.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>r=>{r.persist==null||r.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const r=e.getState().expanded;return r===!0||Object.values(r).some(Boolean)},e.getIsAllRowsExpanded=()=>{const r=e.getState().expanded;return typeof r=="boolean"?r===!0:!(!Object.keys(r).length||e.getRowModel().flatRows.some(o=>!o.getIsExpanded()))},e.getExpandedDepth=()=>{let r=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(i=>{const s=i.split(".");r=Math.max(r,s.length)}),r},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{var o;const i=r===!0?!0:!!(r!=null&&r[e.id]);let s={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(a=>{s[a]=!0}):s=r,n=(o=n)!=null?o:!i,!i&&n)return{...s,[e.id]:!0};if(i&&!n){const{[e.id]:a,...l}=s;return l}return r})},e.getIsExpanded=()=>{var n;const r=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:r===!0||r?.[e.id])},e.getCanExpand=()=>{var n,r,o;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((r=t.options.enableExpanding)!=null?r:!0)&&!!((o=e.subRows)!=null&&o.length)},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{const n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}}},QI=0,JI=10,rR=()=>({pageIndex:QI,pageSize:JI}),uht={getInitialState:e=>({...e,pagination:{...rR(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:ds("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var r,o;if(!t){e._queue(()=>{t=!0});return}if((r=(o=e.options.autoResetAll)!=null?o:e.options.autoResetPageIndex)!=null?r:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=r=>{const o=i=>vu(r,i);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(o)},e.resetPagination=r=>{var o;e.setPagination(r?rR():(o=e.initialState.pagination)!=null?o:rR())},e.setPageIndex=r=>{e.setPagination(o=>{let i=vu(r,o.pageIndex);const s=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return i=Math.max(0,Math.min(i,s)),{...o,pageIndex:i}})},e.resetPageIndex=r=>{var o,i;e.setPageIndex(r?QI:(o=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageIndex)!=null?o:QI)},e.resetPageSize=r=>{var o,i;e.setPageSize(r?JI:(o=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageSize)!=null?o:JI)},e.setPageSize=r=>{e.setPagination(o=>{const i=Math.max(1,vu(r,o.pageSize)),s=o.pageSize*o.pageIndex,a=Math.floor(s/i);return{...o,pageIndex:a,pageSize:i}})},e.setPageCount=r=>e.setPagination(o=>{var i;let s=vu(r,(i=e.options.pageCount)!=null?i:-1);return typeof s=="number"&&(s=Math.max(-1,s)),{...o,pageCount:s}}),e.getPageOptions=ft(()=>[e.getPageCount()],r=>{let o=[];return r&&r>0&&(o=[...new Array(r)].fill(null).map((i,s)=>s)),o},pt(e.options,"debugTable")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:r}=e.getState().pagination,o=e.getPageCount();return o===-1?!0:o===0?!1:r<o-1},e.previousPage=()=>e.setPageIndex(r=>r-1),e.nextPage=()=>e.setPageIndex(r=>r+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var r;return(r=e.options.pageCount)!=null?r:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var r;return(r=e.options.rowCount)!=null?r:e.getPrePaginationRowModel().rows.length}}},oR=()=>({top:[],bottom:[]}),dht={getInitialState:e=>({rowPinning:oR(),...e}),getDefaultOptions:e=>({onRowPinningChange:ds("rowPinning",e)}),createRow:(e,t)=>{e.pin=(n,r,o)=>{const i=r?e.getLeafRows().map(l=>{let{id:c}=l;return c}):[],s=o?e.getParentRows().map(l=>{let{id:c}=l;return c}):[],a=new Set([...s,e.id,...i]);t.setRowPinning(l=>{var c,u;if(n==="bottom"){var f,m;return{top:((f=l?.top)!=null?f:[]).filter(v=>!(a!=null&&a.has(v))),bottom:[...((m=l?.bottom)!=null?m:[]).filter(v=>!(a!=null&&a.has(v))),...Array.from(a)]}}if(n==="top"){var g,y;return{top:[...((g=l?.top)!=null?g:[]).filter(v=>!(a!=null&&a.has(v))),...Array.from(a)],bottom:((y=l?.bottom)!=null?y:[]).filter(v=>!(a!=null&&a.has(v)))}}return{top:((c=l?.top)!=null?c:[]).filter(v=>!(a!=null&&a.has(v))),bottom:((u=l?.bottom)!=null?u:[]).filter(v=>!(a!=null&&a.has(v)))}})},e.getCanPin=()=>{var n;const{enableRowPinning:r,enablePinning:o}=t.options;return typeof r=="function"?r(e):(n=r??o)!=null?n:!0},e.getIsPinned=()=>{const n=[e.id],{top:r,bottom:o}=t.getState().rowPinning,i=n.some(a=>r?.includes(a)),s=n.some(a=>o?.includes(a));return i?"top":s?"bottom":!1},e.getPinnedIndex=()=>{var n,r;const o=e.getIsPinned();if(!o)return-1;const i=(n=o==="top"?t.getTopRows():t.getBottomRows())==null?void 0:n.map(s=>{let{id:a}=s;return a});return(r=i?.indexOf(e.id))!=null?r:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,r;return e.setRowPinning(t?oR():(n=(r=e.initialState)==null?void 0:r.rowPinning)!=null?n:oR())},e.getIsSomeRowsPinned=t=>{var n;const r=e.getState().rowPinning;if(!t){var o,i;return!!((o=r.top)!=null&&o.length||(i=r.bottom)!=null&&i.length)}return!!((n=r[t])!=null&&n.length)},e._getPinnedRows=(t,n,r)=>{var o;return((o=e.options.keepPinnedRows)==null||o?(n??[]).map(s=>{const a=e.getRow(s,!0);return a.getIsAllParentsExpanded()?a:null}):(n??[]).map(s=>t.find(a=>a.id===s))).filter(Boolean).map(s=>({...s,position:r}))},e.getTopRows=ft(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),pt(e.options,"debugRows")),e.getBottomRows=ft(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),pt(e.options,"debugRows")),e.getCenterRows=ft(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,n,r)=>{const o=new Set([...n??[],...r??[]]);return t.filter(i=>!o.has(i.id))},pt(e.options,"debugRows"))}},fht={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:ds("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const r={...n},o=e.getPreGroupedRowModel().flatRows;return t?o.forEach(i=>{i.getCanSelect()&&(r[i.id]=!0)}):o.forEach(i=>{delete r[i.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{const r=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),o={...n};return e.getRowModel().rows.forEach(i=>{eO(o,i.id,r,!0,e)}),o}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=ft(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?iR(e,n):{rows:[],flatRows:[],rowsById:{}},pt(e.options,"debugTable")),e.getFilteredSelectedRowModel=ft(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?iR(e,n):{rows:[],flatRows:[],rowsById:{}},pt(e.options,"debugTable")),e.getGroupedSelectedRowModel=ft(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?iR(e,n):{rows:[],flatRows:[],rowsById:{}},pt(e.options,"debugTable")),e.getIsAllRowsSelected=()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState();let r=!!(t.length&&Object.keys(n).length);return r&&t.some(o=>o.getCanSelect()&&!n[o.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows.filter(o=>o.getCanSelect()),{rowSelection:n}=e.getState();let r=!!t.length;return r&&t.some(o=>!n[o.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{var t;const n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{const o=e.getIsSelected();t.setRowSelection(i=>{var s;if(n=typeof n<"u"?n:!o,e.getCanSelect()&&o===n)return i;const a={...i};return eO(a,e.id,n,(s=r?.selectChildren)!=null?s:!0,t),a})},e.getIsSelected=()=>{const{rowSelection:n}=t.getState();return VB(e,n)},e.getIsSomeSelected=()=>{const{rowSelection:n}=t.getState();return tO(e,n)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=t.getState();return tO(e,n)==="all"},e.getCanSelect=()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},e.getCanSelectSubRows=()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},e.getCanMultiSelect=()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},e.getToggleSelectedHandler=()=>{const n=e.getCanSelect();return r=>{var o;n&&e.toggleSelected((o=r.target)==null?void 0:o.checked)}}}},eO=(e,t,n,r,o)=>{var i;const s=o.getRow(t,!0);n?(s.getCanMultiSelect()||Object.keys(e).forEach(a=>delete e[a]),s.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(i=s.subRows)!=null&&i.length&&s.getCanSelectSubRows()&&s.subRows.forEach(a=>eO(e,a.id,n,r,o))};function iR(e,t){const n=e.getState().rowSelection,r=[],o={},i=function(s,a){return s.map(l=>{var c;const u=VB(l,n);if(u&&(r.push(l),o[l.id]=l),(c=l.subRows)!=null&&c.length&&(l={...l,subRows:i(l.subRows)}),u)return l}).filter(Boolean)};return{rows:i(t.rows),flatRows:r,rowsById:o}}function VB(e,t){var n;return(n=t[e.id])!=null?n:!1}function tO(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let o=!0,i=!1;return e.subRows.forEach(s=>{if(!(i&&!o)&&(s.getCanSelect()&&(VB(s,t)?i=!0:o=!1),s.subRows&&s.subRows.length)){const a=tO(s,t);a==="all"?i=!0:(a==="some"&&(i=!0),o=!1)}}),o?"all":i?"some":!1}const nO=/([0-9]+)/gm,pht=(e,t,n)=>cpe(qu(e.getValue(n)).toLowerCase(),qu(t.getValue(n)).toLowerCase()),hht=(e,t,n)=>cpe(qu(e.getValue(n)),qu(t.getValue(n))),mht=(e,t,n)=>GB(qu(e.getValue(n)).toLowerCase(),qu(t.getValue(n)).toLowerCase()),ght=(e,t,n)=>GB(qu(e.getValue(n)),qu(t.getValue(n))),bht=(e,t,n)=>{const r=e.getValue(n),o=t.getValue(n);return r>o?1:r<o?-1:0},yht=(e,t,n)=>GB(e.getValue(n),t.getValue(n));function GB(e,t){return e===t?0:e>t?1:-1}function qu(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function cpe(e,t){const n=e.split(nO).filter(Boolean),r=t.split(nO).filter(Boolean);for(;n.length&&r.length;){const o=n.shift(),i=r.shift(),s=parseInt(o,10),a=parseInt(i,10),l=[s,a].sort();if(isNaN(l[0])){if(o>i)return 1;if(i>o)return-1;continue}if(isNaN(l[1]))return isNaN(s)?-1:1;if(s>a)return 1;if(a>s)return-1}return n.length-r.length}const cb={alphanumeric:pht,alphanumericCaseSensitive:hht,text:mht,textCaseSensitive:ght,datetime:bht,basic:yht},xht={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:ds("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{const n=t.getFilteredRowModel().flatRows.slice(10);let r=!1;for(const o of n){const i=o?.getValue(e.id);if(Object.prototype.toString.call(i)==="[object Date]")return cb.datetime;if(typeof i=="string"&&(r=!0,i.split(nO).length>1))return cb.alphanumeric}return r?cb.text:cb.basic},e.getAutoSortDir=()=>{const n=t.getFilteredRowModel().flatRows[0];return typeof n?.getValue(e.id)=="string"?"asc":"desc"},e.getSortingFn=()=>{var n,r;if(!e)throw new Error;return tk(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(r=t.options.sortingFns)==null?void 0:r[e.columnDef.sortingFn])!=null?n:cb[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{const o=e.getNextSortingOrder(),i=typeof n<"u"&&n!==null;t.setSorting(s=>{const a=s?.find(g=>g.id===e.id),l=s?.findIndex(g=>g.id===e.id);let c=[],u,f=i?n:o==="desc";if(s!=null&&s.length&&e.getCanMultiSort()&&r?a?u="toggle":u="add":s!=null&&s.length&&l!==s.length-1?u="replace":a?u="toggle":u="replace",u==="toggle"&&(i||o||(u="remove")),u==="add"){var m;c=[...s,{id:e.id,desc:f}],c.splice(0,c.length-((m=t.options.maxMultiSortColCount)!=null?m:Number.MAX_SAFE_INTEGER))}else u==="toggle"?c=s.map(g=>g.id===e.id?{...g,desc:f}:g):u==="remove"?c=s.filter(g=>g.id!==e.id):c=[{id:e.id,desc:f}];return c})},e.getFirstSortDir=()=>{var n,r;return((n=(r=e.columnDef.sortDescFirst)!=null?r:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=n=>{var r,o;const i=e.getFirstSortDir(),s=e.getIsSorted();return s?s!==i&&((r=t.options.enableSortingRemoval)==null||r)&&(!(n&&(o=t.options.enableMultiRemove)!=null)||o)?!1:s==="desc"?"asc":"desc":i},e.getCanSort=()=>{var n,r;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((r=t.options.enableSorting)!=null?r:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,r;return(n=(r=e.columnDef.enableMultiSort)!=null?r:t.options.enableMultiSort)!=null?n:!!e.accessorFn},e.getIsSorted=()=>{var n;const r=(n=t.getState().sorting)==null?void 0:n.find(o=>o.id===e.id);return r?r.desc?"desc":"asc":!1},e.getSortIndex=()=>{var n,r;return(n=(r=t.getState().sorting)==null?void 0:r.findIndex(o=>o.id===e.id))!=null?n:-1},e.clearSorting=()=>{t.setSorting(n=>n!=null&&n.length?n.filter(r=>r.id!==e.id):[])},e.getToggleSortingHandler=()=>{const n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,r;e.setSorting(t?[]:(n=(r=e.initialState)==null?void 0:r.sorting)!=null?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},vht=[Upt,sht,tht,nht,Hpt,zpt,aht,lht,xht,Jpt,cht,uht,dht,fht,oht];function Eht(e){var t,n;const r=[...vht,...(t=e._features)!=null?t:[]];let o={_features:r};const i=o._features.reduce((m,g)=>Object.assign(m,g.getDefaultOptions==null?void 0:g.getDefaultOptions(o)),{}),s=m=>o.options.mergeOptions?o.options.mergeOptions(i,m):{...i,...m};let l={...{},...(n=e.initialState)!=null?n:{}};o._features.forEach(m=>{var g;l=(g=m.getInitialState==null?void 0:m.getInitialState(l))!=null?g:l});const c=[];let u=!1;const f={_features:r,options:{...i,...e},initialState:l,_queue:m=>{c.push(m),u||(u=!0,Promise.resolve().then(()=>{for(;c.length;)c.shift()();u=!1}).catch(g=>setTimeout(()=>{throw g})))},reset:()=>{o.setState(o.initialState)},setOptions:m=>{const g=vu(m,o.options);o.options=s(g)},getState:()=>o.options.state,setState:m=>{o.options.onStateChange==null||o.options.onStateChange(m)},_getRowId:(m,g,y)=>{var v;return(v=o.options.getRowId==null?void 0:o.options.getRowId(m,g,y))!=null?v:`${y?[y.id,g].join("."):g}`},getCoreRowModel:()=>(o._getCoreRowModel||(o._getCoreRowModel=o.options.getCoreRowModel(o)),o._getCoreRowModel()),getRowModel:()=>o.getPaginationRowModel(),getRow:(m,g)=>{let y=(g?o.getPrePaginationRowModel():o.getRowModel()).rowsById[m];if(!y&&(y=o.getCoreRowModel().rowsById[m],!y))throw new Error;return y},_getDefaultColumnDef:ft(()=>[o.options.defaultColumn],m=>{var g;return m=(g=m)!=null?g:{},{header:y=>{const v=y.header.column.columnDef;return v.accessorKey?v.accessorKey:v.accessorFn?v.id:null},cell:y=>{var v,w;return(v=(w=y.renderValue())==null||w.toString==null?void 0:w.toString())!=null?v:null},...o._features.reduce((y,v)=>Object.assign(y,v.getDefaultColumnDef==null?void 0:v.getDefaultColumnDef()),{}),...m}},pt(e,"debugColumns")),_getColumnDefs:()=>o.options.columns,getAllColumns:ft(()=>[o._getColumnDefs()],m=>{const g=function(y,v,w){return w===void 0&&(w=0),y.map(S=>{const T=$pt(o,S,w,v),k=S;return T.columns=k.columns?g(k.columns,T,w+1):[],T})};return g(m)},pt(e,"debugColumns")),getAllFlatColumns:ft(()=>[o.getAllColumns()],m=>m.flatMap(g=>g.getFlatColumns()),pt(e,"debugColumns")),_getAllFlatColumnsById:ft(()=>[o.getAllFlatColumns()],m=>m.reduce((g,y)=>(g[y.id]=y,g),{}),pt(e,"debugColumns")),getAllLeafColumns:ft(()=>[o.getAllColumns(),o._getOrderColumnsFn()],(m,g)=>{let y=m.flatMap(v=>v.getLeafColumns());return g(y)},pt(e,"debugColumns")),getColumn:m=>o._getAllFlatColumnsById()[m]};Object.assign(o,f);for(let m=0;m<o._features.length;m++){const g=o._features[m];g==null||g.createTable==null||g.createTable(o)}return o}function wht(){return e=>ft(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(o,i,s){i===void 0&&(i=0);const a=[];for(let c=0;c<o.length;c++){const u=HB(e,e._getRowId(o[c],c,s),o[c],c,i,void 0,s?.id);if(n.flatRows.push(u),n.rowsById[u.id]=u,a.push(u),e.options.getSubRows){var l;u.originalSubRows=e.options.getSubRows(o[c],c),(l=u.originalSubRows)!=null&&l.length&&(u.subRows=r(u.originalSubRows,i+1,u))}}return a};return n.rows=r(t),n},pt(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function Sht(e){const t=[],n=r=>{var o;t.push(r),(o=r.subRows)!=null&&o.length&&r.getIsExpanded()&&r.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}function upe(e,t,n){return n.options.filterFromLeafRows?Cht(e,t,n):Tht(e,t,n)}function Cht(e,t,n){var r;const o=[],i={},s=(r=n.options.maxLeafRowFilterDepth)!=null?r:100,a=function(l,c){c===void 0&&(c=0);const u=[];for(let m=0;m<l.length;m++){var f;let g=l[m];const y=HB(n,g.id,g.original,g.index,g.depth,void 0,g.parentId);if(y.columnFilters=g.columnFilters,(f=g.subRows)!=null&&f.length&&c<s){if(y.subRows=a(g.subRows,c+1),g=y,t(g)&&!y.subRows.length){u.push(g),i[g.id]=g,o.push(g);continue}if(t(g)||y.subRows.length){u.push(g),i[g.id]=g,o.push(g);continue}}else g=y,t(g)&&(u.push(g),i[g.id]=g,o.push(g))}return u};return{rows:a(e),flatRows:o,rowsById:i}}function Tht(e,t,n){var r;const o=[],i={},s=(r=n.options.maxLeafRowFilterDepth)!=null?r:100,a=function(l,c){c===void 0&&(c=0);const u=[];for(let m=0;m<l.length;m++){let g=l[m];if(t(g)){var f;if((f=g.subRows)!=null&&f.length&&c<s){const v=HB(n,g.id,g.original,g.index,g.depth,void 0,g.parentId);v.subRows=a(g.subRows,c+1),g=v}u.push(g),o.push(g),i[g.id]=g}}return u};return{rows:a(e),flatRows:o,rowsById:i}}function kht(){return(e,t)=>ft(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter,e.getFilteredRowModel()],(n,r,o)=>{if(!n.rows.length||!(r!=null&&r.length)&&!o)return n;const i=[...r.map(a=>a.id).filter(a=>a!==t),o?"__global__":void 0].filter(Boolean),s=a=>{for(let l=0;l<i.length;l++)if(a.columnFilters[i[l]]===!1)return!1;return!0};return upe(n.rows,s,e)},pt(e.options,"debugTable"))}function Aht(){return(e,t)=>ft(()=>{var n;return[(n=e.getColumn(t))==null?void 0:n.getFacetedRowModel()]},n=>{if(!n)return new Map;let r=new Map;for(let i=0;i<n.flatRows.length;i++){const s=n.flatRows[i].getUniqueValues(t);for(let a=0;a<s.length;a++){const l=s[a];if(r.has(l)){var o;r.set(l,((o=r.get(l))!=null?o:0)+1)}else r.set(l,1)}}return r},pt(e.options,"debugTable"))}function Nht(){return e=>ft(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,r)=>{if(!t.rows.length||!(n!=null&&n.length)&&!r){for(let m=0;m<t.flatRows.length;m++)t.flatRows[m].columnFilters={},t.flatRows[m].columnFiltersMeta={};return t}const o=[],i=[];(n??[]).forEach(m=>{var g;const y=e.getColumn(m.id);if(!y)return;const v=y.getFilterFn();v&&o.push({id:m.id,filterFn:v,resolvedValue:(g=v.resolveFilterValue==null?void 0:v.resolveFilterValue(m.value))!=null?g:m.value})});const s=(n??[]).map(m=>m.id),a=e.getGlobalFilterFn(),l=e.getAllLeafColumns().filter(m=>m.getCanGlobalFilter());r&&a&&l.length&&(s.push("__global__"),l.forEach(m=>{var g;i.push({id:m.id,filterFn:a,resolvedValue:(g=a.resolveFilterValue==null?void 0:a.resolveFilterValue(r))!=null?g:r})}));let c,u;for(let m=0;m<t.flatRows.length;m++){const g=t.flatRows[m];if(g.columnFilters={},o.length)for(let y=0;y<o.length;y++){c=o[y];const v=c.id;g.columnFilters[v]=c.filterFn(g,v,c.resolvedValue,w=>{g.columnFiltersMeta[v]=w})}if(i.length){for(let y=0;y<i.length;y++){u=i[y];const v=u.id;if(u.filterFn(g,v,u.resolvedValue,w=>{g.columnFiltersMeta[v]=w})){g.columnFilters.__global__=!0;break}}g.columnFilters.__global__!==!0&&(g.columnFilters.__global__=!1)}}const f=m=>{for(let g=0;g<s.length;g++)if(m.columnFilters[s[g]]===!1)return!1;return!0};return upe(t.rows,f,e)},pt(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex()))}function _ht(e){return t=>ft(()=>[t.getState().pagination,t.getPrePaginationRowModel(),t.options.paginateExpandedRows?void 0:t.getState().expanded],(n,r)=>{if(!r.rows.length)return r;const{pageSize:o,pageIndex:i}=n;let{rows:s,flatRows:a,rowsById:l}=r;const c=o*i,u=c+o;s=s.slice(c,u);let f;t.options.paginateExpandedRows?f={rows:s,flatRows:a,rowsById:l}:f=Sht({rows:s,flatRows:a,rowsById:l}),f.flatRows=[];const m=g=>{f.flatRows.push(g),g.subRows.length&&g.subRows.forEach(m)};return f.rows.forEach(m),f},pt(t.options,"debugTable"))}function Rht(){return e=>ft(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;const r=e.getState().sorting,o=[],i=r.filter(l=>{var c;return(c=e.getColumn(l.id))==null?void 0:c.getCanSort()}),s={};i.forEach(l=>{const c=e.getColumn(l.id);c&&(s[l.id]={sortUndefined:c.columnDef.sortUndefined,invertSorting:c.columnDef.invertSorting,sortingFn:c.getSortingFn()})});const a=l=>{const c=l.map(u=>({...u}));return c.sort((u,f)=>{for(let g=0;g<i.length;g+=1){var m;const y=i[g],v=s[y.id],w=v.sortUndefined,S=(m=y?.desc)!=null?m:!1;let T=0;if(w){const k=u.getValue(y.id),I=f.getValue(y.id),_=k===void 0,R=I===void 0;if(_||R){if(w==="first")return _?-1:1;if(w==="last")return _?1:-1;T=_&&R?0:_?w:-w}}if(T===0&&(T=v.sortingFn(u,f,y.id)),T!==0)return S&&(T*=-1),v.invertSorting&&(T*=-1),T}return u.index-f.index}),c.forEach(u=>{var f;o.push(u),(f=u.subRows)!=null&&f.length&&(u.subRows=a(u.subRows))}),c};return{rows:a(n.rows),flatRows:o,rowsById:n.rowsById}},pt(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function mK(e,t){return e?Dht(e)?x.createElement(e,t):e:null}function Dht(e){return Iht(e)||typeof e=="function"||Oht(e)}function Iht(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Oht(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function Mht(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=x.useState(()=>({current:Eht(t)})),[r,o]=x.useState(()=>n.current.initialState);return n.current.setOptions(i=>({...i,...e,state:{...r,...e.state},onStateChange:s=>{o(s),e.onStateChange==null||e.onStateChange(s)}})),n.current}const dpe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{className:"relative w-full overflow-auto",children:h.jsx("table",{ref:n,className:Ee("w-full caption-bottom text-sm",e),...t})}));dpe.displayName="Table";const fpe=x.forwardRef(({className:e,...t},n)=>h.jsx("thead",{ref:n,className:Ee("[&_tr]:border-b",e),...t}));fpe.displayName="TableHeader";const ppe=x.forwardRef(({className:e,...t},n)=>h.jsx("tbody",{ref:n,className:Ee("[&_tr:last-child]:border-0",e),...t}));ppe.displayName="TableBody";const Lht=x.forwardRef(({className:e,...t},n)=>h.jsx("tfoot",{ref:n,className:Ee("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));Lht.displayName="TableFooter";const CE=x.forwardRef(({className:e,...t},n)=>h.jsx("tr",{ref:n,className:Ee("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));CE.displayName="TableRow";const hpe=x.forwardRef(({className:e,...t},n)=>h.jsx("th",{ref:n,className:Ee("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));hpe.displayName="TableHead";const rO=x.forwardRef(({className:e,...t},n)=>h.jsx("td",{ref:n,className:Ee("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));rO.displayName="TableCell";const Pht=x.forwardRef(({className:e,...t},n)=>h.jsx("caption",{ref:n,className:Ee("mt-4 text-sm text-muted-foreground",e),...t}));Pht.displayName="TableCaption";function Fht({table:e,showRowSelection:t=!0}){return h.jsxs("div",{className:"flex items-center justify-between px-2",children:[t&&h.jsxs("div",{className:"flex-1 text-sm text-muted-foreground",children:[e.getFilteredSelectedRowModel().rows.length," of"," ",e.getFilteredRowModel().rows.length," row(s) selected."]}),h.jsxs("div",{className:"flex items-center space-x-6 lg:space-x-8",children:[h.jsxs("div",{className:"flex items-center space-x-2",children:[h.jsx("p",{className:"text-sm font-medium",children:"Rows per page"}),h.jsxs(ri,{value:`${e.getState().pagination.pageSize}`,onValueChange:n=>{e.setPageSize(Number(n))},children:[h.jsx(zo,{className:"h-8 w-[70px]",children:h.jsx(oi,{placeholder:e.getState().pagination.pageSize})}),h.jsx(Vo,{side:"top",children:[10,20,30,40,50].map(n=>h.jsx(En,{value:`${n}`,children:n},n))})]})]}),h.jsxs("div",{className:"flex w-[100px] items-center justify-center text-sm font-medium",children:["Page ",e.getState().pagination.pageIndex+1," of ",e.getPageCount()]}),h.jsxs("div",{className:"flex items-center space-x-2",children:[h.jsxs(Le,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:[h.jsx("span",{className:"sr-only",children:"Go to first page"}),h.jsx(ybe,{className:"h-4 w-4"})]}),h.jsxs(Le,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:[h.jsx("span",{className:"sr-only",children:"Go to previous page"}),h.jsx(hbe,{className:"h-4 w-4"})]}),h.jsxs(Le,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:[h.jsx("span",{className:"sr-only",children:"Go to next page"}),h.jsx(Au,{className:"h-4 w-4"})]}),h.jsxs(Le,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>e.setPageIndex(e.getPageCount()-1),disabled:!e.getCanNextPage(),children:[h.jsx("span",{className:"sr-only",children:"Go to last page"}),h.jsx(vbe,{className:"h-4 w-4"})]})]})]})]})}function Bht({columns:e,data:t,toolbar:n,onRowClick:r,showPagination:o=!0,showRowSelection:i=!0,initialSorting:s=[],onSelectionChange:a}){const[l,c]=x.useState({}),[u,f]=x.useState({}),[m,g]=x.useState([]),[y,v]=x.useState(s),w=Mht({data:t,columns:e,state:{sorting:y,columnVisibility:u,rowSelection:l,columnFilters:m},enableRowSelection:!0,onRowSelectionChange:c,onSortingChange:v,onColumnFiltersChange:g,onColumnVisibilityChange:f,getCoreRowModel:wht(),getFilteredRowModel:Nht(),getPaginationRowModel:_ht(),getSortedRowModel:Rht(),getFacetedRowModel:kht(),getFacetedUniqueValues:Aht()});return x.useEffect(()=>{if(a){const S=w.getFilteredSelectedRowModel().rows.map(T=>T.original);a(S)}},[l,a,w]),h.jsxs("div",{className:"space-y-4",children:[n,h.jsx("div",{className:"rounded-md border",children:h.jsxs(dpe,{children:[h.jsx(fpe,{children:w.getHeaderGroups().map(S=>h.jsx(CE,{children:S.headers.map(T=>h.jsx(hpe,{colSpan:T.colSpan,children:T.isPlaceholder?null:mK(T.column.columnDef.header,T.getContext())},T.id))},S.id))}),h.jsx(ppe,{children:w.getRowModel().rows?.length?w.getRowModel().rows.map(S=>h.jsx(CE,{"data-state":S.getIsSelected()&&"selected",onClick:()=>r?.(S.original),className:r?"cursor-pointer":"",children:S.getVisibleCells().map(T=>h.jsx(rO,{children:mK(T.column.columnDef.cell,T.getContext())},T.id))},S.id)):h.jsx(CE,{children:h.jsx(rO,{colSpan:e.length,className:"h-24 text-center",children:"No results."})})})]})}),o&&h.jsx(Fht,{table:w,showRowSelection:i})]})}function Rd({column:e,title:t,className:n}){return e.getCanSort()?h.jsx("div",{className:Ee("flex items-center space-x-2",n),children:h.jsxs(gB,{children:[h.jsx(bB,{asChild:!0,children:h.jsxs(Le,{variant:"ghost",size:"sm",className:"-ml-3 h-8 data-[state=open]:bg-accent",children:[h.jsx("span",{children:t}),e.getIsSorted()==="desc"?h.jsx(dR,{className:"ml-2 h-4 w-4"}):e.getIsSorted()==="asc"?h.jsx(kh,{className:"ml-2 h-4 w-4"}):h.jsx(TE,{className:"ml-2 h-4 w-4"})]})}),h.jsxs(UT,{align:"start",children:[h.jsxs(ef,{onClick:()=>e.toggleSorting(!1),children:[h.jsx(kh,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground/70"}),"Asc"]}),h.jsxs(ef,{onClick:()=>e.toggleSorting(!0),children:[h.jsx(dR,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground/70"}),"Desc"]}),e.getCanHide()&&h.jsxs(h.Fragment,{children:[h.jsx(yB,{}),h.jsxs(ef,{onClick:()=>e.toggleVisibility(!1),children:[h.jsx(fR,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground/70"}),"Hide"]})]})]})]})}):h.jsx("div",{className:Ee(n),children:t})}const jht=[{id:"select",header:({table:e})=>h.jsx(ES,{checked:e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":"Select all",className:"translate-y-[2px]",onClick:t=>t.stopPropagation()}),cell:({row:e})=>h.jsx(ES,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":"Select row",className:"translate-y-[2px]",onClick:t=>t.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:"id",header:({column:e})=>h.jsx(Rd,{column:e,title:"ID"}),cell:({row:e})=>h.jsxs("div",{className:"w-[60px] font-mono text-xs text-muted-foreground",children:["#",e.getValue("id")]}),enableSorting:!0,enableHiding:!1},{accessorKey:"title",header:({column:e})=>h.jsx(Rd,{column:e,title:"Title"}),cell:({row:e})=>{const t=e.original;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"font-medium line-clamp-1",children:t.title}),t.description&&h.jsx("span",{className:"text-xs text-muted-foreground line-clamp-1",children:t.description})]})},enableSorting:!0},{accessorKey:"status",header:({column:e})=>h.jsx(Rd,{column:e,title:"Status"}),cell:({row:e})=>{const t=e.getValue("status");return h.jsx($de,{status:t})},filterFn:(e,t,n)=>n.includes(e.getValue(t)),enableSorting:!0},{accessorKey:"priority",header:({column:e})=>h.jsx(Rd,{column:e,title:"Priority"}),cell:({row:e})=>{const t=e.getValue("priority");return h.jsx(Ude,{priority:t})},filterFn:(e,t,n)=>n.includes(e.getValue(t)),enableSorting:!0,sortingFn:(e,t)=>{const n={high:0,medium:1,low:2},r=n[e.getValue("priority")]??1,o=n[t.getValue("priority")]??1;return r-o}},{accessorKey:"assignee",header:({column:e})=>h.jsx(Rd,{column:e,title:"Assignee"}),cell:({row:e})=>{const t=e.getValue("assignee");return t?h.jsx("span",{className:"text-sm font-mono",children:t}):h.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})},filterFn:(e,t,n)=>{const r=e.getValue(t);return r?n.includes(r):n.includes("unassigned")},enableSorting:!0},{accessorKey:"labels",header:({column:e})=>h.jsx(Rd,{column:e,title:"Labels"}),cell:({row:e})=>{const t=e.getValue("labels");return t.length>0?h.jsx(Hde,{labels:t,maxVisible:2}):h.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})},filterFn:(e,t,n)=>{const r=e.getValue(t);return n.some(o=>r.includes(o))},enableSorting:!1},{accessorKey:"acceptanceCriteria",header:({column:e})=>h.jsx(Rd,{column:e,title:"Progress"}),cell:({row:e})=>{const t=e.original.acceptanceCriteria;if(t.length===0)return h.jsx("span",{className:"text-muted-foreground text-sm",children:"-"});const n=t.filter(i=>i.completed).length,r=t.length,o=Math.round(n/r*100);return h.jsxs("div",{className:"flex items-center gap-2 min-w-[80px]",children:[h.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:h.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${o}%`}})}),h.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[n,"/",r]})]})},enableSorting:!1}];function $ht({globalFilter:e,setGlobalFilter:t,statusFilter:n,setStatusFilter:r,priorityFilter:o,setPriorityFilter:i,onNewTask:s}){const a=e||n!=="all"||o!=="all";return h.jsxs("div",{className:"flex items-center justify-between gap-4",children:[h.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[h.jsxs("div",{className:"relative w-[250px]",children:[h.jsx(PS,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),h.jsx(Gn,{placeholder:"Search tasks...",value:e,onChange:l=>t(l.target.value),className:"pl-8"})]}),h.jsxs(ri,{value:n,onValueChange:r,children:[h.jsx(zo,{className:"w-[150px]",children:h.jsx(oi,{placeholder:"Status"})}),h.jsxs(Vo,{children:[h.jsx(En,{value:"all",children:"All Status"}),h.jsx(En,{value:"todo",children:"To Do"}),h.jsx(En,{value:"in-progress",children:"In Progress"}),h.jsx(En,{value:"in-review",children:"In Review"}),h.jsx(En,{value:"blocked",children:"Blocked"}),h.jsx(En,{value:"done",children:"Done"})]})]}),h.jsxs(ri,{value:o,onValueChange:i,children:[h.jsx(zo,{className:"w-[150px]",children:h.jsx(oi,{placeholder:"Priority"})}),h.jsxs(Vo,{children:[h.jsx(En,{value:"all",children:"All Priority"}),h.jsx(En,{value:"high",children:"High"}),h.jsx(En,{value:"medium",children:"Medium"}),h.jsx(En,{value:"low",children:"Low"})]})]}),a&&h.jsxs(Le,{variant:"ghost",onClick:()=>{t(""),r("all"),i("all")},className:"h-8 px-2 lg:px-3",children:["Reset",h.jsx(ti,{className:"ml-2 h-4 w-4"})]})]}),s&&h.jsxs(Le,{onClick:s,className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(Go,{className:"mr-2 h-4 w-4"}),"New Task"]})]})}function Uht({tasks:e,onTaskClick:t,onSelectionChange:n,onNewTask:r}){const[o,i]=x.useState(""),[s,a]=x.useState("all"),[l,c]=x.useState("all"),u=x.useMemo(()=>{let f=e;if(o){const m=o.toLowerCase();f=f.filter(g=>g.id.toLowerCase().includes(m)||g.title.toLowerCase().includes(m)||g.description?.toLowerCase().includes(m)||g.assignee?.toLowerCase().includes(m)||g.labels.some(y=>y.toLowerCase().includes(m)))}return s!=="all"&&(f=f.filter(m=>m.status===s)),l!=="all"&&(f=f.filter(m=>m.priority===l)),f},[e,o,s,l]);return h.jsx(Bht,{columns:jht,data:u,onRowClick:t,onSelectionChange:n,showPagination:!0,showRowSelection:!0,initialSorting:[{id:"priority",desc:!1}],toolbar:h.jsx($ht,{table:null,globalFilter:o,setGlobalFilter:i,statusFilter:s,setStatusFilter:a,priorityFilter:l,setPriorityFilter:c,onNewTask:r})})}const sR=["todo","in-progress","in-review","done","blocked","on-hold","urgent"],Hht=["gray","blue","green","yellow","red","purple","orange","pink","cyan","indigo"];function zht(){const{config:e,loading:t,updateConfig:n}=Sf(),[r,o]=x.useState({}),[i,s]=x.useState(!1),[a,l]=x.useState(null),[c,u]=x.useState("form"),[f,m]=x.useState(""),[g,y]=x.useState(null),[v,w]=x.useState(""),[S,T]=x.useState(!1);x.useEffect(()=>{!t&&!S&&(o(e),m(JSON.stringify(e,null,2)),T(!0))},[e,t,S]);const k=r,I=o;x.useEffect(()=>{c==="form"&&m(JSON.stringify(k,null,2))},[k,c]);const _=async()=>{s(!0),l(null);try{let F=k;if(c==="json")try{F=JSON.parse(f),I(F),y(null)}catch{y("Invalid JSON syntax"),s(!1);return}await n(F),l({type:"success",text:"Configuration saved successfully!"}),setTimeout(()=>l(null),3e3)}catch(F){l({type:"error",text:F instanceof Error?F.message:"Failed to save config"})}finally{s(!1)}},R=()=>{if(!v.trim())return;const F=v.toLowerCase().replace(/\s+/g,"-"),U=k.statuses||sR;if(U.includes(F)){l({type:"error",text:"Status already exists"});return}I({...k,statuses:[...U,F],statusColors:{...k.statusColors||{},[F]:"gray"}}),w("")},D=F=>{const U=k.statuses||sR,G={...k.statusColors||{}};delete G[F],I({...k,statuses:U.filter(j=>j!==F),statusColors:G,visibleColumns:(k.visibleColumns||[]).filter(j=>j!==F)})},M=(F,U)=>{I({...k,statusColors:{...k.statusColors||{},[F]:U}})};if(t)return h.jsx("div",{className:"p-6 flex items-center justify-center h-64",children:h.jsx("div",{className:"text-lg text-muted-foreground",children:"Loading configuration..."})});const $=k.statuses||sR,O=k.statusColors||{};return h.jsx(Xr,{className:"h-full",children:h.jsxs("div",{className:"p-6 max-w-3xl",children:[h.jsxs("div",{className:"mb-6 flex items-center justify-between shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(cO,{className:"w-6 h-6"}),h.jsx("h1",{className:"text-2xl font-bold",children:"Configuration"})]}),h.jsxs("div",{className:"flex rounded-lg border overflow-hidden",children:[h.jsxs("button",{type:"button",onClick:()=>u("form"),className:`px-3 py-1.5 text-sm flex items-center gap-1.5 transition-colors ${c==="form"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"}`,children:[h.jsx(k0e,{className:"w-4 h-4"}),"Form"]}),h.jsxs("button",{type:"button",onClick:()=>u("json"),className:`px-3 py-1.5 text-sm flex items-center gap-1.5 transition-colors ${c==="json"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"}`,children:[h.jsx(Mbe,{className:"w-4 h-4"}),"JSON"]})]})]}),a&&h.jsx("div",{className:`mb-6 p-4 rounded-lg ${a.type==="success"?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-200":"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-200"}`,children:a.text}),c==="json"?h.jsxs("div",{className:"bg-card rounded-lg border p-6 space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"config.json"}),h.jsx("textarea",{value:f,onChange:F=>{m(F.target.value),y(null)},className:"w-full h-96 px-3 py-2 rounded-lg border bg-input font-mono text-sm focus:outline-none focus:ring-2 focus:ring-ring",spellCheck:!1}),g&&h.jsx("p",{className:"mt-2 text-sm text-destructive",children:g})]}),h.jsx("div",{className:"pt-4 border-t",children:h.jsxs(Le,{onClick:_,disabled:i,children:[h.jsx(lo,{className:"w-4 h-4 mr-2"}),i?"Saving...":"Save Configuration"]})})]}):h.jsxs("div",{className:"bg-card rounded-lg border p-6 space-y-6",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Project Name"}),h.jsx(Gn,{type:"text",value:k.name||"",onChange:F=>I({...k,name:F.target.value}),placeholder:"My Project"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Name of your project"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Default Assignee"}),h.jsx(Gn,{type:"text",value:k.defaultAssignee||"",onChange:F=>I({...k,defaultAssignee:F.target.value}),placeholder:"@username"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Default assignee for new tasks (e.g., @claude)"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Default Priority"}),h.jsxs("select",{value:k.defaultPriority||"medium",onChange:F=>I({...k,defaultPriority:F.target.value}),className:"w-full px-3 py-2 rounded-lg border bg-input focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"low",children:"Low"}),h.jsx("option",{value:"medium",children:"Medium"}),h.jsx("option",{value:"high",children:"High"})]}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Default priority for new tasks"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Default Labels"}),h.jsx(Gn,{type:"text",value:k.defaultLabels?.join(", ")||"",onChange:F=>I({...k,defaultLabels:F.target.value.split(",").map(U=>U.trim()).filter(Boolean)}),placeholder:"frontend, backend, ui"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Comma-separated list of default labels for new tasks"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Time Format"}),h.jsxs("select",{value:k.timeFormat||"24h",onChange:F=>I({...k,timeFormat:F.target.value}),className:"w-full px-3 py-2 rounded-lg border bg-input focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"12h",children:"12-hour (AM/PM)"}),h.jsx("option",{value:"24h",children:"24-hour"})]}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Time display format"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Default Editor"}),h.jsx(Gn,{type:"text",value:k.editor||"",onChange:F=>I({...k,editor:F.target.value}),placeholder:"code, vim, nano"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Default editor command for editing files"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Task Statuses"}),h.jsx("div",{className:"space-y-2 mb-3",children:$.map(F=>h.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-accent",children:[h.jsx("span",{className:"flex-1 font-mono text-sm",children:F}),h.jsx("select",{value:O[F]||"gray",onChange:U=>M(F,U.target.value),className:"px-2 py-1 rounded border bg-input text-sm focus:outline-none focus:ring-2 focus:ring-ring",children:Hht.map(U=>h.jsx("option",{value:U,children:U},U))}),h.jsx("button",{type:"button",onClick:()=>D(F),className:"p-1 text-destructive hover:text-destructive hover:bg-destructive/10 rounded transition-colors",title:"Remove status",children:h.jsx(Nu,{className:"w-4 h-4"})})]},F))}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Gn,{type:"text",value:v,onChange:F=>w(F.target.value),placeholder:"new-status",className:"flex-1",onKeyDown:F=>F.key==="Enter"&&R()}),h.jsxs(Le,{onClick:R,className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(Go,{className:"w-4 h-4 mr-2"}),"Add"]})]}),h.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Define custom task statuses and their colors for the Kanban board"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Visible Kanban Columns"}),h.jsx("div",{className:"space-y-2",children:$.map(F=>{const U=k.visibleColumns?.includes(F)??!0,G=F.split("-").map(j=>j.charAt(0).toUpperCase()+j.slice(1)).join(" ");return h.jsxs("label",{className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity",children:[h.jsx("input",{type:"checkbox",checked:U,onChange:j=>{const Q=k.visibleColumns||$,V=j.target.checked?[...Q,F]:Q.filter(K=>K!==F);I({...k,visibleColumns:V})},className:"w-4 h-4 rounded border-border text-primary focus:ring-primary"}),h.jsx("span",{children:G})]},F)})}),h.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Select which columns to show in the Kanban board"})]}),h.jsx("div",{className:"pt-4 border-t",children:h.jsxs(Le,{onClick:_,disabled:i,children:[h.jsx(lo,{className:"w-4 h-4 mr-2"}),i?"Saving...":"Save Configuration"]})})]})]})})}function Vht(e,t=[]){let n=[];function r(i,s){const a=x.createContext(s),l=n.length;n=[...n,s];const c=f=>{const{scope:m,children:g,...y}=f,v=m?.[e]?.[l]||a,w=x.useMemo(()=>y,Object.values(y));return h.jsx(v.Provider,{value:w,children:g})};c.displayName=i+"Provider";function u(f,m){const g=m?.[e]?.[l]||a,y=x.useContext(g);if(y)return y;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[c,u]}const o=()=>{const i=n.map(s=>x.createContext(s));return function(a){const l=a?.[e]||i;return x.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Ght(o,...t)]}function Ght(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Wht(e){const t=qht(e),n=x.forwardRef((r,o)=>{const{children:i,...s}=r,a=x.Children.toArray(i),l=a.find(Kht);if(l){const c=l.props.children,u=a.map(f=>f===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:f);return h.jsx(t,{...s,ref:o,children:x.isValidElement(c)?x.cloneElement(c,void 0,u):null})}return h.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function qht(e){const t=x.forwardRef((n,r)=>{const{children:o,...i}=n;if(x.isValidElement(o)){const s=Zht(o),a=Xht(i,o.props);return o.type!==x.Fragment&&(a.ref=r?Cn(r,s):s),x.cloneElement(o,a)}return x.Children.count(o)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Yht=Symbol("radix.slottable");function Kht(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Yht}function Xht(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const l=i(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Zht(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Qht=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mpe=Qht.reduce((e,t)=>{const n=Wht(`Primitive.${t}`),r=x.forwardRef((o,i)=>{const{asChild:s,...a}=o,l=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Ma="Accordion",Jht=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[WB,emt,tmt]=CT(Ma),[nk]=Vht(Ma,[tmt,Vde]),qB=Vde(),gpe=ue.forwardRef((e,t)=>{const{type:n,...r}=e,o=r,i=r;return h.jsx(WB.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?h.jsx(imt,{...i,ref:t}):h.jsx(omt,{...o,ref:t})})});gpe.displayName=Ma;var[bpe,nmt]=nk(Ma),[ype,rmt]=nk(Ma,{collapsible:!1}),omt=ue.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},collapsible:i=!1,...s}=e,[a,l]=si({prop:n,defaultProp:r??"",onChange:o,caller:Ma});return h.jsx(bpe,{scope:e.__scopeAccordion,value:ue.useMemo(()=>a?[a]:[],[a]),onItemOpen:l,onItemClose:ue.useCallback(()=>i&&l(""),[i,l]),children:h.jsx(ype,{scope:e.__scopeAccordion,collapsible:i,children:h.jsx(xpe,{...s,ref:t})})})}),imt=ue.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},...i}=e,[s,a]=si({prop:n,defaultProp:r??[],onChange:o,caller:Ma}),l=ue.useCallback(u=>a((f=[])=>[...f,u]),[a]),c=ue.useCallback(u=>a((f=[])=>f.filter(m=>m!==u)),[a]);return h.jsx(bpe,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c,children:h.jsx(ype,{scope:e.__scopeAccordion,collapsible:!0,children:h.jsx(xpe,{...i,ref:t})})})}),[smt,rk]=nk(Ma),xpe=ue.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:o,orientation:i="vertical",...s}=e,a=ue.useRef(null),l=Tt(a,t),c=emt(n),f=mm(o)==="ltr",m=We(e.onKeyDown,g=>{if(!Jht.includes(g.key))return;const y=g.target,v=c().filter(M=>!M.ref.current?.disabled),w=v.findIndex(M=>M.ref.current===y),S=v.length;if(w===-1)return;g.preventDefault();let T=w;const k=0,I=S-1,_=()=>{T=w+1,T>I&&(T=k)},R=()=>{T=w-1,T<k&&(T=I)};switch(g.key){case"Home":T=k;break;case"End":T=I;break;case"ArrowRight":i==="horizontal"&&(f?_():R());break;case"ArrowDown":i==="vertical"&&_();break;case"ArrowLeft":i==="horizontal"&&(f?R():_());break;case"ArrowUp":i==="vertical"&&R();break}const D=T%S;v[D].ref.current?.focus()});return h.jsx(smt,{scope:n,disabled:r,direction:o,orientation:i,children:h.jsx(WB.Slot,{scope:n,children:h.jsx(mpe.div,{...s,"data-orientation":i,ref:l,onKeyDown:r?void 0:m})})})}),LS="AccordionItem",[amt,YB]=nk(LS),vpe=ue.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...o}=e,i=rk(LS,n),s=nmt(LS,n),a=qB(n),l=gr(),c=r&&s.value.includes(r)||!1,u=i.disabled||e.disabled;return h.jsx(amt,{scope:n,open:c,disabled:u,triggerId:l,children:h.jsx(qde,{"data-orientation":i.orientation,"data-state":kpe(c),...a,...o,ref:t,disabled:u,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})})});vpe.displayName=LS;var Epe="AccordionHeader",wpe=ue.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=rk(Ma,n),i=YB(Epe,n);return h.jsx(mpe.h3,{"data-orientation":o.orientation,"data-state":kpe(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});wpe.displayName=Epe;var oO="AccordionTrigger",Spe=ue.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=rk(Ma,n),i=YB(oO,n),s=rmt(oO,n),a=qB(n);return h.jsx(WB.ItemSlot,{scope:n,children:h.jsx(wct,{"aria-disabled":i.open&&!s.collapsible||void 0,"data-orientation":o.orientation,id:i.triggerId,...a,...r,ref:t})})});Spe.displayName=oO;var Cpe="AccordionContent",Tpe=ue.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=rk(Ma,n),i=YB(Cpe,n),s=qB(n);return h.jsx(Sct,{role:"region","aria-labelledby":i.triggerId,"data-orientation":o.orientation,...s,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});Tpe.displayName=Cpe;function kpe(e){return e?"open":"closed"}var lmt=gpe,cmt=vpe,umt=wpe,Ape=Spe,Npe=Tpe;const _pe=Xs("group hover:before:opacity-100 before:absolute before:rounded-lg before:left-0 px-2 before:w-full before:opacity-0 before:bg-accent/70 before:h-[2rem] before:-z-10"),dmt=Xs("before:opacity-100 before:bg-primary/20 text-primary font-semibold"),Rpe=Xs("before:opacity-100 before:bg-primary/20 text-primary-foreground"),sm=ue.forwardRef(({data:e,initialSelectedItemId:t,onSelectChange:n,expandAll:r,defaultLeafIcon:o,defaultNodeIcon:i,className:s,onDocumentDrag:a,renderItem:l,...c},u)=>{const[f,m]=ue.useState(t);ue.useEffect(()=>{t!==f&&m(t)},[t]);const[g,y]=ue.useState(null),v=ue.useCallback(k=>{m(k?.id),n&&n(k)},[n]),w=ue.useCallback(k=>{y(k)},[]),S=ue.useCallback(k=>{g&&a&&g.id!==k.id&&a(g,k),y(null)},[g,a]),T=ue.useMemo(()=>{if(!t)return[];const k=[];function I(_,R){if(Array.isArray(_))for(let D=0;D<_.length;D++){if(k.push(_[D].id),I(_[D],R)&&!r)return!0;r||k.pop()}else{if(k.push(_.id),!r&&_.id===R||_.children&&I(_.children,R)&&!r)return!0;r||k.pop()}return!1}return I(e,t),k},[e,r,t]);return h.jsxs("div",{className:Ee("overflow-hidden relative p-2",s),children:[h.jsx(KB,{data:e,ref:u,selectedItemId:f,handleSelectChange:v,expandedItemIds:T,defaultLeafIcon:o,defaultNodeIcon:i,handleDragStart:w,handleDrop:S,draggedItem:g,renderItem:l,level:0,...c}),a&&h.jsx("div",{className:"w-full h-[48px]",onDrop:()=>{S({id:"",name:"parent_div"})}})]})});sm.displayName="TreeView";const KB=ue.forwardRef(({className:e,data:t,selectedItemId:n,handleSelectChange:r,expandedItemIds:o,defaultNodeIcon:i,defaultLeafIcon:s,handleDragStart:a,handleDrop:l,draggedItem:c,renderItem:u,level:f,onSelectChange:m,expandAll:g,initialSelectedItemId:y,onDocumentDrag:v,...w},S)=>(Array.isArray(t)||(t=[t]),h.jsx("div",{ref:S,role:"tree",className:e,...w,children:h.jsx("ul",{children:t.map(T=>h.jsx("li",{children:T.children?h.jsx(fmt,{item:T,level:f??0,selectedItemId:n,expandedItemIds:o,handleSelectChange:r,defaultNodeIcon:i,defaultLeafIcon:s,handleDragStart:a,handleDrop:l,draggedItem:c,renderItem:u}):h.jsx(Dpe,{item:T,level:f??0,selectedItemId:n,handleSelectChange:r,defaultLeafIcon:s,handleDragStart:a,handleDrop:l,draggedItem:c,renderItem:u})},T.id))})})));KB.displayName="TreeItem";const fmt=({item:e,handleSelectChange:t,expandedItemIds:n,selectedItemId:r,defaultNodeIcon:o,defaultLeafIcon:i,handleDragStart:s,handleDrop:a,draggedItem:l,renderItem:c,level:u=0})=>{const[f,m]=ue.useState(n.includes(e.id)?[e.id]:[]),[g,y]=ue.useState(!1),v=!!e.children?.length,w=r===e.id,S=f.includes(e.id);ue.useEffect(()=>{n.includes(e.id)&&!f.includes(e.id)&&m([e.id])},[n,e.id,f]);const T=R=>{if(!e.draggable){R.preventDefault();return}R.dataTransfer.setData("text/plain",e.id),s?.(e)},k=R=>{e.droppable!==!1&&l&&l.id!==e.id&&(R.preventDefault(),y(!0))},I=()=>{y(!1)},_=R=>{R.preventDefault(),y(!1),a?.(e)};return h.jsx(lmt,{type:"multiple",value:f,onValueChange:R=>m(R),children:h.jsxs(cmt,{value:e.id,children:[h.jsx(Ipe,{className:Ee(_pe(),g&&Rpe(),e.className),onClick:()=>{t(e),e.onClick?.()},draggable:!!e.draggable,onDragStart:T,onDragOver:k,onDragLeave:I,onDrop:_,children:c?c({item:e,level:u,isLeaf:!1,isSelected:w,isOpen:S,hasChildren:v}):h.jsxs(h.Fragment,{children:[h.jsx(Mpe,{item:e,isSelected:w,isOpen:S,default:o}),h.jsx("span",{className:"text-sm truncate",children:e.name}),h.jsx(Lpe,{isSelected:w,children:e.actions})]})}),h.jsx(Ope,{className:"ml-4 pl-1 border-l",children:h.jsx(KB,{data:e.children?e.children:e,selectedItemId:r,handleSelectChange:t,expandedItemIds:n,defaultLeafIcon:i,defaultNodeIcon:o,handleDragStart:s,handleDrop:a,draggedItem:l,renderItem:c,level:u+1})})]})})},Dpe=ue.forwardRef(({className:e,item:t,level:n,selectedItemId:r,handleSelectChange:o,defaultLeafIcon:i,handleDragStart:s,handleDrop:a,draggedItem:l,renderItem:c,...u},f)=>{const[m,g]=ue.useState(!1),y=r===t.id,v=k=>{if(!t.draggable||t.disabled){k.preventDefault();return}k.dataTransfer.setData("text/plain",t.id),s?.(t)},w=k=>{t.droppable!==!1&&!t.disabled&&l&&l.id!==t.id&&(k.preventDefault(),g(!0))},S=()=>{g(!1)},T=k=>{t.disabled||(k.preventDefault(),g(!1),a?.(t))};return h.jsx("div",{ref:f,className:Ee("ml-5 flex text-left items-center py-2 cursor-pointer before:right-1",_pe(),e,y&&dmt(),m&&Rpe(),t.disabled&&"opacity-50 cursor-not-allowed pointer-events-none",t.className),onClick:()=>{t.disabled||(o(t),t.onClick?.())},draggable:!!t.draggable&&!t.disabled,onDragStart:v,onDragOver:w,onDragLeave:S,onDrop:T,...u,children:c?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-4 w-4 shrink-0 mr-1"}),c({item:t,level:n,isLeaf:!0,isSelected:y,hasChildren:!1})]}):h.jsxs(h.Fragment,{children:[h.jsx(Mpe,{item:t,isSelected:y,default:i}),h.jsx("span",{className:"flex-grow text-sm truncate",children:t.name}),h.jsx(Lpe,{isSelected:y&&!t.disabled,children:t.actions})]})})});Dpe.displayName="TreeLeaf";const Ipe=ue.forwardRef(({className:e,children:t,...n},r)=>h.jsx(umt,{children:h.jsxs(Ape,{ref:r,className:Ee("flex flex-1 w-full items-center py-2 transition-all first:[&[data-state=open]>svg]:first-of-type:rotate-90",e),...n,children:[h.jsx(Au,{className:"h-4 w-4 shrink-0 transition-transform duration-200 text-accent-foreground/50 mr-1"}),t]})}));Ipe.displayName=Ape.displayName;const Ope=ue.forwardRef(({className:e,children:t,...n},r)=>h.jsx(Npe,{ref:r,className:Ee("overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",e),...n,children:h.jsx("div",{className:"pb-1 pt-0",children:t})}));Ope.displayName=Npe.displayName;const Mpe=({item:e,isOpen:t,isSelected:n,default:r})=>{let o=r;return n&&e.selectedIcon?o=e.selectedIcon:t&&e.openIcon?o=e.openIcon:e.icon&&(o=e.icon),o?h.jsx(o,{className:"h-4 w-4 shrink-0 mr-2"}):h.jsx(h.Fragment,{})},Lpe=({children:e,isSelected:t})=>h.jsx("div",{className:Ee(t?"block":"hidden","absolute right-3 group-hover:block"),children:e});function pmt(){const[e,t]=x.useState([]),[n,r]=x.useState(!0),[o,i]=x.useState(null),[s,a]=x.useState(!1),[l,c]=x.useState(""),[u,f]=x.useState(!1),[m,g]=x.useState(!1),[y,v]=x.useState(""),[w,S]=x.useState(""),[T,k]=x.useState(""),[I,_]=x.useState(""),[R,D]=x.useState(""),[M,$]=x.useState(!1),[O,F]=x.useState(!1),U=x.useRef(null);x.useEffect(()=>{j()},[]),rs("docs:updated",()=>{j()}),rs("docs:refresh",()=>{j()});const G=x.useCallback(()=>{if(e.length===0)return;const ne=window.location.hash.match(/^#\/docs\/(.+)$/);if(ne){const se=decodeURIComponent(ne[1]),pe=PE(se).replace(/^\.\//,"").replace(/^\//,""),ke=pe.replace(/\.md$/,""),Me=e.find(Ce=>{const Re=PE(Ce.path),de=Re.replace(/\.md$/,"");return Re===pe||Re===ke||de===pe||de===ke||Re.endsWith(`/${pe}`)||Re.endsWith(`/${ke}`)||Ce.filename===pe||Ce.filename===ke});Me&&Me!==o&&(i(Me),a(!1))}},[e,o]);x.useEffect(()=>{G()},[G]),x.useEffect(()=>(window.addEventListener("hashchange",G),()=>window.removeEventListener("hashchange",G)),[G]),x.useEffect(()=>{const ie=se=>{let pe=se.target;for(;pe&&pe.tagName!=="A"&&pe!==U.current;)pe=pe.parentElement;if(pe&&pe.tagName==="A"){const Me=pe.getAttribute("href");if(Me&&/^@?task-[\w.]+(.md)?$/.test(Me)){se.preventDefault();const Ce=Me.replace(/^@/,"").replace(".md","");window.location.hash=`/tasks?task=${Ce}`;return}if(Me&&Me.startsWith("@doc/")){se.preventDefault();const Ce=Me.replace("@doc/","");window.location.hash=`/docs/${Ce}.md`;return}if(Me&&(Me.endsWith(".md")||Me.includes(".md#"))){se.preventDefault();let Ce=Me.replace(/^\.\//,"").replace(/^\//,"");Ce=Ce.split("#")[0],window.location.hash=`/docs/${Ce}`}}},ne=U.current;if(ne)return ne.addEventListener("click",ie),()=>ne.removeEventListener("click",ie)},[e,o]);const j=()=>{iO().then(ie=>{t(ie),r(!1)}).catch(ie=>{console.error("Failed to load docs:",ie),r(!1)})},Q=async()=>{if(!y.trim()){alert("Please enter a title");return}$(!0);try{const ie=T.split(",").map(ne=>ne.trim()).filter(ne=>ne);await bge({title:y,description:w,tags:ie,folder:I,content:R}),v(""),S(""),k(""),_(""),D(""),g(!1),j()}catch(ie){console.error("Failed to create doc:",ie),alert("Failed to create document. Please try again.")}finally{$(!1)}},V=()=>{o&&(c(o.content),a(!0))},K=()=>{if(o){const ne=`@doc/${zg(o.path).replace(/\.md$/,"")}`;navigator.clipboard.writeText(ne).then(()=>{F(!0),setTimeout(()=>F(!1),2e3)})}},X=async()=>{if(o){f(!0);try{const ie=await yge(gCe(o.path),{content:l});t(ne=>ne.map(se=>se.path===o.path?{...se,content:l,metadata:{...se.metadata,updatedAt:new Date().toISOString()}}:se)),i(ne=>ne&&{...ne,content:l}),a(!1)}catch(ie){console.error("Failed to save doc:",ie),alert(ie instanceof Error?ie.message:"Failed to save document")}finally{f(!1)}}},J=()=>{a(!1),c("")},B=x.useCallback((ie,ne)=>{const se=new Map;for(const ke of ie){let Me=ke.folder;if(ke.isImported&&ke.source){const Te=ke.path.replace(`${ke.source}/`,"").split("/");Me=Te.length>1?Te.slice(0,-1).join("/"):""}const Ce=Me?Me.split("/"):[];let Re=se;for(let de=0;de<Ce.length;de++){const Te=Ce[de],Ge=Ce.slice(0,de+1).join("/");Re.has(Te)||Re.set(Te,{id:Ge,name:Te,isDoc:!1,children:new Map}),Re=Re.get(Te).children}Re.set(ke.path,{id:ke.path,name:ke.metadata.title,isDoc:!0,doc:ke,children:new Map})}const pe=ke=>Array.from(ke.values()).sort((Me,Ce)=>Me.isDoc!==Ce.isDoc?Me.isDoc?1:-1:Me.name.localeCompare(Ce.name)).map(Me=>Me.isDoc&&Me.doc?{id:Me.id,name:Me.name,icon:Br,onClick:()=>{window.location.hash=`/docs/${zg(Me.doc.path)}`}}:{id:Me.id,name:Me.name,icon:Lr,openIcon:No,children:Me.children.size>0?pe(Me.children):void 0});return pe(se)},[]),q=e.filter(ie=>!ie.isImported),Y=e.filter(ie=>ie.isImported),P=Y.reduce((ie,ne)=>{const se=ne.source||"unknown";return ie[se]||(ie[se]=[]),ie[se].push(ne),ie},{}),le=x.useMemo(()=>B(q,ie=>{window.location.hash=`/docs/${zg(ie.path)}`}),[q,B]),ae=x.useMemo(()=>Object.entries(P).map(([ie,ne])=>({id:`__import_${ie}__`,name:ie,icon:$K,children:B(ne,se=>{window.location.hash=`/docs/${zg(se.path)}`})})),[P,B]);return n?h.jsx("div",{className:"p-6 flex items-center justify-center h-64",children:h.jsx("div",{className:"text-lg text-muted-foreground",children:"Loading documentation..."})}):h.jsxs("div",{className:"p-6 h-full flex flex-col overflow-hidden",children:[h.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[h.jsx("h1",{className:"text-2xl font-bold",children:"Documentation"}),h.jsxs(Le,{onClick:()=>g(!0),className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(Go,{className:"w-4 h-4 mr-2"}),"New Document"]})]}),h.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 flex-1 min-h-0 overflow-hidden",children:[h.jsxs("div",{className:"lg:col-span-1 flex flex-col min-h-0 overflow-hidden",children:[h.jsxs("div",{className:"bg-card rounded-lg border overflow-hidden flex flex-col flex-1 min-h-0",children:[h.jsx("div",{className:"p-4 border-b shrink-0",children:h.jsxs("h2",{className:"font-semibold",children:["All Documents (",e.length,")"]})}),h.jsxs(Xr,{className:"flex-1",children:[q.length>0&&h.jsx(sm,{data:{id:"__local__",name:`Local (${q.length})`,icon:Lr,openIcon:No,children:le},defaultNodeIcon:Lr,defaultLeafIcon:Br,initialSelectedItemId:o?.path}),ae.length>0&&h.jsx(sm,{data:{id:"__imports__",name:`Imports (${Y.length})`,icon:Ah,openIcon:Ah,children:ae},defaultNodeIcon:Lr,defaultLeafIcon:Br,initialSelectedItemId:o?.path})]})]}),e.length===0&&h.jsxs("div",{className:"bg-card rounded-lg border p-8 text-center",children:[h.jsx(Br,{className:"w-5 h-5"}),h.jsx("p",{className:"mt-2 text-muted-foreground",children:"No documentation found"}),h.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Create a doc with: ",h.jsx("code",{className:"font-mono",children:'knowns doc create "Title"'})]})]})]}),h.jsx("div",{className:"lg:col-span-2 flex flex-col min-h-0 overflow-hidden",children:o?h.jsxs("div",{className:"bg-card rounded-lg border overflow-hidden flex flex-col flex-1 min-h-0",children:[h.jsxs("div",{className:"p-6 border-b flex items-start justify-between shrink-0",children:[h.jsxs("div",{className:"flex-1",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[h.jsx("h2",{className:"text-2xl font-bold",children:o.metadata.title}),o.isImported&&h.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 rounded",children:"Imported"})]}),o.isImported&&o.source&&h.jsxs("p",{className:"text-sm text-blue-600 dark:text-blue-400 mb-2",children:["From: ",o.source]}),o.metadata.description&&h.jsx("p",{className:"text-muted-foreground mb-2",children:o.metadata.description}),h.jsxs("button",{type:"button",onClick:K,className:"flex items-center gap-2 px-2 py-1 rounded text-xs text-blue-600 dark:text-blue-400 hover:bg-accent transition-colors group",title:"Click to copy reference",children:[h.jsx(Lr,{className:"w-4 h-4"}),h.jsxs("span",{className:"font-mono",children:["@doc/",zg(o.path).replace(/\.md$/,"")]}),h.jsx("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:O?"✓ Copied!":h.jsx(LK,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"text-sm text-muted-foreground mt-2",children:["Last updated: ",new Date(o.metadata.updatedAt).toLocaleString()]})]}),h.jsx("div",{className:"flex gap-2 ml-4",children:s?h.jsxs(h.Fragment,{children:[h.jsxs(Le,{onClick:X,disabled:u,className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(lo,{className:"w-4 h-4 mr-2"}),u?"Saving...":"Save"]}),h.jsxs(Le,{variant:"secondary",onClick:J,disabled:u,children:[h.jsx(ti,{className:"w-4 h-4 mr-2"}),"Cancel"]})]}):h.jsxs(Le,{onClick:V,disabled:o.isImported,title:o.isImported?"Imported docs are read-only":"Edit document",children:[h.jsx(UK,{className:"w-4 h-4 mr-2"}),"Edit"]})})]}),s?h.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:h.jsx("div",{className:"flex-1 p-6 min-h-0",children:h.jsx(Tu,{markdown:l,onChange:c,placeholder:"Write your documentation here..."})})}):h.jsx(Xr,{className:"flex-1",children:h.jsx("div",{className:"p-6 prose prose-sm dark:prose-invert max-w-none",ref:U,children:h.jsx(DC,{markdown:o.content||""})})})]}):h.jsxs("div",{className:"bg-card rounded-lg border p-12 text-center",children:[h.jsx(Br,{className:"w-5 h-5"}),h.jsx("p",{className:"mt-4 text-muted-foreground",children:"Select a document to view its content"})]})})]}),m&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-card rounded-lg shadow-xl max-w-4xl w-full h-[90vh] flex flex-col",children:[h.jsx("div",{className:"p-6 border-b shrink-0",children:h.jsx("h2",{className:"text-xl font-bold",children:"Create New Document"})}),h.jsxs("div",{className:"p-6 space-y-4 flex-1 flex flex-col overflow-hidden",children:[h.jsxs("div",{className:"shrink-0",children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Title *"}),h.jsx(Gn,{type:"text",value:y,onChange:ie=>v(ie.target.value),placeholder:"Document title"})]}),h.jsxs("div",{className:"shrink-0",children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Description"}),h.jsx(Gn,{type:"text",value:w,onChange:ie=>S(ie.target.value),placeholder:"Brief description"})]}),h.jsxs("div",{className:"shrink-0",children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Folder (optional)"}),h.jsx(Gn,{type:"text",value:I,onChange:ie=>_(ie.target.value),placeholder:"api/auth, guides, etc. (leave empty for root)"})]}),h.jsxs("div",{className:"shrink-0",children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Tags (comma-separated)"}),h.jsx(Gn,{type:"text",value:T,onChange:ie=>k(ie.target.value),placeholder:"guide, tutorial, api"})]}),h.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[h.jsx("label",{className:"block text-sm font-medium mb-2",children:"Content"}),h.jsx("div",{className:"flex-1 min-h-[400px]",children:h.jsx(Tu,{markdown:R,onChange:D,placeholder:"Write your documentation here..."})})]})]}),h.jsxs("div",{className:"p-6 border-t flex justify-end gap-3 shrink-0",children:[h.jsx(Le,{variant:"secondary",onClick:()=>{g(!1),v(""),S(""),k(""),_(""),D("")},disabled:M,children:"Cancel"}),h.jsx(Le,{onClick:Q,disabled:M||!y.trim(),className:"bg-green-700 hover:bg-green-800 text-white",children:M?"Creating...":"Create Document"})]})]})})]})}function hmt(e,t=[]){let n=[];function r(i,s){const a=x.createContext(s),l=n.length;n=[...n,s];const c=f=>{const{scope:m,children:g,...y}=f,v=m?.[e]?.[l]||a,w=x.useMemo(()=>y,Object.values(y));return h.jsx(v.Provider,{value:w,children:g})};c.displayName=i+"Provider";function u(f,m){const g=m?.[e]?.[l]||a,y=x.useContext(g);if(y)return y;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[c,u]}const o=()=>{const i=n.map(s=>x.createContext(s));return function(a){const l=a?.[e]||i;return x.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,mmt(o,...t)]}function mmt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function gmt(e){const t=bmt(e),n=x.forwardRef((r,o)=>{const{children:i,...s}=r,a=x.Children.toArray(i),l=a.find(xmt);if(l){const c=l.props.children,u=a.map(f=>f===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:f);return h.jsx(t,{...s,ref:o,children:x.isValidElement(c)?x.cloneElement(c,void 0,u):null})}return h.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function bmt(e){const t=x.forwardRef((n,r)=>{const{children:o,...i}=n;if(x.isValidElement(o)){const s=Emt(o),a=vmt(i,o.props);return o.type!==x.Fragment&&(a.ref=r?Cn(r,s):s),x.cloneElement(o,a)}return x.Children.count(o)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ymt=Symbol("radix.slottable");function xmt(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ymt}function vmt(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const l=i(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Emt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var wmt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ppe=wmt.reduce((e,t)=>{const n=gmt(`Primitive.${t}`),r=x.forwardRef((o,i)=>{const{asChild:s,...a}=o,l=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),ok="Switch",[Smt]=hmt(ok),[Cmt,Tmt]=Smt(ok),Fpe=x.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[m,g]=x.useState(null),y=Tt(t,k=>g(k)),v=x.useRef(!1),w=m?u||!!m.closest("form"):!0,[S,T]=si({prop:o,defaultProp:i??!1,onChange:c,caller:ok});return h.jsxs(Cmt,{scope:n,checked:S,disabled:a,children:[h.jsx(Ppe.button,{type:"button",role:"switch","aria-checked":S,"aria-required":s,"data-state":Upe(S),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:y,onClick:We(e.onClick,k=>{T(I=>!I),w&&(v.current=k.isPropagationStopped(),v.current||k.stopPropagation())})}),w&&h.jsx($pe,{control:m,bubbles:!v.current,name:r,value:l,checked:S,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});Fpe.displayName=ok;var Bpe="SwitchThumb",jpe=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Tmt(Bpe,n);return h.jsx(Ppe.span,{"data-state":Upe(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});jpe.displayName=Bpe;var kmt="SwitchBubbleInput",$pe=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},i)=>{const s=x.useRef(null),a=Tt(s,i),l=YF(n),c=kF(t);return x.useEffect(()=>{const u=s.current;if(!u)return;const f=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&g){const y=new Event("click",{bubbles:r});g.call(u,n),u.dispatchEvent(y)}},[l,n,r]),h.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});$pe.displayName=kmt;function Upe(e){return e?"checked":"unchecked"}var Hpe=Fpe,Amt=jpe;const Th=x.forwardRef(({className:e,...t},n)=>h.jsx(Hpe,{className:Ee("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:h.jsx(Amt,{className:Ee("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Th.displayName=Hpe.displayName;function gK(e){return e?new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never"}function bK({type:e}){switch(e){case"git":return h.jsx(Xbe,{className:"w-5 h-5 text-orange-500"});case"npm":return h.jsx($K,{className:"w-5 h-5 text-red-500"});case"local":return h.jsx(No,{className:"w-5 h-5 text-blue-500"});default:return h.jsx(Ah,{className:"w-5 h-5 text-gray-500"})}}function aR(e){const t=new Map;for(const r of e){const o=r.split("/");let i=t;for(let s=0;s<o.length;s++){const a=o[s],l=s===o.length-1,c=o.slice(0,s+1).join("/");i.has(a)||i.set(a,{id:c,name:a,isFile:l,children:new Map}),i=i.get(a).children}}const n=r=>Array.from(r.values()).sort((o,i)=>o.isFile!==i.isFile?o.isFile?1:-1:o.name.localeCompare(i.name)).map(o=>({id:o.id,name:o.name,icon:o.isFile?Br:Lr,openIcon:o.isFile?Br:No,children:o.children.size>0?n(o.children):void 0}));return n(t)}const yK=({className:e})=>h.jsx(lo,{className:`${e} text-green-600`}),xK=({className:e})=>h.jsx(ti,{className:`${e} text-muted-foreground`});function lR(e){const t=new Map;for(const r of e){const o=r.path.split("/");let i=t;for(let s=0;s<o.length;s++){const a=o[s],l=s===o.length-1,c=o.slice(0,s+1).join("/");i.has(a)||i.set(a,{id:c,name:a,isFile:l,action:l?r.action:void 0,children:new Map}),i=i.get(a).children}}const n=r=>Array.from(r.values()).sort((o,i)=>o.isFile!==i.isFile?o.isFile?1:-1:o.name.localeCompare(i.name)).map(o=>({id:o.id,name:o.name,icon:o.isFile?o.action==="skip"?xK:yK:Lr,openIcon:o.isFile?o.action==="skip"?xK:yK:No,children:o.children.size>0?n(o.children):void 0}));return n(t)}function Nmt(){const[e,t]=x.useState([]),[n,r]=x.useState(!0),[o,i]=x.useState(null),[s,a]=x.useState(null),[l,c]=x.useState(!1),[u,f]=x.useState(!1),[m,g]=x.useState(""),[y,v]=x.useState(""),[w,S]=x.useState(""),[T,k]=x.useState(""),[I,_]=x.useState(!1),[R,D]=x.useState(!0),[M,$]=x.useState(!1),[O,F]=x.useState(null),[U,G]=x.useState(null),[j,Q]=x.useState(null),[V,K]=x.useState(!1),[X,J]=x.useState(null),[B,q]=x.useState(null),[Y,P]=x.useState(!1),[le,ae]=x.useState(!1),ie=x.useCallback(async()=>{try{const Re=await kp.list();t(Re.imports)}catch(Re){console.error("Failed to load imports:",Re)}finally{r(!1)}},[]);x.useEffect(()=>{ie()},[ie]),rs("imports:added",()=>ie()),rs("imports:synced",()=>ie()),rs("imports:removed",()=>{ie(),s&&(i(null),a(null))});const ne=async Re=>{c(!0),a(Re),J(null);try{const de=await kp.get(Re);i(de.import)}catch(de){console.error("Failed to load import:",de),i(null)}finally{c(!1)}},se=async()=>{if(m.trim()){$(!0),G(null),F(null);try{const Re=await kp.add({source:m,name:y||void 0,type:w||void 0,ref:T||void 0,link:I,dryRun:R});F(Re),R||(ie(),ne(Re.import.name))}catch(Re){G(Re instanceof Error?Re.message:String(Re))}finally{$(!1)}}},pe=async Re=>{Q(Re),J(null);try{const de=await kp.sync(Re);J(de),ie(),s===Re&&ne(Re),so.success(`Synced "${Re}"`,{description:`Added: ${de.summary.added}, Updated: ${de.summary.updated}, Skipped: ${de.summary.skipped}`})}catch(de){console.error("Failed to sync:",de),so.error(`Failed to sync "${Re}"`,{description:de instanceof Error?de.message:String(de)})}finally{Q(null)}},ke=async()=>{K(!0);try{const Re=await kp.syncAll();ie(),s&&ne(s);const{summary:de}=Re;de.total===0?so.info("No imports to sync"):de.failed>0?so.warning(`Synced ${de.successful} of ${de.total} imports`,{description:`${de.failed} failed`}):so.success(`Synced ${de.successful} import${de.successful>1?"s":""}`,{description:"All imports are up to date"})}catch(Re){console.error("Failed to sync all:",Re),so.error("Failed to sync imports",{description:Re instanceof Error?Re.message:String(Re)})}finally{K(!1)}},Me=async()=>{if(s){q(s);try{await kp.remove(s,le),P(!1),i(null),a(null),ie()}catch(Re){console.error("Failed to remove:",Re)}finally{q(null)}}},Ce=()=>{g(""),v(""),S(""),k(""),_(!1),D(!0),F(null),G(null),f(!1)};return n?h.jsx("div",{className:"p-6 flex items-center justify-center h-64",children:h.jsx("div",{className:"text-lg text-muted-foreground",children:"Loading imports..."})}):h.jsxs("div",{className:"p-6 h-full flex flex-col overflow-hidden",children:[h.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold",children:"Imports"}),h.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Import templates and docs from external sources"})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(Le,{variant:"outline",onClick:ke,disabled:V||e.length===0,children:[V?h.jsx(iu,{className:"w-4 h-4 mr-2 animate-spin"}):h.jsx(n0,{className:"w-4 h-4 mr-2"}),"Sync All"]}),h.jsxs(Le,{onClick:()=>f(!0),className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(Go,{className:"w-4 h-4 mr-2"}),"Add Import"]})]})]}),h.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 flex-1 min-h-0 overflow-hidden",children:[h.jsxs("div",{className:"lg:col-span-1 flex flex-col min-h-0 overflow-hidden",children:[h.jsxs("div",{className:"bg-card rounded-lg border overflow-hidden flex flex-col flex-1 min-h-0",children:[h.jsx("div",{className:"p-4 border-b shrink-0",children:h.jsxs("h2",{className:"font-semibold",children:["Configured Imports (",e.length,")"]})}),h.jsx(Xr,{className:"flex-1",children:e.map(Re=>h.jsxs("button",{type:"button",onClick:()=>ne(Re.name),className:`w-full text-left px-4 py-3 flex items-start gap-3 hover:bg-accent text-foreground transition-colors border-b ${s===Re.name?"bg-accent":""}`,children:[h.jsx(bK,{type:Re.type}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"font-medium truncate flex items-center gap-2",children:[Re.name,Re.link&&h.jsx(c0e,{className:"w-3 h-3 text-muted-foreground"})]}),h.jsx("div",{className:"text-sm text-muted-foreground truncate",children:Re.source}),h.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[Re.fileCount," files • Synced ",gK(Re.lastSync)]})]}),h.jsx(Au,{className:"w-4 h-4 text-muted-foreground shrink-0"})]},Re.name))})]}),e.length===0&&h.jsxs("div",{className:"bg-card rounded-lg border p-8 text-center",children:[h.jsx(Ah,{className:"w-12 h-12 mx-auto text-muted-foreground"}),h.jsx("p",{className:"mt-2 font-medium",children:"No imports yet"}),h.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Import templates and docs from git, npm, or local paths"}),h.jsxs(Le,{onClick:()=>f(!0),className:"mt-4",variant:"outline",children:[h.jsx(Go,{className:"w-4 h-4 mr-2"}),"Add your first import"]})]})]}),h.jsx("div",{className:"lg:col-span-2 flex flex-col min-h-0 overflow-hidden",children:l?h.jsxs("div",{className:"bg-card rounded-lg border p-12 text-center",children:[h.jsx(iu,{className:"w-8 h-8 mx-auto animate-spin text-muted-foreground"}),h.jsx("div",{className:"mt-2 text-muted-foreground",children:"Loading import..."})]}):o?h.jsxs("div",{className:"bg-card rounded-lg border overflow-hidden flex flex-col flex-1 min-h-0",children:[h.jsx("div",{className:"p-6 border-b shrink-0 bg-gradient-to-r from-blue-50 to-transparent dark:from-blue-950/20",children:h.jsxs("div",{className:"flex items-start justify-between gap-4",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx(bK,{type:o.type}),h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.link&&h.jsx("span",{className:"text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 px-2 py-0.5 rounded",children:"Symlinked"})]}),h.jsx("p",{className:"text-muted-foreground text-sm mt-1 font-mono",children:o.source})]})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Le,{variant:"outline",size:"sm",onClick:()=>pe(o.name),disabled:j===o.name||o.link,children:j===o.name?h.jsx(iu,{className:"w-4 h-4 animate-spin"}):h.jsx(n0,{className:"w-4 h-4"})}),h.jsx(Le,{variant:"outline",size:"sm",className:"text-red-600 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-950/30",onClick:()=>P(!0),children:h.jsx(Nu,{className:"w-4 h-4"})})]})]})}),h.jsx(Xr,{className:"flex-1",children:h.jsxs("div",{className:"p-6 space-y-6",children:[h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"text-sm text-muted-foreground",children:"Type"}),h.jsx("div",{className:"font-medium capitalize",children:o.type})]}),o.ref&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"text-sm text-muted-foreground",children:"Ref"}),h.jsx("div",{className:"font-medium font-mono",children:o.ref})]}),o.commit&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"text-sm text-muted-foreground",children:"Commit"}),h.jsx("div",{className:"font-medium font-mono text-sm",children:o.commit})]}),o.version&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"text-sm text-muted-foreground",children:"Version"}),h.jsx("div",{className:"font-medium",children:o.version})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[h.jsx(aO,{className:"w-3 h-3"}),"Last Sync"]}),h.jsx("div",{className:"font-medium",children:gK(o.lastSync)})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[h.jsx(Br,{className:"w-3 h-3"}),"Files"]}),h.jsxs("div",{className:"font-medium",children:[o.fileCount," files"]})]})]}),X&&X.import.name===o.name&&h.jsx("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-4",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsx(lo,{className:"w-5 h-5 text-green-600 shrink-0 mt-0.5"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium text-green-800 dark:text-green-300",children:"Sync Complete"}),h.jsxs("div",{className:"text-sm text-green-700 dark:text-green-400 mt-1",children:["Added: ",X.summary.added,", Updated: ",X.summary.updated,", Skipped: ",X.summary.skipped]}),X.warnings&&X.warnings.length>0&&h.jsx("div",{className:"text-sm text-amber-600 dark:text-amber-400 mt-2",children:X.warnings.map((Re,de)=>h.jsxs("div",{children:["⚠️ ",Re]},de))})]})]})}),h.jsxs("div",{children:[h.jsx("h3",{className:"font-semibold mb-3",children:"Imported Files"}),h.jsx("div",{className:"rounded-lg border bg-muted/30 max-h-80 overflow-y-auto",children:o.files.length>0?(()=>{const Re=o.files.filter(Ie=>Ie.startsWith("templates/")),de=o.files.filter(Ie=>Ie.startsWith("docs/")),Te=o.files.filter(Ie=>!Ie.startsWith("templates/")&&!Ie.startsWith("docs/")),Ge=[];return Re.length>0&&Ge.push({id:"__templates__",name:`Templates (${Re.length})`,icon:Lr,openIcon:No,children:aR(Re.map(Ie=>Ie.replace(/^templates\//,"")))}),de.length>0&&Ge.push({id:"__docs__",name:`Docs (${de.length})`,icon:Lr,openIcon:No,children:aR(de.map(Ie=>Ie.replace(/^docs\//,"")))}),Te.length>0&&Ge.push({id:"__other__",name:`Other (${Te.length})`,icon:Lr,openIcon:No,children:aR(Te)}),h.jsx(sm,{data:Ge,expandAll:!0,defaultNodeIcon:Lr,defaultLeafIcon:Br})})():h.jsx("div",{className:"px-4 py-8 text-center text-muted-foreground",children:"No files imported"})})]})]})})]}):h.jsxs("div",{className:"bg-card rounded-lg border p-12 text-center",children:[h.jsx(Ah,{className:"w-16 h-16 mx-auto text-muted-foreground/50"}),h.jsx("h3",{className:"mt-4 text-lg font-medium",children:"Select an import"}),h.jsx("p",{className:"mt-2 text-muted-foreground max-w-md mx-auto",children:"Choose an import from the list to view details, sync, or remove it."})]})})]}),u&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-card rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto",children:[h.jsxs("div",{className:"p-6 border-b",children:[h.jsx("h2",{className:"text-xl font-bold",children:"Add Import"}),h.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Import templates and docs from an external source"})]}),h.jsxs("div",{className:"p-6 space-y-4",children:[h.jsxs("div",{children:[h.jsxs(Xt,{className:"mb-2 block",children:["Source ",h.jsx("span",{className:"text-red-500",children:"*"})]}),h.jsx(Gn,{type:"text",value:m,onChange:Re=>g(Re.target.value),placeholder:"https://github.com/org/repo.git, @org/package, or ../path"}),h.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Git URL, npm package, or local path"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx(Xt,{className:"mb-2 block",children:"Name (optional)"}),h.jsx(Gn,{type:"text",value:y,onChange:Re=>v(Re.target.value),placeholder:"Auto-detect from source"})]}),h.jsxs("div",{children:[h.jsx(Xt,{className:"mb-2 block",children:"Type (optional)"}),h.jsxs("select",{value:w,onChange:Re=>S(Re.target.value),className:"w-full px-3 py-2 rounded-lg border bg-background",children:[h.jsx("option",{value:"",children:"Auto-detect"}),h.jsx("option",{value:"git",children:"Git"}),h.jsx("option",{value:"npm",children:"NPM"}),h.jsx("option",{value:"local",children:"Local"})]})]})]}),h.jsxs("div",{children:[h.jsx(Xt,{className:"mb-2 block",children:"Ref (optional)"}),h.jsx(Gn,{type:"text",value:T,onChange:Re=>k(Re.target.value),placeholder:"Branch, tag, or version"})]}),h.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-muted/30",children:[h.jsx(Th,{id:"link",checked:I,onCheckedChange:_,disabled:w!=="local"&&!m.startsWith(".")}),h.jsxs(Xt,{htmlFor:"link",className:"text-sm cursor-pointer flex-1",children:[h.jsx("span",{className:"font-medium",children:"Symlink"}),h.jsx("span",{className:"text-muted-foreground ml-2",children:"(local only)"})]})]}),h.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-muted/30",children:[h.jsx(Th,{id:"dry-run",checked:R,onCheckedChange:D}),h.jsxs(Xt,{htmlFor:"dry-run",className:"text-sm cursor-pointer flex-1",children:[h.jsx("span",{className:"font-medium",children:"Preview mode"}),h.jsx("span",{className:"text-muted-foreground ml-2",children:"(no files created)"})]})]}),U&&h.jsx("div",{className:"bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-800 rounded-lg p-4",children:h.jsxs("div",{className:"flex items-start gap-2 text-red-600 dark:text-red-400",children:[h.jsx(Jb,{className:"w-5 h-5 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-sm",children:U})]})}),O&&h.jsx("div",{className:`border rounded-lg p-4 ${O.dryRun?"bg-blue-50 dark:bg-blue-950/30 border-blue-200 dark:border-blue-800":"bg-green-50 dark:bg-green-950/30 border-green-200 dark:border-green-800"}`,children:h.jsxs("div",{className:"flex items-start gap-2",children:[O.dryRun?h.jsx(Jb,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 shrink-0"}):h.jsx(lo,{className:"w-5 h-5 text-green-600 shrink-0"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("div",{className:"font-medium",children:O.dryRun?"Preview Complete":"Import Complete"}),h.jsxs("div",{className:"text-sm text-muted-foreground mt-1",children:[O.summary.added," files to add, ",O.summary.updated," to update, ",O.summary.skipped," skipped"]}),O.dryRun&&O.changes.length>0&&h.jsx("div",{className:"mt-3 max-h-48 overflow-y-auto rounded border bg-muted/30",children:(()=>{const Re=O.changes.filter(Ie=>Ie.path.startsWith("templates/")),de=O.changes.filter(Ie=>Ie.path.startsWith("docs/")),Te=O.changes.filter(Ie=>!Ie.path.startsWith("templates/")&&!Ie.path.startsWith("docs/")),Ge=[];return Re.length>0&&Ge.push({id:"__templates__",name:`Templates (${Re.length})`,icon:Lr,openIcon:No,children:lR(Re.map(Ie=>({...Ie,path:Ie.path.replace(/^templates\//,"")})))}),de.length>0&&Ge.push({id:"__docs__",name:`Docs (${de.length})`,icon:Lr,openIcon:No,children:lR(de.map(Ie=>({...Ie,path:Ie.path.replace(/^docs\//,"")})))}),Te.length>0&&Ge.push({id:"__other__",name:`Other (${Te.length})`,icon:Lr,openIcon:No,children:lR(Te)}),h.jsx(sm,{data:Ge,expandAll:!0,defaultNodeIcon:Lr,defaultLeafIcon:Br})})()}),O.dryRun&&h.jsx(Le,{onClick:()=>{D(!1),se()},className:"mt-3 bg-green-600 hover:bg-green-700 text-white",size:"sm",children:"Import Now"})]})]})})]}),h.jsxs("div",{className:"p-6 border-t flex justify-end gap-3",children:[h.jsx(Le,{variant:"secondary",onClick:Ce,disabled:M,children:O&&!O.dryRun?"Close":"Cancel"}),(!O||O.dryRun)&&h.jsx(Le,{onClick:se,disabled:M||!m.trim(),className:R?"":"bg-green-600 hover:bg-green-700 text-white",children:M?h.jsxs(h.Fragment,{children:[h.jsx(iu,{className:"w-4 h-4 mr-2 animate-spin"}),R?"Checking...":"Importing..."]}):R?"Preview":"Import"})]})]})}),Y&&o&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-card rounded-lg shadow-xl max-w-md w-full",children:[h.jsx("div",{className:"p-6 border-b",children:h.jsx("h2",{className:"text-xl font-bold text-red-600",children:"Remove Import"})}),h.jsxs("div",{className:"p-6 space-y-4",children:[h.jsxs("p",{children:["Are you sure you want to remove the import"," ",h.jsx("strong",{children:o.name}),"?"]}),h.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-muted/30",children:[h.jsx(Th,{id:"delete-files",checked:le,onCheckedChange:ae}),h.jsxs(Xt,{htmlFor:"delete-files",className:"text-sm cursor-pointer flex-1",children:[h.jsx("span",{className:"font-medium",children:"Also delete imported files"}),h.jsxs("span",{className:"text-muted-foreground block text-xs mt-0.5",children:[o.fileCount," files will be permanently deleted"]})]})]})]}),h.jsxs("div",{className:"p-6 border-t flex justify-end gap-3",children:[h.jsx(Le,{variant:"secondary",onClick:()=>{P(!1),ae(!1)},disabled:B!==null,children:"Cancel"}),h.jsx(Le,{onClick:Me,disabled:B!==null,className:"bg-red-600 hover:bg-red-700 text-white",children:B?h.jsxs(h.Fragment,{children:[h.jsx(iu,{className:"w-4 h-4 mr-2 animate-spin"}),"Removing..."]}):"Remove"})]})]})})]})}const _mt=[{label:"1 hour ago",value:3600*1e3},{label:"1 day ago",value:1440*60*1e3},{label:"1 week ago",value:10080*60*1e3},{label:"1 month ago",value:720*60*60*1e3},{label:"3 months ago",value:2160*60*60*1e3}];function vK({tasks:e,loading:t,onTasksUpdate:n,onNewTask:r}){const o=s=>{const a=Date.now()-s;return e.filter(l=>l.status==="done"&&new Date(l.updatedAt).getTime()<a).length},i=async(s,a)=>{try{const l=await ma.batchArchiveTasks(s);if(l.count>0){const c=new Set(l.tasks.map(u=>u.id));n(e.filter(u=>!c.has(u.id))),so.success(`Archived ${l.count} task${l.count>1?"s":""} done before ${a}`)}else so.info(`No done tasks found before ${a}`)}catch(l){console.error("Failed to batch archive tasks:",l),so.error("Failed to archive tasks")}};return h.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[h.jsx("div",{className:"shrink-0 p-6 pb-0",children:h.jsxs("div",{className:"mb-4 flex items-center justify-between gap-4",children:[h.jsx("h1",{className:"text-2xl font-bold",children:"Kanban Board"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(gB,{children:[h.jsx(bB,{asChild:!0,children:h.jsxs(Le,{variant:"outline",size:"default",className:"gap-2",children:[h.jsx(uR,{className:"w-4 h-4"}),h.jsx("span",{className:"hidden sm:inline",children:"Batch Archive"}),h.jsx(cc,{className:"w-3 h-3"})]})}),h.jsx(UT,{align:"end",children:_mt.map(s=>{const a=o(s.value);return h.jsxs(ef,{onClick:()=>i(s.value,s.label),disabled:a===0,children:[h.jsxs("span",{className:"flex-1",children:["Done before ",s.label]}),h.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",a,")"]})]},s.value)})})]}),h.jsxs(Le,{onClick:r,className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(Go,{className:"w-4 h-4 mr-2"}),"New Task"]})]})]})}),h.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-6",children:h.jsx(spt,{tasks:e,loading:t,onTasksUpdate:n})})]})}const EK={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold",urgent:"Urgent"};function Rmt(e){return EK[e]?EK[e]:e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Dmt({tasks:e,onTaskClick:t,onNewTask:n}){const[r,o]=x.useState("all"),[i,s]=x.useState("all"),[a,l]=x.useState(new Set),c=e.filter(g=>g.subtasks&&g.subtasks.length>0);let u=r==="all"?e:e.filter(g=>g.status===r);i==="root"?u=u.filter(g=>!g.parent):i!=="all"&&(u=u.filter(g=>g.parent===i));const f={todo:[],"in-progress":[],"in-review":[],blocked:[],done:[]};for(const g of u)f[g.status]&&f[g.status].push(g);const m={high:0,medium:1,low:2};for(const g in f)f[g].sort((y,v)=>{const w=m[y.priority]-m[v.priority];return w!==0?w:y.id.localeCompare(v.id,void 0,{numeric:!0})});return h.jsxs("div",{className:"h-full flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between gap-4 mb-4",children:[h.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[h.jsx(lO,{className:"w-4 h-4 text-muted-foreground"}),h.jsxs(ri,{value:r,onValueChange:o,children:[h.jsx(zo,{className:"w-[150px]",children:h.jsx(oi,{placeholder:"Status"})}),h.jsxs(Vo,{children:[h.jsx(En,{value:"all",children:"All Status"}),h.jsx(En,{value:"todo",children:"To Do"}),h.jsx(En,{value:"in-progress",children:"In Progress"}),h.jsx(En,{value:"in-review",children:"In Review"}),h.jsx(En,{value:"blocked",children:"Blocked"}),h.jsx(En,{value:"done",children:"Done"})]})]}),h.jsxs(ri,{value:i,onValueChange:s,children:[h.jsx(zo,{className:"w-[200px]",children:h.jsx(oi,{placeholder:"Parent"})}),h.jsxs(Vo,{children:[h.jsx(En,{value:"all",children:"All Tasks"}),h.jsx(En,{value:"root",children:"Root Tasks Only"}),c.map(g=>{const y=`Subtasks of #${g.id}: ${g.title}`,v=y.length>40?y.substring(0,40)+"...":y;return h.jsx(En,{value:g.id,title:y,children:v},g.id)})]})]}),h.jsxs("span",{className:"text-muted-foreground text-sm",children:[u.length," ",u.length===1?"task":"tasks"]})]}),h.jsxs(Le,{onClick:n,className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(Go,{className:"mr-2 h-4 w-4"}),"New Task"]})]}),h.jsx(Xr,{className:"flex-1",children:h.jsxs("div",{className:"space-y-6 pr-4",children:[Object.entries(f).map(([g,y])=>y.length===0?null:h.jsxs("div",{children:[h.jsxs("h2",{className:"text-lg font-semibold mb-3",children:[Rmt(g)," (",y.length,")"]}),h.jsx("div",{className:"space-y-2",children:y.map(v=>{const w=a.has(v.id),S=v.parent?e.find(T=>T.id===v.parent):null;return h.jsx("div",{className:"bg-card rounded-lg p-4 border transition-colors hover:bg-accent/50",children:h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[h.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["#",v.id]}),h.jsx($de,{status:v.status}),h.jsx(Ude,{priority:v.priority}),S&&h.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",children:["Subtask of #",S.id]}),v.subtasks&&v.subtasks.length>0&&h.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",children:[v.subtasks.length," subtask",v.subtasks.length>1?"s":""]})]}),h.jsx("button",{type:"button",onClick:()=>t(v),className:"font-medium mb-1 hover:underline text-left w-full",children:v.title}),v.description&&h.jsxs("div",{className:"text-sm text-muted-foreground mt-2",children:[h.jsx("p",{className:w?"":"line-clamp-2",children:v.description}),v.description.length>100&&h.jsx("button",{type:"button",onClick:T=>{T.stopPropagation();const k=new Set(a);w?k.delete(v.id):k.add(v.id),l(k)},className:"text-xs text-primary hover:underline mt-1 font-medium",children:w?"Show less":"Show more"})]}),v.acceptanceCriteria.length>0&&h.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs text-muted-foreground",children:[h.jsx(MK,{className:"w-3 h-3"}),h.jsxs("span",{children:[v.acceptanceCriteria.filter(T=>T.completed).length,"/",v.acceptanceCriteria.length," criteria"]})]}),v.labels.length>0&&h.jsx("div",{className:"mt-2",children:h.jsx(Hde,{labels:v.labels,maxVisible:3})})]}),v.assignee&&h.jsx("span",{className:"text-sm text-muted-foreground font-mono shrink-0",children:v.assignee})]})},v.id)})})]},g)),u.length===0&&h.jsx("div",{className:"text-center py-12",children:h.jsx("p",{className:"text-lg text-muted-foreground",children:"No tasks found"})})]})})]})}function Imt({tasks:e,loading:t,onTasksUpdate:n,selectedTask:r,onTaskClose:o,onNewTask:i}){const[s,a]=x.useState("table"),[l,c]=x.useState(null),[u,f]=x.useState([]);x.useEffect(()=>{r&&c(r)},[r]);const m=y=>{window.location.hash=`/tasks/${y.id}`},g=y=>{window.location.hash=`/tasks/${y}`};return t?h.jsx("div",{className:"p-6 flex items-center justify-center h-64",children:h.jsx("div",{className:"text-lg text-muted-foreground",children:"Loading tasks..."})}):h.jsxs("div",{className:"p-6 h-full flex flex-col overflow-hidden",children:[h.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx("h1",{className:"text-2xl font-bold",children:"All Tasks"}),h.jsxs("span",{className:"text-muted-foreground",children:[e.length," ",e.length===1?"task":"tasks"]})]}),h.jsx("div",{className:"flex items-center gap-2",children:h.jsxs("div",{className:"flex items-center border rounded-lg p-1",children:[h.jsxs(Le,{variant:s==="table"?"secondary":"ghost",size:"sm",onClick:()=>a("table"),className:"h-8 px-3",children:[h.jsx(a0e,{className:"h-4 w-4 mr-2"}),"Table"]}),h.jsxs(Le,{variant:s==="grouped"?"secondary":"ghost",size:"sm",onClick:()=>a("grouped"),className:"h-8 px-3",children:[h.jsx(i0e,{className:"h-4 w-4 mr-2"}),"Grouped"]})]})})]}),h.jsx("div",{className:"flex-1 overflow-hidden",children:s==="table"?h.jsx(Xr,{className:"h-full",children:h.jsx("div",{className:"pr-4",children:h.jsx(Uht,{tasks:e,onTaskClick:m,onSelectionChange:f,onNewTask:i})})}):h.jsx(Dmt,{tasks:e,onTaskClick:m,onNewTask:i})}),u.length>0&&h.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 bg-primary text-primary-foreground px-4 py-2 rounded-lg shadow-lg flex items-center gap-4",children:[h.jsxs("span",{className:"text-sm font-medium",children:[u.length," task",u.length>1?"s":""," selected"]}),h.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>{console.log("Bulk action on:",u)},children:"Bulk Edit"})]}),h.jsx(pfe,{task:l,allTasks:e,onClose:()=>{c(null),o&&o()},onUpdate:n,onNavigateToTask:g})]})}const Omt=e=>e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^(.)/,t=>t.toUpperCase()),Mmt=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),Lmt=e=>e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^(.)/,t=>t.toLowerCase());function wK(e,t){const n=new Map;for(const o of e){const i=o.name.split("/");let s=n;for(let a=0;a<i.length;a++){const l=i[a],c=a===i.length-1,u=i.slice(0,a+1).join("/");s.has(l)||s.set(l,{id:u,name:l,isTemplate:c,template:c?o:void 0,children:new Map}),s=s.get(l).children}}const r=o=>Array.from(o.values()).sort((i,s)=>i.isTemplate!==s.isTemplate?i.isTemplate?1:-1:i.name.localeCompare(s.name)).map(i=>({id:i.id,name:i.name,icon:i.isTemplate?Md:Lr,openIcon:i.isTemplate?Md:No,children:i.children.size>0?r(i.children):void 0,onClick:i.isTemplate?()=>t(i.id):void 0}));return r(n)}function Pmt(){const[e,t]=x.useState([]),[n,r]=x.useState(!0),[o,i]=x.useState(null),[s,a]=x.useState(null),[l,c]=x.useState(!1),[u,f]=x.useState({}),[m,g]=x.useState(!0),[y,v]=x.useState(!1),[w,S]=x.useState(null),[T,k]=x.useState(null),[I,_]=x.useState(!1),[R,D]=x.useState(""),[M,$]=x.useState(""),[O,F]=x.useState(""),[U,G]=x.useState(!1),[j,Q]=x.useState(!1),[V,K]=x.useState(new Set),[X,J]=x.useState({}),[B,q]=x.useState(new Set),Y=x.useMemo(()=>o?o.prompts.filter(de=>de.required).every(de=>u[de.name]?.trim()):!1,[o,u]),P=x.useCallback(de=>{let Te=de;for(const[Ge,Ie]of Object.entries(u))Ie&&(Te=Te.replace(new RegExp(`\\{\\{\\s*${Ge}\\s*\\}\\}`,"g"),Ie).replace(new RegExp(`\\{\\{\\s*pascalCase\\s+${Ge}\\s*\\}\\}`,"g"),Omt(Ie)).replace(new RegExp(`\\{\\{\\s*camelCase\\s+${Ge}\\s*\\}\\}`,"g"),Lmt(Ie)).replace(new RegExp(`\\{\\{\\s*kebabCase\\s+${Ge}\\s*\\}\\}`,"g"),Mmt(Ie)));return Te},[u]),le=x.useMemo(()=>o?o.files.map(de=>{if(de.type==="add"){const Ge=P(de.destination);return{type:"add",destination:de.destination,preview:Ge,condition:de.condition,template:de.template}}const Te=P(de.destination);return{type:"addMany",destination:de.destination,preview:Te,condition:de.condition,source:de.source,globPattern:de.globPattern}}):[],[o,P]),ae=x.useCallback(async()=>{try{const de=await jg.list();t(de.templates)}catch(de){console.error("Failed to load templates:",de)}finally{r(!1)}},[]);x.useEffect(()=>{ae()},[ae]),rs("templates:created",()=>{ae()}),rs("templates:run",()=>{});const ie=x.useCallback(()=>{if(e.length===0)return;const Te=window.location.hash.match(/^#\/templates\/(.+)$/);if(Te){const Ge=decodeURIComponent(Te[1]);Ge!==s&&ne(Ge)}},[e,s]);x.useEffect(()=>{ie()},[ie]),x.useEffect(()=>(window.addEventListener("hashchange",ie),()=>window.removeEventListener("hashchange",ie)),[ie]);const ne=async de=>{c(!0),S(null),k(null),a(de);try{const Te=await jg.get(de);i(Te.template);const Ge={};for(const Ie of Te.template.prompts)Ie.default!==void 0?Ge[Ie.name]=String(Ie.default):Ie.type==="confirm"?Ge[Ie.name]="false":Ge[Ie.name]="";f(Ge)}catch(Te){console.error("Failed to load template:",Te),i(null)}finally{c(!1)}},se=de=>{const Te=de.split("/").map(encodeURIComponent).join("/");window.location.hash=`/templates/${Te}`},pe=()=>{if(o){const de=`@template/${o.name}`;navigator.clipboard.writeText(de).then(()=>{Q(!0),setTimeout(()=>Q(!1),2e3)})}},ke=async()=>{if(o){v(!0),S(null),k(null);try{const de=await jg.run(o.name,u,m);S(de)}catch(de){k(de instanceof Error?de.message:String(de))}finally{v(!1)}}},Me=async()=>{if(R.trim()){G(!0);try{await jg.create({name:R,description:M||void 0,doc:O||void 0}),D(""),$(""),F(""),_(!1),ae()}catch(de){console.error("Failed to create template:",de),alert(de instanceof Error?de.message:"Failed to create template")}finally{G(!1)}}},Ce=()=>{o?.doc&&(window.location.hash=`/docs/${o.doc}.md`)},Re=async de=>{const Te=new Set(V);if(V.has(de))Te.delete(de),K(Te);else if(Te.add(de),K(Te),!X[de]&&o){q(Ge=>new Set(Ge).add(de));try{const Ge=await jg.previewFile(o.name,de,u);J(Ie=>({...Ie,[de]:Ge.content}))}catch(Ge){console.error("Failed to load preview:",Ge),J(Ie=>({...Ie,[de]:`Error loading preview: ${Ge instanceof Error?Ge.message:String(Ge)}`}))}finally{q(Ge=>{const Ie=new Set(Ge);return Ie.delete(de),Ie})}}};return x.useEffect(()=>{J({})},[u]),n?h.jsx("div",{className:"p-6 flex items-center justify-center h-64",children:h.jsx("div",{className:"text-lg text-muted-foreground",children:"Loading templates..."})}):h.jsxs("div",{className:"p-6 h-full flex flex-col overflow-hidden",children:[h.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold",children:"Code Templates"}),h.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Generate boilerplate code from reusable templates"})]}),h.jsxs(Le,{onClick:()=>_(!0),className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(Go,{className:"w-4 h-4 mr-2"}),"New Template"]})]}),h.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 flex-1 min-h-0 overflow-hidden",children:[h.jsx("div",{className:"lg:col-span-1 flex flex-col min-h-0 overflow-hidden",children:h.jsx("div",{className:"bg-card rounded-lg border overflow-hidden flex flex-col flex-1 min-h-0",children:h.jsx(Xr,{className:"flex-1",children:(()=>{const de=e.filter(bt=>!bt.isImported),Te=e.filter(bt=>bt.isImported),Ge=Te.reduce((bt,it)=>{const te=it.source||"unknown";return bt[te]||(bt[te]=[]),bt[te].push(it),bt},{}),Ie=[];de.length>0&&Ie.push({id:"__local__",name:`Local (${de.length})`,icon:Lr,openIcon:No,children:wK(de,se)});const cn=Object.keys(Ge);if(cn.length>0){const bt=cn.map(it=>{const te=new Map,fe=Ge[it].map(Pe=>{const je=Pe.name.startsWith(`${it}/`)?Pe.name.slice(it.length+1):Pe.name;return te.set(je,Pe.name),{...Pe,name:je}}),ge=Pe=>{const je=te.get(Pe)||Pe;se(je)};return{id:`__import_${it}__`,name:`${it} (${Ge[it].length})`,icon:Lr,openIcon:No,children:wK(fe,ge)}});Ie.push({id:"__imports__",name:`Imports (${Te.length})`,icon:Lr,openIcon:No,children:bt})}return Ie.length===0?h.jsxs("div",{className:"p-8 text-center",children:[h.jsx(Md,{className:"w-12 h-12 mx-auto text-muted-foreground"}),h.jsx("p",{className:"mt-2 font-medium",children:"No templates yet"}),h.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Templates help you generate consistent code quickly"}),h.jsxs(Le,{onClick:()=>_(!0),className:"mt-4",variant:"outline",children:[h.jsx(Go,{className:"w-4 h-4 mr-2"}),"Create your first template"]})]}):h.jsx(sm,{data:Ie,defaultNodeIcon:Lr,defaultLeafIcon:Md,initialSelectedItemId:s||void 0})})()})})}),h.jsx("div",{className:"lg:col-span-2 flex flex-col min-h-0 overflow-hidden",children:l?h.jsx("div",{className:"bg-card rounded-lg border p-12 text-center",children:h.jsx("div",{className:"text-muted-foreground",children:"Loading template..."})}):o?h.jsxs("div",{className:"bg-card rounded-lg border overflow-hidden flex flex-col flex-1 min-h-0",children:[h.jsx("div",{className:"p-6 border-b shrink-0 bg-gradient-to-r from-blue-50 to-transparent dark:from-blue-950/20",children:h.jsx("div",{className:"flex items-start justify-between gap-4",children:h.jsxs("div",{className:"flex-1",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx(I0e,{className:"w-5 h-5 text-blue-500"}),h.jsx("h2",{className:"text-xl font-bold",children:o.name})]}),o.description&&h.jsx("p",{className:"text-muted-foreground",children:o.description}),h.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[h.jsxs("button",{type:"button",onClick:pe,className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 hover:bg-blue-200 dark:hover:bg-blue-900/50 transition-colors",title:"Click to copy reference",children:[h.jsx(LK,{className:"w-3 h-3"}),h.jsxs("span",{className:"font-mono",children:["@template/",o.name]}),j&&h.jsx(lo,{className:"w-3 h-3"})]}),o.doc&&h.jsxs("button",{type:"button",onClick:Ce,className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 hover:bg-green-200 dark:hover:bg-green-900/50 transition-colors",children:[h.jsx(Br,{className:"w-3 h-3"}),h.jsx("span",{children:"View Documentation"})]})]})]})})}),h.jsx(Xr,{className:"flex-1",children:h.jsxs("div",{className:"p-6 space-y-6",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[h.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 text-sm font-bold",children:"1"}),h.jsx("h3",{className:"font-semibold",children:"Fill in the values"}),o.prompts.length===0&&h.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded",children:"No input needed"})]}),o.prompts.length>0&&h.jsx("div",{className:"space-y-4 pl-8",children:o.prompts.map(de=>h.jsxs("div",{className:"space-y-2",children:[h.jsxs(Xt,{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-medium",children:de.name}),de.required?h.jsx("span",{className:"text-xs bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 px-1.5 py-0.5 rounded",children:"Required"}):h.jsx("span",{className:"text-xs bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 px-1.5 py-0.5 rounded",children:"Optional"})]}),de.message&&h.jsx("p",{className:"text-sm text-muted-foreground -mt-1",children:de.message}),de.type==="confirm"?h.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30",children:[h.jsx(Th,{checked:u[de.name]==="true",onCheckedChange:Te=>f(Ge=>({...Ge,[de.name]:Te?"true":"false"}))}),h.jsx("span",{className:"text-sm",children:u[de.name]==="true"?"Yes":"No"})]}):de.choices?h.jsxs("select",{value:u[de.name]||"",onChange:Te=>f(Ge=>({...Ge,[de.name]:Te.target.value})),className:"w-full px-3 py-2 rounded-lg border bg-background",children:[h.jsx("option",{value:"",children:"-- Select an option --"}),de.choices.map(Te=>h.jsx("option",{value:Te.value,children:Te.label},Te.value))]}):h.jsx(Gn,{type:"text",value:u[de.name]||"",onChange:Te=>f(Ge=>({...Ge,[de.name]:Te.target.value})),placeholder:de.default!==void 0?`Default: ${de.default}`:`Enter ${de.name}...`,className:de.required&&!u[de.name]?.trim()?"border-orange-300 dark:border-orange-700":""})]},de.name))})]}),h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[h.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 text-sm font-bold",children:"2"}),h.jsx("h3",{className:"font-semibold",children:"Files that will be created"})]}),h.jsx("div",{className:"pl-8",children:h.jsx("div",{className:"mb-3 p-3 rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800",children:h.jsxs("div",{className:"flex items-center gap-2 text-amber-800 dark:text-amber-300",children:[h.jsx(No,{className:"w-4 h-4"}),h.jsx("span",{className:"text-sm font-medium",children:"Output directory:"}),h.jsx("code",{className:"text-sm font-mono bg-amber-100 dark:bg-amber-900/50 px-2 py-0.5 rounded",children:o.destination==="./"?"Project root":o.destination})]})})}),h.jsx("div",{className:"pl-8",children:h.jsxs("div",{className:"rounded-lg border bg-muted/30 overflow-hidden",children:[le.map((de,Te)=>{const Ge=de.type==="add",Ie=de.type==="add"?de.template:null,cn=Ie?V.has(Ie):!1,bt=Ie?B.has(Ie):!1,it=Ie?X[Ie]:null;return h.jsxs("div",{className:"border-b last:border-b-0",children:[h.jsxs("button",{type:"button",onClick:()=>Ge&&Ie&&Re(Ie),className:`w-full flex items-center gap-3 px-4 py-3 text-left ${Ge?"hover:bg-accent/50 cursor-pointer":""}`,disabled:!Ge,children:[Ge?cn?h.jsx(cc,{className:"w-4 h-4 text-muted-foreground shrink-0"}):h.jsx(Au,{className:"w-4 h-4 text-muted-foreground shrink-0"}):null,de.type==="addMany"?h.jsx(No,{className:"w-4 h-4 text-yellow-600 dark:text-yellow-500 shrink-0"}):h.jsx(Md,{className:"w-4 h-4 text-blue-500 shrink-0"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("code",{className:"text-sm font-mono block truncate",children:de.type==="addMany"?`${de.preview}/${de.globPattern||"**/*.hbs"}`:de.preview}),de.preview!==de.destination&&h.jsxs("span",{className:"text-xs text-muted-foreground",children:["Pattern: ",de.destination]}),de.type==="addMany"&&h.jsx("span",{className:"text-xs text-blue-600 dark:text-blue-400 ml-2",children:"(multiple files)"})]}),de.condition&&h.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded shrink-0",children:"Conditional"}),Ge&&h.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:cn?"Hide":"Preview"})]}),cn&&h.jsx("div",{className:"border-t bg-gray-950 dark:bg-gray-900",children:bt?h.jsxs("div",{className:"p-4 flex items-center justify-center text-muted-foreground",children:[h.jsx(iu,{className:"w-4 h-4 animate-spin mr-2"}),"Loading preview..."]}):h.jsx("pre",{className:"p-4 text-xs font-mono text-gray-300 overflow-x-auto max-h-80 overflow-y-auto",children:h.jsx("code",{children:it||"No content"})})})]},Te)}),le.length===0&&h.jsxs("div",{className:"px-4 py-8 text-center text-muted-foreground",children:[h.jsx(kbe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),h.jsx("p",{children:"No files configured in this template"})]})]})})]}),h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[h.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 text-sm font-bold",children:"3"}),h.jsx("h3",{className:"font-semibold",children:"Generate files"})]}),h.jsxs("div",{className:"pl-8",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-4 p-4 rounded-lg border bg-muted/30",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Th,{id:"dry-run",checked:m,onCheckedChange:g}),h.jsx(Xt,{htmlFor:"dry-run",className:"text-sm cursor-pointer",children:"Preview mode"}),h.jsx("span",{className:"text-xs text-muted-foreground",children:"(no files created)"})]}),h.jsx("div",{className:"flex-1"}),h.jsx(Le,{onClick:ke,disabled:y||!Y,size:"lg",className:m?"":"bg-green-600 hover:bg-green-700 text-white",children:y?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"animate-spin mr-2",children:"⏳"}),"Running..."]}):m?h.jsxs(h.Fragment,{children:[h.jsx(e0,{className:"w-4 h-4 mr-2"}),"Preview Result"]}):h.jsxs(h.Fragment,{children:[h.jsx(Za,{className:"w-4 h-4 mr-2"}),"Generate Files"]})})]}),!Y&&o.prompts.some(de=>de.required)&&h.jsxs("p",{className:"text-sm text-orange-600 dark:text-orange-400 mt-2 flex items-center gap-1",children:[h.jsx(Jb,{className:"w-4 h-4"}),"Please fill in all required fields above"]})]})]}),T&&h.jsx("div",{className:"bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-800 rounded-lg p-4",children:h.jsxs("div",{className:"flex items-start gap-2 text-red-600 dark:text-red-400",children:[h.jsx(Jb,{className:"w-5 h-5 shrink-0 mt-0.5"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Error"}),h.jsx("div",{className:"text-sm",children:T})]})]})}),w&&h.jsx("div",{className:`border rounded-lg p-4 ${w.dryRun?"bg-blue-50 dark:bg-blue-950/30 border-blue-200 dark:border-blue-800":"bg-green-50 dark:bg-green-950/30 border-green-200 dark:border-green-800"}`,children:h.jsxs("div",{className:"flex items-start gap-3",children:[w.dryRun?h.jsx(e0,{className:"w-6 h-6 text-blue-600 dark:text-blue-400 shrink-0"}):h.jsx(lo,{className:"w-6 h-6 text-green-600 dark:text-green-400 shrink-0"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("div",{className:"font-semibold text-lg",children:w.dryRun?"Preview Complete":"Files Generated!"}),h.jsx("div",{className:"text-sm text-muted-foreground mb-4",children:w.dryRun?"Turn off preview mode and click 'Generate Files' to create these files.":w.message}),h.jsx("div",{className:"space-y-2",children:w.files.map((de,Te)=>h.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[de.skipped?h.jsx(ti,{className:"w-4 h-4 text-muted-foreground shrink-0"}):h.jsx(lo,{className:"w-4 h-4 text-green-600 shrink-0"}),h.jsx("code",{className:`font-mono ${de.skipped?"text-muted-foreground":""}`,children:de.path}),de.skipped&&de.skipReason&&h.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",de.skipReason,")"]})]},Te))}),w.dryRun&&w.files.length>0&&h.jsxs(Le,{onClick:()=>{g(!1),ke()},className:"mt-4 bg-green-600 hover:bg-green-700 text-white",children:[h.jsx(Za,{className:"w-4 h-4 mr-2"}),"Generate These Files Now"]})]})]})})]})})]}):h.jsxs("div",{className:"bg-card rounded-lg border p-12 text-center",children:[h.jsx(Md,{className:"w-16 h-16 mx-auto text-muted-foreground/50"}),h.jsx("h3",{className:"mt-4 text-lg font-medium",children:"Select a template"}),h.jsx("p",{className:"mt-2 text-muted-foreground max-w-md mx-auto",children:"Choose a template from the list to generate code. Templates help you create consistent files quickly."})]})})]}),I&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-card rounded-lg shadow-xl max-w-md w-full",children:[h.jsxs("div",{className:"p-6 border-b",children:[h.jsx("h2",{className:"text-xl font-bold",children:"Create New Template"}),h.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Templates are stored in .knowns/templates/"})]}),h.jsxs("div",{className:"p-6 space-y-4",children:[h.jsxs("div",{children:[h.jsxs(Xt,{className:"mb-2 block",children:["Template Name ",h.jsx("span",{className:"text-red-500",children:"*"})]}),h.jsx(Gn,{type:"text",value:R,onChange:de=>D(de.target.value),placeholder:"e.g., react-component, api-endpoint"}),h.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Use lowercase with hyphens (kebab-case)"})]}),h.jsxs("div",{children:[h.jsx(Xt,{className:"mb-2 block",children:"Description"}),h.jsx(Gn,{type:"text",value:M,onChange:de=>$(de.target.value),placeholder:"e.g., Generate a new React component with tests"})]}),h.jsxs("div",{children:[h.jsx(Xt,{className:"mb-2 block",children:"Link to Documentation"}),h.jsx(Gn,{type:"text",value:O,onChange:de=>F(de.target.value),placeholder:"e.g., patterns/react-component"}),h.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Optional: Link to a doc that explains when/how to use this template"})]})]}),h.jsxs("div",{className:"p-6 border-t flex justify-end gap-3",children:[h.jsx(Le,{variant:"secondary",onClick:()=>{_(!1),D(""),$(""),F("")},disabled:U,children:"Cancel"}),h.jsx(Le,{onClick:Me,disabled:U||!R.trim(),className:"bg-green-700 hover:bg-green-800 text-white",children:U?"Creating...":"Create Template"})]})]})})]})}const zpe=x.createContext({isDark:!1,toggle:()=>{}}),qm=()=>x.useContext(zpe);function Fmt(){const{config:e}=Sf(),[t,n]=x.useState([]),[r,o]=x.useState(!0),[i,s]=x.useState(!1),[a,l]=x.useState(!1),[c,u]=x.useState(()=>{if(typeof window<"u"){const D=localStorage.getItem("theme");return D?D==="dark":window.matchMedia("(prefers-color-scheme: dark)").matches}return!1}),f=()=>{const D=window.location.hash.slice(1);return D.startsWith("/tasks")?"tasks":D.startsWith("/docs")?"docs":D.startsWith("/templates")?"templates":D.startsWith("/imports")?"imports":D.startsWith("/config")?"config":(D.startsWith("/kanban")||D==="/"||D==="","kanban")},m=D=>{const M=window.location.hash.slice(1),$="(?:kanban|tasks)",O=M.match(new RegExp(`^/${$}/([^?]+)`))||M.match(/[?&]id=([^&]+)/);return O?O[1]:null},[g,y]=x.useState(f()),[v,w]=x.useState(window.location.hash);x.useEffect(()=>{const D=()=>{y(f()),w(window.location.hash)};return window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[f]),x.useEffect(()=>{c?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))},[c]),x.useEffect(()=>{const D=M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&(M.preventDefault(),l($=>!$))};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[]),x.useEffect(()=>{ma.getTasks().then(D=>{n(D),o(!1)}).catch(D=>{console.error("Failed to load tasks:",D),o(!1)})},[]),rs("tasks:updated",({task:D})=>{n(M=>{const $=M.findIndex(O=>O.id===D.id);if($>=0){const O=[...M];return O[$]=D,O}return[...M,D]})}),rs("tasks:refresh",()=>{ma.getTasks().then(n).catch(console.error)});const S=()=>{ma.getTasks().then(n).catch(console.error)},T=D=>{n(D)},k=async D=>{const M=!c;if(!document.startViewTransition||window.matchMedia("(prefers-reduced-motion: reduce)").matches){u(M);return}const $=D.clientX,O=D.clientY,F=Math.hypot(Math.max($,window.innerWidth-$),Math.max(O,window.innerHeight-O));await document.startViewTransition(()=>{u(M)}).ready,document.documentElement.animate({clipPath:[`circle(0px at ${$}px ${O}px)`,`circle(${F}px at ${$}px ${O}px)`]},{duration:400,easing:"ease-out",pseudoElement:"::view-transition-new(root)"})},I=D=>{window.location.hash=`/kanban/${D.id}`},_=D=>{D?.path?window.location.hash=`/docs/${D.path}`:D?.filename?window.location.hash=`/docs/${D.filename}`:window.location.hash="/docs"},R=()=>{switch(g){case"kanban":return h.jsx(vK,{tasks:t,loading:r,onTasksUpdate:T,onNewTask:()=>s(!0)});case"tasks":{const D=m(),M=D?t.find($=>$.id===D):null;return h.jsx(Imt,{tasks:t,loading:r,onTasksUpdate:S,selectedTask:M,onTaskClose:()=>{window.location.hash="/tasks"},onNewTask:()=>s(!0)})}case"docs":return h.jsx(pmt,{});case"templates":return h.jsx(Pmt,{});case"imports":return h.jsx(Nmt,{});case"config":return h.jsx(zht,{});default:return h.jsx(vK,{tasks:t,loading:r,onTasksUpdate:T,onNewTask:()=>s(!0)})}};return h.jsxs(zpe.Provider,{value:{isDark:c,toggle:k},children:[h.jsxs(Gfe,{children:[h.jsx(Npt,{currentPage:g,onSearchClick:()=>l(!0)}),h.jsxs("main",{className:"flex flex-1 flex-col bg-background overflow-hidden",children:[h.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[h.jsx(qfe,{className:"-ml-1"}),h.jsx(ny,{orientation:"vertical",className:"mr-2 h-4"}),h.jsx(Glt,{}),h.jsx("div",{className:"flex flex-1 items-center gap-2 text-sm",children:h.jsx("span",{className:"font-semibold text-foreground",children:e.name||"Knowns"})}),h.jsx(sct,{onTaskClick:D=>{window.location.hash=`/kanban/${D}`}}),h.jsx(Qlt,{isDark:c,onToggle:k,size:"sm"}),h.jsx(Mpt,{})]}),h.jsx("div",{className:"flex-1 w-full overflow-y-auto overflow-x-hidden",children:R()})]}),h.jsx(lpt,{isOpen:i,allTasks:t,onClose:()=>s(!1),onCreated:S}),h.jsx(Ppt,{open:a,onOpenChange:l,onTaskSelect:I,onDocSelect:_})]}),h.jsx(Wge,{})]})}function Bmt(){return h.jsx(Z0e,{children:h.jsx(QCe,{children:h.jsx(eTe,{children:h.jsx(Yge,{children:h.jsx(Hlt,{children:h.jsx(Fmt,{})})})})})})}const Vpe=document.getElementById("root");if(!Vpe)throw new Error("Root element not found");CK.createRoot(Vpe).render(h.jsx(Bmt,{}));