knowns 0.10.2 → 0.10.4
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.
- package/README.md +2 -0
- package/dist/index.js +34 -24
- package/dist/mcp/server.js +30 -21
- package/dist/ui/assets/{index-B37hMpJr.js → index-BG8AreIh.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
`},Eut={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 wut(e){let{announcements:t=Eut,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=vut}=e;const{announce:i,announcement:s}=but(),a=l1("DndLiveRegion"),[l,c]=x.useState(!1);if(x.useEffect(()=>{c(!0)},[]),yut(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=he.createElement(he.Fragment,null,he.createElement(mut,{id:r,value:o.draggable}),he.createElement(gut,{id:a,announcement:s}));return n?Wr.createPortal(u,n):u}var Gr;(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"})(Gr||(Gr={}));function NS(){}function U_(e,t){return x.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Sut(){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 Aa=Object.freeze({x:0,y:0});function vB(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Cut(e,t){const n=AS(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 EB(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Tut(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function jI(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 kut(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function AY(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 Aut=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=AY(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=vB(AY(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(EB)},NY=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=jI(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=jI(l),u=o.reduce((m,g,y)=>m+vB(c[y],g),0),f=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:f}})}}return i.sort(EB)};function Nut(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 Xde=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=Nut(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(Tut)};function _ut(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 Rut=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&&_ut(r,a)){const c=jI(a).reduce((f,m)=>f+vB(r,m),0),u=Number((c/4).toFixed(4));o.push({id:s,data:{droppableContainer:i,value:u}})}}return o.sort(EB)};function Dut(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Zde(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Aa}function Iut(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 Out=Iut(1);function Qde(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 Mut(e,t,n){const r=Qde(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 Lut={ignoreTransform:!1};function Bm(e,t){t===void 0&&(t=Lut);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=di(e).getComputedStyle(e);c&&(n=Mut(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 _Y(e){return Bm(e,{ignoreTransform:!0})}function Put(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Fut(e,t){return t===void 0&&(t=di(e).getComputedStyle(e)),t.position==="fixed"}function But(e,t){t===void 0&&(t=di(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 wB(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(xB(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!s1(o)||Wde(o)||n.includes(o))return n;const i=di(e).getComputedStyle(o);return o!==e&&But(o,i)&&n.push(o),Fut(o,i)?n:r(o.parentNode)}return e?r(e):n}function Jde(e){const[t]=wB(e,1);return t??null}function H_(e){return!HT||!e?null:Pm(e)?e:yB(e)?xB(e)||e===Fm(e).scrollingElement?window:s1(e)?e:null:null}function efe(e){return Pm(e)?e.scrollX:e.scrollLeft}function tfe(e){return Pm(e)?e.scrollY:e.scrollTop}function $I(e){return{x:efe(e),y:tfe(e)}}var ro;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ro||(ro={}));function nfe(e){return!HT||!e?!1:e===document.scrollingElement}function rfe(e){const t={x:0,y:0},n=nfe(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 jut={x:.2,y:.2};function $ut(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=jut);const{isTop:c,isBottom:u,isLeft:f,isRight:m}=rfe(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=ro.Backward,y.y=r*Math.abs((t.top+v.height-i)/v.height)):!u&&l>=t.bottom-v.height&&(g.y=ro.Forward,y.y=r*Math.abs((t.bottom-v.height-l)/v.height)),!m&&a>=t.right-v.width?(g.x=ro.Forward,y.x=r*Math.abs((t.right-v.width-a)/v.width)):!f&&s<=t.left+v.width&&(g.x=ro.Backward,y.x=r*Math.abs((t.left+v.width-s)/v.width)),{direction:g,speed:y}}function Uut(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 ofe(e){return e.reduce((t,n)=>xh(t,$I(n)),Aa)}function Hut(e){return e.reduce((t,n)=>t+efe(n),0)}function zut(e){return e.reduce((t,n)=>t+tfe(n),0)}function ife(e,t){if(t===void 0&&(t=Bm),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);Jde(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Vut=[["x",["left","right"],Hut],["y",["top","bottom"],zut]];class SB{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=wB(n),o=ofe(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of Vut)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 Ub{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 Gut(e){const{EventTarget:t}=di(e);return e instanceof t?e:Fm(e)}function z_(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 Rs;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Rs||(Rs={}));function RY(e){e.preventDefault()}function qut(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 sfe={start:[vn.Space,vn.Enter],cancel:[vn.Esc],end:[vn.Space,vn.Enter,vn.Tab]},Wut=(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 CB{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 Ub(Fm(n)),this.windowListeners=new Ub(di(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rs.Resize,this.handleCancel),this.windowListeners.add(Rs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&ife(r),n(Aa)}handleKeyDown(t){if(VT(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=sfe,coordinateGetter:s=Wut,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}:Aa;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(t,{active:n,context:r.current,currentCoordinates:u});if(f){const m=kS(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:A,isBottom:R,maxScroll:_,minScroll:D}=rfe(v),I=Uut(v),L={x:Math.min(w===vn.Right?I.right-I.width/2:I.right,Math.max(w===vn.Right?I.left:I.left+I.width/2,f.x)),y:Math.min(w===vn.Down?I.bottom-I.height/2:I.bottom,Math.max(w===vn.Down?I.top:I.top+I.height/2,f.y))},j=w===vn.Right&&!T||w===vn.Left&&!A,O=w===vn.Down&&!R||w===vn.Up&&!S;if(j&&L.x!==f.x){const F=v.scrollLeft+m.x,U=w===vn.Right&&F<=_.x||w===vn.Left&&F>=D.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-D.x,g.x&&v.scrollBy({left:-g.x,behavior:a});break}else if(O&&L.y!==f.y){const F=v.scrollTop+m.y,U=w===vn.Down&&F<=_.y||w===vn.Up&&F>=D.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-D.y,g.y&&v.scrollBy({top:-g.y,behavior:a});break}}this.handleMove(t,xh(kS(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()}}CB.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=sfe,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 DY(e){return!!(e&&"distance"in e)}function IY(e){return!!(e&&"delay"in e)}class TB{constructor(t,n,r){var o;r===void 0&&(r=Gut(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=Fm(s),this.documentListeners=new Ub(this.document),this.listeners=new Ub(r),this.windowListeners=new Ub(di(s)),this.initialCoordinates=(o=AS(i))!=null?o:Aa,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(Rs.Resize,this.handleCancel),this.windowListeners.add(Rs.DragStart,RY),this.windowListeners.add(Rs.VisibilityChange,this.handleCancel),this.windowListeners.add(Rs.ContextMenu,RY),this.documentListeners.add(Rs.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(IY(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(DY(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(Rs.Click,qut,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rs.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=AS(t))!=null?n:Aa,c=kS(o,l);if(!r&&a){if(DY(a)){if(a.tolerance!=null&&z_(c,a.tolerance))return this.handleCancel();if(z_(c,a.distance))return this.handleStart()}if(IY(a)&&z_(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 Yut={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class afe extends TB{constructor(t){const{event:n}=t,r=Fm(n.target);super(t,Yut,r)}}afe.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 Kut={move:{name:"mousemove"},end:{name:"mouseup"}};var UI;(function(e){e[e.RightClick=2]="RightClick"})(UI||(UI={}));class lfe extends TB{constructor(t){super(t,Kut,Fm(t.event.target))}}lfe.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===UI.RightClick?!1:(r?.({event:n}),!0)}}];const V_={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class cfe extends TB{constructor(t){super(t,V_)}static setup(){return window.addEventListener(V_.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(V_.move.name,t)};function t(){}}}cfe.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 Hb;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Hb||(Hb={}));var _S;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(_S||(_S={}));function Xut(e){let{acceleration:t,activator:n=Hb.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=_S.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:m}=e;const g=Qut({delta:f,disabled:!i}),[y,v]=uut(),w=x.useRef({x:0,y:0}),S=x.useRef({x:0,y:0}),T=x.useMemo(()=>{switch(n){case Hb.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Hb.DraggableRect:return o}},[n,o,l]),A=x.useRef(null),R=x.useCallback(()=>{const D=A.current;if(!D)return;const I=w.current.x*S.current.x,L=w.current.y*S.current.y;D.scrollBy(I,L)},[]),_=x.useMemo(()=>a===_S.TreeOrder?[...c].reverse():c,[a,c]);x.useEffect(()=>{if(!i||!c.length||!T){v();return}for(const D of _){if(r?.(D)===!1)continue;const I=c.indexOf(D),L=u[I];if(!L)continue;const{direction:j,speed:O}=$ut(D,L,T,t,m);for(const F of["x","y"])g[F][j[F]]||(O[F]=0,j[F]=0);if(O.x>0||O.y>0){v(),A.current=D,y(R,s),w.current=O,S.current=j;return}}w.current={x:0,y:0},S.current={x:0,y:0},v()},[t,R,r,v,i,s,JSON.stringify(T),JSON.stringify(g),y,c,_,u,JSON.stringify(m)])}const Zut={x:{[ro.Backward]:!1,[ro.Forward]:!1},y:{[ro.Backward]:!1,[ro.Forward]:!1}};function Qut(e){let{delta:t,disabled:n}=e;const r=TS(t);return a1(o=>{if(n||!r||!o)return Zut;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[ro.Backward]:o.x[ro.Backward]||i.x===-1,[ro.Forward]:o.x[ro.Forward]||i.x===1},y:{[ro.Backward]:o.y[ro.Backward]||i.y===-1,[ro.Forward]:o.y[ro.Forward]||i.y===1}}},[n,t,r])}function Jut(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return a1(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function edt(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 J0;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(J0||(J0={}));var HI;(function(e){e.Optimized="optimized"})(HI||(HI={}));const OY=new Map;function tdt(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=Q0(f),g=x.useCallback(function(S){S===void 0&&(S=[]),!m.current&&s(T=>T===null?S:T.concat(S.filter(A=>!T.includes(A))))},[m]),y=x.useRef(null),v=a1(S=>{if(f&&!n)return OY;if(!S||S===OY||u.current!==e||i!=null){const T=new Map;for(let A of e){if(!A)continue;if(i&&i.length>0&&!i.includes(A.id)&&A.rect.current){T.set(A.id,A.rect.current);continue}const R=A.node.current,_=R?new SB(l(R),R):null;A.rect.current=_,_&&T.set(A.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 J0.Always:return!1;case J0.BeforeDragging:return n;default:return!n}}}function kB(e,t){return a1(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function ndt(e,t){return kB(e,t)}function rdt(e){let{callback:t,disabled:n}=e;const r=zT(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 GT(e){let{callback:t,disabled:n}=e;const r=zT(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 odt(e){return new SB(Bm(e),e)}function MY(e,t,n){t===void 0&&(t=odt);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=rdt({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=GT({callback:i});return ka(()=>{i(),e?(a?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[e]),r}function idt(e){const t=kB(e);return Zde(e,t)}const LY=[];function sdt(e){const t=x.useRef(e),n=a1(r=>e?r&&r!==LY&&e&&t.current&&e.parentNode===t.current.parentNode?r:wB(e):LY,[e]);return x.useEffect(()=>{t.current=e},[e]),n}function adt(e){const[t,n]=x.useState(null),r=x.useRef(e),o=x.useCallback(i=>{const s=H_(i.target);s&&n(a=>a?(a.set(s,$I(s)),new Map(a)):null)},[]);return x.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=H_(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,$I(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=H_(l);c?.removeEventListener("scroll",o)})}},[o,e]),x.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>xh(i,s),Aa):ofe(e):Aa,[e,t])}function PY(e,t){t===void 0&&(t=[]);const n=x.useRef(null);return x.useEffect(()=>{n.current=null},t),x.useEffect(()=>{const r=e!==Aa;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?kS(e,n.current):Aa}function ldt(e){x.useEffect(()=>{if(!HT)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 cdt(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 ufe(e){return x.useMemo(()=>e?Put(e):null,[e])}const FY=[];function udt(e,t){t===void 0&&(t=Bm);const[n]=e,r=ufe(n?di(n):null),[o,i]=x.useState(FY);function s(){i(()=>e.length?e.map(l=>nfe(l)?r:new SB(t(l),l)):FY)}const a=GT({callback:s});return ka(()=>{a?.disconnect(),s(),e.forEach(l=>a?.observe(l))},[e]),o}function dfe(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return s1(t)?t:e}function ddt(e){let{measure:t}=e;const[n,r]=x.useState(null),o=x.useCallback(c=>{for(const{target:u}of c)if(s1(u)){r(f=>{const m=t(u);return f?{...f,width:m.width,height:m.height}:m});break}},[t]),i=GT({callback:o}),s=x.useCallback(c=>{const u=dfe(c);i?.disconnect(),u&&i?.observe(u),r(u?t(u):null)},[t,i]),[a,l]=CS(s);return x.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const fdt=[{sensor:afe,options:{}},{sensor:CB,options:{}}],pdt={current:{}},pE={draggable:{measure:_Y},droppable:{measure:_Y,strategy:J0.WhileDragging,frequency:HI.Optimized},dragOverlay:{measure:Bm}};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 hdt={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:NS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:pE,measureDroppableContainers:NS,windowRect:null,measuringScheduled:!1},ffe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:NS,draggableNodes:new Map,over:null,measureDroppableContainers:NS},c1=x.createContext(ffe),pfe=x.createContext(hdt);function mdt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new zb}}}function gdt(e,t){switch(t.type){case Gr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Gr.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 Gr.DragEnd:case Gr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Gr.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 Gr.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 Gr.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 bdt(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=x.useContext(c1),i=TS(r),s=TS(n?.id);return x.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!VT(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=put(u);if(f){f.focus();break}}})}},[r,t,o,s,i]),null}function hfe(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function ydt(e){return x.useMemo(()=>({draggable:{...pE.draggable,...e?.draggable},droppable:{...pE.droppable,...e?.droppable},dragOverlay:{...pE.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function xdt(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;ka(()=>{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=Zde(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=Jde(c);m&&m.scrollBy({top:f.y,left:f.x})}},[t,s,a,r,n])}const qT=x.createContext({...Aa,scaleX:1,scaleY:1});var nu;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(nu||(nu={}));const vdt=x.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=fdt,collisionDetection:f=Xde,measuring:m,modifiers:g,...y}=t;const v=x.useReducer(gdt,void 0,mdt),[w,S]=v,[T,A]=xut(),[R,_]=x.useState(nu.Uninitialized),D=R===nu.Initialized,{draggable:{active:I,nodes:L,translate:j},droppable:{containers:O}}=w,F=I!=null?L.get(I):null,U=x.useRef({initial:null,translated:null}),Y=x.useMemo(()=>{var nn;return I!=null?{id:I,data:(nn=F?.data)!=null?nn:pdt,rect:U}:null},[I,F]),$=x.useRef(null),[G,H]=x.useState(null),[X,Z]=x.useState(null),J=Q0(y,Object.values(y)),B=l1("DndDescribedBy",s),W=x.useMemo(()=>O.getEnabled(),[O]),K=ydt(m),{droppableRects:P,measureDroppableContainers:le,measuringScheduled:ae}=tdt(W,{dragging:D,dependencies:[j.x,j.y],config:K.droppable}),de=Jut(L,I),ie=x.useMemo(()=>X?AS(X):null,[X]),ue=mo(),re=ndt(de,K.draggable.measure);xdt({activeNode:I!=null?L.get(I):null,config:ue.layoutShiftCompensation,initialRect:re,measure:K.draggable.measure});const be=MY(de,K.draggable.measure,re),Oe=MY(de?de.parentElement:null),we=x.useRef({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:L,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Re=O.getNodeFor((n=we.current.over)==null?void 0:n.id),se=ddt({measure:K.dragOverlay.measure}),Ce=(r=se.nodeRef.current)!=null?r:de,Be=D?(o=se.rect)!=null?o:be:null,Pe=!!(se.nodeRef.current&&se.rect),hn=idt(Pe?null:be),Mt=ufe(Ce?di(Ce):null),vt=sdt(D?Re??de:null),ne=udt(vt),fe=hfe(g,{transform:{x:j.x-hn.x,y:j.y-hn.y,scaleX:1,scaleY:1},activatorEvent:X,active:Y,activeNodeRect:be,containerNodeRect:Oe,draggingNodeRect:Be,over:we.current.over,overlayNodeRect:se.rect,scrollableAncestors:vt,scrollableAncestorRects:ne,windowRect:Mt}),ve=ie?xh(ie,j):null,$e=adt(vt),ze=PY($e),q=PY($e,[be]),ye=xh(fe,ze),Fe=Be?Out(Be,fe):null,We=Y&&Fe?f({active:Y,collisionRect:Fe,droppableRects:P,droppableContainers:W,pointerCoordinates:ve}):null,st=kut(We,"id"),[cn,mn]=x.useState(null),Mn=Pe?fe:xh(fe,q),wn=Dut(Mn,(i=cn?.rect)!=null?i:null,be),Sn=x.useRef(null),_e=x.useCallback((nn,rn)=>{let{sensor:Ke,options:Wt}=rn;if($.current==null)return;const xt=L.get($.current);if(!xt)return;const Pt=nn.nativeEvent,Yn=new Ke({active:$.current,activeNode:xt,event:Pt,options:Wt,context:we,onAbort(Jt){if(!L.get(Jt))return;const{onDragAbort:_n}=J.current,nr={id:Jt};_n?.(nr),T({type:"onDragAbort",event:nr})},onPending(Jt,tr,_n,nr){if(!L.get(Jt))return;const{onDragPending:go}=J.current,ps={id:Jt,constraint:tr,initialCoordinates:_n,offset:nr};go?.(ps),T({type:"onDragPending",event:ps})},onStart(Jt){const tr=$.current;if(tr==null)return;const _n=L.get(tr);if(!_n)return;const{onDragStart:nr}=J.current,fs={activatorEvent:Pt,active:{id:tr,data:_n.data,rect:U}};Wr.unstable_batchedUpdates(()=>{nr?.(fs),_(nu.Initializing),S({type:Gr.DragStart,initialCoordinates:Jt,active:tr}),T({type:"onDragStart",event:fs}),H(Sn.current),Z(Pt)})},onMove(Jt){S({type:Gr.DragMove,coordinates:Jt})},onEnd:Qt(Gr.DragEnd),onCancel:Qt(Gr.DragCancel)});Sn.current=Yn;function Qt(Jt){return async function(){const{active:_n,collisions:nr,over:fs,scrollAdjustedTranslate:go}=we.current;let ps=null;if(_n&&go){const{cancelDrop:bc}=J.current;ps={activatorEvent:Pt,active:_n,collisions:nr,delta:go,over:fs},Jt===Gr.DragEnd&&typeof bc=="function"&&await Promise.resolve(bc(ps))&&(Jt=Gr.DragCancel)}$.current=null,Wr.unstable_batchedUpdates(()=>{S({type:Jt}),_(nu.Uninitialized),mn(null),H(null),Z(null),Sn.current=null;const bc=Jt===Gr.DragEnd?"onDragEnd":"onDragCancel";if(ps){const hs=J.current[bc];hs?.(ps),T({type:bc,event:ps})}})}}},[L]),Xe=x.useCallback((nn,rn)=>(Ke,Wt)=>{const xt=Ke.nativeEvent,Pt=L.get(Wt);if($.current!==null||!Pt||xt.dndKit||xt.defaultPrevented)return;const Yn={active:Pt};nn(Ke,rn.options,Yn)===!0&&(xt.dndKit={capturedBy:rn.sensor},$.current=Wt,_e(Ke,rn))},[L,_e]),bt=edt(u,Xe);ldt(u),ka(()=>{be&&R===nu.Initializing&&_(nu.Initialized)},[be,R]),x.useEffect(()=>{const{onDragMove:nn}=J.current,{active:rn,activatorEvent:Ke,collisions:Wt,over:xt}=we.current;if(!rn||!Ke)return;const Pt={active:rn,activatorEvent:Ke,collisions:Wt,delta:{x:ye.x,y:ye.y},over:xt};Wr.unstable_batchedUpdates(()=>{nn?.(Pt),T({type:"onDragMove",event:Pt})})},[ye.x,ye.y]),x.useEffect(()=>{const{active:nn,activatorEvent:rn,collisions:Ke,droppableContainers:Wt,scrollAdjustedTranslate:xt}=we.current;if(!nn||$.current==null||!rn||!xt)return;const{onDragOver:Pt}=J.current,Yn=Wt.get(st),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:xt.x,y:xt.y},over:Qt};Wr.unstable_batchedUpdates(()=>{mn(Qt),Pt?.(Jt),T({type:"onDragOver",event:Jt})})},[st]),ka(()=>{we.current={activatorEvent:X,active:Y,activeNode:de,collisionRect:Fe,collisions:We,droppableRects:P,draggableNodes:L,draggingNode:Ce,draggingNodeRect:Be,droppableContainers:O,over:cn,scrollableAncestors:vt,scrollAdjustedTranslate:ye},U.current={initial:Be,translated:Fe}},[Y,de,We,Fe,L,Ce,Be,P,O,cn,vt,ye]),Xut({...ue,delta:j,draggingRect:Fe,pointerCoordinates:ve,scrollableAncestors:vt,scrollableAncestorRects:ne});const ct=x.useMemo(()=>({active:Y,activeNode:de,activeNodeRect:be,activatorEvent:X,collisions:We,containerNodeRect:Oe,dragOverlay:se,draggableNodes:L,droppableContainers:O,droppableRects:P,over:cn,measureDroppableContainers:le,scrollableAncestors:vt,scrollableAncestorRects:ne,measuringConfiguration:K,measuringScheduled:ae,windowRect:Mt}),[Y,de,be,X,We,Oe,se,L,O,P,cn,le,vt,ne,K,ae,Mt]),lr=x.useMemo(()=>({activatorEvent:X,activators:bt,active:Y,activeNodeRect:be,ariaDescribedById:{draggable:B},dispatch:S,draggableNodes:L,over:cn,measureDroppableContainers:le}),[X,bt,Y,be,S,B,L,cn,le]);return he.createElement(Kde.Provider,{value:A},he.createElement(c1.Provider,{value:lr},he.createElement(pfe.Provider,{value:ct},he.createElement(qT.Provider,{value:wn},c)),he.createElement(bdt,{disabled:a?.restoreFocus===!1})),he.createElement(wut,{...a,hiddenTextDescribedById:B}));function mo(){const nn=G?.autoScrollEnabled===!1,rn=typeof l=="object"?l.enabled===!1:l===!1,Ke=D&&!nn&&!rn;return typeof l=="object"?{...l,enabled:Ke}:{enabled:Ke}}}),Edt=x.createContext(null),BY="button",wdt="Draggable";function Sdt(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=l1(wdt),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:m}=x.useContext(c1),{role:g=BY,roleDescription:y="draggable",tabIndex:v=0}=o??{},w=l?.id===t,S=x.useContext(w?qT:Edt),[T,A]=CS(),[R,_]=CS(),D=cdt(s,t),I=Q0(n);ka(()=>(f.set(t,{id:t,key:i,node:T,activatorNode:R,data:I}),()=>{const j=f.get(t);j&&j.key===i&&f.delete(t)}),[f,t]);const L=x.useMemo(()=>({role:g,tabIndex:v,"aria-disabled":r,"aria-pressed":w&&g===BY?!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:L,isDragging:w,listeners:r?void 0:D,node:T,over:m,setNodeRef:A,setActivatorNodeRef:_,transform:S}}function mfe(){return x.useContext(pfe)}const Cdt="Droppable",Tdt={timeout:25};function gfe(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=l1(Cdt),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=x.useContext(c1),u=x.useRef({disabled:n}),f=x.useRef(!1),m=x.useRef(null),g=x.useRef(null),{disabled:y,updateMeasurementsFor:v,timeout:w}={...Tdt,...o},S=Q0(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]),A=GT({callback:T,disabled:y||!s}),R=x.useCallback((L,j)=>{A&&(j&&(A.unobserve(j),f.current=!1),L&&A.observe(L))},[A]),[_,D]=CS(R),I=Q0(t);return x.useEffect(()=>{!A||!_.current||(A.disconnect(),f.current=!1,A.observe(_.current))},[_,A]),x.useEffect(()=>(a({type:Gr.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:m,data:I}}),()=>a({type:Gr.UnregisterDroppable,key:i,id:r})),[r]),x.useEffect(()=>{n!==u.current.disabled&&(a({type:Gr.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:D}}function kdt(e){let{animation:t,children:n}=e;const[r,o]=x.useState(null),[i,s]=x.useState(null),a=TS(n);return!n&&!r&&a&&o(a),ka(()=>{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]),he.createElement(he.Fragment,null,n,r?x.cloneElement(r,{ref:s}):null)}const Adt={x:0,y:0,scaleX:1,scaleY:1};function Ndt(e){let{children:t}=e;return he.createElement(c1.Provider,{value:ffe},he.createElement(qT.Provider,{value:Adt},t))}const _dt={position:"fixed",touchAction:"none"},Rdt=e=>VT(e)?"transform 250ms ease":void 0,Ddt=x.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Rdt}=e;if(!a)return null;const f=o?c:{...c,scaleX:1,scaleY:1},m={..._dt,width:a.width,height:a.height,top:a.top,left:a.left,transform:zu.Transform.toString(f),transformOrigin:o&&r?Cut(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return he.createElement(n,{className:s,style:m,ref:t},i)}),Idt=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)}},Odt=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:zu.Transform.toString(t)},{transform:zu.Transform.toString(n)}]},Mdt={duration:250,easing:"ease",keyframes:Odt,sideEffects:Idt({styles:{active:{opacity:"0"}}})};function Ldt(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return zT((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=dfe(s);if(!c)return;const{transform:u}=di(s).getComputedStyle(s),f=Qde(u);if(!f)return;const m=typeof t=="function"?t:Pdt(t);return ife(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 Pdt(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...Mdt,...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 jY=0;function Fdt(e){return x.useMemo(()=>{if(e!=null)return jY++,jY},[e])}const Bdt=he.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:A,scrollableAncestorRects:R,windowRect:_}=mfe(),D=x.useContext(qT),I=Fdt(f?.id),L=hfe(s,{activatorEvent:u,active:f,activeNodeRect:m,containerNodeRect:g,draggingNodeRect:w.rect,over:S,overlayNodeRect:w.rect,scrollableAncestors:A,scrollableAncestorRects:R,transform:D,windowRect:_}),j=kB(m),O=Ldt({config:r,draggableNodes:y,droppableContainers:v,measuringConfiguration:T}),F=j?w.setRef:void 0;return he.createElement(Ndt,null,he.createElement(kdt,{animation:O},f&&I?he.createElement(Ddt,{key:I,id:f.id,ref:F,as:a,activatorEvent:u,adjustScale:t,className:l,transition:i,rect:j,style:{zIndex:c,...o},transform:L},n):null))});function RS(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function jdt(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function kv(e){return e!==null&&e>=0}function $dt(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 Udt(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=RS(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}},yfe="Sortable",xfe=he.createContext({activeIndex:-1,containerId:yfe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:bfe,disabled:{draggable:!1,droppable:!1}});function Hdt(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}=mfe(),f=l1(yfe,n),m=a.rect!==null,g=x.useMemo(()=>r.map(D=>typeof D=="object"&&"id"in D?D.id:D),[r]),y=s!=null,v=s?g.indexOf(s.id):-1,w=c?g.indexOf(c.id):-1,S=x.useRef(g),T=!$dt(g,S.current),A=w!==-1&&v===-1||T,R=Udt(i);ka(()=>{T&&y&&u(g)},[T,g,y,u]),x.useEffect(()=>{S.current=g},[g]);const _=x.useMemo(()=>({activeIndex:v,containerId:f,disabled:R,disableTransforms:A,items:g,overIndex:w,useDragOverlay:m,sortedRects:jdt(g,l),strategy:o}),[v,f,R.draggable,R.droppable,A,g,w,l,m,o]);return he.createElement(xfe.Provider,{value:_},t)}const zdt=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return RS(n,r,o).indexOf(t)},Vdt=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},Gdt={duration:200,easing:"ease"},vfe="transform",qdt=zu.Transition.toString({property:vfe,duration:0,easing:"linear"}),Wdt={roleDescription:"sortable"};function Ydt(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=x.useState(null),a=x.useRef(n);return ka(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=Bm(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 Kdt(e){let{animateLayoutChanges:t=Vdt,attributes:n,disabled:r,data:o,getNewIndex:i=zdt,id:s,strategy:a,resizeObserverConfig:l,transition:c=Gdt}=e;const{items:u,containerId:f,activeIndex:m,disabled:g,disableTransforms:y,sortedRects:v,overIndex:w,useDragOverlay:S,strategy:T}=x.useContext(xfe),A=Xdt(r,g),R=u.indexOf(s),_=x.useMemo(()=>({sortable:{containerId:f,index:R,items:u},...o}),[f,o,R,u]),D=x.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:I,node:L,isOver:j,setNodeRef:O}=gfe({id:s,data:_,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:D,...l}}),{active:F,activatorEvent:U,activeNodeRect:Y,attributes:$,setNodeRef:G,listeners:H,isDragging:X,over:Z,setActivatorNodeRef:J,transform:B}=Sdt({id:s,data:_,attributes:{...Wdt,...n},disabled:A.draggable}),W=cut(O,G),K=!!F,P=K&&!y&&kv(m)&&kv(w),le=!S&&X,ae=le&&P?B:null,ie=P?ae??(a??T)({rects:v,activeNodeRect:Y,activeIndex:m,overIndex:w,index:R}):null,ue=kv(m)&&kv(w)?i({id:s,items:u,activeIndex:m,overIndex:w}):R,re=F?.id,be=x.useRef({activeId:re,items:u,newIndex:ue,containerId:f}),Oe=u!==be.current.items,we=t({active:F,containerId:f,isDragging:X,isSorting:K,id:s,index:R,items:u,newIndex:be.current.newIndex,previousItems:be.current.items,previousContainerId:be.current.containerId,transition:c,wasDragging:be.current.activeId!=null}),Re=Ydt({disabled:!we,index:R,node:L,rect:I});return x.useEffect(()=>{K&&be.current.newIndex!==ue&&(be.current.newIndex=ue),f!==be.current.containerId&&(be.current.containerId=f),u!==be.current.items&&(be.current.items=u)},[K,ue,f,u]),x.useEffect(()=>{if(re===be.current.activeId)return;if(re!=null&&be.current.activeId==null){be.current.activeId=re;return}const Ce=setTimeout(()=>{be.current.activeId=re},50);return()=>clearTimeout(Ce)},[re]),{active:F,activeIndex:m,attributes:$,data:_,rect:I,index:R,newIndex:ue,items:u,isOver:j,isSorting:K,isDragging:X,listeners:H,node:L,overIndex:w,over:Z,setNodeRef:W,setActivatorNodeRef:J,setDroppableNodeRef:O,setDraggableNodeRef:G,transform:Re??ie,transition:se()};function se(){if(Re||Oe&&be.current.newIndex===R)return qdt;if(!(le&&!VT(U)||!c)&&(K||we))return zu.Transition.toString({...c,property:vfe})}}function Xdt(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 Zdt={},$Y=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:()=>{(Zdt?"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},Qdt=e=>e?$Y(e):$Y,Efe={},{useDebugValue:Jdt}=he,{useSyncExternalStoreWithSelector:eft}=QKe;let UY=!1;const tft=e=>e;function nft(e,t=tft,n){(Efe?"production":void 0)!=="production"&&n&&!UY&&(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"),UY=!0);const r=eft(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Jdt(r),r}const HY=e=>{(Efe?"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"?Qdt(e):e,n=(r,o)=>nft(t,r,o);return Object.assign(n,t),n},rft=e=>e?HY(e):HY;var zY,VY;const GY=typeof window<"u"&&((zY=window.document)!=null&&zY.createElement||((VY=window.navigator)==null?void 0:VY.product)==="ReactNative")?he.useLayoutEffect:he.useEffect;function oft(){const e=rft(t=>({current:new Array,version:0,set:t}));return{In:({children:t})=>{const n=e(o=>o.set),r=e(o=>o.version);return GY(()=>{n(o=>({version:o.version+1}))},[]),GY(()=>(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 he.createElement(he.Fragment,null,t)}}}const G_=768;function WT(){const[e,t]=x.useState(void 0);return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${G_-1}px)`),r=()=>{t(window.innerWidth<G_)};return n.addEventListener("change",r),t(window.innerWidth<G_),()=>n.removeEventListener("change",r)},[]),!!e}const wfe=oft(),AB=x.createContext({columns:[],data:[],activeCardId:null}),ift=({id:e,children:t,className:n})=>{const{isOver:r,setNodeRef:o}=gfe({id:e});return h.jsx("div",{className:ke("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})},sft=({id:e,name:t,children:n,className:r})=>{const{attributes:o,listeners:i,setNodeRef:s,transition:a,transform:l,isDragging:c}=Kdt({id:e}),{activeCardId:u}=x.useContext(AB),f={transition:a,transform:zu.Transform.toString(l)};return h.jsxs(h.Fragment,{children:[h.jsx("div",{style:f,...i,...o,ref:s,children:h.jsx(Zd,{className:ke("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(wfe.In,{children:h.jsx(Zd,{className:ke("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})})})]})},aft=({children:e,className:t,...n})=>{const{data:r}=x.useContext(AB),o=r.filter(s=>s.column===n.id),i=o.map(s=>s.id);return h.jsxs(Yr,{className:"overflow-hidden flex-1",children:[h.jsx(Hdt,{items:i,children:h.jsx("div",{className:ke("flex flex-grow flex-col gap-2 p-2",t),...n,children:o.map(e)})}),h.jsx(qS,{orientation:"vertical"})]})},lft=({className:e,...t})=>h.jsx("div",{className:ke("m-0 p-2 font-semibold text-sm",e),...t}),cft=e=>t=>{const{droppableRects:n,droppableContainers:r,pointerCoordinates:o}=t,i=y=>!e.includes(y),s=y=>e.includes(y),a=Rut(t),l=a.filter(y=>i(y.id)),c=a.filter(y=>s(y.id));if(l.length>0){const v=NY(t).filter(w=>i(w.id));return v.length>0?[v[0]]:[l[0]]}if(c.length>0)return[c[0]];const u=Xde(t),f=u.filter(y=>i(y.id)),m=u.filter(y=>s(y.id));if(f.length>0){const v=Aut(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,A=Math.sqrt(Math.pow(o.x-S,2)+Math.pow(o.y-T,2)),R={left:w.left-150,right:w.right+150,top:w.top-50,bottom:w.bottom+50};o.x>=R.left&&o.x<=R.right&&o.y>=R.top&&o.y<=R.bottom&&(!y||A<y.distance)&&(y={id:v,distance:A})}if(y)return[{id:y.id}]}const g=NY(t);if(g.length>0){const y=g.find(v=>s(v.id));return y?[y]:[g[0]]}return[]},uft=({children:e,onDragStart:t,onDragEnd:n,onDragOver:r,className:o,columns:i,data:s,onDataChange:a,...l})=>{const[c,u]=x.useState(null),f=WT(),m=x.useMemo(()=>i.map(A=>A.id),[i]),g=x.useMemo(()=>cft(m),[m]),y=Sut(U_(lfe,{activationConstraint:{distance:8}}),U_(cfe,{activationConstraint:{delay:150,tolerance:8}}),U_(CB)),v=A=>{s.find(_=>_.id===A.active.id)&&u(A.active.id),t?.(A)},w=A=>{const{active:R,over:_}=A;if(!_)return;const D=s.find(F=>F.id===R.id),I=s.find(F=>F.id===_.id);if(!D)return;const L=D.column,O=i.some(F=>F.id===_.id)?_.id:I?.column||L;if(L!==O){let F=[...s];const U=F.findIndex(Y=>Y.id===R.id);if(F[U]={...F[U],column:O},I){const Y=F.findIndex($=>$.id===_.id);F=RS(F,U,Y)}a?.(F)}r?.(A)},S=A=>{u(null),n?.(A);const{active:R,over:_}=A;if(!_||R.id===_.id)return;if(i.some(O=>O.id===_.id)){const O=s.find(F=>F.id===R.id);if(O&&O.column!==_.id){let F=[...s];const U=F.findIndex(Y=>Y.id===R.id);F[U]={...F[U],column:_.id},a?.(F)}return}let I=[...s];const L=I.findIndex(O=>O.id===R.id),j=I.findIndex(O=>O.id===_.id);L!==-1&&j!==-1&&(I=RS(I,L,j),a?.(I))},T={onDragStart({active:A}){const{name:R,column:_}=s.find(D=>D.id===A.id)??{};return`Picked up the card "${R}" from the "${_}" column`},onDragOver({active:A,over:R}){const{name:_}=s.find(I=>I.id===A.id)??{},D=i.find(I=>I.id===R?.id)?.name;return`Dragged the card "${_}" over the "${D}" column`},onDragEnd({active:A,over:R}){const{name:_}=s.find(I=>I.id===A.id)??{},D=i.find(I=>I.id===R?.id)?.name;return`Dropped the card "${_}" into the "${D}" column`},onDragCancel({active:A}){const{name:R}=s.find(_=>_.id===A.id)??{};return`Cancelled dragging the card "${R}"`}};return h.jsx(AB.Provider,{value:{columns:i,data:s,activeCardId:c},children:h.jsxs(vdt,{accessibility:{announcements:T},collisionDetection:g,onDragEnd:S,onDragOver:w,onDragStart:v,sensors:y,...l,children:[h.jsx("div",{className:ke("flex gap-4",f&&"flex-col",o),children:i.map(A=>e(A))}),typeof window<"u"&&Wr.createPortal(h.jsx(Bdt,{children:h.jsx(wfe.Out,{})}),document.body)]})})},qY={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold"};function db(e){return qY[e]?qY[e]:e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function dft({tasks:e,loading:t,onTasksUpdate:n}){const{config:r,updateConfig:o}=yf(),[i,s]=x.useState(new Set),[a,l]=x.useState(!1),c=WT(),u=r?.statuses||["todo","in-progress","in-review","done","blocked"],f=r?.statusColors||KO,m=x.useMemo(()=>u.filter(O=>i.has(O)).map(O=>({id:O,name:db(O),color:f[O]||"gray"})),[u,i,f]),g={high:0,medium:1,low:2},y=x.useMemo(()=>[...e].sort((F,U)=>{const Y=g[F.priority]??2,$=g[U.priority]??2;return Y!==$?Y-$: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(Y=>Y.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)}},A=O=>{s(F=>{const U=new Set(F);return U.has(O)?U.delete(O):U.add(O),T(U),U})},R=async O=>{const F=O.filter(Y=>{const $=e.find(G=>G.id===Y.id);return $&&$.status!==Y.column}),U=e.map(Y=>{const $=O.find(G=>G.id===Y.id);return $&&$.column!==Y.status?{...Y,status:$.column}:Y});n(U);for(const Y of F)try{await ha.updateTask(Y.id,{status:Y.column}),oo.success("Status updated",{description:`#${Y.id} moved to ${db(Y.column)}`})}catch($){console.error("Failed to update task:",$),oo.error("Failed to update status",{description:$ instanceof Error?$.message:"Unknown error"}),ha.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}`},D=()=>{window.location.hash="/"},I=O=>{n(e.map(F=>F.id===O.id?O:F))},L=O=>{window.location.hash=`/kanban/${O}`},j=async O=>{try{await ha.archiveTask(O),n(e.filter(F=>F.id!==O)),D()}catch(F){console.error("Failed to archive task:",F)}};return h.jsxs("div",{className:"flex flex-col h-full",children:[c?h.jsxs(Ade,{open:a,onOpenChange:l,className:"shrink-0 bg-card rounded-lg mb-4 border border-border",children:[h.jsxs(Nde,{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(fK,{className:"w-4 h-4 text-muted-foreground"}):h.jsx(Ps,{className:"w-4 h-4 text-muted-foreground"})]}),h.jsx(_de,{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(Y=>Y.status===O).length;return h.jsxs("button",{type:"button",onClick:()=>A(O),className:ke("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(Yb,{className:"w-3.5 h-3.5"}):h.jsx(rR,{className:"w-3.5 h-3.5"}),h.jsxs("span",{className:"font-medium",children:[db(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(Y=>Y.status===O).length;return h.jsxs("button",{type:"button",onClick:()=>A(O),className:ke("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(Yb,{className:"w-4 h-4"}):h.jsx(rR,{className:"w-4 h-4"}),h.jsxs("span",{className:"text-sm font-medium",children:[db(O)," (",U,")"]})]},O)})]})}),h.jsxs(Yr,{className:"flex-1",children:[i.size>0?h.jsx(uft,{columns:m,data:y,onDataChange:R,className:"min-h-full pb-4",children:O=>{const F=pCe(O.id,f),U=y.filter(Y=>Y.column===O.id).length;return h.jsxs(ift,{id:O.id,className:ke("min-w-[320px] max-w-[380px]",c&&"min-w-0 max-w-none w-full",F.bg,F.border),children:[h.jsxs(lft,{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(aft,{id:O.id,children:Y=>h.jsx(fft,{item:Y,statusColors:f,onClick:()=>_(Y.task)},Y.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(qS,{orientation:"horizontal"})]}),h.jsx(qde,{task:w,allTasks:e,onClose:D,onUpdate:I,onArchive:j,onNavigateToTask:L})]})}function fft({item:e,statusColors:t,onClick:n}){const{task:r}=e,o=Th(r.status,t),i=r.acceptanceCriteria.filter(a=>a.completed).length,s=r.acceptanceCriteria.length;return h.jsx(sft,{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:ke("text-xs px-1.5 py-0.5 rounded font-medium",o),children:db(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(hK,{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(K0,{name:r.assignee,size:"sm"}),h.jsx("span",{children:r.assignee})]})]})})}const WY=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],YY={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 pft({isOpen:e,allTasks:t,onClose:n,onCreated:r}){const{currentUser:o}=dQ(),{config:i}=yf(),s=x.useRef(null),a=x.useRef(null),l=x.useMemo(()=>{const q=i.statuses||["todo","in-progress","in-review","done","blocked"];return gQ(q)},[i.statuses]),c=i.statusColors||{},[u,f]=x.useState(""),[m,g]=x.useState(""),[y,v]=x.useState("todo"),[w,S]=x.useState("medium"),[T,A]=x.useState(""),[R,_]=x.useState([]),[D,I]=x.useState(""),[L,j]=x.useState([]),[O,F]=x.useState(""),[U,Y]=x.useState(""),[$,G]=x.useState(!1),[H,X]=x.useState(null),[Z,J]=x.useState(!1),[B,W]=x.useState(""),[K,P]=x.useState(!1),[le,ae]=x.useState(""),[de,ie]=x.useState(!1),[ue,re]=x.useState(!1),{preferences:be,toggleTaskCreateLayout:Oe}=hQ(),we=be.taskCreateLayout==="maximized",Re=x.useRef(null),se={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"),A(""),_([]),I(""),j([]),F(""),Y(""),X(null),J(!1),W(""),P(!1),ae(""),ie(!1),re(!1))},[e]),x.useEffect(()=>{e&&setTimeout(()=>s.current?.focus(),100)},[e,we]),x.useEffect(()=>{K&&Re.current&&Re.current.focus()},[K]);const Ce=x.useCallback(()=>{B.trim()&&(j(q=>[...q,{id:crypto.randomUUID(),text:B.trim()}]),W(""),P(!1))},[B]),Be=x.useCallback(q=>{j(ye=>ye.filter(Fe=>Fe.id!==q))},[]),Pe=x.useCallback(()=>{le.trim()&&(R.includes(le.trim())||_(q=>[...q,le.trim()]),ae(""),ie(!1))},[le,R]),hn=x.useCallback(q=>{_(ye=>ye.filter(Fe=>Fe!==q))},[]),Mt=async q=>{if(q.preventDefault(),X(null),!u.trim()){X("Title is required");return}G(!0);try{const ye={title:u.trim(),description:m.trim()||void 0,status:y,priority:w,labels:R,assignee:T.trim()||void 0,parent:D||void 0,acceptanceCriteria:L.map(Fe=>({text:Fe.text,completed:!1})),implementationPlan:O.trim()||void 0,implementationNotes:U.trim()||void 0};await Nme(ye),J(!0),oo.success("Task created successfully",{description:u.trim()}),setTimeout(()=>{r(),n()},800)}catch(ye){const Fe=ye instanceof Error?ye.message:"Failed to create task";X(Fe),oo.error("Failed to create task",{description:Fe})}finally{G(!1)}},vt=D?t.find(q=>q.id===D):null,ne=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:q=>f(q.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:$})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(Le,{variant:"ghost",size:"icon",onClick:Oe,className:"h-8 w-8 text-foreground hover:text-foreground",title:we?"Minimize":"Maximize",children:we?h.jsx(xK,{className:"w-4 h-4"}):h.jsx(yK,{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(Qo,{className:"w-4 h-4"})})]})]}),fe=(Z||H)&&h.jsxs("div",{className:"px-4 pt-4",children:[Z&&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!"}),H&&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:H})]}),ve=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(wK,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Description"})]}),h.jsx(Su,{markdown:m,onChange:g,placeholder:"Add a more detailed description...",readOnly:$})]}),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(em,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Acceptance Criteria"}),L.length>0&&h.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",L.length,")"]})]})}),h.jsx("div",{className:"space-y-2",children:L.map(q=>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:q.text}),h.jsx("button",{type:"button",onClick:()=>Be(q.id),className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-red-500 p-1 transition-all",title:"Delete",children:h.jsx(Tu,{className:"w-4 h-4"})})]},q.id))}),K?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:q=>W(q.target.value),onKeyDown:q=>{q.key==="Enter"&&B.trim()&&(q.preventDefault(),Ce()),q.key==="Escape"&&(W(""),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:$}),h.jsxs("div",{className:"flex gap-2 mt-2",children:[h.jsx(Le,{type:"button",size:"sm",onClick:Ce,disabled:!B.trim()||$,className:"bg-green-700 hover:bg-green-800 text-white",children:"Add"}),h.jsx(Le,{type:"button",variant:"ghost",size:"sm",onClick:()=>{W(""),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:$,children:[h.jsx(Ho,{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(ni,{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(Su,{markdown:O,onChange:F,placeholder:"Describe how you plan to implement this task...",readOnly:$})]}),h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(Xbe,{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(Su,{markdown:U,onChange:Y,placeholder:"Add notes, observations, or any other relevant information...",readOnly:$})]})]}),$e=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(ei,{value:y,onValueChange:q=>v(q),disabled:$,children:[h.jsx($o,{className:ke("w-full",Th(y,c)),children:h.jsx(ti,{})}),h.jsx(Uo,{children:l.map(q=>h.jsx(En,{value:q.value,children:q.label},q.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(ei,{value:w,onValueChange:q=>S(q),disabled:$,children:[h.jsx($o,{className:ke("w-full",YY[w]),children:h.jsx(ti,{})}),h.jsx(Uo,{children:WY.map(q=>h.jsx(En,{value:q.value,children:q.label},q.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(xS,{value:T,onChange:A,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:R.map(q=>h.jsxs(cc,{variant:"secondary",className:"gap-1 pr-1",children:[q,h.jsx("button",{type:"button",onClick:()=>hn(q),className:"ml-1 hover:text-destructive",children:h.jsx(Qo,{className:"w-3 h-3"})})]},q))}),de?h.jsxs("div",{className:"space-y-2",children:[h.jsx(Gn,{value:le,onChange:q=>ae(q.target.value),onKeyDown:q=>{q.key==="Enter"&&le.trim()&&(q.preventDefault(),Pe()),q.key==="Escape"&&(ae(""),ie(!1))},placeholder:"Label name",disabled:$,autoFocus:!0}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Le,{size:"sm",onClick:Pe,disabled:!le.trim()||$,children:"Add"}),h.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>{ae(""),ie(!1)},children:"Cancel"})]})]}):h.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground",onClick:()=>ie(!0),disabled:$,children:[h.jsx(Ho,{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(V0,{open:ue,onOpenChange:re,children:[h.jsx(G0,{asChild:!0,children:h.jsxs(Le,{variant:"outline",role:"combobox","aria-expanded":ue,className:"w-full justify-between h-auto min-h-10 py-2",disabled:$,title:vt?`#${vt.id} - ${vt.title}`:void 0,children:[vt?h.jsxs("div",{className:"flex items-center gap-2 text-left overflow-hidden min-w-0 flex-1",children:[h.jsx(Eh,{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:["#",vt.id]}),h.jsx("p",{className:"truncate text-sm",children:vt.title})]})]}):h.jsx("span",{className:"text-muted-foreground",children:"Select parent task..."}),h.jsx(yE,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),h.jsx(qh,{className:"w-[400px] p-0",align:"start",children:h.jsxs(Wh,{children:[h.jsx(Yh,{placeholder:"Search tasks..."}),h.jsxs(Kh,{children:[h.jsx(Xh,{children:"No task found."}),h.jsxs(rl,{children:[h.jsxs(Ji,{value:"none",onSelect:()=>{I(""),re(!1)},children:[h.jsx(so,{className:ke("mr-2 h-4 w-4 shrink-0",D?"opacity-0":"opacity-100")}),h.jsx("span",{className:"text-muted-foreground",children:"None"})]}),t.map(q=>h.jsxs(Ji,{value:`${q.id} ${q.title}`,onSelect:()=>{I(q.id),re(!1)},title:`#${q.id} - ${q.title}`,children:[h.jsx(so,{className:ke("mr-2 h-4 w-4 shrink-0",D===q.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:["#",q.id]}),h.jsx("p",{className:"truncate text-sm",children:q.title})]})]},q.id))]})]})]})})]})]})]}),ze=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:$,children:"Cancel"}),h.jsx(Le,{type:"button",onClick:Mt,className:"bg-green-700 hover:bg-green-800 text-white",disabled:$||Z||!u.trim(),children:$?"Creating...":"Create Task"})]});return we?h.jsx(TE,{children:e&&h.jsx(zO,{open:e,onOpenChange:q=>!q&&n(),children:h.jsxs(zS,{className:"max-w-6xl w-[95vw] h-[90vh] p-0 gap-0 overflow-hidden flex flex-col",hideCloseButton:!0,children:[h.jsx(VO,{className:"sr-only",children:"Create New Task"}),h.jsxs(_E.div,{ref:a,className:"flex flex-col h-full overflow-hidden",variants:se,initial:"hidden",animate:"visible",exit:"exit",children:[ne,fe,h.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[h.jsx(Yr,{className:"flex-1",children:ve}),h.jsx("div",{className:"shrink-0 w-72 border-l bg-muted/20",children:h.jsx(Yr,{className:"h-full",children:$e})})]}),ze]})]})})}):h.jsx(TE,{children:e&&h.jsx($O,{open:e,onOpenChange:q=>!q&&n(),children:h.jsx(HS,{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(_E.div,{ref:a,className:"flex flex-col h-full overflow-hidden",variants:se,initial:"hidden",animate:"visible",exit:"exit",children:[ne,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(ei,{value:y,onValueChange:q=>v(q),disabled:$,children:[h.jsx($o,{className:ke("w-full h-9",Th(y,c)),children:h.jsx(ti,{})}),h.jsx(Uo,{children:l.map(q=>h.jsx(En,{value:q.value,children:q.label},q.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(ei,{value:w,onValueChange:q=>S(q),disabled:$,children:[h.jsx($o,{className:ke("w-full h-9",YY[w]),children:h.jsx(ti,{})}),h.jsx(Uo,{children:WY.map(q=>h.jsx(En,{value:q.value,children:q.label},q.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(xS,{value:T,onChange:A,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:[R.map(q=>h.jsxs(cc,{variant:"secondary",className:"gap-1 pr-1 text-xs",children:[q,h.jsx("button",{type:"button",onClick:()=>hn(q),className:"ml-0.5 hover:text-destructive",children:h.jsx(Qo,{className:"w-3 h-3"})})]},q)),!de&&h.jsxs(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground",onClick:()=>ie(!0),children:[h.jsx(Ho,{className:"w-3 h-3 mr-1"}),"Add"]})]}),de&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{value:le,onChange:q=>ae(q.target.value),onKeyDown:q=>{q.key==="Enter"&&le.trim()&&Pe(),q.key==="Escape"&&(ae(""),ie(!1))},placeholder:"Label",className:"h-7 w-24 text-xs",autoFocus:!0}),h.jsx(Le,{size:"sm",className:"h-7 px-2",onClick:Pe,disabled:!le.trim(),children:"Add"}),h.jsx(Le,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>{ae(""),ie(!1)},children:h.jsx(Qo,{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(V0,{open:ue,onOpenChange:re,children:[h.jsx(G0,{asChild:!0,children:h.jsxs(Le,{variant:"outline",role:"combobox",size:"sm",className:"h-7 justify-between min-w-[120px] max-w-[250px]",disabled:$,title:vt?`#${vt.id} - ${vt.title}`:void 0,children:[vt?h.jsxs("span",{className:"truncate text-xs",children:["#",vt.id," - ",vt.title]}):h.jsx("span",{className:"text-muted-foreground text-xs",children:"None"}),h.jsx(yE,{className:"ml-1 h-3 w-3 shrink-0 opacity-50"})]})}),h.jsx(qh,{className:"w-[400px] p-0",align:"end",children:h.jsxs(Wh,{children:[h.jsx(Yh,{placeholder:"Search tasks..."}),h.jsxs(Kh,{children:[h.jsx(Xh,{children:"No task found."}),h.jsxs(rl,{children:[h.jsxs(Ji,{value:"none",onSelect:()=>{I(""),re(!1)},children:[h.jsx(so,{className:ke("mr-2 h-4 w-4 shrink-0",D?"opacity-0":"opacity-100")}),h.jsx("span",{className:"text-muted-foreground",children:"None"})]}),t.map(q=>h.jsxs(Ji,{value:`${q.id} ${q.title}`,onSelect:()=>{I(q.id),re(!1)},title:`#${q.id} - ${q.title}`,children:[h.jsx(so,{className:ke("mr-2 h-4 w-4 shrink-0",D===q.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:["#",q.id]}),h.jsx("p",{className:"truncate text-sm",children:q.title})]})]},q.id))]})]})]})})]})]})]})]})}),h.jsx(Yr,{className:"flex-1",children:ve})]}),ze]})})})})}const hft="/assets/logo-BkDQ9x4a.png",mft="sidebar_state",gft=3600*24*7,bft="16rem",yft="18rem",xft="3rem",vft="b",Sfe=x.createContext(null);function u1(){const e=x.useContext(Sfe);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Cfe=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:i,...s},a)=>{const l=WT(),[c,u]=x.useState(!1),[f,m]=x.useState(e),g=t??f,y=x.useCallback(T=>{const A=typeof T=="function"?T(g):T;n?n(A):m(A),document.cookie=`${mft}=${A}; path=/; max-age=${gft}`},[n,g]),v=x.useCallback(()=>l?u(T=>!T):y(T=>!T),[l,y,u]);x.useEffect(()=>{const T=A=>{A.key===vft&&(A.metaKey||A.ctrlKey)&&(A.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(Sfe.Provider,{value:S,children:h.jsx(bde,{delayDuration:0,children:h.jsx("div",{style:{"--sidebar-width":bft,"--sidebar-width-icon":xft,...o},className:ke("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:a,...s,children:i})})})});Cfe.displayName="SidebarProvider";const Tfe=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}=u1();return n==="none"?h.jsx("div",{className:ke("flex h-full w-[var(--sidebar-width)] flex-col bg-sidebar text-sidebar-foreground",r),ref:s,...i,children:o}):a?h.jsx($O,{open:c,onOpenChange:u,...i,children:h.jsxs(HS,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[var(--sidebar-width)] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":yft},side:e,children:[h.jsxs(UO,{className:"sr-only",children:[h.jsx(HO,{children:"Sidebar"}),h.jsx(WZ,{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:ke("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:ke("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})})]})});Tfe.displayName="Sidebar";const kfe=x.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=u1();return h.jsxs(Le,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:ke("h-7 w-7",e),onClick:i=>{t?.(i),o()},...n,children:[h.jsx(Obe,{}),h.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});kfe.displayName="SidebarTrigger";const Afe=x.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=u1();return h.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:ke("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})});Afe.displayName="SidebarRail";const Eft=x.forwardRef(({className:e,...t},n)=>h.jsx("main",{ref:n,className:ke("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}));Eft.displayName="SidebarInset";const wft=x.forwardRef(({className:e,...t},n)=>h.jsx(Gn,{ref:n,"data-sidebar":"input",className:ke("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));wft.displayName="SidebarInput";const Nfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"header",className:ke("flex flex-col gap-2 p-2",e),...t}));Nfe.displayName="SidebarHeader";const _fe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"footer",className:ke("flex flex-col gap-2 p-2",e),...t}));_fe.displayName="SidebarFooter";const Sft=x.forwardRef(({className:e,...t},n)=>h.jsx(Y0,{ref:n,"data-sidebar":"separator",className:ke("mx-2 w-auto bg-sidebar-border",e),...t}));Sft.displayName="SidebarSeparator";const Rfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"content",className:ke("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Rfe.displayName="SidebarContent";const Dfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"group",className:ke("relative flex w-full min-w-0 flex-col p-2",e),...t}));Dfe.displayName="SidebarGroup";const Ife=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?qu:"div";return h.jsx(o,{ref:r,"data-sidebar":"group-label",className:ke("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})});Ife.displayName="SidebarGroupLabel";const Cft=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?qu:"button";return h.jsx(o,{ref:r,"data-sidebar":"group-action",className:ke("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})});Cft.displayName="SidebarGroupAction";const Ofe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"group-content",className:ke("w-full text-sm",e),...t}));Ofe.displayName="SidebarGroupContent";const hE=x.forwardRef(({className:e,...t},n)=>h.jsx("ul",{ref:n,"data-sidebar":"menu",className:ke("flex w-full min-w-0 flex-col gap-1",e),...t}));hE.displayName="SidebarMenu";const mE=x.forwardRef(({className:e,...t},n)=>h.jsx("li",{ref:n,"data-sidebar":"menu-item",className:ke("group/menu-item relative",e),...t}));mE.displayName="SidebarMenuItem";const Tft=pc("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"}}),gE=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:i,...s},a)=>{const l=e?qu:"button",{isMobile:c,state:u}=u1(),f=h.jsx(l,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:ke(Tft({variant:n,size:r}),i),...s});return o?(typeof o=="string"&&(o={children:o}),h.jsxs(yde,{children:[h.jsx(xde,{asChild:!0,children:f}),h.jsx(sB,{side:"right",align:"center",hidden:u!=="collapsed"||c,...o})]})):f});gE.displayName="SidebarMenuButton";const kft=x.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const i=t?qu:"button";return h.jsx(i,{ref:o,"data-sidebar":"menu-action",className:ke("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})});kft.displayName="SidebarMenuAction";const Aft=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:ke("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}));Aft.displayName="SidebarMenuBadge";const Nft=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:ke("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&h.jsx(KW,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),h.jsx(KW,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});Nft.displayName="SidebarMenuSkeleton";const _ft=x.forwardRef(({className:e,...t},n)=>h.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:ke("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}));_ft.displayName="SidebarMenuSub";const Rft=x.forwardRef(({...e},t)=>h.jsx("li",{ref:t,...e}));Rft.displayName="SidebarMenuSubItem";const Dft=x.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},i)=>{const s=e?qu:"a";return h.jsx(s,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:ke("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})});Dft.displayName="SidebarMenuSubButton";const Ift=[{id:"kanban",label:"Kanban",icon:gbe,href:"#/"},{id:"tasks",label:"Tasks",icon:bK,href:"#/tasks"},{id:"docs",label:"Docs",icon:ni,href:"#/docs"},{id:"templates",label:"Templates",icon:tb,href:"#/templates"},{id:"imports",label:"Imports",icon:Wb,href:"#/imports"}];function Oft({currentPage:e,onSearchClick:t}){const{state:n}=u1(),r=WT(),o=n==="expanded";return h.jsxs(Tfe,{collapsible:"icon",variant:r?"floating":"sidebar",children:[h.jsxs(Nfe,{children:[h.jsx(hE,{children:h.jsx(mE,{children:h.jsx(gE,{size:"lg",asChild:!0,children:h.jsxs("a",{href:"#/",children:[h.jsx("img",{src:hft,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(DS,{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(Rfe,{children:h.jsxs(Dfe,{children:[h.jsx(Ife,{children:"Navigation"}),h.jsx(Ofe,{children:h.jsx(hE,{children:Ift.map(i=>{const s=e===i.id;return h.jsx(mE,{children:h.jsx(gE,{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(_fe,{children:[h.jsx(hE,{children:h.jsx(mE,{children:h.jsx(gE,{asChild:!0,isActive:e==="config",tooltip:"Settings",children:h.jsxs("a",{href:"#/config",children:[h.jsx(JI,{}),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.2"})]})})]}),h.jsx(Afe,{})]})}const Mft=[{value:"all",label:"All"},{value:"status",label:"Status"},{value:"assignee",label:"Assignee"},{value:"content",label:"Content"}];function Lft(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 Pft(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 Fft(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 Bft({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 ha.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]),es("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(P9,{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(Kb,{className:`w-4 h-4 ${c?"animate-spin":""}`})})]}),t&&h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(QI,{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:Mft.map(y=>h.jsx("option",{value:y.value,children:y.label},y.value))})]}),h.jsx(Yr,{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(K0,{name:y.author,size:"xs"}):h.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${Fft(y.changes)}`,children:h.jsx(P9,{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:Lft(y)}),h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Pft(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 jft(){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 ha.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]),es("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(V0,{open:n,onOpenChange:a,children:[h.jsx(G0,{asChild:!0,children:h.jsxs(Le,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Notifications",children:[h.jsx(Sge,{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(Bft,{limit:20,showFilter:!1,onTaskClick:l=>{r(!1),window.location.hash=`/kanban/${l}`}})})]})})]})}const KY={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"},$ft={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold"};function Uft({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(zO,{open:e,onOpenChange:t,children:h.jsx(zS,{className:"overflow-hidden p-0 max-w-2xl",hideClose:!0,children:h.jsxs(Wh,{shouldFilter:!1,children:[h.jsx(Yh,{placeholder:"Search tasks and docs...",value:o,onValueChange:i}),h.jsxs(Kh,{children:[h.jsx(Xh,{children:l?"Searching...":o?"No results found.":"Type to search..."}),s.tasks.length>0&&h.jsx(rl,{heading:"Tasks",children:s.tasks.slice(0,8).map(m=>{const g=KY[m.status]||KY.todo,y=$ft[m.status]||m.status;return h.jsxs(Ji,{value:`task-${m.id}`,onSelect:()=>u(m),children:[h.jsx(bK,{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(gS,{}),s.docs.length>0&&h.jsx(rl,{heading:"Documentation",children:s.docs.slice(0,8).map(m=>{const g=m.metadata?.title||m.filename;return h.jsxs(Ji,{value:`doc-${m.path}`,onSelect:()=>f(m),children:[h.jsx(ni,{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 yu(e,t){return typeof e=="function"?e(t):e}function cs(e,t){return n=>{t.setState(r=>({...r,[e]:yu(n,r[e])}))}}function YT(e){return e instanceof Function}function Hft(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function zft(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 dt(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
|
+
`},Eut={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 wut(e){let{announcements:t=Eut,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=vut}=e;const{announce:i,announcement:s}=but(),a=l1("DndLiveRegion"),[l,c]=x.useState(!1);if(x.useEffect(()=>{c(!0)},[]),yut(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=he.createElement(he.Fragment,null,he.createElement(mut,{id:r,value:o.draggable}),he.createElement(gut,{id:a,announcement:s}));return n?Wr.createPortal(u,n):u}var Gr;(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"})(Gr||(Gr={}));function NS(){}function U_(e,t){return x.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Sut(){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 Aa=Object.freeze({x:0,y:0});function vB(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Cut(e,t){const n=AS(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 EB(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Tut(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function jI(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 kut(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function AY(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 Aut=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=AY(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=vB(AY(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(EB)},NY=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=jI(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=jI(l),u=o.reduce((m,g,y)=>m+vB(c[y],g),0),f=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:f}})}}return i.sort(EB)};function Nut(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 Xde=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=Nut(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(Tut)};function _ut(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 Rut=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&&_ut(r,a)){const c=jI(a).reduce((f,m)=>f+vB(r,m),0),u=Number((c/4).toFixed(4));o.push({id:s,data:{droppableContainer:i,value:u}})}}return o.sort(EB)};function Dut(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Zde(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Aa}function Iut(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 Out=Iut(1);function Qde(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 Mut(e,t,n){const r=Qde(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 Lut={ignoreTransform:!1};function Bm(e,t){t===void 0&&(t=Lut);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=di(e).getComputedStyle(e);c&&(n=Mut(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 _Y(e){return Bm(e,{ignoreTransform:!0})}function Put(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Fut(e,t){return t===void 0&&(t=di(e).getComputedStyle(e)),t.position==="fixed"}function But(e,t){t===void 0&&(t=di(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 wB(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(xB(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!s1(o)||Wde(o)||n.includes(o))return n;const i=di(e).getComputedStyle(o);return o!==e&&But(o,i)&&n.push(o),Fut(o,i)?n:r(o.parentNode)}return e?r(e):n}function Jde(e){const[t]=wB(e,1);return t??null}function H_(e){return!HT||!e?null:Pm(e)?e:yB(e)?xB(e)||e===Fm(e).scrollingElement?window:s1(e)?e:null:null}function efe(e){return Pm(e)?e.scrollX:e.scrollLeft}function tfe(e){return Pm(e)?e.scrollY:e.scrollTop}function $I(e){return{x:efe(e),y:tfe(e)}}var ro;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ro||(ro={}));function nfe(e){return!HT||!e?!1:e===document.scrollingElement}function rfe(e){const t={x:0,y:0},n=nfe(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 jut={x:.2,y:.2};function $ut(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=jut);const{isTop:c,isBottom:u,isLeft:f,isRight:m}=rfe(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=ro.Backward,y.y=r*Math.abs((t.top+v.height-i)/v.height)):!u&&l>=t.bottom-v.height&&(g.y=ro.Forward,y.y=r*Math.abs((t.bottom-v.height-l)/v.height)),!m&&a>=t.right-v.width?(g.x=ro.Forward,y.x=r*Math.abs((t.right-v.width-a)/v.width)):!f&&s<=t.left+v.width&&(g.x=ro.Backward,y.x=r*Math.abs((t.left+v.width-s)/v.width)),{direction:g,speed:y}}function Uut(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 ofe(e){return e.reduce((t,n)=>xh(t,$I(n)),Aa)}function Hut(e){return e.reduce((t,n)=>t+efe(n),0)}function zut(e){return e.reduce((t,n)=>t+tfe(n),0)}function ife(e,t){if(t===void 0&&(t=Bm),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);Jde(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Vut=[["x",["left","right"],Hut],["y",["top","bottom"],zut]];class SB{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=wB(n),o=ofe(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of Vut)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 Ub{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 Gut(e){const{EventTarget:t}=di(e);return e instanceof t?e:Fm(e)}function z_(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 Rs;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Rs||(Rs={}));function RY(e){e.preventDefault()}function qut(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 sfe={start:[vn.Space,vn.Enter],cancel:[vn.Esc],end:[vn.Space,vn.Enter,vn.Tab]},Wut=(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 CB{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 Ub(Fm(n)),this.windowListeners=new Ub(di(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rs.Resize,this.handleCancel),this.windowListeners.add(Rs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&ife(r),n(Aa)}handleKeyDown(t){if(VT(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=sfe,coordinateGetter:s=Wut,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}:Aa;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(t,{active:n,context:r.current,currentCoordinates:u});if(f){const m=kS(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:A,isBottom:R,maxScroll:_,minScroll:D}=rfe(v),I=Uut(v),L={x:Math.min(w===vn.Right?I.right-I.width/2:I.right,Math.max(w===vn.Right?I.left:I.left+I.width/2,f.x)),y:Math.min(w===vn.Down?I.bottom-I.height/2:I.bottom,Math.max(w===vn.Down?I.top:I.top+I.height/2,f.y))},j=w===vn.Right&&!T||w===vn.Left&&!A,O=w===vn.Down&&!R||w===vn.Up&&!S;if(j&&L.x!==f.x){const F=v.scrollLeft+m.x,U=w===vn.Right&&F<=_.x||w===vn.Left&&F>=D.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-D.x,g.x&&v.scrollBy({left:-g.x,behavior:a});break}else if(O&&L.y!==f.y){const F=v.scrollTop+m.y,U=w===vn.Down&&F<=_.y||w===vn.Up&&F>=D.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-D.y,g.y&&v.scrollBy({top:-g.y,behavior:a});break}}this.handleMove(t,xh(kS(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()}}CB.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=sfe,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 DY(e){return!!(e&&"distance"in e)}function IY(e){return!!(e&&"delay"in e)}class TB{constructor(t,n,r){var o;r===void 0&&(r=Gut(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=Fm(s),this.documentListeners=new Ub(this.document),this.listeners=new Ub(r),this.windowListeners=new Ub(di(s)),this.initialCoordinates=(o=AS(i))!=null?o:Aa,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(Rs.Resize,this.handleCancel),this.windowListeners.add(Rs.DragStart,RY),this.windowListeners.add(Rs.VisibilityChange,this.handleCancel),this.windowListeners.add(Rs.ContextMenu,RY),this.documentListeners.add(Rs.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(IY(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(DY(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(Rs.Click,qut,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rs.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=AS(t))!=null?n:Aa,c=kS(o,l);if(!r&&a){if(DY(a)){if(a.tolerance!=null&&z_(c,a.tolerance))return this.handleCancel();if(z_(c,a.distance))return this.handleStart()}if(IY(a)&&z_(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 Yut={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class afe extends TB{constructor(t){const{event:n}=t,r=Fm(n.target);super(t,Yut,r)}}afe.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 Kut={move:{name:"mousemove"},end:{name:"mouseup"}};var UI;(function(e){e[e.RightClick=2]="RightClick"})(UI||(UI={}));class lfe extends TB{constructor(t){super(t,Kut,Fm(t.event.target))}}lfe.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===UI.RightClick?!1:(r?.({event:n}),!0)}}];const V_={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class cfe extends TB{constructor(t){super(t,V_)}static setup(){return window.addEventListener(V_.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(V_.move.name,t)};function t(){}}}cfe.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 Hb;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Hb||(Hb={}));var _S;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(_S||(_S={}));function Xut(e){let{acceleration:t,activator:n=Hb.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=_S.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:m}=e;const g=Qut({delta:f,disabled:!i}),[y,v]=uut(),w=x.useRef({x:0,y:0}),S=x.useRef({x:0,y:0}),T=x.useMemo(()=>{switch(n){case Hb.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Hb.DraggableRect:return o}},[n,o,l]),A=x.useRef(null),R=x.useCallback(()=>{const D=A.current;if(!D)return;const I=w.current.x*S.current.x,L=w.current.y*S.current.y;D.scrollBy(I,L)},[]),_=x.useMemo(()=>a===_S.TreeOrder?[...c].reverse():c,[a,c]);x.useEffect(()=>{if(!i||!c.length||!T){v();return}for(const D of _){if(r?.(D)===!1)continue;const I=c.indexOf(D),L=u[I];if(!L)continue;const{direction:j,speed:O}=$ut(D,L,T,t,m);for(const F of["x","y"])g[F][j[F]]||(O[F]=0,j[F]=0);if(O.x>0||O.y>0){v(),A.current=D,y(R,s),w.current=O,S.current=j;return}}w.current={x:0,y:0},S.current={x:0,y:0},v()},[t,R,r,v,i,s,JSON.stringify(T),JSON.stringify(g),y,c,_,u,JSON.stringify(m)])}const Zut={x:{[ro.Backward]:!1,[ro.Forward]:!1},y:{[ro.Backward]:!1,[ro.Forward]:!1}};function Qut(e){let{delta:t,disabled:n}=e;const r=TS(t);return a1(o=>{if(n||!r||!o)return Zut;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[ro.Backward]:o.x[ro.Backward]||i.x===-1,[ro.Forward]:o.x[ro.Forward]||i.x===1},y:{[ro.Backward]:o.y[ro.Backward]||i.y===-1,[ro.Forward]:o.y[ro.Forward]||i.y===1}}},[n,t,r])}function Jut(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return a1(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function edt(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 J0;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(J0||(J0={}));var HI;(function(e){e.Optimized="optimized"})(HI||(HI={}));const OY=new Map;function tdt(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=Q0(f),g=x.useCallback(function(S){S===void 0&&(S=[]),!m.current&&s(T=>T===null?S:T.concat(S.filter(A=>!T.includes(A))))},[m]),y=x.useRef(null),v=a1(S=>{if(f&&!n)return OY;if(!S||S===OY||u.current!==e||i!=null){const T=new Map;for(let A of e){if(!A)continue;if(i&&i.length>0&&!i.includes(A.id)&&A.rect.current){T.set(A.id,A.rect.current);continue}const R=A.node.current,_=R?new SB(l(R),R):null;A.rect.current=_,_&&T.set(A.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 J0.Always:return!1;case J0.BeforeDragging:return n;default:return!n}}}function kB(e,t){return a1(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function ndt(e,t){return kB(e,t)}function rdt(e){let{callback:t,disabled:n}=e;const r=zT(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 GT(e){let{callback:t,disabled:n}=e;const r=zT(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 odt(e){return new SB(Bm(e),e)}function MY(e,t,n){t===void 0&&(t=odt);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=rdt({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=GT({callback:i});return ka(()=>{i(),e?(a?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[e]),r}function idt(e){const t=kB(e);return Zde(e,t)}const LY=[];function sdt(e){const t=x.useRef(e),n=a1(r=>e?r&&r!==LY&&e&&t.current&&e.parentNode===t.current.parentNode?r:wB(e):LY,[e]);return x.useEffect(()=>{t.current=e},[e]),n}function adt(e){const[t,n]=x.useState(null),r=x.useRef(e),o=x.useCallback(i=>{const s=H_(i.target);s&&n(a=>a?(a.set(s,$I(s)),new Map(a)):null)},[]);return x.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=H_(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,$I(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=H_(l);c?.removeEventListener("scroll",o)})}},[o,e]),x.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>xh(i,s),Aa):ofe(e):Aa,[e,t])}function PY(e,t){t===void 0&&(t=[]);const n=x.useRef(null);return x.useEffect(()=>{n.current=null},t),x.useEffect(()=>{const r=e!==Aa;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?kS(e,n.current):Aa}function ldt(e){x.useEffect(()=>{if(!HT)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 cdt(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 ufe(e){return x.useMemo(()=>e?Put(e):null,[e])}const FY=[];function udt(e,t){t===void 0&&(t=Bm);const[n]=e,r=ufe(n?di(n):null),[o,i]=x.useState(FY);function s(){i(()=>e.length?e.map(l=>nfe(l)?r:new SB(t(l),l)):FY)}const a=GT({callback:s});return ka(()=>{a?.disconnect(),s(),e.forEach(l=>a?.observe(l))},[e]),o}function dfe(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return s1(t)?t:e}function ddt(e){let{measure:t}=e;const[n,r]=x.useState(null),o=x.useCallback(c=>{for(const{target:u}of c)if(s1(u)){r(f=>{const m=t(u);return f?{...f,width:m.width,height:m.height}:m});break}},[t]),i=GT({callback:o}),s=x.useCallback(c=>{const u=dfe(c);i?.disconnect(),u&&i?.observe(u),r(u?t(u):null)},[t,i]),[a,l]=CS(s);return x.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const fdt=[{sensor:afe,options:{}},{sensor:CB,options:{}}],pdt={current:{}},pE={draggable:{measure:_Y},droppable:{measure:_Y,strategy:J0.WhileDragging,frequency:HI.Optimized},dragOverlay:{measure:Bm}};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 hdt={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:NS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:pE,measureDroppableContainers:NS,windowRect:null,measuringScheduled:!1},ffe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:NS,draggableNodes:new Map,over:null,measureDroppableContainers:NS},c1=x.createContext(ffe),pfe=x.createContext(hdt);function mdt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new zb}}}function gdt(e,t){switch(t.type){case Gr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Gr.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 Gr.DragEnd:case Gr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Gr.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 Gr.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 Gr.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 bdt(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=x.useContext(c1),i=TS(r),s=TS(n?.id);return x.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!VT(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=put(u);if(f){f.focus();break}}})}},[r,t,o,s,i]),null}function hfe(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function ydt(e){return x.useMemo(()=>({draggable:{...pE.draggable,...e?.draggable},droppable:{...pE.droppable,...e?.droppable},dragOverlay:{...pE.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function xdt(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;ka(()=>{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=Zde(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=Jde(c);m&&m.scrollBy({top:f.y,left:f.x})}},[t,s,a,r,n])}const qT=x.createContext({...Aa,scaleX:1,scaleY:1});var nu;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(nu||(nu={}));const vdt=x.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=fdt,collisionDetection:f=Xde,measuring:m,modifiers:g,...y}=t;const v=x.useReducer(gdt,void 0,mdt),[w,S]=v,[T,A]=xut(),[R,_]=x.useState(nu.Uninitialized),D=R===nu.Initialized,{draggable:{active:I,nodes:L,translate:j},droppable:{containers:O}}=w,F=I!=null?L.get(I):null,U=x.useRef({initial:null,translated:null}),Y=x.useMemo(()=>{var nn;return I!=null?{id:I,data:(nn=F?.data)!=null?nn:pdt,rect:U}:null},[I,F]),$=x.useRef(null),[G,H]=x.useState(null),[X,Z]=x.useState(null),J=Q0(y,Object.values(y)),B=l1("DndDescribedBy",s),W=x.useMemo(()=>O.getEnabled(),[O]),K=ydt(m),{droppableRects:P,measureDroppableContainers:le,measuringScheduled:ae}=tdt(W,{dragging:D,dependencies:[j.x,j.y],config:K.droppable}),de=Jut(L,I),ie=x.useMemo(()=>X?AS(X):null,[X]),ue=mo(),re=ndt(de,K.draggable.measure);xdt({activeNode:I!=null?L.get(I):null,config:ue.layoutShiftCompensation,initialRect:re,measure:K.draggable.measure});const be=MY(de,K.draggable.measure,re),Oe=MY(de?de.parentElement:null),we=x.useRef({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:L,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Re=O.getNodeFor((n=we.current.over)==null?void 0:n.id),se=ddt({measure:K.dragOverlay.measure}),Ce=(r=se.nodeRef.current)!=null?r:de,Be=D?(o=se.rect)!=null?o:be:null,Pe=!!(se.nodeRef.current&&se.rect),hn=idt(Pe?null:be),Mt=ufe(Ce?di(Ce):null),vt=sdt(D?Re??de:null),ne=udt(vt),fe=hfe(g,{transform:{x:j.x-hn.x,y:j.y-hn.y,scaleX:1,scaleY:1},activatorEvent:X,active:Y,activeNodeRect:be,containerNodeRect:Oe,draggingNodeRect:Be,over:we.current.over,overlayNodeRect:se.rect,scrollableAncestors:vt,scrollableAncestorRects:ne,windowRect:Mt}),ve=ie?xh(ie,j):null,$e=adt(vt),ze=PY($e),q=PY($e,[be]),ye=xh(fe,ze),Fe=Be?Out(Be,fe):null,We=Y&&Fe?f({active:Y,collisionRect:Fe,droppableRects:P,droppableContainers:W,pointerCoordinates:ve}):null,st=kut(We,"id"),[cn,mn]=x.useState(null),Mn=Pe?fe:xh(fe,q),wn=Dut(Mn,(i=cn?.rect)!=null?i:null,be),Sn=x.useRef(null),_e=x.useCallback((nn,rn)=>{let{sensor:Ke,options:Wt}=rn;if($.current==null)return;const xt=L.get($.current);if(!xt)return;const Pt=nn.nativeEvent,Yn=new Ke({active:$.current,activeNode:xt,event:Pt,options:Wt,context:we,onAbort(Jt){if(!L.get(Jt))return;const{onDragAbort:_n}=J.current,nr={id:Jt};_n?.(nr),T({type:"onDragAbort",event:nr})},onPending(Jt,tr,_n,nr){if(!L.get(Jt))return;const{onDragPending:go}=J.current,ps={id:Jt,constraint:tr,initialCoordinates:_n,offset:nr};go?.(ps),T({type:"onDragPending",event:ps})},onStart(Jt){const tr=$.current;if(tr==null)return;const _n=L.get(tr);if(!_n)return;const{onDragStart:nr}=J.current,fs={activatorEvent:Pt,active:{id:tr,data:_n.data,rect:U}};Wr.unstable_batchedUpdates(()=>{nr?.(fs),_(nu.Initializing),S({type:Gr.DragStart,initialCoordinates:Jt,active:tr}),T({type:"onDragStart",event:fs}),H(Sn.current),Z(Pt)})},onMove(Jt){S({type:Gr.DragMove,coordinates:Jt})},onEnd:Qt(Gr.DragEnd),onCancel:Qt(Gr.DragCancel)});Sn.current=Yn;function Qt(Jt){return async function(){const{active:_n,collisions:nr,over:fs,scrollAdjustedTranslate:go}=we.current;let ps=null;if(_n&&go){const{cancelDrop:bc}=J.current;ps={activatorEvent:Pt,active:_n,collisions:nr,delta:go,over:fs},Jt===Gr.DragEnd&&typeof bc=="function"&&await Promise.resolve(bc(ps))&&(Jt=Gr.DragCancel)}$.current=null,Wr.unstable_batchedUpdates(()=>{S({type:Jt}),_(nu.Uninitialized),mn(null),H(null),Z(null),Sn.current=null;const bc=Jt===Gr.DragEnd?"onDragEnd":"onDragCancel";if(ps){const hs=J.current[bc];hs?.(ps),T({type:bc,event:ps})}})}}},[L]),Xe=x.useCallback((nn,rn)=>(Ke,Wt)=>{const xt=Ke.nativeEvent,Pt=L.get(Wt);if($.current!==null||!Pt||xt.dndKit||xt.defaultPrevented)return;const Yn={active:Pt};nn(Ke,rn.options,Yn)===!0&&(xt.dndKit={capturedBy:rn.sensor},$.current=Wt,_e(Ke,rn))},[L,_e]),bt=edt(u,Xe);ldt(u),ka(()=>{be&&R===nu.Initializing&&_(nu.Initialized)},[be,R]),x.useEffect(()=>{const{onDragMove:nn}=J.current,{active:rn,activatorEvent:Ke,collisions:Wt,over:xt}=we.current;if(!rn||!Ke)return;const Pt={active:rn,activatorEvent:Ke,collisions:Wt,delta:{x:ye.x,y:ye.y},over:xt};Wr.unstable_batchedUpdates(()=>{nn?.(Pt),T({type:"onDragMove",event:Pt})})},[ye.x,ye.y]),x.useEffect(()=>{const{active:nn,activatorEvent:rn,collisions:Ke,droppableContainers:Wt,scrollAdjustedTranslate:xt}=we.current;if(!nn||$.current==null||!rn||!xt)return;const{onDragOver:Pt}=J.current,Yn=Wt.get(st),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:xt.x,y:xt.y},over:Qt};Wr.unstable_batchedUpdates(()=>{mn(Qt),Pt?.(Jt),T({type:"onDragOver",event:Jt})})},[st]),ka(()=>{we.current={activatorEvent:X,active:Y,activeNode:de,collisionRect:Fe,collisions:We,droppableRects:P,draggableNodes:L,draggingNode:Ce,draggingNodeRect:Be,droppableContainers:O,over:cn,scrollableAncestors:vt,scrollAdjustedTranslate:ye},U.current={initial:Be,translated:Fe}},[Y,de,We,Fe,L,Ce,Be,P,O,cn,vt,ye]),Xut({...ue,delta:j,draggingRect:Fe,pointerCoordinates:ve,scrollableAncestors:vt,scrollableAncestorRects:ne});const ct=x.useMemo(()=>({active:Y,activeNode:de,activeNodeRect:be,activatorEvent:X,collisions:We,containerNodeRect:Oe,dragOverlay:se,draggableNodes:L,droppableContainers:O,droppableRects:P,over:cn,measureDroppableContainers:le,scrollableAncestors:vt,scrollableAncestorRects:ne,measuringConfiguration:K,measuringScheduled:ae,windowRect:Mt}),[Y,de,be,X,We,Oe,se,L,O,P,cn,le,vt,ne,K,ae,Mt]),lr=x.useMemo(()=>({activatorEvent:X,activators:bt,active:Y,activeNodeRect:be,ariaDescribedById:{draggable:B},dispatch:S,draggableNodes:L,over:cn,measureDroppableContainers:le}),[X,bt,Y,be,S,B,L,cn,le]);return he.createElement(Kde.Provider,{value:A},he.createElement(c1.Provider,{value:lr},he.createElement(pfe.Provider,{value:ct},he.createElement(qT.Provider,{value:wn},c)),he.createElement(bdt,{disabled:a?.restoreFocus===!1})),he.createElement(wut,{...a,hiddenTextDescribedById:B}));function mo(){const nn=G?.autoScrollEnabled===!1,rn=typeof l=="object"?l.enabled===!1:l===!1,Ke=D&&!nn&&!rn;return typeof l=="object"?{...l,enabled:Ke}:{enabled:Ke}}}),Edt=x.createContext(null),BY="button",wdt="Draggable";function Sdt(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=l1(wdt),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:m}=x.useContext(c1),{role:g=BY,roleDescription:y="draggable",tabIndex:v=0}=o??{},w=l?.id===t,S=x.useContext(w?qT:Edt),[T,A]=CS(),[R,_]=CS(),D=cdt(s,t),I=Q0(n);ka(()=>(f.set(t,{id:t,key:i,node:T,activatorNode:R,data:I}),()=>{const j=f.get(t);j&&j.key===i&&f.delete(t)}),[f,t]);const L=x.useMemo(()=>({role:g,tabIndex:v,"aria-disabled":r,"aria-pressed":w&&g===BY?!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:L,isDragging:w,listeners:r?void 0:D,node:T,over:m,setNodeRef:A,setActivatorNodeRef:_,transform:S}}function mfe(){return x.useContext(pfe)}const Cdt="Droppable",Tdt={timeout:25};function gfe(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=l1(Cdt),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=x.useContext(c1),u=x.useRef({disabled:n}),f=x.useRef(!1),m=x.useRef(null),g=x.useRef(null),{disabled:y,updateMeasurementsFor:v,timeout:w}={...Tdt,...o},S=Q0(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]),A=GT({callback:T,disabled:y||!s}),R=x.useCallback((L,j)=>{A&&(j&&(A.unobserve(j),f.current=!1),L&&A.observe(L))},[A]),[_,D]=CS(R),I=Q0(t);return x.useEffect(()=>{!A||!_.current||(A.disconnect(),f.current=!1,A.observe(_.current))},[_,A]),x.useEffect(()=>(a({type:Gr.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:m,data:I}}),()=>a({type:Gr.UnregisterDroppable,key:i,id:r})),[r]),x.useEffect(()=>{n!==u.current.disabled&&(a({type:Gr.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:D}}function kdt(e){let{animation:t,children:n}=e;const[r,o]=x.useState(null),[i,s]=x.useState(null),a=TS(n);return!n&&!r&&a&&o(a),ka(()=>{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]),he.createElement(he.Fragment,null,n,r?x.cloneElement(r,{ref:s}):null)}const Adt={x:0,y:0,scaleX:1,scaleY:1};function Ndt(e){let{children:t}=e;return he.createElement(c1.Provider,{value:ffe},he.createElement(qT.Provider,{value:Adt},t))}const _dt={position:"fixed",touchAction:"none"},Rdt=e=>VT(e)?"transform 250ms ease":void 0,Ddt=x.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Rdt}=e;if(!a)return null;const f=o?c:{...c,scaleX:1,scaleY:1},m={..._dt,width:a.width,height:a.height,top:a.top,left:a.left,transform:zu.Transform.toString(f),transformOrigin:o&&r?Cut(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return he.createElement(n,{className:s,style:m,ref:t},i)}),Idt=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)}},Odt=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:zu.Transform.toString(t)},{transform:zu.Transform.toString(n)}]},Mdt={duration:250,easing:"ease",keyframes:Odt,sideEffects:Idt({styles:{active:{opacity:"0"}}})};function Ldt(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return zT((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=dfe(s);if(!c)return;const{transform:u}=di(s).getComputedStyle(s),f=Qde(u);if(!f)return;const m=typeof t=="function"?t:Pdt(t);return ife(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 Pdt(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...Mdt,...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 jY=0;function Fdt(e){return x.useMemo(()=>{if(e!=null)return jY++,jY},[e])}const Bdt=he.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:A,scrollableAncestorRects:R,windowRect:_}=mfe(),D=x.useContext(qT),I=Fdt(f?.id),L=hfe(s,{activatorEvent:u,active:f,activeNodeRect:m,containerNodeRect:g,draggingNodeRect:w.rect,over:S,overlayNodeRect:w.rect,scrollableAncestors:A,scrollableAncestorRects:R,transform:D,windowRect:_}),j=kB(m),O=Ldt({config:r,draggableNodes:y,droppableContainers:v,measuringConfiguration:T}),F=j?w.setRef:void 0;return he.createElement(Ndt,null,he.createElement(kdt,{animation:O},f&&I?he.createElement(Ddt,{key:I,id:f.id,ref:F,as:a,activatorEvent:u,adjustScale:t,className:l,transition:i,rect:j,style:{zIndex:c,...o},transform:L},n):null))});function RS(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function jdt(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function kv(e){return e!==null&&e>=0}function $dt(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 Udt(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=RS(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}},yfe="Sortable",xfe=he.createContext({activeIndex:-1,containerId:yfe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:bfe,disabled:{draggable:!1,droppable:!1}});function Hdt(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}=mfe(),f=l1(yfe,n),m=a.rect!==null,g=x.useMemo(()=>r.map(D=>typeof D=="object"&&"id"in D?D.id:D),[r]),y=s!=null,v=s?g.indexOf(s.id):-1,w=c?g.indexOf(c.id):-1,S=x.useRef(g),T=!$dt(g,S.current),A=w!==-1&&v===-1||T,R=Udt(i);ka(()=>{T&&y&&u(g)},[T,g,y,u]),x.useEffect(()=>{S.current=g},[g]);const _=x.useMemo(()=>({activeIndex:v,containerId:f,disabled:R,disableTransforms:A,items:g,overIndex:w,useDragOverlay:m,sortedRects:jdt(g,l),strategy:o}),[v,f,R.draggable,R.droppable,A,g,w,l,m,o]);return he.createElement(xfe.Provider,{value:_},t)}const zdt=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return RS(n,r,o).indexOf(t)},Vdt=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},Gdt={duration:200,easing:"ease"},vfe="transform",qdt=zu.Transition.toString({property:vfe,duration:0,easing:"linear"}),Wdt={roleDescription:"sortable"};function Ydt(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=x.useState(null),a=x.useRef(n);return ka(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=Bm(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 Kdt(e){let{animateLayoutChanges:t=Vdt,attributes:n,disabled:r,data:o,getNewIndex:i=zdt,id:s,strategy:a,resizeObserverConfig:l,transition:c=Gdt}=e;const{items:u,containerId:f,activeIndex:m,disabled:g,disableTransforms:y,sortedRects:v,overIndex:w,useDragOverlay:S,strategy:T}=x.useContext(xfe),A=Xdt(r,g),R=u.indexOf(s),_=x.useMemo(()=>({sortable:{containerId:f,index:R,items:u},...o}),[f,o,R,u]),D=x.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:I,node:L,isOver:j,setNodeRef:O}=gfe({id:s,data:_,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:D,...l}}),{active:F,activatorEvent:U,activeNodeRect:Y,attributes:$,setNodeRef:G,listeners:H,isDragging:X,over:Z,setActivatorNodeRef:J,transform:B}=Sdt({id:s,data:_,attributes:{...Wdt,...n},disabled:A.draggable}),W=cut(O,G),K=!!F,P=K&&!y&&kv(m)&&kv(w),le=!S&&X,ae=le&&P?B:null,ie=P?ae??(a??T)({rects:v,activeNodeRect:Y,activeIndex:m,overIndex:w,index:R}):null,ue=kv(m)&&kv(w)?i({id:s,items:u,activeIndex:m,overIndex:w}):R,re=F?.id,be=x.useRef({activeId:re,items:u,newIndex:ue,containerId:f}),Oe=u!==be.current.items,we=t({active:F,containerId:f,isDragging:X,isSorting:K,id:s,index:R,items:u,newIndex:be.current.newIndex,previousItems:be.current.items,previousContainerId:be.current.containerId,transition:c,wasDragging:be.current.activeId!=null}),Re=Ydt({disabled:!we,index:R,node:L,rect:I});return x.useEffect(()=>{K&&be.current.newIndex!==ue&&(be.current.newIndex=ue),f!==be.current.containerId&&(be.current.containerId=f),u!==be.current.items&&(be.current.items=u)},[K,ue,f,u]),x.useEffect(()=>{if(re===be.current.activeId)return;if(re!=null&&be.current.activeId==null){be.current.activeId=re;return}const Ce=setTimeout(()=>{be.current.activeId=re},50);return()=>clearTimeout(Ce)},[re]),{active:F,activeIndex:m,attributes:$,data:_,rect:I,index:R,newIndex:ue,items:u,isOver:j,isSorting:K,isDragging:X,listeners:H,node:L,overIndex:w,over:Z,setNodeRef:W,setActivatorNodeRef:J,setDroppableNodeRef:O,setDraggableNodeRef:G,transform:Re??ie,transition:se()};function se(){if(Re||Oe&&be.current.newIndex===R)return qdt;if(!(le&&!VT(U)||!c)&&(K||we))return zu.Transition.toString({...c,property:vfe})}}function Xdt(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 Zdt={},$Y=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:()=>{(Zdt?"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},Qdt=e=>e?$Y(e):$Y,Efe={},{useDebugValue:Jdt}=he,{useSyncExternalStoreWithSelector:eft}=QKe;let UY=!1;const tft=e=>e;function nft(e,t=tft,n){(Efe?"production":void 0)!=="production"&&n&&!UY&&(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"),UY=!0);const r=eft(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Jdt(r),r}const HY=e=>{(Efe?"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"?Qdt(e):e,n=(r,o)=>nft(t,r,o);return Object.assign(n,t),n},rft=e=>e?HY(e):HY;var zY,VY;const GY=typeof window<"u"&&((zY=window.document)!=null&&zY.createElement||((VY=window.navigator)==null?void 0:VY.product)==="ReactNative")?he.useLayoutEffect:he.useEffect;function oft(){const e=rft(t=>({current:new Array,version:0,set:t}));return{In:({children:t})=>{const n=e(o=>o.set),r=e(o=>o.version);return GY(()=>{n(o=>({version:o.version+1}))},[]),GY(()=>(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 he.createElement(he.Fragment,null,t)}}}const G_=768;function WT(){const[e,t]=x.useState(void 0);return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${G_-1}px)`),r=()=>{t(window.innerWidth<G_)};return n.addEventListener("change",r),t(window.innerWidth<G_),()=>n.removeEventListener("change",r)},[]),!!e}const wfe=oft(),AB=x.createContext({columns:[],data:[],activeCardId:null}),ift=({id:e,children:t,className:n})=>{const{isOver:r,setNodeRef:o}=gfe({id:e});return h.jsx("div",{className:ke("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})},sft=({id:e,name:t,children:n,className:r})=>{const{attributes:o,listeners:i,setNodeRef:s,transition:a,transform:l,isDragging:c}=Kdt({id:e}),{activeCardId:u}=x.useContext(AB),f={transition:a,transform:zu.Transform.toString(l)};return h.jsxs(h.Fragment,{children:[h.jsx("div",{style:f,...i,...o,ref:s,children:h.jsx(Zd,{className:ke("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(wfe.In,{children:h.jsx(Zd,{className:ke("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})})})]})},aft=({children:e,className:t,...n})=>{const{data:r}=x.useContext(AB),o=r.filter(s=>s.column===n.id),i=o.map(s=>s.id);return h.jsxs(Yr,{className:"overflow-hidden flex-1",children:[h.jsx(Hdt,{items:i,children:h.jsx("div",{className:ke("flex flex-grow flex-col gap-2 p-2",t),...n,children:o.map(e)})}),h.jsx(qS,{orientation:"vertical"})]})},lft=({className:e,...t})=>h.jsx("div",{className:ke("m-0 p-2 font-semibold text-sm",e),...t}),cft=e=>t=>{const{droppableRects:n,droppableContainers:r,pointerCoordinates:o}=t,i=y=>!e.includes(y),s=y=>e.includes(y),a=Rut(t),l=a.filter(y=>i(y.id)),c=a.filter(y=>s(y.id));if(l.length>0){const v=NY(t).filter(w=>i(w.id));return v.length>0?[v[0]]:[l[0]]}if(c.length>0)return[c[0]];const u=Xde(t),f=u.filter(y=>i(y.id)),m=u.filter(y=>s(y.id));if(f.length>0){const v=Aut(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,A=Math.sqrt(Math.pow(o.x-S,2)+Math.pow(o.y-T,2)),R={left:w.left-150,right:w.right+150,top:w.top-50,bottom:w.bottom+50};o.x>=R.left&&o.x<=R.right&&o.y>=R.top&&o.y<=R.bottom&&(!y||A<y.distance)&&(y={id:v,distance:A})}if(y)return[{id:y.id}]}const g=NY(t);if(g.length>0){const y=g.find(v=>s(v.id));return y?[y]:[g[0]]}return[]},uft=({children:e,onDragStart:t,onDragEnd:n,onDragOver:r,className:o,columns:i,data:s,onDataChange:a,...l})=>{const[c,u]=x.useState(null),f=WT(),m=x.useMemo(()=>i.map(A=>A.id),[i]),g=x.useMemo(()=>cft(m),[m]),y=Sut(U_(lfe,{activationConstraint:{distance:8}}),U_(cfe,{activationConstraint:{delay:150,tolerance:8}}),U_(CB)),v=A=>{s.find(_=>_.id===A.active.id)&&u(A.active.id),t?.(A)},w=A=>{const{active:R,over:_}=A;if(!_)return;const D=s.find(F=>F.id===R.id),I=s.find(F=>F.id===_.id);if(!D)return;const L=D.column,O=i.some(F=>F.id===_.id)?_.id:I?.column||L;if(L!==O){let F=[...s];const U=F.findIndex(Y=>Y.id===R.id);if(F[U]={...F[U],column:O},I){const Y=F.findIndex($=>$.id===_.id);F=RS(F,U,Y)}a?.(F)}r?.(A)},S=A=>{u(null),n?.(A);const{active:R,over:_}=A;if(!_||R.id===_.id)return;if(i.some(O=>O.id===_.id)){const O=s.find(F=>F.id===R.id);if(O&&O.column!==_.id){let F=[...s];const U=F.findIndex(Y=>Y.id===R.id);F[U]={...F[U],column:_.id},a?.(F)}return}let I=[...s];const L=I.findIndex(O=>O.id===R.id),j=I.findIndex(O=>O.id===_.id);L!==-1&&j!==-1&&(I=RS(I,L,j),a?.(I))},T={onDragStart({active:A}){const{name:R,column:_}=s.find(D=>D.id===A.id)??{};return`Picked up the card "${R}" from the "${_}" column`},onDragOver({active:A,over:R}){const{name:_}=s.find(I=>I.id===A.id)??{},D=i.find(I=>I.id===R?.id)?.name;return`Dragged the card "${_}" over the "${D}" column`},onDragEnd({active:A,over:R}){const{name:_}=s.find(I=>I.id===A.id)??{},D=i.find(I=>I.id===R?.id)?.name;return`Dropped the card "${_}" into the "${D}" column`},onDragCancel({active:A}){const{name:R}=s.find(_=>_.id===A.id)??{};return`Cancelled dragging the card "${R}"`}};return h.jsx(AB.Provider,{value:{columns:i,data:s,activeCardId:c},children:h.jsxs(vdt,{accessibility:{announcements:T},collisionDetection:g,onDragEnd:S,onDragOver:w,onDragStart:v,sensors:y,...l,children:[h.jsx("div",{className:ke("flex gap-4",f&&"flex-col",o),children:i.map(A=>e(A))}),typeof window<"u"&&Wr.createPortal(h.jsx(Bdt,{children:h.jsx(wfe.Out,{})}),document.body)]})})},qY={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold"};function db(e){return qY[e]?qY[e]:e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function dft({tasks:e,loading:t,onTasksUpdate:n}){const{config:r,updateConfig:o}=yf(),[i,s]=x.useState(new Set),[a,l]=x.useState(!1),c=WT(),u=r?.statuses||["todo","in-progress","in-review","done","blocked"],f=r?.statusColors||KO,m=x.useMemo(()=>u.filter(O=>i.has(O)).map(O=>({id:O,name:db(O),color:f[O]||"gray"})),[u,i,f]),g={high:0,medium:1,low:2},y=x.useMemo(()=>[...e].sort((F,U)=>{const Y=g[F.priority]??2,$=g[U.priority]??2;return Y!==$?Y-$: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(Y=>Y.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)}},A=O=>{s(F=>{const U=new Set(F);return U.has(O)?U.delete(O):U.add(O),T(U),U})},R=async O=>{const F=O.filter(Y=>{const $=e.find(G=>G.id===Y.id);return $&&$.status!==Y.column}),U=e.map(Y=>{const $=O.find(G=>G.id===Y.id);return $&&$.column!==Y.status?{...Y,status:$.column}:Y});n(U);for(const Y of F)try{await ha.updateTask(Y.id,{status:Y.column}),oo.success("Status updated",{description:`#${Y.id} moved to ${db(Y.column)}`})}catch($){console.error("Failed to update task:",$),oo.error("Failed to update status",{description:$ instanceof Error?$.message:"Unknown error"}),ha.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}`},D=()=>{window.location.hash="/"},I=O=>{n(e.map(F=>F.id===O.id?O:F))},L=O=>{window.location.hash=`/kanban/${O}`},j=async O=>{try{await ha.archiveTask(O),n(e.filter(F=>F.id!==O)),D()}catch(F){console.error("Failed to archive task:",F)}};return h.jsxs("div",{className:"flex flex-col h-full",children:[c?h.jsxs(Ade,{open:a,onOpenChange:l,className:"shrink-0 bg-card rounded-lg mb-4 border border-border",children:[h.jsxs(Nde,{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(fK,{className:"w-4 h-4 text-muted-foreground"}):h.jsx(Ps,{className:"w-4 h-4 text-muted-foreground"})]}),h.jsx(_de,{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(Y=>Y.status===O).length;return h.jsxs("button",{type:"button",onClick:()=>A(O),className:ke("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(Yb,{className:"w-3.5 h-3.5"}):h.jsx(rR,{className:"w-3.5 h-3.5"}),h.jsxs("span",{className:"font-medium",children:[db(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(Y=>Y.status===O).length;return h.jsxs("button",{type:"button",onClick:()=>A(O),className:ke("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(Yb,{className:"w-4 h-4"}):h.jsx(rR,{className:"w-4 h-4"}),h.jsxs("span",{className:"text-sm font-medium",children:[db(O)," (",U,")"]})]},O)})]})}),h.jsxs(Yr,{className:"flex-1",children:[i.size>0?h.jsx(uft,{columns:m,data:y,onDataChange:R,className:"min-h-full pb-4",children:O=>{const F=pCe(O.id,f),U=y.filter(Y=>Y.column===O.id).length;return h.jsxs(ift,{id:O.id,className:ke("min-w-[320px] max-w-[380px]",c&&"min-w-0 max-w-none w-full",F.bg,F.border),children:[h.jsxs(lft,{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(aft,{id:O.id,children:Y=>h.jsx(fft,{item:Y,statusColors:f,onClick:()=>_(Y.task)},Y.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(qS,{orientation:"horizontal"})]}),h.jsx(qde,{task:w,allTasks:e,onClose:D,onUpdate:I,onArchive:j,onNavigateToTask:L})]})}function fft({item:e,statusColors:t,onClick:n}){const{task:r}=e,o=Th(r.status,t),i=r.acceptanceCriteria.filter(a=>a.completed).length,s=r.acceptanceCriteria.length;return h.jsx(sft,{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:ke("text-xs px-1.5 py-0.5 rounded font-medium",o),children:db(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(hK,{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(K0,{name:r.assignee,size:"sm"}),h.jsx("span",{children:r.assignee})]})]})})}const WY=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],YY={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 pft({isOpen:e,allTasks:t,onClose:n,onCreated:r}){const{currentUser:o}=dQ(),{config:i}=yf(),s=x.useRef(null),a=x.useRef(null),l=x.useMemo(()=>{const q=i.statuses||["todo","in-progress","in-review","done","blocked"];return gQ(q)},[i.statuses]),c=i.statusColors||{},[u,f]=x.useState(""),[m,g]=x.useState(""),[y,v]=x.useState("todo"),[w,S]=x.useState("medium"),[T,A]=x.useState(""),[R,_]=x.useState([]),[D,I]=x.useState(""),[L,j]=x.useState([]),[O,F]=x.useState(""),[U,Y]=x.useState(""),[$,G]=x.useState(!1),[H,X]=x.useState(null),[Z,J]=x.useState(!1),[B,W]=x.useState(""),[K,P]=x.useState(!1),[le,ae]=x.useState(""),[de,ie]=x.useState(!1),[ue,re]=x.useState(!1),{preferences:be,toggleTaskCreateLayout:Oe}=hQ(),we=be.taskCreateLayout==="maximized",Re=x.useRef(null),se={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"),A(""),_([]),I(""),j([]),F(""),Y(""),X(null),J(!1),W(""),P(!1),ae(""),ie(!1),re(!1))},[e]),x.useEffect(()=>{e&&setTimeout(()=>s.current?.focus(),100)},[e,we]),x.useEffect(()=>{K&&Re.current&&Re.current.focus()},[K]);const Ce=x.useCallback(()=>{B.trim()&&(j(q=>[...q,{id:crypto.randomUUID(),text:B.trim()}]),W(""),P(!1))},[B]),Be=x.useCallback(q=>{j(ye=>ye.filter(Fe=>Fe.id!==q))},[]),Pe=x.useCallback(()=>{le.trim()&&(R.includes(le.trim())||_(q=>[...q,le.trim()]),ae(""),ie(!1))},[le,R]),hn=x.useCallback(q=>{_(ye=>ye.filter(Fe=>Fe!==q))},[]),Mt=async q=>{if(q.preventDefault(),X(null),!u.trim()){X("Title is required");return}G(!0);try{const ye={title:u.trim(),description:m.trim()||void 0,status:y,priority:w,labels:R,assignee:T.trim()||void 0,parent:D||void 0,acceptanceCriteria:L.map(Fe=>({text:Fe.text,completed:!1})),implementationPlan:O.trim()||void 0,implementationNotes:U.trim()||void 0};await Nme(ye),J(!0),oo.success("Task created successfully",{description:u.trim()}),setTimeout(()=>{r(),n()},800)}catch(ye){const Fe=ye instanceof Error?ye.message:"Failed to create task";X(Fe),oo.error("Failed to create task",{description:Fe})}finally{G(!1)}},vt=D?t.find(q=>q.id===D):null,ne=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:q=>f(q.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:$})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(Le,{variant:"ghost",size:"icon",onClick:Oe,className:"h-8 w-8 text-foreground hover:text-foreground",title:we?"Minimize":"Maximize",children:we?h.jsx(xK,{className:"w-4 h-4"}):h.jsx(yK,{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(Qo,{className:"w-4 h-4"})})]})]}),fe=(Z||H)&&h.jsxs("div",{className:"px-4 pt-4",children:[Z&&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!"}),H&&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:H})]}),ve=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(wK,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Description"})]}),h.jsx(Su,{markdown:m,onChange:g,placeholder:"Add a more detailed description...",readOnly:$})]}),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(em,{className:"w-5 h-5 text-muted-foreground"}),h.jsx("h3",{className:"font-semibold text-sm text-muted-foreground",children:"Acceptance Criteria"}),L.length>0&&h.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",L.length,")"]})]})}),h.jsx("div",{className:"space-y-2",children:L.map(q=>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:q.text}),h.jsx("button",{type:"button",onClick:()=>Be(q.id),className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-red-500 p-1 transition-all",title:"Delete",children:h.jsx(Tu,{className:"w-4 h-4"})})]},q.id))}),K?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:q=>W(q.target.value),onKeyDown:q=>{q.key==="Enter"&&B.trim()&&(q.preventDefault(),Ce()),q.key==="Escape"&&(W(""),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:$}),h.jsxs("div",{className:"flex gap-2 mt-2",children:[h.jsx(Le,{type:"button",size:"sm",onClick:Ce,disabled:!B.trim()||$,className:"bg-green-700 hover:bg-green-800 text-white",children:"Add"}),h.jsx(Le,{type:"button",variant:"ghost",size:"sm",onClick:()=>{W(""),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:$,children:[h.jsx(Ho,{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(ni,{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(Su,{markdown:O,onChange:F,placeholder:"Describe how you plan to implement this task...",readOnly:$})]}),h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(Xbe,{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(Su,{markdown:U,onChange:Y,placeholder:"Add notes, observations, or any other relevant information...",readOnly:$})]})]}),$e=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(ei,{value:y,onValueChange:q=>v(q),disabled:$,children:[h.jsx($o,{className:ke("w-full",Th(y,c)),children:h.jsx(ti,{})}),h.jsx(Uo,{children:l.map(q=>h.jsx(En,{value:q.value,children:q.label},q.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(ei,{value:w,onValueChange:q=>S(q),disabled:$,children:[h.jsx($o,{className:ke("w-full",YY[w]),children:h.jsx(ti,{})}),h.jsx(Uo,{children:WY.map(q=>h.jsx(En,{value:q.value,children:q.label},q.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(xS,{value:T,onChange:A,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:R.map(q=>h.jsxs(cc,{variant:"secondary",className:"gap-1 pr-1",children:[q,h.jsx("button",{type:"button",onClick:()=>hn(q),className:"ml-1 hover:text-destructive",children:h.jsx(Qo,{className:"w-3 h-3"})})]},q))}),de?h.jsxs("div",{className:"space-y-2",children:[h.jsx(Gn,{value:le,onChange:q=>ae(q.target.value),onKeyDown:q=>{q.key==="Enter"&&le.trim()&&(q.preventDefault(),Pe()),q.key==="Escape"&&(ae(""),ie(!1))},placeholder:"Label name",disabled:$,autoFocus:!0}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Le,{size:"sm",onClick:Pe,disabled:!le.trim()||$,children:"Add"}),h.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>{ae(""),ie(!1)},children:"Cancel"})]})]}):h.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground",onClick:()=>ie(!0),disabled:$,children:[h.jsx(Ho,{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(V0,{open:ue,onOpenChange:re,children:[h.jsx(G0,{asChild:!0,children:h.jsxs(Le,{variant:"outline",role:"combobox","aria-expanded":ue,className:"w-full justify-between h-auto min-h-10 py-2",disabled:$,title:vt?`#${vt.id} - ${vt.title}`:void 0,children:[vt?h.jsxs("div",{className:"flex items-center gap-2 text-left overflow-hidden min-w-0 flex-1",children:[h.jsx(Eh,{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:["#",vt.id]}),h.jsx("p",{className:"truncate text-sm",children:vt.title})]})]}):h.jsx("span",{className:"text-muted-foreground",children:"Select parent task..."}),h.jsx(yE,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),h.jsx(qh,{className:"w-[400px] p-0",align:"start",children:h.jsxs(Wh,{children:[h.jsx(Yh,{placeholder:"Search tasks..."}),h.jsxs(Kh,{children:[h.jsx(Xh,{children:"No task found."}),h.jsxs(rl,{children:[h.jsxs(Ji,{value:"none",onSelect:()=>{I(""),re(!1)},children:[h.jsx(so,{className:ke("mr-2 h-4 w-4 shrink-0",D?"opacity-0":"opacity-100")}),h.jsx("span",{className:"text-muted-foreground",children:"None"})]}),t.map(q=>h.jsxs(Ji,{value:`${q.id} ${q.title}`,onSelect:()=>{I(q.id),re(!1)},title:`#${q.id} - ${q.title}`,children:[h.jsx(so,{className:ke("mr-2 h-4 w-4 shrink-0",D===q.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:["#",q.id]}),h.jsx("p",{className:"truncate text-sm",children:q.title})]})]},q.id))]})]})]})})]})]})]}),ze=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:$,children:"Cancel"}),h.jsx(Le,{type:"button",onClick:Mt,className:"bg-green-700 hover:bg-green-800 text-white",disabled:$||Z||!u.trim(),children:$?"Creating...":"Create Task"})]});return we?h.jsx(TE,{children:e&&h.jsx(zO,{open:e,onOpenChange:q=>!q&&n(),children:h.jsxs(zS,{className:"max-w-6xl w-[95vw] h-[90vh] p-0 gap-0 overflow-hidden flex flex-col",hideCloseButton:!0,children:[h.jsx(VO,{className:"sr-only",children:"Create New Task"}),h.jsxs(_E.div,{ref:a,className:"flex flex-col h-full overflow-hidden",variants:se,initial:"hidden",animate:"visible",exit:"exit",children:[ne,fe,h.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[h.jsx(Yr,{className:"flex-1",children:ve}),h.jsx("div",{className:"shrink-0 w-72 border-l bg-muted/20",children:h.jsx(Yr,{className:"h-full",children:$e})})]}),ze]})]})})}):h.jsx(TE,{children:e&&h.jsx($O,{open:e,onOpenChange:q=>!q&&n(),children:h.jsx(HS,{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(_E.div,{ref:a,className:"flex flex-col h-full overflow-hidden",variants:se,initial:"hidden",animate:"visible",exit:"exit",children:[ne,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(ei,{value:y,onValueChange:q=>v(q),disabled:$,children:[h.jsx($o,{className:ke("w-full h-9",Th(y,c)),children:h.jsx(ti,{})}),h.jsx(Uo,{children:l.map(q=>h.jsx(En,{value:q.value,children:q.label},q.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(ei,{value:w,onValueChange:q=>S(q),disabled:$,children:[h.jsx($o,{className:ke("w-full h-9",YY[w]),children:h.jsx(ti,{})}),h.jsx(Uo,{children:WY.map(q=>h.jsx(En,{value:q.value,children:q.label},q.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(xS,{value:T,onChange:A,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:[R.map(q=>h.jsxs(cc,{variant:"secondary",className:"gap-1 pr-1 text-xs",children:[q,h.jsx("button",{type:"button",onClick:()=>hn(q),className:"ml-0.5 hover:text-destructive",children:h.jsx(Qo,{className:"w-3 h-3"})})]},q)),!de&&h.jsxs(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground",onClick:()=>ie(!0),children:[h.jsx(Ho,{className:"w-3 h-3 mr-1"}),"Add"]})]}),de&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{value:le,onChange:q=>ae(q.target.value),onKeyDown:q=>{q.key==="Enter"&&le.trim()&&Pe(),q.key==="Escape"&&(ae(""),ie(!1))},placeholder:"Label",className:"h-7 w-24 text-xs",autoFocus:!0}),h.jsx(Le,{size:"sm",className:"h-7 px-2",onClick:Pe,disabled:!le.trim(),children:"Add"}),h.jsx(Le,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>{ae(""),ie(!1)},children:h.jsx(Qo,{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(V0,{open:ue,onOpenChange:re,children:[h.jsx(G0,{asChild:!0,children:h.jsxs(Le,{variant:"outline",role:"combobox",size:"sm",className:"h-7 justify-between min-w-[120px] max-w-[250px]",disabled:$,title:vt?`#${vt.id} - ${vt.title}`:void 0,children:[vt?h.jsxs("span",{className:"truncate text-xs",children:["#",vt.id," - ",vt.title]}):h.jsx("span",{className:"text-muted-foreground text-xs",children:"None"}),h.jsx(yE,{className:"ml-1 h-3 w-3 shrink-0 opacity-50"})]})}),h.jsx(qh,{className:"w-[400px] p-0",align:"end",children:h.jsxs(Wh,{children:[h.jsx(Yh,{placeholder:"Search tasks..."}),h.jsxs(Kh,{children:[h.jsx(Xh,{children:"No task found."}),h.jsxs(rl,{children:[h.jsxs(Ji,{value:"none",onSelect:()=>{I(""),re(!1)},children:[h.jsx(so,{className:ke("mr-2 h-4 w-4 shrink-0",D?"opacity-0":"opacity-100")}),h.jsx("span",{className:"text-muted-foreground",children:"None"})]}),t.map(q=>h.jsxs(Ji,{value:`${q.id} ${q.title}`,onSelect:()=>{I(q.id),re(!1)},title:`#${q.id} - ${q.title}`,children:[h.jsx(so,{className:ke("mr-2 h-4 w-4 shrink-0",D===q.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:["#",q.id]}),h.jsx("p",{className:"truncate text-sm",children:q.title})]})]},q.id))]})]})]})})]})]})]})]})}),h.jsx(Yr,{className:"flex-1",children:ve})]}),ze]})})})})}const hft="/assets/logo-BkDQ9x4a.png",mft="sidebar_state",gft=3600*24*7,bft="16rem",yft="18rem",xft="3rem",vft="b",Sfe=x.createContext(null);function u1(){const e=x.useContext(Sfe);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Cfe=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:i,...s},a)=>{const l=WT(),[c,u]=x.useState(!1),[f,m]=x.useState(e),g=t??f,y=x.useCallback(T=>{const A=typeof T=="function"?T(g):T;n?n(A):m(A),document.cookie=`${mft}=${A}; path=/; max-age=${gft}`},[n,g]),v=x.useCallback(()=>l?u(T=>!T):y(T=>!T),[l,y,u]);x.useEffect(()=>{const T=A=>{A.key===vft&&(A.metaKey||A.ctrlKey)&&(A.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(Sfe.Provider,{value:S,children:h.jsx(bde,{delayDuration:0,children:h.jsx("div",{style:{"--sidebar-width":bft,"--sidebar-width-icon":xft,...o},className:ke("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:a,...s,children:i})})})});Cfe.displayName="SidebarProvider";const Tfe=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}=u1();return n==="none"?h.jsx("div",{className:ke("flex h-full w-[var(--sidebar-width)] flex-col bg-sidebar text-sidebar-foreground",r),ref:s,...i,children:o}):a?h.jsx($O,{open:c,onOpenChange:u,...i,children:h.jsxs(HS,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[var(--sidebar-width)] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":yft},side:e,children:[h.jsxs(UO,{className:"sr-only",children:[h.jsx(HO,{children:"Sidebar"}),h.jsx(WZ,{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:ke("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:ke("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})})]})});Tfe.displayName="Sidebar";const kfe=x.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=u1();return h.jsxs(Le,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:ke("h-7 w-7",e),onClick:i=>{t?.(i),o()},...n,children:[h.jsx(Obe,{}),h.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});kfe.displayName="SidebarTrigger";const Afe=x.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=u1();return h.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:ke("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})});Afe.displayName="SidebarRail";const Eft=x.forwardRef(({className:e,...t},n)=>h.jsx("main",{ref:n,className:ke("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}));Eft.displayName="SidebarInset";const wft=x.forwardRef(({className:e,...t},n)=>h.jsx(Gn,{ref:n,"data-sidebar":"input",className:ke("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));wft.displayName="SidebarInput";const Nfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"header",className:ke("flex flex-col gap-2 p-2",e),...t}));Nfe.displayName="SidebarHeader";const _fe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"footer",className:ke("flex flex-col gap-2 p-2",e),...t}));_fe.displayName="SidebarFooter";const Sft=x.forwardRef(({className:e,...t},n)=>h.jsx(Y0,{ref:n,"data-sidebar":"separator",className:ke("mx-2 w-auto bg-sidebar-border",e),...t}));Sft.displayName="SidebarSeparator";const Rfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"content",className:ke("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Rfe.displayName="SidebarContent";const Dfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"group",className:ke("relative flex w-full min-w-0 flex-col p-2",e),...t}));Dfe.displayName="SidebarGroup";const Ife=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?qu:"div";return h.jsx(o,{ref:r,"data-sidebar":"group-label",className:ke("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})});Ife.displayName="SidebarGroupLabel";const Cft=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?qu:"button";return h.jsx(o,{ref:r,"data-sidebar":"group-action",className:ke("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})});Cft.displayName="SidebarGroupAction";const Ofe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"group-content",className:ke("w-full text-sm",e),...t}));Ofe.displayName="SidebarGroupContent";const hE=x.forwardRef(({className:e,...t},n)=>h.jsx("ul",{ref:n,"data-sidebar":"menu",className:ke("flex w-full min-w-0 flex-col gap-1",e),...t}));hE.displayName="SidebarMenu";const mE=x.forwardRef(({className:e,...t},n)=>h.jsx("li",{ref:n,"data-sidebar":"menu-item",className:ke("group/menu-item relative",e),...t}));mE.displayName="SidebarMenuItem";const Tft=pc("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"}}),gE=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:i,...s},a)=>{const l=e?qu:"button",{isMobile:c,state:u}=u1(),f=h.jsx(l,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:ke(Tft({variant:n,size:r}),i),...s});return o?(typeof o=="string"&&(o={children:o}),h.jsxs(yde,{children:[h.jsx(xde,{asChild:!0,children:f}),h.jsx(sB,{side:"right",align:"center",hidden:u!=="collapsed"||c,...o})]})):f});gE.displayName="SidebarMenuButton";const kft=x.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const i=t?qu:"button";return h.jsx(i,{ref:o,"data-sidebar":"menu-action",className:ke("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})});kft.displayName="SidebarMenuAction";const Aft=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:ke("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}));Aft.displayName="SidebarMenuBadge";const Nft=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:ke("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&h.jsx(KW,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),h.jsx(KW,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});Nft.displayName="SidebarMenuSkeleton";const _ft=x.forwardRef(({className:e,...t},n)=>h.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:ke("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}));_ft.displayName="SidebarMenuSub";const Rft=x.forwardRef(({...e},t)=>h.jsx("li",{ref:t,...e}));Rft.displayName="SidebarMenuSubItem";const Dft=x.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},i)=>{const s=e?qu:"a";return h.jsx(s,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:ke("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})});Dft.displayName="SidebarMenuSubButton";const Ift=[{id:"kanban",label:"Kanban",icon:gbe,href:"#/"},{id:"tasks",label:"Tasks",icon:bK,href:"#/tasks"},{id:"docs",label:"Docs",icon:ni,href:"#/docs"},{id:"templates",label:"Templates",icon:tb,href:"#/templates"},{id:"imports",label:"Imports",icon:Wb,href:"#/imports"}];function Oft({currentPage:e,onSearchClick:t}){const{state:n}=u1(),r=WT(),o=n==="expanded";return h.jsxs(Tfe,{collapsible:"icon",variant:r?"floating":"sidebar",children:[h.jsxs(Nfe,{children:[h.jsx(hE,{children:h.jsx(mE,{children:h.jsx(gE,{size:"lg",asChild:!0,children:h.jsxs("a",{href:"#/",children:[h.jsx("img",{src:hft,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(DS,{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(Rfe,{children:h.jsxs(Dfe,{children:[h.jsx(Ife,{children:"Navigation"}),h.jsx(Ofe,{children:h.jsx(hE,{children:Ift.map(i=>{const s=e===i.id;return h.jsx(mE,{children:h.jsx(gE,{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(_fe,{children:[h.jsx(hE,{children:h.jsx(mE,{children:h.jsx(gE,{asChild:!0,isActive:e==="config",tooltip:"Settings",children:h.jsxs("a",{href:"#/config",children:[h.jsx(JI,{}),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.4"})]})})]}),h.jsx(Afe,{})]})}const Mft=[{value:"all",label:"All"},{value:"status",label:"Status"},{value:"assignee",label:"Assignee"},{value:"content",label:"Content"}];function Lft(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 Pft(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 Fft(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 Bft({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 ha.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]),es("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(P9,{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(Kb,{className:`w-4 h-4 ${c?"animate-spin":""}`})})]}),t&&h.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[h.jsx(QI,{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:Mft.map(y=>h.jsx("option",{value:y.value,children:y.label},y.value))})]}),h.jsx(Yr,{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(K0,{name:y.author,size:"xs"}):h.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${Fft(y.changes)}`,children:h.jsx(P9,{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:Lft(y)}),h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Pft(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 jft(){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 ha.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]),es("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(V0,{open:n,onOpenChange:a,children:[h.jsx(G0,{asChild:!0,children:h.jsxs(Le,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Notifications",children:[h.jsx(Sge,{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(Bft,{limit:20,showFilter:!1,onTaskClick:l=>{r(!1),window.location.hash=`/kanban/${l}`}})})]})})]})}const KY={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"},$ft={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold"};function Uft({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(zO,{open:e,onOpenChange:t,children:h.jsx(zS,{className:"overflow-hidden p-0 max-w-2xl",hideClose:!0,children:h.jsxs(Wh,{shouldFilter:!1,children:[h.jsx(Yh,{placeholder:"Search tasks and docs...",value:o,onValueChange:i}),h.jsxs(Kh,{children:[h.jsx(Xh,{children:l?"Searching...":o?"No results found.":"Type to search..."}),s.tasks.length>0&&h.jsx(rl,{heading:"Tasks",children:s.tasks.slice(0,8).map(m=>{const g=KY[m.status]||KY.todo,y=$ft[m.status]||m.status;return h.jsxs(Ji,{value:`task-${m.id}`,onSelect:()=>u(m),children:[h.jsx(bK,{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(gS,{}),s.docs.length>0&&h.jsx(rl,{heading:"Documentation",children:s.docs.slice(0,8).map(m=>{const g=m.metadata?.title||m.filename;return h.jsxs(Ji,{value:`doc-${m.path}`,onSelect:()=>f(m),children:[h.jsx(ni,{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 yu(e,t){return typeof e=="function"?e(t):e}function cs(e,t){return n=>{t.setState(r=>({...r,[e]:yu(n,r[e])}))}}function YT(e){return e instanceof Function}function Hft(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function zft(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 dt(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 ft(e,t,n,r){return{debug:()=>{var o;return(o=e?.debugAll)!=null?o:e[t]},key:!1,onChange:r}}function Vft(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:dt(()=>[e,n,t,i],(s,a,l,c)=>({table:s,column:a,row:l,cell:c,getValue:c.getValue,renderValue:c.renderValue}),ft(e.options,"debugCells"))};return e._features.forEach(s=>{s.createCell==null||s.createCell(i,n,t,e)},{}),i}function Gft(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:dt(()=>[!0],()=>{var m;return[f,...(m=f.columns)==null?void 0:m.flatMap(g=>g.getFlatColumns())]},ft(e.options,"debugColumns")),getLeafColumns:dt(()=>[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]},ft(e.options,"debugColumns"))};for(const m of e._features)m.createColumn==null||m.createColumn(f,e);return f}const Lo="debugHeaders";function XY(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 qft={createTable:e=>{e.getHeaderGroups=dt(()=>[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 Av(t,[...a,...c,...l],e)},ft(e.options,Lo)),e.getCenterHeaderGroups=dt(()=>[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))),Av(t,n,e,"center")),ft(e.options,Lo)),e.getLeftHeaderGroups=dt(()=>[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 Av(t,i,e,"left")},ft(e.options,Lo)),e.getRightHeaderGroups=dt(()=>[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 Av(t,i,e,"right")},ft(e.options,Lo)),e.getFooterGroups=dt(()=>[e.getHeaderGroups()],t=>[...t].reverse(),ft(e.options,Lo)),e.getLeftFooterGroups=dt(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),ft(e.options,Lo)),e.getCenterFooterGroups=dt(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),ft(e.options,Lo)),e.getRightFooterGroups=dt(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),ft(e.options,Lo)),e.getFlatHeaders=dt(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),ft(e.options,Lo)),e.getLeftFlatHeaders=dt(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),ft(e.options,Lo)),e.getCenterFlatHeaders=dt(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),ft(e.options,Lo)),e.getRightFlatHeaders=dt(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),ft(e.options,Lo)),e.getCenterLeafHeaders=dt(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),ft(e.options,Lo)),e.getLeftLeafHeaders=dt(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),ft(e.options,Lo)),e.getRightLeafHeaders=dt(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),ft(e.options,Lo)),e.getLeafHeaders=dt(()=>[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()},ft(e.options,Lo))}};function Av(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 A,R=!1;if(T&&w.column.parent?A=w.column.parent:(A=w.column,R=!0),S&&S?.column===A)S.subHeaders.push(w);else{const _=XY(n,A,{id:[r,g,A.id,w?.id].filter(Boolean).join("_"),isPlaceholder:R,placeholderId:R?`${v.filter(D=>D.column===A).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)=>XY(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(A=>{let{colSpan:R,rowSpan:_}=A;v+=R,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 NB=(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:()=>zft(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:dt(()=>[e.getAllLeafColumns()],l=>l.map(c=>Vft(e,a,c,c.id)),ft(e.options,"debugRows")),_getAllCellsByColumnId:dt(()=>[a.getAllCells()],l=>l.reduce((c,u)=>(c[u.column.id]=u,c),{}),ft(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},Wft={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()}}},Mfe=(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))};Mfe.autoRemove=e=>xa(e);const Lfe=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};Lfe.autoRemove=e=>xa(e);const Pfe=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};Pfe.autoRemove=e=>xa(e);const Ffe=(e,t,n)=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(n)};Ffe.autoRemove=e=>xa(e);const Bfe=(e,t,n)=>!n.some(r=>{var o;return!((o=e.getValue(t))!=null&&o.includes(r))});Bfe.autoRemove=e=>xa(e)||!(e!=null&&e.length);const jfe=(e,t,n)=>n.some(r=>{var o;return(o=e.getValue(t))==null?void 0:o.includes(r)});jfe.autoRemove=e=>xa(e)||!(e!=null&&e.length);const $fe=(e,t,n)=>e.getValue(t)===n;$fe.autoRemove=e=>xa(e);const Ufe=(e,t,n)=>e.getValue(t)==n;Ufe.autoRemove=e=>xa(e);const _B=(e,t,n)=>{let[r,o]=n;const i=e.getValue(t);return i>=r&&i<=o};_B.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]};_B.autoRemove=e=>xa(e)||xa(e[0])&&xa(e[1]);const Kl={includesString:Mfe,includesStringSensitive:Lfe,equalsString:Pfe,arrIncludes:Ffe,arrIncludesAll:Bfe,arrIncludesSome:jfe,equals:$fe,weakEquals:Ufe,inNumberRange:_B};function xa(e){return e==null||e===""}const Yft={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:cs("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"?Kl.includesString:typeof r=="number"?Kl.inNumberRange:typeof r=="boolean"||r!==null&&typeof r=="object"?Kl.equals:Array.isArray(r)?Kl.arrIncludes:Kl.weakEquals},e.getFilterFn=()=>{var n,r;return YT(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:Kl[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=yu(n,i?i.value:void 0);if(ZY(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=yu(t,o))==null?void 0:i.filter(s=>{const a=n.find(l=>l.id===s.id);if(a){const l=a.getFilterFn();if(ZY(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 ZY(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const Kft=(e,t,n)=>n.reduce((r,o)=>{const i=o.getValue(e);return r+(typeof i=="number"?i:0)},0),Xft=(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},Zft=(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},Qft=(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]},Jft=(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},ept=(e,t)=>{if(!t.length)return;const n=t.map(i=>i.getValue(e));if(!Hft(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},tpt=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),npt=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,rpt=(e,t)=>t.length,q_={sum:Kft,min:Xft,max:Zft,extent:Qft,mean:Jft,median:ept,unique:tpt,uniqueCount:npt,count:rpt},opt={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:cs("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 q_.sum;if(Object.prototype.toString.call(r)==="[object Date]")return q_.extent},e.getAggregationFn=()=>{var n,r;if(!e)throw new Error;return YT(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:q_[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 ipt(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 spt={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:cs("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=dt(n=>[Vb(t,n)],n=>n.findIndex(r=>r.id===e.id),ft(t.options,"debugColumns")),e.getIsFirstColumn=n=>{var r;return((r=Vb(t,n)[0])==null?void 0:r.id)===e.id},e.getIsLastColumn=n=>{var r;const o=Vb(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=dt(()=>[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 ipt(i,n,r)},ft(e.options,"debugTable"))}},W_=()=>({left:[],right:[]}),apt={getInitialState:e=>({columnPinning:W_(),...e}),getDefaultOptions:e=>({onColumnPinningChange:cs("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=dt(()=>[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))},ft(t.options,"debugRows")),e.getLeftVisibleCells=dt(()=>[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"})),ft(t.options,"debugRows")),e.getRightVisibleCells=dt(()=>[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"})),ft(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?W_():(n=(r=e.initialState)==null?void 0:r.columnPinning)!=null?n:W_())},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=dt(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(r=>t.find(o=>o.id===r)).filter(Boolean),ft(e.options,"debugColumns")),e.getRightLeafColumns=dt(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(r=>t.find(o=>o.id===r)).filter(Boolean),ft(e.options,"debugColumns")),e.getCenterLeafColumns=dt(()=>[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))},ft(e.options,"debugColumns"))}};function lpt(e){return e||(typeof document<"u"?document:null)}const Nv={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},Y_=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),cpt={getDefaultColumnDef:()=>Nv,getInitialState:e=>({columnSizing:{},columnSizingInfo:Y_(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:cs("columnSizing",e),onColumnSizingInfoChange:cs("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:Nv.minSize,(r=i??e.columnDef.size)!=null?r:Nv.size),(o=e.columnDef.maxSize)!=null?o:Nv.maxSize)},e.getStart=dt(n=>[n,Vb(t,n),t.getState().columnSizing],(n,r)=>r.slice(0,e.getIndex(n)).reduce((o,i)=>o+i.getSize(),0),ft(t.options,"debugColumns")),e.getAfter=dt(n=>[n,Vb(t,n),t.getState().columnSizing],(n,r)=>r.slice(e.getIndex(n)+1).reduce((o,i)=>o+i.getSize(),0),ft(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(),K_(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=K_(i)?Math.round(i.touches[0].clientX):i.clientX,c={},u=(S,T)=>{typeof T=="number"&&(t.setColumnSizingInfo(A=>{var R,_;const D=t.options.columnResizeDirection==="rtl"?-1:1,I=(T-((R=A?.startOffset)!=null?R:0))*D,L=Math.max(I/((_=A?.startSize)!=null?_:0),-.999999);return A.columnSizingStart.forEach(j=>{let[O,F]=j;c[O]=Math.round(Math.max(F+F*L,0)*100)/100}),{...A,deltaOffset:I,deltaPercentage:L}}),(t.options.columnResizeMode==="onChange"||S==="end")&&t.setColumnSizing(A=>({...A,...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=lpt(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=upt()?{passive:!1}:!1;K_(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?Y_():(n=e.initialState.columnSizingInfo)!=null?n:Y_())},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 _v=null;function upt(){if(typeof _v=="boolean")return _v;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 _v=e,_v}function K_(e){return e.type==="touchstart"}const dpt={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:cs("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=dt(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(r=>r.column.getIsVisible()),ft(t.options,"debugRows")),e.getVisibleCells=dt(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,r,o)=>[...n,...r,...o],ft(t.options,"debugRows"))},createTable:e=>{const t=(n,r)=>dt(()=>[r(),r().filter(o=>o.getIsVisible()).map(o=>o.id).join("_")],o=>o.filter(i=>i.getIsVisible==null?void 0:i.getIsVisible()),ft(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 Vb(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const fpt={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()}}},ppt={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:cs("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=()=>Kl.includesString,e.getGlobalFilterFn=()=>{var t,n;const{globalFilterFn:r}=e.options;return YT(r)?r:r==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[r])!=null?t:Kl[r]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},hpt={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:cs("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()}}}},zI=0,VI=10,X_=()=>({pageIndex:zI,pageSize:VI}),mpt={getInitialState:e=>({...e,pagination:{...X_(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:cs("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=>yu(r,i);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(o)},e.resetPagination=r=>{var o;e.setPagination(r?X_():(o=e.initialState.pagination)!=null?o:X_())},e.setPageIndex=r=>{e.setPagination(o=>{let i=yu(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?zI:(o=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageIndex)!=null?o:zI)},e.resetPageSize=r=>{var o,i;e.setPageSize(r?VI:(o=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageSize)!=null?o:VI)},e.setPageSize=r=>{e.setPagination(o=>{const i=Math.max(1,yu(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=yu(r,(i=e.options.pageCount)!=null?i:-1);return typeof s=="number"&&(s=Math.max(-1,s)),{...o,pageCount:s}}),e.getPageOptions=dt(()=>[e.getPageCount()],r=>{let o=[];return r&&r>0&&(o=[...new Array(r)].fill(null).map((i,s)=>s)),o},ft(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}}},Z_=()=>({top:[],bottom:[]}),gpt={getInitialState:e=>({rowPinning:Z_(),...e}),getDefaultOptions:e=>({onRowPinningChange:cs("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?Z_():(n=(r=e.initialState)==null?void 0:r.rowPinning)!=null?n:Z_())},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=dt(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),ft(e.options,"debugRows")),e.getBottomRows=dt(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),ft(e.options,"debugRows")),e.getCenterRows=dt(()=>[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))},ft(e.options,"debugRows"))}},bpt={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:cs("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=>{GI(o,i.id,r,!0,e)}),o}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=dt(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?Q_(e,n):{rows:[],flatRows:[],rowsById:{}},ft(e.options,"debugTable")),e.getFilteredSelectedRowModel=dt(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?Q_(e,n):{rows:[],flatRows:[],rowsById:{}},ft(e.options,"debugTable")),e.getGroupedSelectedRowModel=dt(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?Q_(e,n):{rows:[],flatRows:[],rowsById:{}},ft(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 GI(a,e.id,n,(s=r?.selectChildren)!=null?s:!0,t),a})},e.getIsSelected=()=>{const{rowSelection:n}=t.getState();return RB(e,n)},e.getIsSomeSelected=()=>{const{rowSelection:n}=t.getState();return qI(e,n)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=t.getState();return qI(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)}}}},GI=(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=>GI(e,a.id,n,r,o))};function Q_(e,t){const n=e.getState().rowSelection,r=[],o={},i=function(s,a){return s.map(l=>{var c;const u=RB(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 RB(e,t){var n;return(n=t[e.id])!=null?n:!1}function qI(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()&&(RB(s,t)?i=!0:o=!1),s.subRows&&s.subRows.length)){const a=qI(s,t);a==="all"?i=!0:(a==="some"&&(i=!0),o=!1)}}),o?"all":i?"some":!1}const WI=/([0-9]+)/gm,ypt=(e,t,n)=>Hfe(Vu(e.getValue(n)).toLowerCase(),Vu(t.getValue(n)).toLowerCase()),xpt=(e,t,n)=>Hfe(Vu(e.getValue(n)),Vu(t.getValue(n))),vpt=(e,t,n)=>DB(Vu(e.getValue(n)).toLowerCase(),Vu(t.getValue(n)).toLowerCase()),Ept=(e,t,n)=>DB(Vu(e.getValue(n)),Vu(t.getValue(n))),wpt=(e,t,n)=>{const r=e.getValue(n),o=t.getValue(n);return r>o?1:r<o?-1:0},Spt=(e,t,n)=>DB(e.getValue(n),t.getValue(n));function DB(e,t){return e===t?0:e>t?1:-1}function Vu(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function Hfe(e,t){const n=e.split(WI).filter(Boolean),r=t.split(WI).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 eb={alphanumeric:ypt,alphanumericCaseSensitive:xpt,text:vpt,textCaseSensitive:Ept,datetime:wpt,basic:Spt},Cpt={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:cs("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 eb.datetime;if(typeof i=="string"&&(r=!0,i.split(WI).length>1))return eb.alphanumeric}return r?eb.text:eb.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 YT(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:eb[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())}},Tpt=[qft,dpt,spt,apt,Wft,Yft,fpt,ppt,Cpt,opt,hpt,mpt,gpt,bpt,cpt];function kpt(e){var t,n;const r=[...Tpt,...(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=yu(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:dt(()=>[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}},ft(e,"debugColumns")),_getColumnDefs:()=>o.options.columns,getAllColumns:dt(()=>[o._getColumnDefs()],m=>{const g=function(y,v,w){return w===void 0&&(w=0),y.map(S=>{const T=Gft(o,S,w,v),A=S;return T.columns=A.columns?g(A.columns,T,w+1):[],T})};return g(m)},ft(e,"debugColumns")),getAllFlatColumns:dt(()=>[o.getAllColumns()],m=>m.flatMap(g=>g.getFlatColumns()),ft(e,"debugColumns")),_getAllFlatColumnsById:dt(()=>[o.getAllFlatColumns()],m=>m.reduce((g,y)=>(g[y.id]=y,g),{}),ft(e,"debugColumns")),getAllLeafColumns:dt(()=>[o.getAllColumns(),o._getOrderColumnsFn()],(m,g)=>{let y=m.flatMap(v=>v.getLeafColumns());return g(y)},ft(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 Apt(){return e=>dt(()=>[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=NB(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},ft(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function Npt(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 zfe(e,t,n){return n.options.filterFromLeafRows?_pt(e,t,n):Rpt(e,t,n)}function _pt(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=NB(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 Rpt(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=NB(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 Dpt(){return(e,t)=>dt(()=>[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 zfe(n.rows,s,e)},ft(e.options,"debugTable"))}function Ipt(){return(e,t)=>dt(()=>{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},ft(e.options,"debugTable"))}function Opt(){return e=>dt(()=>[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 zfe(t.rows,f,e)},ft(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex()))}function Mpt(e){return t=>dt(()=>[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=Npt({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},ft(t.options,"debugTable"))}function Lpt(){return e=>dt(()=>[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 A=u.getValue(y.id),R=f.getValue(y.id),_=A===void 0,D=R===void 0;if(_||D){if(w==="first")return _?-1:1;if(w==="last")return _?1:-1;T=_&&D?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}},ft(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function QY(e,t){return e?Ppt(e)?x.createElement(e,t):e:null}function Ppt(e){return Fpt(e)||typeof e=="function"||Bpt(e)}function Fpt(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Bpt(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function jpt(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=x.useState(()=>({current:kpt(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 Vfe=x.forwardRef(({className:e,...t},n)=>h.jsx("div",{className:"relative w-full overflow-auto",children:h.jsx("table",{ref:n,className:ke("w-full caption-bottom text-sm",e),...t})}));Vfe.displayName="Table";const Gfe=x.forwardRef(({className:e,...t},n)=>h.jsx("thead",{ref:n,className:ke("[&_tr]:border-b",e),...t}));Gfe.displayName="TableHeader";const qfe=x.forwardRef(({className:e,...t},n)=>h.jsx("tbody",{ref:n,className:ke("[&_tr:last-child]:border-0",e),...t}));qfe.displayName="TableBody";const $pt=x.forwardRef(({className:e,...t},n)=>h.jsx("tfoot",{ref:n,className:ke("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));$pt.displayName="TableFooter";const bE=x.forwardRef(({className:e,...t},n)=>h.jsx("tr",{ref:n,className:ke("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));bE.displayName="TableRow";const Wfe=x.forwardRef(({className:e,...t},n)=>h.jsx("th",{ref:n,className:ke("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}));Wfe.displayName="TableHead";const YI=x.forwardRef(({className:e,...t},n)=>h.jsx("td",{ref:n,className:ke("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));YI.displayName="TableCell";const Upt=x.forwardRef(({className:e,...t},n)=>h.jsx("caption",{ref:n,className:ke("mt-4 text-sm text-muted-foreground",e),...t}));Upt.displayName="TableCaption";function Hpt({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(ei,{value:`${e.getState().pagination.pageSize}`,onValueChange:n=>{e.setPageSize(Number(n))},children:[h.jsx($o,{className:"h-8 w-[70px]",children:h.jsx(ti,{placeholder:e.getState().pagination.pageSize})}),h.jsx(Uo,{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(Oge,{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(_ge,{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(Fs,{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(Lge,{className:"h-4 w-4"})]})]})]})]})}function zpt({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=jpt({data:t,columns:e,state:{sorting:y,columnVisibility:u,rowSelection:l,columnFilters:m},enableRowSelection:!0,onRowSelectionChange:c,onSortingChange:v,onColumnFiltersChange:g,onColumnVisibilityChange:f,getCoreRowModel:Apt(),getFilteredRowModel:Opt(),getPaginationRowModel:Mpt(),getSortedRowModel:Lpt(),getFacetedRowModel:Dpt(),getFacetedUniqueValues:Ipt()});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(Vfe,{children:[h.jsx(Gfe,{children:w.getHeaderGroups().map(S=>h.jsx(bE,{children:S.headers.map(T=>h.jsx(Wfe,{colSpan:T.colSpan,children:T.isPlaceholder?null:QY(T.column.columnDef.header,T.getContext())},T.id))},S.id))}),h.jsx(qfe,{children:w.getRowModel().rows?.length?w.getRowModel().rows.map(S=>h.jsx(bE,{"data-state":S.getIsSelected()&&"selected",onClick:()=>r?.(S.original),className:r?"cursor-pointer":"",children:S.getVisibleCells().map(T=>h.jsx(YI,{children:QY(T.column.columnDef.cell,T.getContext())},T.id))},S.id)):h.jsx(bE,{children:h.jsx(YI,{colSpan:e.length,className:"h-24 text-center",children:"No results."})})})]})}),o&&h.jsx(Hpt,{table:w,showRowSelection:i})]})}const Yfe=nce,Kfe=rce,Vpt=x.forwardRef(({className:e,inset:t,children:n,...r},o)=>h.jsxs(MF,{ref:o,className:ke("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,h.jsx(Fs,{className:"ml-auto"})]}));Vpt.displayName=MF.displayName;const Gpt=x.forwardRef(({className:e,...t},n)=>h.jsx(LF,{ref:n,className:ke("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",e),...t}));Gpt.displayName=LF.displayName;const IB=x.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(Fnt,{children:h.jsx(NF,{ref:r,sideOffset:t,className:ke("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",e),...n})}));IB.displayName=NF.displayName;const Gb=x.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(RF,{ref:r,className:ke("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));Gb.displayName=RF.displayName;const qpt=x.forwardRef(({className:e,children:t,checked:n,...r},o)=>h.jsxs(DF,{ref:o,className:ke("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(IF,{children:h.jsx(so,{className:"h-4 w-4"})})}),t]}));qpt.displayName=DF.displayName;const Wpt=x.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(oce,{ref:r,className:ke("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(IF,{children:h.jsx(pK,{className:"h-2 w-2 fill-current"})})}),t]}));Wpt.displayName=oce.displayName;const Ypt=x.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(_F,{ref:r,className:ke("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ypt.displayName=_F.displayName;const Xfe=x.forwardRef(({className:e,...t},n)=>h.jsx(OF,{ref:n,className:ke("-mx-1 my-1 h-px bg-muted",e),...t}));Xfe.displayName=OF.displayName;function Ad({column:e,title:t,className:n}){return e.getCanSort()?h.jsx("div",{className:ke("flex items-center space-x-2",n),children:h.jsxs(Yfe,{children:[h.jsx(Kfe,{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(nR,{className:"ml-2 h-4 w-4"}):e.getIsSorted()==="asc"?h.jsx(Eh,{className:"ml-2 h-4 w-4"}):h.jsx(yE,{className:"ml-2 h-4 w-4"})]})}),h.jsxs(IB,{align:"start",children:[h.jsxs(Gb,{onClick:()=>e.toggleSorting(!1),children:[h.jsx(Eh,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground/70"}),"Asc"]}),h.jsxs(Gb,{onClick:()=>e.toggleSorting(!0),children:[h.jsx(nR,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground/70"}),"Desc"]}),e.getCanHide()&&h.jsxs(h.Fragment,{children:[h.jsx(Xfe,{}),h.jsxs(Gb,{onClick:()=>e.toggleVisibility(!1),children:[h.jsx(rR,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground/70"}),"Hide"]})]})]})]})}):h.jsx("div",{className:ke(n),children:t})}const Kpt=[{id:"select",header:({table:e})=>h.jsx(bS,{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(bS,{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(Ad,{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(Ad,{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(Ad,{column:e,title:"Status"}),cell:({row:e})=>{const t=e.getValue("status");return h.jsx(vde,{status:t})},filterFn:(e,t,n)=>n.includes(e.getValue(t)),enableSorting:!0},{accessorKey:"priority",header:({column:e})=>h.jsx(Ad,{column:e,title:"Priority"}),cell:({row:e})=>{const t=e.getValue("priority");return h.jsx(Ede,{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(Ad,{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(Ad,{column:e,title:"Labels"}),cell:({row:e})=>{const t=e.getValue("labels");return t.length>0?h.jsx(wde,{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(Ad,{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 Xpt({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(DS,{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(ei,{value:n,onValueChange:r,children:[h.jsx($o,{className:"w-[150px]",children:h.jsx(ti,{placeholder:"Status"})}),h.jsxs(Uo,{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(ei,{value:o,onValueChange:i,children:[h.jsx($o,{className:"w-[150px]",children:h.jsx(ti,{placeholder:"Priority"})}),h.jsxs(Uo,{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(Qo,{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(Ho,{className:"mr-2 h-4 w-4"}),"New Task"]})]})}function Zpt({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(zpt,{columns:Kpt,data:u,onRowClick:t,onSelectionChange:n,showPagination:!0,showRowSelection:!0,initialSorting:[{id:"priority",desc:!1}],toolbar:h.jsx(Xpt,{table:null,globalFilter:o,setGlobalFilter:i,statusFilter:s,setStatusFilter:a,priorityFilter:l,setPriorityFilter:c,onNewTask:r})})}const J_=["todo","in-progress","in-review","done","blocked","on-hold","urgent"],Qpt=["gray","blue","green","yellow","red","purple","orange","pink","cyan","indigo"];function Jpt(){const{config:e,loading:t,updateConfig:n}=yf(),[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 A=r,R=o;x.useEffect(()=>{c==="form"&&m(JSON.stringify(A,null,2))},[A,c]);const _=async()=>{s(!0),l(null);try{let F=A;if(c==="json")try{F=JSON.parse(f),R(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)}},D=()=>{if(!v.trim())return;const F=v.toLowerCase().replace(/\s+/g,"-"),U=A.statuses||J_;if(U.includes(F)){l({type:"error",text:"Status already exists"});return}R({...A,statuses:[...U,F],statusColors:{...A.statusColors||{},[F]:"gray"}}),w("")},I=F=>{const U=A.statuses||J_,Y={...A.statusColors||{}};delete Y[F],R({...A,statuses:U.filter($=>$!==F),statusColors:Y,visibleColumns:(A.visibleColumns||[]).filter($=>$!==F)})},L=(F,U)=>{R({...A,statusColors:{...A.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 j=A.statuses||J_,O=A.statusColors||{};return h.jsx(Yr,{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(JI,{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(jbe,{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(Wge,{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(so,{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:A.name||"",onChange:F=>R({...A,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:A.defaultAssignee||"",onChange:F=>R({...A,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:A.defaultPriority||"medium",onChange:F=>R({...A,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:A.defaultLabels?.join(", ")||"",onChange:F=>R({...A,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:A.timeFormat||"24h",onChange:F=>R({...A,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:A.editor||"",onChange:F=>R({...A,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:j.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=>L(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:Qpt.map(U=>h.jsx("option",{value:U,children:U},U))}),h.jsx("button",{type:"button",onClick:()=>I(F),className:"p-1 text-destructive hover:text-destructive hover:bg-destructive/10 rounded transition-colors",title:"Remove status",children:h.jsx(Tu,{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"&&D()}),h.jsxs(Le,{onClick:D,className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(Ho,{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:j.map(F=>{const U=A.visibleColumns?.includes(F)??!0,Y=F.split("-").map($=>$.charAt(0).toUpperCase()+$.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:$=>{const G=A.visibleColumns||j,H=$.target.checked?[...G,F]:G.filter(X=>X!==F);R({...A,visibleColumns:H})},className:"w-4 h-4 rounded border-border text-primary focus:ring-primary"}),h.jsx("span",{children:Y})]},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(so,{className:"w-4 h-4 mr-2"}),i?"Saving...":"Save Configuration"]})})]})]})})}function eht(){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,A]=x.useState(""),[R,_]=x.useState(""),[D,I]=x.useState(""),[L,j]=x.useState(!1),[O,F]=x.useState(new Set(["(root)","__local__","__imports__"])),[U,Y]=x.useState(!1),$=x.useRef(null);x.useEffect(()=>{H()},[]),es("docs:updated",()=>{H()}),es("docs:refresh",()=>{H()});const G=x.useCallback(()=>{if(e.length===0)return;const be=window.location.hash.match(/^#\/docs\/(.+)$/);if(be){const Oe=decodeURIComponent(be[1]),we=IE(Oe).replace(/^\.\//,"").replace(/^\//,""),Re=we.replace(/\.md$/,""),se=e.find(Ce=>{const Be=IE(Ce.path),Pe=Be.replace(/\.md$/,"");return Be===we||Be===Re||Pe===we||Pe===Re||Be.endsWith(`/${we}`)||Be.endsWith(`/${Re}`)||Ce.filename===we||Ce.filename===Re});se&&se!==o&&(i(se),a(!1))}},[e,o]);x.useEffect(()=>{G()},[G]),x.useEffect(()=>{o&&F(re=>{const be=new Set(re);if(o.isImported&&o.source){be.add("__imports__"),be.add(`__import_${o.source}__`);const we=o.path.replace(`${o.source}/`,"").split("/");if(we.length>1){let se=`__import_${o.source}__`;for(let Ce=0;Ce<we.length-1;Ce++)se=`${se}/${we.slice(0,Ce+1).join("/")}`,be.add(se)}}else if(o.folder){const Oe=o.folder.split("/");let we="";for(const Re of Oe)we=we?`${we}/${Re}`:Re,be.add(we)}return be})},[o]),x.useEffect(()=>(window.addEventListener("hashchange",G),()=>window.removeEventListener("hashchange",G)),[G]),x.useEffect(()=>{const re=Oe=>{let we=Oe.target;for(;we&&we.tagName!=="A"&&we!==$.current;)we=we.parentElement;if(we&&we.tagName==="A"){const se=we.getAttribute("href");if(se&&/^@?task-[\w.]+(.md)?$/.test(se)){Oe.preventDefault();const Ce=se.replace(/^@/,"").replace(".md","");window.location.hash=`/tasks?task=${Ce}`;return}if(se&&se.startsWith("@doc/")){Oe.preventDefault();const Ce=se.replace("@doc/","");window.location.hash=`/docs/${Ce}.md`;return}if(se&&(se.endsWith(".md")||se.includes(".md#"))){Oe.preventDefault();let Ce=se.replace(/^\.\//,"").replace(/^\//,"");Ce=Ce.split("#")[0],window.location.hash=`/docs/${Ce}`}}},be=$.current;if(be)return be.addEventListener("click",re),()=>be.removeEventListener("click",re)},[e,o]);const H=()=>{KI().then(re=>{t(re),r(!1)}).catch(re=>{console.error("Failed to load docs:",re),r(!1)})},X=async()=>{if(!y.trim()){alert("Please enter a title");return}j(!0);try{const re=T.split(",").map(be=>be.trim()).filter(be=>be);await Ime({title:y,description:w,tags:re,folder:R,content:D}),v(""),S(""),A(""),_(""),I(""),g(!1),H()}catch(re){console.error("Failed to create doc:",re),alert("Failed to create document. Please try again.")}finally{j(!1)}},Z=()=>{o&&(c(o.content),a(!0))},J=()=>{if(o){const be=`@doc/${FN(o.path).replace(/\.md$/,"")}`;navigator.clipboard.writeText(be).then(()=>{Y(!0),setTimeout(()=>Y(!1),2e3)})}},B=async()=>{if(o){f(!0);try{const re=await Ome(ASe(o.path),{content:l});t(be=>be.map(Oe=>Oe.path===o.path?{...Oe,content:l,metadata:{...Oe.metadata,updatedAt:new Date().toISOString()}}:Oe)),i(be=>be&&{...be,content:l}),a(!1)}catch(re){console.error("Failed to save doc:",re),alert(re instanceof Error?re.message:"Failed to save document")}finally{f(!1)}}},W=()=>{a(!1),c("")},K=re=>{F(be=>{const Oe=new Set(be);return Oe.has(re)?Oe.delete(re):Oe.add(re),Oe})},P=(re,be="")=>{const Oe={name:"(root)",path:be,docs:[],children:new Map};for(const we of re){let Re=we.folder;if(we.isImported&&we.source){const Ce=we.path.replace(`${we.source}/`,"").split("/");Re=Ce.length>1?Ce.slice(0,-1).join("/"):""}if(!Re)Oe.docs.push(we);else{const se=Re.split("/");let Ce=Oe;for(let Be=0;Be<se.length;Be++){const Pe=se[Be],hn=be?`${be}/${se.slice(0,Be+1).join("/")}`:se.slice(0,Be+1).join("/");Ce.children.has(Pe)||Ce.children.set(Pe,{name:Pe,path:hn,docs:[],children:new Map}),Ce=Ce.children.get(Pe)}Ce.docs.push(we)}}return Oe},le=e.filter(re=>!re.isImported),ae=e.filter(re=>re.isImported),de=ae.reduce((re,be)=>{const Oe=be.source||"unknown";return re[Oe]||(re[Oe]=[]),re[Oe].push(be),re},{}),ie=re=>{let be=re.docs.length;for(const Oe of re.children.values())be+=ie(Oe);return be},ue=(re,be=0)=>{const Oe=[],we=be===0||O.has(re.path),Re=`${be*16}px`;if(be>0){const se=ie(re);Oe.push(h.jsxs("button",{type:"button",onClick:()=>K(re.path),className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-accent text-foreground transition-colors",style:{paddingLeft:Re},children:[we?h.jsx(Ps,{className:"w-4 h-4"}):h.jsx(Fs,{className:"w-4 h-4"}),we?h.jsx(xE,{className:"w-4 h-4"}):h.jsx(dN,{className:"w-4 h-4"}),h.jsx("span",{className:"text-sm font-medium",children:re.name}),h.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",se,")"]})]},`folder-${re.path}`))}if(we||be===0){const se=Array.from(re.children.values()).sort((Be,Pe)=>Be.name.localeCompare(Pe.name));for(const Be of se)Oe.push(...ue(Be,be+1));const Ce=[...re.docs].sort((Be,Pe)=>Be.metadata.title.localeCompare(Pe.metadata.title));for(const Be of Ce)Oe.push(h.jsxs("button",{type:"button",onClick:()=>{window.location.hash=`/docs/${FN(Be.path)}`},className:`w-full text-left px-3 py-2 flex items-center gap-2 hover:bg-accent text-foreground transition-colors ${o?.path===Be.path?"bg-accent":""}`,style:{paddingLeft:`${(be+1)*16}px`},children:[h.jsx(ni,{className:`w-5 h-5 ${Be.isImported?"text-blue-500":""}`}),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-sm font-medium truncate",children:Be.metadata.title}),Be.isImported&&h.jsx("span",{className:"shrink-0 px-1 py-0.5 text-[10px] font-medium bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300 rounded",children:"imported"})]}),Be.metadata.description&&h.jsx("div",{className:"text-xs text-muted-foreground truncate",children:Be.metadata.description})]})]},`doc-${Be.path}`))}return Oe};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(Ho,{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(Yr,{className:"flex-1",children:[le.length>0&&h.jsxs("div",{children:[h.jsxs("button",{type:"button",onClick:()=>K("__local__"),className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-accent text-foreground transition-colors bg-muted/50",children:[O.has("__local__")?h.jsx(Ps,{className:"w-4 h-4"}):h.jsx(Fs,{className:"w-4 h-4"}),h.jsx(dN,{className:"w-4 h-4"}),h.jsx("span",{className:"text-sm font-semibold",children:"Local"}),h.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",le.length,")"]})]}),O.has("__local__")&&ue(P(le))]}),Object.keys(de).length>0&&h.jsxs("div",{children:[h.jsxs("button",{type:"button",onClick:()=>K("__imports__"),className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-accent text-foreground transition-colors bg-blue-50 dark:bg-blue-950/30",children:[O.has("__imports__")?h.jsx(Ps,{className:"w-4 h-4"}):h.jsx(Fs,{className:"w-4 h-4"}),h.jsx(Wb,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),h.jsx("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:"Imports"}),h.jsxs("span",{className:"text-xs text-blue-600 dark:text-blue-400",children:["(",ae.length,")"]})]}),O.has("__imports__")&&h.jsx("div",{children:Object.entries(de).map(([re,be])=>h.jsxs("div",{children:[h.jsxs("button",{type:"button",onClick:()=>K(`__import_${re}__`),className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-accent text-foreground transition-colors",style:{paddingLeft:"16px"},children:[O.has(`__import_${re}__`)?h.jsx(Ps,{className:"w-4 h-4"}):h.jsx(Fs,{className:"w-4 h-4"}),h.jsx(vK,{className:"w-4 h-4 text-blue-500"}),h.jsx("span",{className:"text-sm font-medium truncate",children:re}),h.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",be.length,")"]})]}),O.has(`__import_${re}__`)&&h.jsx("div",{style:{paddingLeft:"16px"},children:ue(P(be,`__import_${re}__`),0)})]},re))})]})]})]}),e.length===0&&h.jsxs("div",{className:"bg-card rounded-lg border p-8 text-center",children:[h.jsx(ni,{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:J,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(dN,{className:"w-4 h-4"}),h.jsxs("span",{className:"font-mono",children:["@doc/",FN(o.path).replace(/\.md$/,"")]}),h.jsx("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:U?"✓ Copied!":h.jsx(mK,{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:B,disabled:u,className:"bg-green-700 hover:bg-green-800 text-white",children:[h.jsx(so,{className:"w-4 h-4 mr-2"}),u?"Saving...":"Save"]}),h.jsxs(Le,{variant:"secondary",onClick:W,disabled:u,children:[h.jsx(Qo,{className:"w-4 h-4 mr-2"}),"Cancel"]})]}):h.jsxs(Le,{onClick:Z,disabled:o.isImported,title:o.isImported?"Imported docs are read-only":"Edit document",children:[h.jsx(EK,{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(Su,{markdown:l,onChange:c,placeholder:"Write your documentation here..."})})}):h.jsx(Yr,{className:"flex-1",children:h.jsx("div",{className:"p-6 prose prose-sm dark:prose-invert max-w-none",ref:$,children:h.jsx(kC,{markdown:o.content||""})})})]}):h.jsxs("div",{className:"bg-card rounded-lg border p-12 text-center",children:[h.jsx(ni,{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:re=>v(re.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:re=>S(re.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:R,onChange:re=>_(re.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:re=>A(re.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(Su,{markdown:D,onChange:I,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(""),A(""),_(""),I("")},disabled:L,children:"Cancel"}),h.jsx(Le,{onClick:X,disabled:L||!y.trim(),className:"bg-green-700 hover:bg-green-800 text-white",children:L?"Creating...":"Create Document"})]})]})})]})}function tht(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,nht(o,...t)]}function nht(...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 rht(e){const t=oht(e),n=x.forwardRef((r,o)=>{const{children:i,...s}=r,a=x.Children.toArray(i),l=a.find(sht);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 oht(e){const t=x.forwardRef((n,r)=>{const{children:o,...i}=n;if(x.isValidElement(o)){const s=lht(o),a=aht(i,o.props);return o.type!==x.Fragment&&(a.ref=r?Nn(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 iht=Symbol("radix.slottable");function sht(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===iht}function aht(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 lht(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 cht=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Zfe=cht.reduce((e,t)=>{const n=rht(`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}},{}),KT="Switch",[uht]=tht(KT),[dht,fht]=uht(KT),Qfe=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=At(t,A=>g(A)),v=x.useRef(!1),w=m?u||!!m.closest("form"):!0,[S,T]=ss({prop:o,defaultProp:i??!1,onChange:c,caller:KT});return h.jsxs(dht,{scope:n,checked:S,disabled:a,children:[h.jsx(Zfe.button,{type:"button",role:"switch","aria-checked":S,"aria-required":s,"data-state":npe(S),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:y,onClick:qe(e.onClick,A=>{T(R=>!R),w&&(v.current=A.isPropagationStopped(),v.current||A.stopPropagation())})}),w&&h.jsx(tpe,{control:m,bubbles:!v.current,name:r,value:l,checked:S,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});Qfe.displayName=KT;var Jfe="SwitchThumb",epe=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=fht(Jfe,n);return h.jsx(Zfe.span,{"data-state":npe(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});epe.displayName=Jfe;var pht="SwitchBubbleInput",tpe=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},i)=>{const s=x.useRef(null),a=At(s,i),l=jF(n),c=bF(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}})});tpe.displayName=pht;function npe(e){return e?"checked":"unchecked"}var rpe=Qfe,hht=epe;const vh=x.forwardRef(({className:e,...t},n)=>h.jsx(rpe,{className:ke("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(hht,{className:ke("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")})}));vh.displayName=rpe.displayName;function JY(e){return e?new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never"}function eK({type:e}){switch(e){case"git":return h.jsx(cbe,{className:"w-5 h-5 text-orange-500"});case"npm":return h.jsx(vK,{className:"w-5 h-5 text-red-500"});case"local":return h.jsx(xE,{className:"w-5 h-5 text-blue-500"});default:return h.jsx(Wb,{className:"w-5 h-5 text-gray-500"})}}function mht(){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,A]=x.useState(""),[R,_]=x.useState(!1),[D,I]=x.useState(!0),[L,j]=x.useState(!1),[O,F]=x.useState(null),[U,Y]=x.useState(null),[$,G]=x.useState(null),[H,X]=x.useState(!1),[Z,J]=x.useState(null),[B,W]=x.useState(null),[K,P]=x.useState(!1),[le,ae]=x.useState(!1),de=x.useCallback(async()=>{try{const Re=await Ep.list();t(Re.imports)}catch(Re){console.error("Failed to load imports:",Re)}finally{r(!1)}},[]);x.useEffect(()=>{de()},[de]),es("imports:added",()=>de()),es("imports:synced",()=>de()),es("imports:removed",()=>{de(),s&&(i(null),a(null))});const ie=async Re=>{c(!0),a(Re),J(null);try{const se=await Ep.get(Re);i(se.import)}catch(se){console.error("Failed to load import:",se),i(null)}finally{c(!1)}},ue=async()=>{if(m.trim()){j(!0),Y(null),F(null);try{const Re=await Ep.add({source:m,name:y||void 0,type:w||void 0,ref:T||void 0,link:R,dryRun:D});F(Re),D||(de(),ie(Re.import.name))}catch(Re){Y(Re instanceof Error?Re.message:String(Re))}finally{j(!1)}}},re=async Re=>{G(Re),J(null);try{const se=await Ep.sync(Re);J(se),de(),s===Re&&ie(Re),oo.success(`Synced "${Re}"`,{description:`Added: ${se.summary.added}, Updated: ${se.summary.updated}, Skipped: ${se.summary.skipped}`})}catch(se){console.error("Failed to sync:",se),oo.error(`Failed to sync "${Re}"`,{description:se instanceof Error?se.message:String(se)})}finally{G(null)}},be=async()=>{X(!0);try{const Re=await Ep.syncAll();de(),s&&ie(s);const{summary:se}=Re;se.total===0?oo.info("No imports to sync"):se.failed>0?oo.warning(`Synced ${se.successful} of ${se.total} imports`,{description:`${se.failed} failed`}):oo.success(`Synced ${se.successful} import${se.successful>1?"s":""}`,{description:"All imports are up to date"})}catch(Re){console.error("Failed to sync all:",Re),oo.error("Failed to sync imports",{description:Re instanceof Error?Re.message:String(Re)})}finally{X(!1)}},Oe=async()=>{if(s){W(s);try{await Ep.remove(s,le),P(!1),i(null),a(null),de()}catch(Re){console.error("Failed to remove:",Re)}finally{W(null)}}},we=()=>{g(""),v(""),S(""),A(""),_(!1),I(!0),F(null),Y(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:be,disabled:H||e.length===0,children:[H?h.jsx(ru,{className:"w-4 h-4 mr-2 animate-spin"}):h.jsx(Kb,{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(Ho,{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(Yr,{className:"flex-1",children:e.map(Re=>h.jsxs("button",{type:"button",onClick:()=>ie(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(eK,{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(wbe,{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 ",JY(Re.lastSync)]})]}),h.jsx(Fs,{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(Wb,{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(Ho,{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(ru,{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(eK,{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:()=>re(o.name),disabled:$===o.name||o.link,children:$===o.name?h.jsx(ru,{className:"w-4 h-4 animate-spin"}):h.jsx(Kb,{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(Tu,{className:"w-4 h-4"})})]})]})}),h.jsx(Yr,{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(ZI,{className:"w-3 h-3"}),"Last Sync"]}),h.jsx("div",{className:"font-medium",children:JY(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(ni,{className:"w-3 h-3"}),"Files"]}),h.jsxs("div",{className:"font-medium",children:[o.fileCount," files"]})]})]}),Z&&Z.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(so,{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: ",Z.summary.added,", Updated: ",Z.summary.updated,", Skipped: ",Z.summary.skipped]}),Z.warnings&&Z.warnings.length>0&&h.jsx("div",{className:"text-sm text-amber-600 dark:text-amber-400 mt-2",children:Z.warnings.map((Re,se)=>h.jsxs("div",{children:["⚠️ ",Re]},se))})]})]})}),h.jsxs("div",{children:[h.jsx("h3",{className:"font-semibold mb-3",children:"Imported Files"}),h.jsxs("div",{className:"rounded-lg border bg-muted/30 max-h-64 overflow-y-auto",children:[o.files.map((Re,se)=>h.jsxs("div",{className:"px-4 py-2 flex items-center gap-2 border-b last:border-b-0 text-sm",children:[h.jsx(ni,{className:"w-4 h-4 text-muted-foreground shrink-0"}),h.jsx("code",{className:"font-mono truncate",children:Re})]},se)),o.files.length===0&&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(Wb,{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=>A(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(vh,{id:"link",checked:R,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(vh,{id:"dry-run",checked:D,onCheckedChange:I}),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(qb,{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(qb,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 shrink-0"}):h.jsx(so,{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.jsxs("div",{className:"mt-3 max-h-32 overflow-y-auto text-sm",children:[O.changes.slice(0,10).map((Re,se)=>h.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[Re.action==="skip"?h.jsx(Qo,{className:"w-3 h-3 text-muted-foreground"}):h.jsx(so,{className:"w-3 h-3 text-green-600"}),h.jsx("code",{className:"font-mono text-xs truncate",children:Re.path})]},se)),O.changes.length>10&&h.jsxs("div",{className:"text-muted-foreground mt-1",children:["...and ",O.changes.length-10," more"]})]}),O.dryRun&&h.jsx(Le,{onClick:()=>{I(!1),ue()},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:we,disabled:L,children:O&&!O.dryRun?"Close":"Cancel"}),(!O||O.dryRun)&&h.jsx(Le,{onClick:ue,disabled:L||!m.trim(),className:D?"":"bg-green-600 hover:bg-green-700 text-white",children:L?h.jsxs(h.Fragment,{children:[h.jsx(ru,{className:"w-4 h-4 mr-2 animate-spin"}),D?"Checking...":"Importing..."]}):D?"Preview":"Import"})]})]})}),K&&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(vh,{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:Oe,disabled:B!==null,className:"bg-red-600 hover:bg-red-700 text-white",children:B?h.jsxs(h.Fragment,{children:[h.jsx(ru,{className:"w-4 h-4 mr-2 animate-spin"}),"Removing..."]}):"Remove"})]})]})})]})}const ght=[{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 tK({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 ha.batchArchiveTasks(s);if(l.count>0){const c=new Set(l.tasks.map(u=>u.id));n(e.filter(u=>!c.has(u.id))),oo.success(`Archived ${l.count} task${l.count>1?"s":""} done before ${a}`)}else oo.info(`No done tasks found before ${a}`)}catch(l){console.error("Failed to batch archive tasks:",l),oo.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(Yfe,{children:[h.jsx(Kfe,{asChild:!0,children:h.jsxs(Le,{variant:"outline",size:"default",className:"gap-2",children:[h.jsx(tR,{className:"w-4 h-4"}),h.jsx("span",{className:"hidden sm:inline",children:"Batch Archive"}),h.jsx(Ps,{className:"w-3 h-3"})]})}),h.jsx(IB,{align:"end",children:ght.map(s=>{const a=o(s.value);return h.jsxs(Gb,{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(Ho,{className:"w-4 h-4 mr-2"}),"New Task"]})]})]})}),h.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-6",children:h.jsx(dft,{tasks:e,loading:t,onTasksUpdate:n})})]})}const nK={todo:"To Do","in-progress":"In Progress","in-review":"In Review",done:"Done",blocked:"Blocked","on-hold":"On Hold",urgent:"Urgent"};function bht(e){return nK[e]?nK[e]:e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function yht({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(QI,{className:"w-4 h-4 text-muted-foreground"}),h.jsxs(ei,{value:r,onValueChange:o,children:[h.jsx($o,{className:"w-[150px]",children:h.jsx(ti,{placeholder:"Status"})}),h.jsxs(Uo,{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(ei,{value:i,onValueChange:s,children:[h.jsx($o,{className:"w-[200px]",children:h.jsx(ti,{placeholder:"Parent"})}),h.jsxs(Uo,{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(Ho,{className:"mr-2 h-4 w-4"}),"New Task"]})]}),h.jsx(Yr,{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:[bht(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(vde,{status:v.status}),h.jsx(Ede,{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 A=new Set(a);w?A.delete(v.id):A.add(v.id),l(A)},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(hK,{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(wde,{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 xht({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(vbe,{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(ybe,{className:"h-4 w-4 mr-2"}),"Grouped"]})]})})]}),h.jsx("div",{className:"flex-1 overflow-hidden",children:s==="table"?h.jsx(Yr,{className:"h-full",children:h.jsx("div",{className:"pr-4",children:h.jsx(Zpt,{tasks:e,onTaskClick:m,onSelectionChange:f,onNewTask:i})})}):h.jsx(yht,{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(qde,{task:l,allTasks:e,onClose:()=>{c(null),o&&o()},onUpdate:n,onNavigateToTask:g})]})}const vht=e=>e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^(.)/,t=>t.toUpperCase()),Eht=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),wht=e=>e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^(.)/,t=>t.toLowerCase());function Sht(){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,A]=x.useState(null),[R,_]=x.useState(!1),[D,I]=x.useState(""),[L,j]=x.useState(""),[O,F]=x.useState(""),[U,Y]=x.useState(!1),[$,G]=x.useState(!1),[H,X]=x.useState(new Set),[Z,J]=x.useState({}),[B,W]=x.useState(new Set),K=x.useMemo(()=>o?o.prompts.filter(se=>se.required).every(se=>u[se.name]?.trim()):!1,[o,u]),P=x.useCallback(se=>{let Ce=se;for(const[Be,Pe]of Object.entries(u))Pe&&(Ce=Ce.replace(new RegExp(`\\{\\{\\s*${Be}\\s*\\}\\}`,"g"),Pe).replace(new RegExp(`\\{\\{\\s*pascalCase\\s+${Be}\\s*\\}\\}`,"g"),vht(Pe)).replace(new RegExp(`\\{\\{\\s*camelCase\\s+${Be}\\s*\\}\\}`,"g"),wht(Pe)).replace(new RegExp(`\\{\\{\\s*kebabCase\\s+${Be}\\s*\\}\\}`,"g"),Eht(Pe)));return Ce},[u]),le=x.useMemo(()=>o?o.files.map(se=>{if(se.type==="add"){const Be=P(se.destination);return{type:"add",destination:se.destination,preview:Be,condition:se.condition,template:se.template}}const Ce=P(se.destination);return{type:"addMany",destination:se.destination,preview:Ce,condition:se.condition,source:se.source,globPattern:se.globPattern}}):[],[o,P]),ae=x.useCallback(async()=>{try{const se=await Dg.list();t(se.templates)}catch(se){console.error("Failed to load templates:",se)}finally{r(!1)}},[]);x.useEffect(()=>{ae()},[ae]),es("templates:created",()=>{ae()}),es("templates:run",()=>{});const de=x.useCallback(()=>{if(e.length===0)return;const Ce=window.location.hash.match(/^#\/templates\/(.+)$/);if(Ce){const Be=decodeURIComponent(Ce[1]);Be!==s&&ie(Be)}},[e,s]);x.useEffect(()=>{de()},[de]),x.useEffect(()=>(window.addEventListener("hashchange",de),()=>window.removeEventListener("hashchange",de)),[de]);const ie=async se=>{c(!0),S(null),A(null),a(se);try{const Ce=await Dg.get(se);i(Ce.template);const Be={};for(const Pe of Ce.template.prompts)Pe.default!==void 0?Be[Pe.name]=String(Pe.default):Pe.type==="confirm"?Be[Pe.name]="false":Be[Pe.name]="";f(Be)}catch(Ce){console.error("Failed to load template:",Ce),i(null)}finally{c(!1)}},ue=se=>{window.location.hash=`/templates/${encodeURIComponent(se)}`},re=()=>{if(o){const se=`@template/${o.name}`;navigator.clipboard.writeText(se).then(()=>{G(!0),setTimeout(()=>G(!1),2e3)})}},be=async()=>{if(o){v(!0),S(null),A(null);try{const se=await Dg.run(o.name,u,m);S(se)}catch(se){A(se instanceof Error?se.message:String(se))}finally{v(!1)}}},Oe=async()=>{if(D.trim()){Y(!0);try{await Dg.create({name:D,description:L||void 0,doc:O||void 0}),I(""),j(""),F(""),_(!1),ae()}catch(se){console.error("Failed to create template:",se),alert(se instanceof Error?se.message:"Failed to create template")}finally{Y(!1)}}},we=()=>{o?.doc&&(window.location.hash=`/docs/${o.doc}.md`)},Re=async se=>{const Ce=new Set(H);if(H.has(se))Ce.delete(se),X(Ce);else if(Ce.add(se),X(Ce),!Z[se]&&o){W(Be=>new Set(Be).add(se));try{const Be=await Dg.previewFile(o.name,se,u);J(Pe=>({...Pe,[se]:Be.content}))}catch(Be){console.error("Failed to load preview:",Be),J(Pe=>({...Pe,[se]:`Error loading preview: ${Be instanceof Error?Be.message:String(Be)}`}))}finally{W(Be=>{const Pe=new Set(Be);return Pe.delete(se),Pe})}}};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(Ho,{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.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:["Available Templates (",e.length,")"]})}),h.jsx(Yr,{className:"flex-1",children:e.map(se=>h.jsxs("button",{type:"button",onClick:()=>ue(se.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===se.name?"bg-accent":""}`,children:[h.jsx(tb,{className:"w-5 h-5 mt-0.5 shrink-0 text-blue-500"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"font-medium truncate",children:se.name}),se.description&&h.jsx("div",{className:"text-sm text-muted-foreground line-clamp-2",children:se.description})]}),h.jsx(Fs,{className:"w-4 h-4 text-muted-foreground shrink-0"})]},se.name))})]}),e.length===0&&h.jsxs("div",{className:"bg-card rounded-lg border p-8 text-center",children:[h.jsx(tb,{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(Ho,{className:"w-4 h-4 mr-2"}),"Create your first template"]})]})]}),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(Gbe,{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:re,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(mK,{className:"w-3 h-3"}),h.jsxs("span",{className:"font-mono",children:["@template/",o.name]}),$&&h.jsx(so,{className:"w-3 h-3"})]}),o.doc&&h.jsxs("button",{type:"button",onClick:we,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(ni,{className:"w-3 h-3"}),h.jsx("span",{children:"View Documentation"})]})]})]})})}),h.jsx(Yr,{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(se=>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:se.name}),se.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"})]}),se.message&&h.jsx("p",{className:"text-sm text-muted-foreground -mt-1",children:se.message}),se.type==="confirm"?h.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30",children:[h.jsx(vh,{checked:u[se.name]==="true",onCheckedChange:Ce=>f(Be=>({...Be,[se.name]:Ce?"true":"false"}))}),h.jsx("span",{className:"text-sm",children:u[se.name]==="true"?"Yes":"No"})]}):se.choices?h.jsxs("select",{value:u[se.name]||"",onChange:Ce=>f(Be=>({...Be,[se.name]:Ce.target.value})),className:"w-full px-3 py-2 rounded-lg border bg-background",children:[h.jsx("option",{value:"",children:"-- Select an option --"}),se.choices.map(Ce=>h.jsx("option",{value:Ce.value,children:Ce.label},Ce.value))]}):h.jsx(Gn,{type:"text",value:u[se.name]||"",onChange:Ce=>f(Be=>({...Be,[se.name]:Ce.target.value})),placeholder:se.default!==void 0?`Default: ${se.default}`:`Enter ${se.name}...`,className:se.required&&!u[se.name]?.trim()?"border-orange-300 dark:border-orange-700":""})]},se.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(xE,{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((se,Ce)=>{const Be=se.type==="add",Pe=se.type==="add"?se.template:null,hn=Pe?H.has(Pe):!1,Mt=Pe?B.has(Pe):!1,vt=Pe?Z[Pe]:null;return h.jsxs("div",{className:"border-b last:border-b-0",children:[h.jsxs("button",{type:"button",onClick:()=>Be&&Pe&&Re(Pe),className:`w-full flex items-center gap-3 px-4 py-3 text-left ${Be?"hover:bg-accent/50 cursor-pointer":""}`,disabled:!Be,children:[Be?hn?h.jsx(Ps,{className:"w-4 h-4 text-muted-foreground shrink-0"}):h.jsx(Fs,{className:"w-4 h-4 text-muted-foreground shrink-0"}):null,se.type==="addMany"?h.jsx(xE,{className:"w-4 h-4 text-yellow-600 dark:text-yellow-500 shrink-0"}):h.jsx(tb,{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:se.type==="addMany"?`${se.preview}/${se.globPattern||"**/*.hbs"}`:se.preview}),se.preview!==se.destination&&h.jsxs("span",{className:"text-xs text-muted-foreground",children:["Pattern: ",se.destination]}),se.type==="addMany"&&h.jsx("span",{className:"text-xs text-blue-600 dark:text-blue-400 ml-2",children:"(multiple files)"})]}),se.condition&&h.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded shrink-0",children:"Conditional"}),Be&&h.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:hn?"Hide":"Preview"})]}),hn&&h.jsx("div",{className:"border-t bg-gray-950 dark:bg-gray-900",children:Mt?h.jsxs("div",{className:"p-4 flex items-center justify-center text-muted-foreground",children:[h.jsx(ru,{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:vt||"No content"})})})]},Ce)}),le.length===0&&h.jsxs("div",{className:"px-4 py-8 text-center text-muted-foreground",children:[h.jsx(Uge,{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(vh,{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:be,disabled:y||!K,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(Yb,{className:"w-4 h-4 mr-2"}),"Preview Result"]}):h.jsxs(h.Fragment,{children:[h.jsx(Zl,{className:"w-4 h-4 mr-2"}),"Generate Files"]})})]}),!K&&o.prompts.some(se=>se.required)&&h.jsxs("p",{className:"text-sm text-orange-600 dark:text-orange-400 mt-2 flex items-center gap-1",children:[h.jsx(qb,{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(qb,{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(Yb,{className:"w-6 h-6 text-blue-600 dark:text-blue-400 shrink-0"}):h.jsx(so,{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((se,Ce)=>h.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[se.skipped?h.jsx(Qo,{className:"w-4 h-4 text-muted-foreground shrink-0"}):h.jsx(so,{className:"w-4 h-4 text-green-600 shrink-0"}),h.jsx("code",{className:`font-mono ${se.skipped?"text-muted-foreground":""}`,children:se.path}),se.skipped&&se.skipReason&&h.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",se.skipReason,")"]})]},Ce))}),w.dryRun&&w.files.length>0&&h.jsxs(Le,{onClick:()=>{g(!1),be()},className:"mt-4 bg-green-600 hover:bg-green-700 text-white",children:[h.jsx(Zl,{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(tb,{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."})]})})]}),R&&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:D,onChange:se=>I(se.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:L,onChange:se=>j(se.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:se=>F(se.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),I(""),j(""),F("")},disabled:U,children:"Cancel"}),h.jsx(Le,{onClick:Oe,disabled:U||!D.trim(),className:"bg-green-700 hover:bg-green-800 text-white",children:U?"Creating...":"Create Template"})]})]})})]})}const ope=x.createContext({isDark:!1,toggle:()=>{}}),jm=()=>x.useContext(ope);function Cht(){const{config:e}=yf(),[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 I=localStorage.getItem("theme");return I?I==="dark":window.matchMedia("(prefers-color-scheme: dark)").matches}return!1}),f=()=>{const I=window.location.hash.slice(1);return I.startsWith("/tasks")?"tasks":I.startsWith("/docs")?"docs":I.startsWith("/templates")?"templates":I.startsWith("/imports")?"imports":I.startsWith("/config")?"config":(I.startsWith("/kanban")||I==="/"||I==="","kanban")},m=I=>{const L=window.location.hash.slice(1),j="(?:kanban|tasks)",O=L.match(new RegExp(`^/${j}/([^?]+)`))||L.match(/[?&]id=([^&]+)/);return O?O[1]:null},[g,y]=x.useState(f()),[v,w]=x.useState(window.location.hash);x.useEffect(()=>{const I=()=>{y(f()),w(window.location.hash)};return window.addEventListener("hashchange",I),()=>window.removeEventListener("hashchange",I)},[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 I=L=>{(L.metaKey||L.ctrlKey)&&L.key==="k"&&(L.preventDefault(),l(j=>!j))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[]),x.useEffect(()=>{ha.getTasks().then(I=>{n(I),o(!1)}).catch(I=>{console.error("Failed to load tasks:",I),o(!1)})},[]),es("tasks:updated",({task:I})=>{n(L=>{const j=L.findIndex(O=>O.id===I.id);if(j>=0){const O=[...L];return O[j]=I,O}return[...L,I]})}),es("tasks:refresh",()=>{ha.getTasks().then(n).catch(console.error)});const S=()=>{ha.getTasks().then(n).catch(console.error)},T=I=>{n(I)},A=async I=>{const L=!c;if(!document.startViewTransition||window.matchMedia("(prefers-reduced-motion: reduce)").matches){u(L);return}const j=I.clientX,O=I.clientY,F=Math.hypot(Math.max(j,window.innerWidth-j),Math.max(O,window.innerHeight-O));await document.startViewTransition(()=>{u(L)}).ready,document.documentElement.animate({clipPath:[`circle(0px at ${j}px ${O}px)`,`circle(${F}px at ${j}px ${O}px)`]},{duration:400,easing:"ease-out",pseudoElement:"::view-transition-new(root)"})},R=I=>{window.location.hash=`/kanban/${I.id}`},_=I=>{I?.path?window.location.hash=`/docs/${I.path}`:I?.filename?window.location.hash=`/docs/${I.filename}`:window.location.hash="/docs"},D=()=>{switch(g){case"kanban":return h.jsx(tK,{tasks:t,loading:r,onTasksUpdate:T,onNewTask:()=>s(!0)});case"tasks":{const I=m(),L=I?t.find(j=>j.id===I):null;return h.jsx(xht,{tasks:t,loading:r,onTasksUpdate:S,selectedTask:L,onTaskClose:()=>{window.location.hash="/tasks"},onNewTask:()=>s(!0)})}case"docs":return h.jsx(eht,{});case"templates":return h.jsx(Sht,{});case"imports":return h.jsx(mht,{});case"config":return h.jsx(Jpt,{});default:return h.jsx(tK,{tasks:t,loading:r,onTasksUpdate:T,onNewTask:()=>s(!0)})}};return h.jsxs(ope.Provider,{value:{isDark:c,toggle:A},children:[h.jsxs(Cfe,{children:[h.jsx(Oft,{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(kfe,{className:"-ml-1"}),h.jsx(Y0,{orientation:"vertical",className:"mr-2 h-4"}),h.jsx(nlt,{}),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(flt,{onTaskClick:I=>{window.location.hash=`/kanban/${I}`}}),h.jsx(clt,{isDark:c,onToggle:A,size:"sm"}),h.jsx(jft,{})]}),h.jsx("div",{className:"flex-1 w-full overflow-y-auto overflow-x-hidden",children:D()})]}),h.jsx(pft,{isOpen:i,allTasks:t,onClose:()=>s(!1),onCreated:S}),h.jsx(Uft,{open:a,onOpenChange:l,onTaskSelect:R,onDocSelect:_})]}),h.jsx(age,{})]})}function Tht(){return h.jsx(l0e,{children:h.jsx(cCe,{children:h.jsx(dCe,{children:h.jsx(cge,{children:h.jsx(Jat,{children:h.jsx(Cht,{})})})})})})}const ipe=document.getElementById("root");if(!ipe)throw new Error("Root element not found");oK.createRoot(ipe).render(h.jsx(Tht,{}));
|