md-task-viewer 0.1.2 → 0.1.3

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.
@@ -50,7 +50,7 @@ Error generating stack: `+n.message+`
50
50
  To pick up a draggable item, press the space bar.
51
51
  While dragging, use the arrow keys to move the item.
52
52
  Press space again to drop the item in its new position, or press escape to cancel.
53
- `},ly={onDragStart(i){let{active:f}=i;return"Picked up draggable item "+f.id+"."},onDragOver(i){let{active:f,over:o}=i;return o?"Draggable item "+f.id+" was moved over droppable area "+o.id+".":"Draggable item "+f.id+" is no longer over a droppable area."},onDragEnd(i){let{active:f,over:o}=i;return o?"Draggable item "+f.id+" was dropped over droppable area "+o.id:"Draggable item "+f.id+" was dropped."},onDragCancel(i){let{active:f}=i;return"Dragging was cancelled. Draggable item "+f.id+" was dropped."}};function ny(i){let{announcements:f=ly,container:o,hiddenTextDescribedById:s,screenReaderInstructions:d=ey}=i;const{announce:g,announcement:y}=Ig(),S=Du("DndLiveRegion"),[E,m]=x.useState(!1);if(x.useEffect(()=>{m(!0)},[]),Pg(x.useMemo(()=>({onDragStart(M){let{active:Y}=M;g(f.onDragStart({active:Y}))},onDragMove(M){let{active:Y,over:w}=M;f.onDragMove&&g(f.onDragMove({active:Y,over:w}))},onDragOver(M){let{active:Y,over:w}=M;g(f.onDragOver({active:Y,over:w}))},onDragEnd(M){let{active:Y,over:w}=M;g(f.onDragEnd({active:Y,over:w}))},onDragCancel(M){let{active:Y,over:w}=M;g(f.onDragCancel({active:Y,over:w}))}}),[g,f])),!E)return null;const _=ve.createElement(ve.Fragment,null,ve.createElement($g,{id:s,value:d.draggable}),ve.createElement(Fg,{id:S,announcement:y}));return o?hu.createPortal(_,o):_}var $t;(function(i){i.DragStart="dragStart",i.DragMove="dragMove",i.DragEnd="dragEnd",i.DragCancel="dragCancel",i.DragOver="dragOver",i.RegisterDroppable="registerDroppable",i.SetDroppableDisabled="setDroppableDisabled",i.UnregisterDroppable="unregisterDroppable"})($t||($t={}));function Vi(){}function Xh(i,f){return x.useMemo(()=>({sensor:i,options:f??{}}),[i,f])}function ay(){for(var i=arguments.length,f=new Array(i),o=0;o<i;o++)f[o]=arguments[o];return x.useMemo(()=>[...f].filter(s=>s!=null),[...f])}const nl=Object.freeze({x:0,y:0});function nv(i,f){return Math.sqrt(Math.pow(i.x-f.x,2)+Math.pow(i.y-f.y,2))}function av(i,f){let{data:{value:o}}=i,{data:{value:s}}=f;return o-s}function uy(i,f){let{data:{value:o}}=i,{data:{value:s}}=f;return s-o}function wh(i){let{left:f,top:o,height:s,width:d}=i;return[{x:f,y:o},{x:f+d,y:o},{x:f,y:o+s},{x:f+d,y:o+s}]}function uv(i,f){if(!i||i.length===0)return null;const[o]=i;return o[f]}function Gh(i,f,o){return f===void 0&&(f=i.left),o===void 0&&(o=i.top),{x:f+i.width*.5,y:o+i.height*.5}}const iy=i=>{let{collisionRect:f,droppableRects:o,droppableContainers:s}=i;const d=Gh(f,f.left,f.top),g=[];for(const y of s){const{id:S}=y,E=o.get(S);if(E){const m=nv(Gh(E),d);g.push({id:S,data:{droppableContainer:y,value:m}})}}return g.sort(av)},cy=i=>{let{collisionRect:f,droppableRects:o,droppableContainers:s}=i;const d=wh(f),g=[];for(const y of s){const{id:S}=y,E=o.get(S);if(E){const m=wh(E),_=d.reduce((Y,w,P)=>Y+nv(m[P],w),0),M=Number((_/4).toFixed(4));g.push({id:S,data:{droppableContainer:y,value:M}})}}return g.sort(av)};function fy(i,f){const o=Math.max(f.top,i.top),s=Math.max(f.left,i.left),d=Math.min(f.left+f.width,i.left+i.width),g=Math.min(f.top+f.height,i.top+i.height),y=d-s,S=g-o;if(s<d&&o<g){const E=f.width*f.height,m=i.width*i.height,_=y*S,M=_/(E+m-_);return Number(M.toFixed(4))}return 0}const sy=i=>{let{collisionRect:f,droppableRects:o,droppableContainers:s}=i;const d=[];for(const g of s){const{id:y}=g,S=o.get(y);if(S){const E=fy(S,f);E>0&&d.push({id:y,data:{droppableContainer:g,value:E}})}}return d.sort(uy)};function oy(i,f,o){return{...i,scaleX:f&&o?f.width/o.width:1,scaleY:f&&o?f.height/o.height:1}}function iv(i,f){return i&&f?{x:i.left-f.left,y:i.top-f.top}:nl}function ry(i){return function(o){for(var s=arguments.length,d=new Array(s>1?s-1:0),g=1;g<s;g++)d[g-1]=arguments[g];return d.reduce((y,S)=>({...y,top:y.top+i*S.y,bottom:y.bottom+i*S.y,left:y.left+i*S.x,right:y.right+i*S.x}),{...o})}}const dy=ry(1);function hy(i){if(i.startsWith("matrix3d(")){const f=i.slice(9,-1).split(/, /);return{x:+f[12],y:+f[13],scaleX:+f[0],scaleY:+f[5]}}else if(i.startsWith("matrix(")){const f=i.slice(7,-1).split(/, /);return{x:+f[4],y:+f[5],scaleX:+f[0],scaleY:+f[3]}}return null}function vy(i,f,o){const s=hy(f);if(!s)return i;const{scaleX:d,scaleY:g,x:y,y:S}=s,E=i.left-y-(1-d)*parseFloat(o),m=i.top-S-(1-g)*parseFloat(o.slice(o.indexOf(" ")+1)),_=d?i.width/d:i.width,M=g?i.height/g:i.height;return{width:_,height:M,top:m,right:E+_,bottom:m+M,left:E}}const gy={ignoreTransform:!1};function ba(i,f){f===void 0&&(f=gy);let o=i.getBoundingClientRect();if(f.ignoreTransform){const{transform:m,transformOrigin:_}=ze(i).getComputedStyle(i);m&&(o=vy(o,m,_))}const{top:s,left:d,width:g,height:y,bottom:S,right:E}=o;return{top:s,left:d,width:g,height:y,bottom:S,right:E}}function Lh(i){return ba(i,{ignoreTransform:!0})}function yy(i){const f=i.innerWidth,o=i.innerHeight;return{top:0,left:0,right:f,bottom:o,width:f,height:o}}function my(i,f){return f===void 0&&(f=ze(i).getComputedStyle(i)),f.position==="fixed"}function by(i,f){f===void 0&&(f=ze(i).getComputedStyle(i));const o=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(d=>{const g=f[d];return typeof g=="string"?o.test(g):!1})}function ki(i,f){const o=[];function s(d){if(f!=null&&o.length>=f||!d)return o;if(Cs(d)&&d.scrollingElement!=null&&!o.includes(d.scrollingElement))return o.push(d.scrollingElement),o;if(!Eu(d)||tv(d)||o.includes(d))return o;const g=ze(i).getComputedStyle(d);return d!==i&&by(d,g)&&o.push(d),my(d,g)?o:s(d.parentNode)}return i?s(i):o}function cv(i){const[f]=ki(i,1);return f??null}function bs(i){return!Wi||!i?null:ya(i)?i:xs(i)?Cs(i)||i===ma(i).scrollingElement?window:Eu(i)?i:null:null}function fv(i){return ya(i)?i.scrollX:i.scrollLeft}function sv(i){return ya(i)?i.scrollY:i.scrollTop}function Ds(i){return{x:fv(i),y:sv(i)}}var te;(function(i){i[i.Forward=1]="Forward",i[i.Backward=-1]="Backward"})(te||(te={}));function ov(i){return!Wi||!i?!1:i===document.scrollingElement}function rv(i){const f={x:0,y:0},o=ov(i)?{height:window.innerHeight,width:window.innerWidth}:{height:i.clientHeight,width:i.clientWidth},s={x:i.scrollWidth-o.width,y:i.scrollHeight-o.height},d=i.scrollTop<=f.y,g=i.scrollLeft<=f.x,y=i.scrollTop>=s.y,S=i.scrollLeft>=s.x;return{isTop:d,isLeft:g,isBottom:y,isRight:S,maxScroll:s,minScroll:f}}const py={x:.2,y:.2};function Sy(i,f,o,s,d){let{top:g,left:y,right:S,bottom:E}=o;s===void 0&&(s=10),d===void 0&&(d=py);const{isTop:m,isBottom:_,isLeft:M,isRight:Y}=rv(i),w={x:0,y:0},P={x:0,y:0},X={height:f.height*d.y,width:f.width*d.x};return!m&&g<=f.top+X.height?(w.y=te.Backward,P.y=s*Math.abs((f.top+X.height-g)/X.height)):!_&&E>=f.bottom-X.height&&(w.y=te.Forward,P.y=s*Math.abs((f.bottom-X.height-E)/X.height)),!Y&&S>=f.right-X.width?(w.x=te.Forward,P.x=s*Math.abs((f.right-X.width-S)/X.width)):!M&&y<=f.left+X.width&&(w.x=te.Backward,P.x=s*Math.abs((f.left+X.width-y)/X.width)),{direction:w,speed:P}}function Ey(i){if(i===document.scrollingElement){const{innerWidth:g,innerHeight:y}=window;return{top:0,left:0,right:g,bottom:y,width:g,height:y}}const{top:f,left:o,right:s,bottom:d}=i.getBoundingClientRect();return{top:f,left:o,right:s,bottom:d,width:i.clientWidth,height:i.clientHeight}}function dv(i){return i.reduce((f,o)=>ga(f,Ds(o)),nl)}function Ty(i){return i.reduce((f,o)=>f+fv(o),0)}function Dy(i){return i.reduce((f,o)=>f+sv(o),0)}function Ay(i,f){if(f===void 0&&(f=ba),!i)return;const{top:o,left:s,bottom:d,right:g}=f(i);cv(i)&&(d<=0||g<=0||o>=window.innerHeight||s>=window.innerWidth)&&i.scrollIntoView({block:"center",inline:"center"})}const zy=[["x",["left","right"],Ty],["y",["top","bottom"],Dy]];class _s{constructor(f,o){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 s=ki(o),d=dv(s);this.rect={...f},this.width=f.width,this.height=f.height;for(const[g,y,S]of zy)for(const E of y)Object.defineProperty(this,E,{get:()=>{const m=S(s),_=d[g]-m;return this.rect[E]+_},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class vu{constructor(f){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(o=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...o)})},this.target=f}add(f,o,s){var d;(d=this.target)==null||d.addEventListener(f,o,s),this.listeners.push([f,o,s])}}function My(i){const{EventTarget:f}=ze(i);return i instanceof f?i:ma(i)}function ps(i,f){const o=Math.abs(i.x),s=Math.abs(i.y);return typeof f=="number"?Math.sqrt(o**2+s**2)>f:"x"in f&&"y"in f?o>f.x&&s>f.y:"x"in f?o>f.x:"y"in f?s>f.y:!1}var $e;(function(i){i.Click="click",i.DragStart="dragstart",i.Keydown="keydown",i.ContextMenu="contextmenu",i.Resize="resize",i.SelectionChange="selectionchange",i.VisibilityChange="visibilitychange"})($e||($e={}));function Qh(i){i.preventDefault()}function Oy(i){i.stopPropagation()}var pt;(function(i){i.Space="Space",i.Down="ArrowDown",i.Right="ArrowRight",i.Left="ArrowLeft",i.Up="ArrowUp",i.Esc="Escape",i.Enter="Enter",i.Tab="Tab"})(pt||(pt={}));const hv={start:[pt.Space,pt.Enter],cancel:[pt.Esc],end:[pt.Space,pt.Enter,pt.Tab]},xy=(i,f)=>{let{currentCoordinates:o}=f;switch(i.code){case pt.Right:return{...o,x:o.x+25};case pt.Left:return{...o,x:o.x-25};case pt.Down:return{...o,y:o.y+25};case pt.Up:return{...o,y:o.y-25}}};class Us{constructor(f){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=f;const{event:{target:o}}=f;this.props=f,this.listeners=new vu(ma(o)),this.windowListeners=new vu(ze(o)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add($e.Resize,this.handleCancel),this.windowListeners.add($e.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add($e.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:f,onStart:o}=this.props,s=f.node.current;s&&Ay(s),o(nl)}handleKeyDown(f){if(Ns(f)){const{active:o,context:s,options:d}=this.props,{keyboardCodes:g=hv,coordinateGetter:y=xy,scrollBehavior:S="smooth"}=d,{code:E}=f;if(g.end.includes(E)){this.handleEnd(f);return}if(g.cancel.includes(E)){this.handleCancel(f);return}const{collisionRect:m}=s.current,_=m?{x:m.left,y:m.top}:nl;this.referenceCoordinates||(this.referenceCoordinates=_);const M=y(f,{active:o,context:s.current,currentCoordinates:_});if(M){const Y=bu(M,_),w={x:0,y:0},{scrollableAncestors:P}=s.current;for(const X of P){const Z=f.code,{isTop:V,isRight:at,isLeft:W,isBottom:et,maxScroll:it,minScroll:$}=rv(X),Q=Ey(X),nt={x:Math.min(Z===pt.Right?Q.right-Q.width/2:Q.right,Math.max(Z===pt.Right?Q.left:Q.left+Q.width/2,M.x)),y:Math.min(Z===pt.Down?Q.bottom-Q.height/2:Q.bottom,Math.max(Z===pt.Down?Q.top:Q.top+Q.height/2,M.y))},ot=Z===pt.Right&&!at||Z===pt.Left&&!W,Rt=Z===pt.Down&&!et||Z===pt.Up&&!V;if(ot&&nt.x!==M.x){const rt=X.scrollLeft+Y.x,Mt=Z===pt.Right&&rt<=it.x||Z===pt.Left&&rt>=$.x;if(Mt&&!Y.y){X.scrollTo({left:rt,behavior:S});return}Mt?w.x=X.scrollLeft-rt:w.x=Z===pt.Right?X.scrollLeft-it.x:X.scrollLeft-$.x,w.x&&X.scrollBy({left:-w.x,behavior:S});break}else if(Rt&&nt.y!==M.y){const rt=X.scrollTop+Y.y,Mt=Z===pt.Down&&rt<=it.y||Z===pt.Up&&rt>=$.y;if(Mt&&!Y.x){X.scrollTo({top:rt,behavior:S});return}Mt?w.y=X.scrollTop-rt:w.y=Z===pt.Down?X.scrollTop-it.y:X.scrollTop-$.y,w.y&&X.scrollBy({top:-w.y,behavior:S});break}}this.handleMove(f,ga(bu(M,this.referenceCoordinates),w))}}}handleMove(f,o){const{onMove:s}=this.props;f.preventDefault(),s(o)}handleEnd(f){const{onEnd:o}=this.props;f.preventDefault(),this.detach(),o()}handleCancel(f){const{onCancel:o}=this.props;f.preventDefault(),this.detach(),o()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Us.activators=[{eventName:"onKeyDown",handler:(i,f,o)=>{let{keyboardCodes:s=hv,onActivation:d}=f,{active:g}=o;const{code:y}=i.nativeEvent;if(s.start.includes(y)){const S=g.activatorNode.current;return S&&i.target!==S?!1:(i.preventDefault(),d==null||d({event:i.nativeEvent}),!0)}return!1}}];function Zh(i){return!!(i&&"distance"in i)}function Vh(i){return!!(i&&"delay"in i)}class js{constructor(f,o,s){var d;s===void 0&&(s=My(f.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=f,this.events=o;const{event:g}=f,{target:y}=g;this.props=f,this.events=o,this.document=ma(y),this.documentListeners=new vu(this.document),this.listeners=new vu(s),this.windowListeners=new vu(ze(y)),this.initialCoordinates=(d=Ts(g))!=null?d:nl,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:f,props:{options:{activationConstraint:o,bypassActivationConstraint:s}}}=this;if(this.listeners.add(f.move.name,this.handleMove,{passive:!1}),this.listeners.add(f.end.name,this.handleEnd),f.cancel&&this.listeners.add(f.cancel.name,this.handleCancel),this.windowListeners.add($e.Resize,this.handleCancel),this.windowListeners.add($e.DragStart,Qh),this.windowListeners.add($e.VisibilityChange,this.handleCancel),this.windowListeners.add($e.ContextMenu,Qh),this.documentListeners.add($e.Keydown,this.handleKeydown),o){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Vh(o)){this.timeoutId=setTimeout(this.handleStart,o.delay),this.handlePending(o);return}if(Zh(o)){this.handlePending(o);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(f,o){const{active:s,onPending:d}=this.props;d(s,f,this.initialCoordinates,o)}handleStart(){const{initialCoordinates:f}=this,{onStart:o}=this.props;f&&(this.activated=!0,this.documentListeners.add($e.Click,Oy,{capture:!0}),this.removeTextSelection(),this.documentListeners.add($e.SelectionChange,this.removeTextSelection),o(f))}handleMove(f){var o;const{activated:s,initialCoordinates:d,props:g}=this,{onMove:y,options:{activationConstraint:S}}=g;if(!d)return;const E=(o=Ts(f))!=null?o:nl,m=bu(d,E);if(!s&&S){if(Zh(S)){if(S.tolerance!=null&&ps(m,S.tolerance))return this.handleCancel();if(ps(m,S.distance))return this.handleStart()}if(Vh(S)&&ps(m,S.tolerance))return this.handleCancel();this.handlePending(S,m);return}f.cancelable&&f.preventDefault(),y(E)}handleEnd(){const{onAbort:f,onEnd:o}=this.props;this.detach(),this.activated||f(this.props.active),o()}handleCancel(){const{onAbort:f,onCancel:o}=this.props;this.detach(),this.activated||f(this.props.active),o()}handleKeydown(f){f.code===pt.Esc&&this.handleCancel()}removeTextSelection(){var f;(f=this.document.getSelection())==null||f.removeAllRanges()}}const Cy={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Hs extends js{constructor(f){const{event:o}=f,s=ma(o.target);super(f,Cy,s)}}Hs.activators=[{eventName:"onPointerDown",handler:(i,f)=>{let{nativeEvent:o}=i,{onActivation:s}=f;return!o.isPrimary||o.button!==0?!1:(s==null||s({event:o}),!0)}}];const Ry={move:{name:"mousemove"},end:{name:"mouseup"}};var As;(function(i){i[i.RightClick=2]="RightClick"})(As||(As={}));class Ny extends js{constructor(f){super(f,Ry,ma(f.event.target))}}Ny.activators=[{eventName:"onMouseDown",handler:(i,f)=>{let{nativeEvent:o}=i,{onActivation:s}=f;return o.button===As.RightClick?!1:(s==null||s({event:o}),!0)}}];const Ss={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class _y extends js{constructor(f){super(f,Ss)}static setup(){return window.addEventListener(Ss.move.name,f,{capture:!1,passive:!1}),function(){window.removeEventListener(Ss.move.name,f)};function f(){}}}_y.activators=[{eventName:"onTouchStart",handler:(i,f)=>{let{nativeEvent:o}=i,{onActivation:s}=f;const{touches:d}=o;return d.length>1?!1:(s==null||s({event:o}),!0)}}];var gu;(function(i){i[i.Pointer=0]="Pointer",i[i.DraggableRect=1]="DraggableRect"})(gu||(gu={}));var Ki;(function(i){i[i.TreeOrder=0]="TreeOrder",i[i.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ki||(Ki={}));function Uy(i){let{acceleration:f,activator:o=gu.Pointer,canScroll:s,draggingRect:d,enabled:g,interval:y=5,order:S=Ki.TreeOrder,pointerCoordinates:E,scrollableAncestors:m,scrollableAncestorRects:_,delta:M,threshold:Y}=i;const w=Hy({delta:M,disabled:!g}),[P,X]=Vg(),Z=x.useRef({x:0,y:0}),V=x.useRef({x:0,y:0}),at=x.useMemo(()=>{switch(o){case gu.Pointer:return E?{top:E.y,bottom:E.y,left:E.x,right:E.x}:null;case gu.DraggableRect:return d}},[o,d,E]),W=x.useRef(null),et=x.useCallback(()=>{const $=W.current;if(!$)return;const Q=Z.current.x*V.current.x,nt=Z.current.y*V.current.y;$.scrollBy(Q,nt)},[]),it=x.useMemo(()=>S===Ki.TreeOrder?[...m].reverse():m,[S,m]);x.useEffect(()=>{if(!g||!m.length||!at){X();return}for(const $ of it){if((s==null?void 0:s($))===!1)continue;const Q=m.indexOf($),nt=_[Q];if(!nt)continue;const{direction:ot,speed:Rt}=Sy($,nt,at,f,Y);for(const rt of["x","y"])w[rt][ot[rt]]||(Rt[rt]=0,ot[rt]=0);if(Rt.x>0||Rt.y>0){X(),W.current=$,P(et,y),Z.current=Rt,V.current=ot;return}}Z.current={x:0,y:0},V.current={x:0,y:0},X()},[f,et,s,X,g,y,JSON.stringify(at),JSON.stringify(w),P,m,it,_,JSON.stringify(Y)])}const jy={x:{[te.Backward]:!1,[te.Forward]:!1},y:{[te.Backward]:!1,[te.Forward]:!1}};function Hy(i){let{delta:f,disabled:o}=i;const s=Es(f);return Tu(d=>{if(o||!s||!d)return jy;const g={x:Math.sign(f.x-s.x),y:Math.sign(f.y-s.y)};return{x:{[te.Backward]:d.x[te.Backward]||g.x===-1,[te.Forward]:d.x[te.Forward]||g.x===1},y:{[te.Backward]:d.y[te.Backward]||g.y===-1,[te.Forward]:d.y[te.Forward]||g.y===1}}},[o,f,s])}function By(i,f){const o=f!=null?i.get(f):void 0,s=o?o.node.current:null;return Tu(d=>{var g;return f==null?null:(g=s??d)!=null?g:null},[s,f])}function qy(i,f){return x.useMemo(()=>i.reduce((o,s)=>{const{sensor:d}=s,g=d.activators.map(y=>({eventName:y.eventName,handler:f(y.handler,s)}));return[...o,...g]},[]),[i,f])}var Su;(function(i){i[i.Always=0]="Always",i[i.BeforeDragging=1]="BeforeDragging",i[i.WhileDragging=2]="WhileDragging"})(Su||(Su={}));var zs;(function(i){i.Optimized="optimized"})(zs||(zs={}));const Kh=new Map;function Yy(i,f){let{dragging:o,dependencies:s,config:d}=f;const[g,y]=x.useState(null),{frequency:S,measure:E,strategy:m}=d,_=x.useRef(i),M=Z(),Y=mu(M),w=x.useCallback(function(V){V===void 0&&(V=[]),!Y.current&&y(at=>at===null?V:at.concat(V.filter(W=>!at.includes(W))))},[Y]),P=x.useRef(null),X=Tu(V=>{if(M&&!o)return Kh;if(!V||V===Kh||_.current!==i||g!=null){const at=new Map;for(let W of i){if(!W)continue;if(g&&g.length>0&&!g.includes(W.id)&&W.rect.current){at.set(W.id,W.rect.current);continue}const et=W.node.current,it=et?new _s(E(et),et):null;W.rect.current=it,it&&at.set(W.id,it)}return at}return V},[i,g,o,M,E]);return x.useEffect(()=>{_.current=i},[i]),x.useEffect(()=>{M||w()},[o,M]),x.useEffect(()=>{g&&g.length>0&&y(null)},[JSON.stringify(g)]),x.useEffect(()=>{M||typeof S!="number"||P.current!==null||(P.current=setTimeout(()=>{w(),P.current=null},S))},[S,M,w,...s]),{droppableRects:X,measureDroppableContainers:w,measuringScheduled:g!=null};function Z(){switch(m){case Su.Always:return!1;case Su.BeforeDragging:return o;default:return!o}}}function vv(i,f){return Tu(o=>i?o||(typeof f=="function"?f(i):i):null,[f,i])}function Xy(i,f){return vv(i,f)}function wy(i){let{callback:f,disabled:o}=i;const s=Rs(f),d=x.useMemo(()=>{if(o||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:g}=window;return new g(s)},[s,o]);return x.useEffect(()=>()=>d==null?void 0:d.disconnect(),[d]),d}function $i(i){let{callback:f,disabled:o}=i;const s=Rs(f),d=x.useMemo(()=>{if(o||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:g}=window;return new g(s)},[o]);return x.useEffect(()=>()=>d==null?void 0:d.disconnect(),[d]),d}function Gy(i){return new _s(ba(i),i)}function Jh(i,f,o){f===void 0&&(f=Gy);const[s,d]=x.useState(null);function g(){d(E=>{if(!i)return null;if(i.isConnected===!1){var m;return(m=E??o)!=null?m:null}const _=f(i);return JSON.stringify(E)===JSON.stringify(_)?E:_})}const y=wy({callback(E){if(i)for(const m of E){const{type:_,target:M}=m;if(_==="childList"&&M instanceof HTMLElement&&M.contains(i)){g();break}}}}),S=$i({callback:g});return rl(()=>{g(),i?(S==null||S.observe(i),y==null||y.observe(document.body,{childList:!0,subtree:!0})):(S==null||S.disconnect(),y==null||y.disconnect())},[i]),s}function Ly(i){const f=vv(i);return iv(i,f)}const Wh=[];function Qy(i){const f=x.useRef(i),o=Tu(s=>i?s&&s!==Wh&&i&&f.current&&i.parentNode===f.current.parentNode?s:ki(i):Wh,[i]);return x.useEffect(()=>{f.current=i},[i]),o}function Zy(i){const[f,o]=x.useState(null),s=x.useRef(i),d=x.useCallback(g=>{const y=bs(g.target);y&&o(S=>S?(S.set(y,Ds(y)),new Map(S)):null)},[]);return x.useEffect(()=>{const g=s.current;if(i!==g){y(g);const S=i.map(E=>{const m=bs(E);return m?(m.addEventListener("scroll",d,{passive:!0}),[m,Ds(m)]):null}).filter(E=>E!=null);o(S.length?new Map(S):null),s.current=i}return()=>{y(i),y(g)};function y(S){S.forEach(E=>{const m=bs(E);m==null||m.removeEventListener("scroll",d)})}},[d,i]),x.useMemo(()=>i.length?f?Array.from(f.values()).reduce((g,y)=>ga(g,y),nl):dv(i):nl,[i,f])}function kh(i,f){f===void 0&&(f=[]);const o=x.useRef(null);return x.useEffect(()=>{o.current=null},f),x.useEffect(()=>{const s=i!==nl;s&&!o.current&&(o.current=i),!s&&o.current&&(o.current=null)},[i]),o.current?bu(i,o.current):nl}function Vy(i){x.useEffect(()=>{if(!Wi)return;const f=i.map(o=>{let{sensor:s}=o;return s.setup==null?void 0:s.setup()});return()=>{for(const o of f)o==null||o()}},i.map(f=>{let{sensor:o}=f;return o}))}function Ky(i,f){return x.useMemo(()=>i.reduce((o,s)=>{let{eventName:d,handler:g}=s;return o[d]=y=>{g(y,f)},o},{}),[i,f])}function gv(i){return x.useMemo(()=>i?yy(i):null,[i])}const $h=[];function Jy(i,f){f===void 0&&(f=ba);const[o]=i,s=gv(o?ze(o):null),[d,g]=x.useState($h);function y(){g(()=>i.length?i.map(E=>ov(E)?s:new _s(f(E),E)):$h)}const S=$i({callback:y});return rl(()=>{S==null||S.disconnect(),y(),i.forEach(E=>S==null?void 0:S.observe(E))},[i]),d}function Wy(i){if(!i)return null;if(i.children.length>1)return i;const f=i.children[0];return Eu(f)?f:i}function ky(i){let{measure:f}=i;const[o,s]=x.useState(null),d=x.useCallback(m=>{for(const{target:_}of m)if(Eu(_)){s(M=>{const Y=f(_);return M?{...M,width:Y.width,height:Y.height}:Y});break}},[f]),g=$i({callback:d}),y=x.useCallback(m=>{const _=Wy(m);g==null||g.disconnect(),_&&(g==null||g.observe(_)),s(_?f(_):null)},[f,g]),[S,E]=Zi(y);return x.useMemo(()=>({nodeRef:S,rect:o,setRef:E}),[o,S,E])}const $y=[{sensor:Hs,options:{}},{sensor:Us,options:{}}],Fy={current:{}},Qi={draggable:{measure:Lh},droppable:{measure:Lh,strategy:Su.WhileDragging,frequency:zs.Optimized},dragOverlay:{measure:ba}};class yu extends Map{get(f){var o;return f!=null&&(o=super.get(f))!=null?o:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(f=>{let{disabled:o}=f;return!o})}getNodeFor(f){var o,s;return(o=(s=this.get(f))==null?void 0:s.node.current)!=null?o:void 0}}const Iy={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new yu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Vi},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Qi,measureDroppableContainers:Vi,windowRect:null,measuringScheduled:!1},Py={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Vi,draggableNodes:new Map,over:null,measureDroppableContainers:Vi},Fi=x.createContext(Py),yv=x.createContext(Iy);function tm(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new yu}}}function em(i,f){switch(f.type){case $t.DragStart:return{...i,draggable:{...i.draggable,initialCoordinates:f.initialCoordinates,active:f.active}};case $t.DragMove:return i.draggable.active==null?i:{...i,draggable:{...i.draggable,translate:{x:f.coordinates.x-i.draggable.initialCoordinates.x,y:f.coordinates.y-i.draggable.initialCoordinates.y}}};case $t.DragEnd:case $t.DragCancel:return{...i,draggable:{...i.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $t.RegisterDroppable:{const{element:o}=f,{id:s}=o,d=new yu(i.droppable.containers);return d.set(s,o),{...i,droppable:{...i.droppable,containers:d}}}case $t.SetDroppableDisabled:{const{id:o,key:s,disabled:d}=f,g=i.droppable.containers.get(o);if(!g||s!==g.key)return i;const y=new yu(i.droppable.containers);return y.set(o,{...g,disabled:d}),{...i,droppable:{...i.droppable,containers:y}}}case $t.UnregisterDroppable:{const{id:o,key:s}=f,d=i.droppable.containers.get(o);if(!d||s!==d.key)return i;const g=new yu(i.droppable.containers);return g.delete(o),{...i,droppable:{...i.droppable,containers:g}}}default:return i}}function lm(i){let{disabled:f}=i;const{active:o,activatorEvent:s,draggableNodes:d}=x.useContext(Fi),g=Es(s),y=Es(o==null?void 0:o.id);return x.useEffect(()=>{if(!f&&!s&&g&&y!=null){if(!Ns(g)||document.activeElement===g.target)return;const S=d.get(y);if(!S)return;const{activatorNode:E,node:m}=S;if(!E.current&&!m.current)return;requestAnimationFrame(()=>{for(const _ of[E.current,m.current]){if(!_)continue;const M=Wg(_);if(M){M.focus();break}}})}},[s,f,d,y,g]),null}function nm(i,f){let{transform:o,...s}=f;return i!=null&&i.length?i.reduce((d,g)=>g({transform:d,...s}),o):o}function am(i){return x.useMemo(()=>({draggable:{...Qi.draggable,...i==null?void 0:i.draggable},droppable:{...Qi.droppable,...i==null?void 0:i.droppable},dragOverlay:{...Qi.dragOverlay,...i==null?void 0:i.dragOverlay}}),[i==null?void 0:i.draggable,i==null?void 0:i.droppable,i==null?void 0:i.dragOverlay])}function um(i){let{activeNode:f,measure:o,initialRect:s,config:d=!0}=i;const g=x.useRef(!1),{x:y,y:S}=typeof d=="boolean"?{x:d,y:d}:d;rl(()=>{if(!y&&!S||!f){g.current=!1;return}if(g.current||!s)return;const m=f==null?void 0:f.node.current;if(!m||m.isConnected===!1)return;const _=o(m),M=iv(_,s);if(y||(M.x=0),S||(M.y=0),g.current=!0,Math.abs(M.x)>0||Math.abs(M.y)>0){const Y=cv(m);Y&&Y.scrollBy({top:M.y,left:M.x})}},[f,y,S,s,o])}const mv=x.createContext({...nl,scaleX:1,scaleY:1});var cn;(function(i){i[i.Uninitialized=0]="Uninitialized",i[i.Initializing=1]="Initializing",i[i.Initialized=2]="Initialized"})(cn||(cn={}));const im=x.memo(function(f){var o,s,d,g;let{id:y,accessibility:S,autoScroll:E=!0,children:m,sensors:_=$y,collisionDetection:M=sy,measuring:Y,modifiers:w,...P}=f;const X=x.useReducer(em,void 0,tm),[Z,V]=X,[at,W]=ty(),[et,it]=x.useState(cn.Uninitialized),$=et===cn.Initialized,{draggable:{active:Q,nodes:nt,translate:ot},droppable:{containers:Rt}}=Z,rt=Q!=null?nt.get(Q):null,Mt=x.useRef({initial:null,translated:null}),Yt=x.useMemo(()=>{var Xt;return Q!=null?{id:Q,data:(Xt=rt==null?void 0:rt.data)!=null?Xt:Fy,rect:Mt}:null},[Q,rt]),Ht=x.useRef(null),[Qt,R]=x.useState(null),[T,q]=x.useState(null),G=mu(P,Object.values(P)),tt=Du("DndDescribedBy",y),v=x.useMemo(()=>Rt.getEnabled(),[Rt]),O=am(Y),{droppableRects:B,measureDroppableContainers:L,measuringScheduled:F}=Yy(v,{dragging:$,dependencies:[ot.x,ot.y],config:O.droppable}),k=By(nt,Q),ct=x.useMemo(()=>T?Ts(T):null,[T]),Dt=Rn(),mt=Xy(k,O.draggable.measure);um({activeNode:Q!=null?nt.get(Q):null,config:Dt.layoutShiftCompensation,initialRect:mt,measure:O.draggable.measure});const dt=Jh(k,O.draggable.measure,mt),je=Jh(k?k.parentElement:null),ce=x.useRef({activatorEvent:null,active:null,activeNode:k,collisionRect:null,collisions:null,droppableRects:B,draggableNodes:nt,draggingNode:null,draggingNodeRect:null,droppableContainers:Rt,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),dl=Rt.getNodeFor((o=ce.current.over)==null?void 0:o.id),ee=ky({measure:O.dragOverlay.measure}),al=(s=ee.nodeRef.current)!=null?s:k,ul=$?(d=ee.rect)!=null?d:dt:null,Au=!!(ee.nodeRef.current&&ee.rect),pa=Ly(Au?null:dt),fn=gv(al?ze(al):null),He=Qy($?dl??k:null),jl=Jy(He),xn=nm(w,{transform:{x:ot.x-pa.x,y:ot.y-pa.y,scaleX:1,scaleY:1},activatorEvent:T,active:Yt,activeNodeRect:dt,containerNodeRect:je,draggingNodeRect:ul,over:ce.current.over,overlayNodeRect:ee.rect,scrollableAncestors:He,scrollableAncestorRects:jl,windowRect:fn}),zu=ct?ga(ct,ot):null,fe=Zy(He),Ii=kh(fe),Mu=kh(fe,[dt]),hl=ga(xn,Ii),Fe=ul?dy(ul,xn):null,sn=Yt&&Fe?M({active:Yt,collisionRect:Fe,droppableRects:B,droppableContainers:v,pointerCoordinates:zu}):null,Sa=uv(sn,"id"),[il,Ou]=x.useState(null),on=Au?xn:ga(xn,Mu),de=oy(on,(g=il==null?void 0:il.rect)!=null?g:null,dt),Be=x.useRef(null),se=x.useCallback((Xt,wt)=>{let{sensor:Ft,options:ge}=wt;if(Ht.current==null)return;const ye=nt.get(Ht.current);if(!ye)return;const oe=Xt.nativeEvent,me=new Ft({active:Ht.current,activeNode:ye,event:oe,options:ge,context:ce,onAbort(Wt){if(!nt.get(Wt))return;const{onDragAbort:Me}=G.current,Ye={id:Wt};Me==null||Me(Ye),at({type:"onDragAbort",event:Ye})},onPending(Wt,Ie,Me,Ye){if(!nt.get(Wt))return;const{onDragPending:gl}=G.current,Pe={id:Wt,constraint:Ie,initialCoordinates:Me,offset:Ye};gl==null||gl(Pe),at({type:"onDragPending",event:Pe})},onStart(Wt){const Ie=Ht.current;if(Ie==null)return;const Me=nt.get(Ie);if(!Me)return;const{onDragStart:Ye}=G.current,vl={activatorEvent:oe,active:{id:Ie,data:Me.data,rect:Mt}};hu.unstable_batchedUpdates(()=>{Ye==null||Ye(vl),it(cn.Initializing),V({type:$t.DragStart,initialCoordinates:Wt,active:Ie}),at({type:"onDragStart",event:vl}),R(Be.current),q(oe)})},onMove(Wt){V({type:$t.DragMove,coordinates:Wt})},onEnd:qe($t.DragEnd),onCancel:qe($t.DragCancel)});Be.current=me;function qe(Wt){return async function(){const{active:Me,collisions:Ye,over:vl,scrollAdjustedTranslate:gl}=ce.current;let Pe=null;if(Me&&gl){const{cancelDrop:Hl}=G.current;Pe={activatorEvent:oe,active:Me,collisions:Ye,delta:gl,over:vl},Wt===$t.DragEnd&&typeof Hl=="function"&&await Promise.resolve(Hl(Pe))&&(Wt=$t.DragCancel)}Ht.current=null,hu.unstable_batchedUpdates(()=>{V({type:Wt}),it(cn.Uninitialized),Ou(null),R(null),q(null),Be.current=null;const Hl=Wt===$t.DragEnd?"onDragEnd":"onDragCancel";if(Pe){const Xe=G.current[Hl];Xe==null||Xe(Pe),at({type:Hl,event:Pe})}})}}},[nt]),Pi=x.useCallback((Xt,wt)=>(Ft,ge)=>{const ye=Ft.nativeEvent,oe=nt.get(ge);if(Ht.current!==null||!oe||ye.dndKit||ye.defaultPrevented)return;const me={active:oe};Xt(Ft,wt.options,me)===!0&&(ye.dndKit={capturedBy:wt.sensor},Ht.current=ge,se(Ft,wt))},[nt,se]),xu=qy(_,Pi);Vy(_),rl(()=>{dt&&et===cn.Initializing&&it(cn.Initialized)},[dt,et]),x.useEffect(()=>{const{onDragMove:Xt}=G.current,{active:wt,activatorEvent:Ft,collisions:ge,over:ye}=ce.current;if(!wt||!Ft)return;const oe={active:wt,activatorEvent:Ft,collisions:ge,delta:{x:hl.x,y:hl.y},over:ye};hu.unstable_batchedUpdates(()=>{Xt==null||Xt(oe),at({type:"onDragMove",event:oe})})},[hl.x,hl.y]),x.useEffect(()=>{const{active:Xt,activatorEvent:wt,collisions:Ft,droppableContainers:ge,scrollAdjustedTranslate:ye}=ce.current;if(!Xt||Ht.current==null||!wt||!ye)return;const{onDragOver:oe}=G.current,me=ge.get(Sa),qe=me&&me.rect.current?{id:me.id,rect:me.rect.current,data:me.data,disabled:me.disabled}:null,Wt={active:Xt,activatorEvent:wt,collisions:Ft,delta:{x:ye.x,y:ye.y},over:qe};hu.unstable_batchedUpdates(()=>{Ou(qe),oe==null||oe(Wt),at({type:"onDragOver",event:Wt})})},[Sa]),rl(()=>{ce.current={activatorEvent:T,active:Yt,activeNode:k,collisionRect:Fe,collisions:sn,droppableRects:B,draggableNodes:nt,draggingNode:al,draggingNodeRect:ul,droppableContainers:Rt,over:il,scrollableAncestors:He,scrollAdjustedTranslate:hl},Mt.current={initial:ul,translated:Fe}},[Yt,k,sn,Fe,nt,al,ul,B,Rt,il,He,hl]),Uy({...Dt,delta:ot,draggingRect:Fe,pointerCoordinates:zu,scrollableAncestors:He,scrollableAncestorRects:jl});const tc=x.useMemo(()=>({active:Yt,activeNode:k,activeNodeRect:dt,activatorEvent:T,collisions:sn,containerNodeRect:je,dragOverlay:ee,draggableNodes:nt,droppableContainers:Rt,droppableRects:B,over:il,measureDroppableContainers:L,scrollableAncestors:He,scrollableAncestorRects:jl,measuringConfiguration:O,measuringScheduled:F,windowRect:fn}),[Yt,k,dt,T,sn,je,ee,nt,Rt,B,il,L,He,jl,O,F,fn]),Cn=x.useMemo(()=>({activatorEvent:T,activators:xu,active:Yt,activeNodeRect:dt,ariaDescribedById:{draggable:tt},dispatch:V,draggableNodes:nt,over:il,measureDroppableContainers:L}),[T,xu,Yt,dt,V,tt,nt,il,L]);return ve.createElement(lv.Provider,{value:W},ve.createElement(Fi.Provider,{value:Cn},ve.createElement(yv.Provider,{value:tc},ve.createElement(mv.Provider,{value:de},m)),ve.createElement(lm,{disabled:(S==null?void 0:S.restoreFocus)===!1})),ve.createElement(ny,{...S,hiddenTextDescribedById:tt}));function Rn(){const Xt=(Qt==null?void 0:Qt.autoScrollEnabled)===!1,wt=typeof E=="object"?E.enabled===!1:E===!1,Ft=$&&!Xt&&!wt;return typeof E=="object"?{...E,enabled:Ft}:{enabled:Ft}}}),cm=x.createContext(null),Fh="button",fm="Draggable";function sm(i){let{id:f,data:o,disabled:s=!1,attributes:d}=i;const g=Du(fm),{activators:y,activatorEvent:S,active:E,activeNodeRect:m,ariaDescribedById:_,draggableNodes:M,over:Y}=x.useContext(Fi),{role:w=Fh,roleDescription:P="draggable",tabIndex:X=0}=d??{},Z=(E==null?void 0:E.id)===f,V=x.useContext(Z?mv:cm),[at,W]=Zi(),[et,it]=Zi(),$=Ky(y,f),Q=mu(o);rl(()=>(M.set(f,{id:f,key:g,node:at,activatorNode:et,data:Q}),()=>{const ot=M.get(f);ot&&ot.key===g&&M.delete(f)}),[M,f]);const nt=x.useMemo(()=>({role:w,tabIndex:X,"aria-disabled":s,"aria-pressed":Z&&w===Fh?!0:void 0,"aria-roledescription":P,"aria-describedby":_.draggable}),[s,w,X,Z,P,_.draggable]);return{active:E,activatorEvent:S,activeNodeRect:m,attributes:nt,isDragging:Z,listeners:s?void 0:$,node:at,over:Y,setNodeRef:W,setActivatorNodeRef:it,transform:V}}function om(){return x.useContext(yv)}const rm="Droppable",dm={timeout:25};function hm(i){let{data:f,disabled:o=!1,id:s,resizeObserverConfig:d}=i;const g=Du(rm),{active:y,dispatch:S,over:E,measureDroppableContainers:m}=x.useContext(Fi),_=x.useRef({disabled:o}),M=x.useRef(!1),Y=x.useRef(null),w=x.useRef(null),{disabled:P,updateMeasurementsFor:X,timeout:Z}={...dm,...d},V=mu(X??s),at=x.useCallback(()=>{if(!M.current){M.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{m(Array.isArray(V.current)?V.current:[V.current]),w.current=null},Z)},[Z]),W=$i({callback:at,disabled:P||!y}),et=x.useCallback((nt,ot)=>{W&&(ot&&(W.unobserve(ot),M.current=!1),nt&&W.observe(nt))},[W]),[it,$]=Zi(et),Q=mu(f);return x.useEffect(()=>{!W||!it.current||(W.disconnect(),M.current=!1,W.observe(it.current))},[it,W]),x.useEffect(()=>(S({type:$t.RegisterDroppable,element:{id:s,key:g,disabled:o,node:it,rect:Y,data:Q}}),()=>S({type:$t.UnregisterDroppable,key:g,id:s})),[s]),x.useEffect(()=>{o!==_.current.disabled&&(S({type:$t.SetDroppableDisabled,id:s,key:g,disabled:o}),_.current.disabled=o)},[s,g,o,S]),{active:y,rect:Y,isOver:(E==null?void 0:E.id)===s,node:it,over:E,setNodeRef:$}}function Bs(i,f,o){const s=i.slice();return s.splice(o<0?s.length+o:o,0,s.splice(f,1)[0]),s}function vm(i,f){return i.reduce((o,s,d)=>{const g=f.get(s);return g&&(o[d]=g),o},Array(i.length))}function Gi(i){return i!==null&&i>=0}function gm(i,f){if(i===f)return!0;if(i.length!==f.length)return!1;for(let o=0;o<i.length;o++)if(i[o]!==f[o])return!1;return!0}function ym(i){return typeof i=="boolean"?{draggable:i,droppable:i}:i}const bv=i=>{let{rects:f,activeIndex:o,overIndex:s,index:d}=i;const g=Bs(f,s,o),y=f[d],S=g[d];return!S||!y?null:{x:S.left-y.left,y:S.top-y.top,scaleX:S.width/y.width,scaleY:S.height/y.height}},Li={scaleX:1,scaleY:1},mm=i=>{var f;let{activeIndex:o,activeNodeRect:s,index:d,rects:g,overIndex:y}=i;const S=(f=g[o])!=null?f:s;if(!S)return null;if(d===o){const m=g[y];return m?{x:0,y:o<y?m.top+m.height-(S.top+S.height):m.top-S.top,...Li}:null}const E=bm(g,d,o);return d>o&&d<=y?{x:0,y:-S.height-E,...Li}:d<o&&d>=y?{x:0,y:S.height+E,...Li}:{x:0,y:0,...Li}};function bm(i,f,o){const s=i[f],d=i[f-1],g=i[f+1];return s?o<f?d?s.top-(d.top+d.height):g?g.top-(s.top+s.height):0:g?g.top-(s.top+s.height):d?s.top-(d.top+d.height):0:0}const pv="Sortable",Sv=ve.createContext({activeIndex:-1,containerId:pv,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:bv,disabled:{draggable:!1,droppable:!1}});function pm(i){let{children:f,id:o,items:s,strategy:d=bv,disabled:g=!1}=i;const{active:y,dragOverlay:S,droppableRects:E,over:m,measureDroppableContainers:_}=om(),M=Du(pv,o),Y=S.rect!==null,w=x.useMemo(()=>s.map($=>typeof $=="object"&&"id"in $?$.id:$),[s]),P=y!=null,X=y?w.indexOf(y.id):-1,Z=m?w.indexOf(m.id):-1,V=x.useRef(w),at=!gm(w,V.current),W=Z!==-1&&X===-1||at,et=ym(g);rl(()=>{at&&P&&_(w)},[at,w,P,_]),x.useEffect(()=>{V.current=w},[w]);const it=x.useMemo(()=>({activeIndex:X,containerId:M,disabled:et,disableTransforms:W,items:w,overIndex:Z,useDragOverlay:Y,sortedRects:vm(w,E),strategy:d}),[X,M,et.draggable,et.droppable,W,w,Z,E,Y,d]);return ve.createElement(Sv.Provider,{value:it},f)}const Sm=i=>{let{id:f,items:o,activeIndex:s,overIndex:d}=i;return Bs(o,s,d).indexOf(f)},Em=i=>{let{containerId:f,isSorting:o,wasDragging:s,index:d,items:g,newIndex:y,previousItems:S,previousContainerId:E,transition:m}=i;return!m||!s||S!==g&&d===y?!1:o?!0:y!==d&&f===E},Tm={duration:200,easing:"ease"},Ev="transform",Dm=pu.Transition.toString({property:Ev,duration:0,easing:"linear"}),Am={roleDescription:"sortable"};function zm(i){let{disabled:f,index:o,node:s,rect:d}=i;const[g,y]=x.useState(null),S=x.useRef(o);return rl(()=>{if(!f&&o!==S.current&&s.current){const E=d.current;if(E){const m=ba(s.current,{ignoreTransform:!0}),_={x:E.left-m.left,y:E.top-m.top,scaleX:E.width/m.width,scaleY:E.height/m.height};(_.x||_.y)&&y(_)}}o!==S.current&&(S.current=o)},[f,o,s,d]),x.useEffect(()=>{g&&y(null)},[g]),g}function Mm(i){let{animateLayoutChanges:f=Em,attributes:o,disabled:s,data:d,getNewIndex:g=Sm,id:y,strategy:S,resizeObserverConfig:E,transition:m=Tm}=i;const{items:_,containerId:M,activeIndex:Y,disabled:w,disableTransforms:P,sortedRects:X,overIndex:Z,useDragOverlay:V,strategy:at}=x.useContext(Sv),W=Om(s,w),et=_.indexOf(y),it=x.useMemo(()=>({sortable:{containerId:M,index:et,items:_},...d}),[M,d,et,_]),$=x.useMemo(()=>_.slice(_.indexOf(y)),[_,y]),{rect:Q,node:nt,isOver:ot,setNodeRef:Rt}=hm({id:y,data:it,disabled:W.droppable,resizeObserverConfig:{updateMeasurementsFor:$,...E}}),{active:rt,activatorEvent:Mt,activeNodeRect:Yt,attributes:Ht,setNodeRef:Qt,listeners:R,isDragging:T,over:q,setActivatorNodeRef:G,transform:tt}=sm({id:y,data:it,attributes:{...Am,...o},disabled:W.draggable}),v=Zg(Rt,Qt),O=!!rt,B=O&&!P&&Gi(Y)&&Gi(Z),L=!V&&T,F=L&&B?tt:null,ct=B?F??(S??at)({rects:X,activeNodeRect:Yt,activeIndex:Y,overIndex:Z,index:et}):null,Dt=Gi(Y)&&Gi(Z)?g({id:y,items:_,activeIndex:Y,overIndex:Z}):et,mt=rt==null?void 0:rt.id,dt=x.useRef({activeId:mt,items:_,newIndex:Dt,containerId:M}),je=_!==dt.current.items,ce=f({active:rt,containerId:M,isDragging:T,isSorting:O,id:y,index:et,items:_,newIndex:dt.current.newIndex,previousItems:dt.current.items,previousContainerId:dt.current.containerId,transition:m,wasDragging:dt.current.activeId!=null}),dl=zm({disabled:!ce,index:et,node:nt,rect:Q});return x.useEffect(()=>{O&&dt.current.newIndex!==Dt&&(dt.current.newIndex=Dt),M!==dt.current.containerId&&(dt.current.containerId=M),_!==dt.current.items&&(dt.current.items=_)},[O,Dt,M,_]),x.useEffect(()=>{if(mt===dt.current.activeId)return;if(mt!=null&&dt.current.activeId==null){dt.current.activeId=mt;return}const al=setTimeout(()=>{dt.current.activeId=mt},50);return()=>clearTimeout(al)},[mt]),{active:rt,activeIndex:Y,attributes:Ht,data:it,rect:Q,index:et,newIndex:Dt,items:_,isOver:ot,isSorting:O,isDragging:T,listeners:R,node:nt,overIndex:Z,over:q,setNodeRef:v,setActivatorNodeRef:G,setDroppableNodeRef:Rt,setDraggableNodeRef:Qt,transform:dl??ct,transition:ee()};function ee(){if(dl||je&&dt.current.newIndex===et)return Dm;if(!(L&&!Ns(Mt)||!m)&&(O||ce))return pu.Transition.toString({...m,property:Ev})}}function Om(i,f){var o,s;return typeof i=="boolean"?{draggable:i,droppable:!1}:{draggable:(o=i==null?void 0:i.draggable)!=null?o:f.draggable,droppable:(s=i==null?void 0:i.droppable)!=null?s:f.droppable}}function Ji(i){if(!i)return!1;const f=i.data.current;return!!(f&&"sortable"in f&&typeof f.sortable=="object"&&"containerId"in f.sortable&&"items"in f.sortable&&"index"in f.sortable)}const xm=[pt.Down,pt.Right,pt.Up,pt.Left],Cm=(i,f)=>{let{context:{active:o,collisionRect:s,droppableRects:d,droppableContainers:g,over:y,scrollableAncestors:S}}=f;if(xm.includes(i.code)){if(i.preventDefault(),!o||!s)return;const E=[];g.getEnabled().forEach(M=>{if(!M||M!=null&&M.disabled)return;const Y=d.get(M.id);if(Y)switch(i.code){case pt.Down:s.top<Y.top&&E.push(M);break;case pt.Up:s.top>Y.top&&E.push(M);break;case pt.Left:s.left>Y.left&&E.push(M);break;case pt.Right:s.left<Y.left&&E.push(M);break}});const m=cy({collisionRect:s,droppableRects:d,droppableContainers:E});let _=uv(m,"id");if(_===(y==null?void 0:y.id)&&m.length>1&&(_=m[1].id),_!=null){const M=g.get(o.id),Y=g.get(_),w=Y?d.get(Y.id):null,P=Y==null?void 0:Y.node.current;if(P&&w&&M&&Y){const Z=ki(P).some(($,Q)=>S[Q]!==$),V=Tv(M,Y),at=Rm(M,Y),W=Z||!V?{x:0,y:0}:{x:at?s.width-w.width:0,y:at?s.height-w.height:0},et={x:w.left,y:w.top};return W.x&&W.y?et:bu(et,W)}}}};function Tv(i,f){return!Ji(i)||!Ji(f)?!1:i.data.current.sortable.containerId===f.data.current.sortable.containerId}function Rm(i,f){return!Ji(i)||!Ji(f)||!Tv(i,f)?!1:i.data.current.sortable.index<f.data.current.sortable.index}function Nm(i){return i.normalize("NFC").replace(/[\s\u3000]+/g,"-").replace(/[^\p{L}\p{N}-]+/gu,"").replace(/^-+|-+$/g,"")||"untitled-task"}function Ms(i){return i?new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(i)):"-"}function du(i){return{originalPath:i.path,path:i.path,title:i.frontmatter.title,priority:i.frontmatter.priority,status:i.frontmatter.status,content:i.content,updatedAt:i.frontmatter.updatedAt,createdAt:i.frontmatter.createdAt,extraFrontmatter:i.extraFrontmatter}}function _m({task:i,selected:f,onSelect:o}){const{attributes:s,listeners:d,setNodeRef:g,transform:y,transition:S}=Mm({id:i.path}),E={transform:pu.Transform.toString(y),transition:S};return H.jsxs("button",{ref:g,style:E,type:"button",className:`task-row${f?" task-row-selected":""}`,onClick:()=>o(i.path),...s,...d,children:[H.jsxs("span",{className:"task-row-badges",children:[H.jsx("span",{className:`badge badge-${i.frontmatter.priority.toLowerCase()}`,children:i.frontmatter.priority}),H.jsx("span",{className:`badge badge-${i.frontmatter.status.toLowerCase()}`,children:i.frontmatter.status})]}),H.jsx("strong",{children:i.frontmatter.title}),H.jsx("small",{children:i.path}),H.jsxs("small",{children:["Updated ",Ms(i.frontmatter.updatedAt)]})]})}async function un(i,f){const o=new Headers(f==null?void 0:f.headers);(f==null?void 0:f.body)!==void 0&&!o.has("Content-Type")&&o.set("Content-Type","application/json");const s=await fetch(i,{headers:o,...f});if(!s.ok){const d=await s.json().catch(()=>null);throw new Error((d==null?void 0:d.error)??`Request failed: ${s.status}`)}if(s.status!==204)return await s.json()}function Um({taskDirs:i,ignorePaths:f,busy:o,onSave:s,onClose:d}){const[g,y]=x.useState(i),[S,E]=x.useState(f.length>0?f:[""]);function m(X,Z){const V=[...g];V[X]=Z,y(V)}function _(){y([...g,""])}function M(X){y(g.filter((Z,V)=>V!==X))}function Y(X,Z){const V=[...S];V[X]=Z,E(V)}function w(){E([...S,""])}function P(X){E(S.filter((Z,V)=>V!==X))}return H.jsx("div",{className:"settings-overlay",onClick:d,children:H.jsxs("div",{className:"settings-modal",onClick:X=>X.stopPropagation(),children:[H.jsxs("div",{className:"panel-header",children:[H.jsx("h2",{children:"Settings"}),H.jsx("button",{type:"button",className:"ghost-button",onClick:d,children:"Close"})]}),H.jsxs("div",{className:"settings-body",children:[H.jsxs("label",{children:[H.jsx("span",{className:"settings-label",children:"Task directories"}),H.jsx("small",{className:"settings-hint",children:"Directories to scan for .md task files (relative to root)"})]}),H.jsx("div",{className:"settings-dir-list",children:g.map((X,Z)=>H.jsxs("div",{className:"settings-dir-row",children:[H.jsx("input",{value:X,onChange:V=>m(Z,V.target.value),placeholder:"e.g. tasks"}),H.jsx("button",{type:"button",className:"ghost-button settings-remove-button",onClick:()=>M(Z),disabled:g.length<=1,title:"Remove",children:H.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:H.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},Z))}),H.jsx("button",{type:"button",className:"ghost-button",onClick:_,children:"+ Add directory"}),H.jsxs("label",{children:[H.jsx("span",{className:"settings-label",children:"Ignore patterns"}),H.jsx("small",{className:"settings-hint",children:"Glob patterns for paths to exclude (e.g. __done__/**, archived/**)"})]}),H.jsx("div",{className:"settings-dir-list",children:S.map((X,Z)=>H.jsxs("div",{className:"settings-dir-row",children:[H.jsx("input",{value:X,onChange:V=>Y(Z,V.target.value),placeholder:"e.g. __done__/**"}),H.jsx("button",{type:"button",className:"ghost-button settings-remove-button",onClick:()=>P(Z),disabled:S.length<=1,title:"Remove",children:H.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:H.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},Z))}),H.jsx("button",{type:"button",className:"ghost-button",onClick:w,children:"+ Add pattern"})]}),H.jsxs("div",{className:"form-actions",children:[H.jsx("button",{type:"button",className:"primary-button",disabled:o||g.every(X=>!X.trim()),onClick:()=>s(g.filter(X=>X.trim()),S.filter(X=>X.trim())),children:"Save"}),H.jsx("button",{type:"button",className:"ghost-button",onClick:d,children:"Cancel"})]})]})})}function jm(){const[i,f]=x.useState([]),[o,s]=x.useState([]),[d,g]=x.useState(null),[y,S]=x.useState(null),[E,m]=x.useState("Loading tasks..."),[_,M]=x.useState(!1),[Y,w]=x.useState(!1),[P,X]=x.useState(["."]),[Z,V]=x.useState([]),[at,W]=x.useState(!1),[et,it]=x.useState(!0),$=x.useMemo(()=>i.find(T=>T.path===d)??null,[d,i]),Q=x.useMemo(()=>et?i.filter(T=>T.frontmatter.status!=="DONE"):i,[i,et]),nt=ay(Xh(Hs,{activationConstraint:{distance:8}}),Xh(Us,{coordinateGetter:Cm}));async function ot(T){const q=await un("/api/tasks");f(q.tasks),s(q.errors),g(G=>{var tt;return G&&q.tasks.some(v=>v.path===G)?G:((tt=q.tasks[0])==null?void 0:tt.path)??null}),T!=null&&T.preserveDraft||S(G=>{if(G!=null&&G.originalPath){const tt=q.tasks.find(v=>v.path===G.originalPath);if(tt)return du(tt)}return null})}async function Rt(){try{const T=await un("/api/config");X(T.taskDirs),V(T.ignorePaths??[])}catch{}}async function rt(T,q){M(!0);try{const G=await un("/api/config",{method:"PUT",body:JSON.stringify({taskDirs:T,ignorePaths:q})});X(G.taskDirs),V(G.ignorePaths??[]),m("Settings saved."),await ot()}catch(G){m(G instanceof Error?G.message:"Failed to save settings.")}finally{M(!1)}}x.useEffect(()=>{Rt(),ot(),m("Tasks loaded.")},[]),x.useEffect(()=>{if(!$){y!=null&&y.originalPath||S(T=>T??null);return}S(T=>!T||T.originalPath!==$.path?du($):T)},[$]),x.useEffect(()=>{const T=new EventSource("/api/events");return T.onmessage=()=>{ot({preserveDraft:!0})},T.onerror=()=>{T.close()},()=>T.close()},[]);async function Mt(){if(y){M(!0),m("");try{if(y.originalPath){const T=await un(`/api/tasks/${encodeURIComponent(y.originalPath)}`,{method:"PATCH",body:JSON.stringify({path:y.path,title:y.title,priority:y.priority,status:y.status,content:y.content,extraFrontmatter:y.extraFrontmatter,baseUpdatedAt:y.updatedAt})});await ot(),g(T.path),S(du(T)),m("Task saved.")}else{const T=await un("/api/tasks",{method:"POST",body:JSON.stringify({path:y.path||void 0,title:y.title,priority:y.priority,status:y.status,content:y.content,extraFrontmatter:y.extraFrontmatter})});await ot(),g(T.path),S(du(T)),m("Task created.")}}catch(T){m(T instanceof Error?T.message:"Failed to save task.")}finally{M(!1)}}}async function Yt(){if(y!=null&&y.originalPath){M(!0),m("");try{await un(`/api/tasks/${encodeURIComponent(y.originalPath)}`,{method:"DELETE"}),S(null),await ot(),m("Task deleted.")}catch(T){m(T instanceof Error?T.message:"Failed to delete task.")}finally{M(!1)}}}async function Ht(T){const{active:q,over:G}=T;if(!G||q.id===G.id)return;const tt=i.findIndex(B=>B.path===q.id),v=i.findIndex(B=>B.path===G.id),O=Bs(i,tt,v);f(O);try{await un("/api/order",{method:"PUT",body:JSON.stringify({order:O.map(B=>B.path)})}),m("Task order updated.")}catch(B){m(B instanceof Error?B.message:"Failed to save order."),await ot()}}async function Qt(T,q){if(y!=null&&y.originalPath)try{const G=await un(`/api/task-fields/${encodeURIComponent(y.originalPath)}`,{method:"PATCH",body:JSON.stringify({[T]:q})});await ot(),g(G.path),S(tt=>tt&&{...tt,[T]:q,updatedAt:G.frontmatter.updatedAt})}catch(G){m(G instanceof Error?G.message:`Failed to update ${T}.`)}}const R=!!y&&(y.originalPath===null||y.path!==y.originalPath||y.title!==($==null?void 0:$.frontmatter.title)||y.content!==($==null?void 0:$.content));return H.jsxs("div",{className:"app-shell",children:[H.jsxs("header",{className:"app-header",children:[H.jsxs("div",{className:"app-header-left",children:[H.jsx("h1",{children:"Markdown Task Viewer"}),H.jsx("p",{className:"eyebrow",children:"v0"})]}),H.jsxs("div",{className:"app-header-actions",children:[H.jsx("button",{type:"button",className:"ghost-button settings-button",onClick:()=>w(!0),title:"Settings",children:H.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"currentColor",children:H.jsx("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.062 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})}),H.jsx("button",{type:"button",className:"primary-button",onClick:()=>{W(!1),S({originalPath:null,path:P[0]?`${P[0]}/`:"",title:"",priority:"MUST",status:"TODO",content:"",extraFrontmatter:{}})},children:"New Task"})]})]}),H.jsxs("main",{className:"layout-grid",children:[H.jsxs("section",{className:"panel",children:[H.jsxs("div",{className:"panel-header",children:[H.jsx("h2",{children:"Tasks"}),H.jsxs("span",{className:"panel-header-right",children:[H.jsxs("label",{className:"filter-toggle",children:[H.jsx("input",{type:"checkbox",checked:et,onChange:()=>it(!et)}),H.jsx("span",{children:"Hide DONE"})]}),H.jsxs("span",{children:[Q.length," items"]})]})]}),H.jsxs("div",{className:"sidebar-scroll",children:[H.jsx(im,{sensors:nt,collisionDetection:iy,onDragEnd:T=>void Ht(T),children:H.jsx(pm,{items:Q.map(T=>T.path),strategy:mm,children:H.jsxs("div",{className:"task-list",children:[Q.map(T=>H.jsx(_m,{task:T,selected:T.path===d,onSelect:q=>{g(q);const G=i.find(tt=>tt.path===q);G&&S(du(G))}},T.path)),Q.length===0?H.jsx("p",{className:"empty-list",children:et?"No active tasks.":"No tasks yet. Create your first markdown task."}):null]})})}),o.length>0?H.jsxs("div",{className:"error-panel",children:[H.jsx("h3",{children:"Unreadable Markdown"}),o.map(T=>H.jsxs("p",{children:[H.jsx("strong",{children:T.path}),H.jsx("span",{children:T.message})]},T.path))]}):null]})]}),H.jsxs("section",{className:"panel editor-panel",children:[H.jsxs("div",{className:"panel-header",children:[H.jsx("h2",{children:y!=null&&y.originalPath?"Edit Task":"Task Details"}),R?H.jsx("span",{className:"dirty-state",children:"Unsaved changes"}):null]}),y?H.jsxs("div",{className:"task-form",children:[H.jsxs("div",{className:"field-row field-row-top",children:[H.jsxs("label",{children:[H.jsx("span",{children:"Priority"}),H.jsxs("select",{value:y.priority,onChange:T=>{const q=T.target.value;S({...y,priority:q}),y.originalPath&&Qt("priority",q)},children:[H.jsx("option",{value:"MUST",children:"MUST"}),H.jsx("option",{value:"WANT",children:"WANT"})]})]}),H.jsxs("label",{children:[H.jsx("span",{children:"Status"}),H.jsxs("select",{value:y.status,onChange:T=>{const q=T.target.value;S({...y,status:q}),y.originalPath&&Qt("status",q)},children:[H.jsx("option",{value:"TODO",children:"TODO"}),H.jsx("option",{value:"WIP",children:"WIP"}),H.jsx("option",{value:"DONE",children:"DONE"})]})]})]}),H.jsxs("label",{children:[H.jsx("span",{children:"Title"}),H.jsx("input",{value:y.title,onChange:T=>{const q=T.target.value,G={title:q};if(!at&&y.originalPath===null){const tt=P[0]||"",v=tt?`${tt}/`:"";G.path=q.trim()?`${v}/${Nm(q)}.md`:`${v}/`}S({...y,...G})},placeholder:"Write release notes",required:!0})]}),H.jsxs("label",{children:[H.jsx("span",{children:"Relative path"}),H.jsx("input",{value:y.path,onChange:T=>{W(!0),S({...y,path:T.target.value})},placeholder:"planning/release-notes.md"})]}),H.jsxs("div",{className:"meta-strip",children:[H.jsxs("span",{children:["Created ",Ms(y.createdAt)]}),H.jsxs("span",{children:["Updated ",Ms(y.updatedAt)]})]}),H.jsxs("label",{className:"editor-label",children:[H.jsx("span",{children:"Markdown body"}),H.jsx("textarea",{value:y.content,onChange:T=>S({...y,content:T.target.value}),onKeyDown:T=>{if(T.nativeEvent.isComposing)return;const q=T.currentTarget,{selectionStart:G,selectionEnd:tt,value:v}=q;if(T.key==="Tab"){T.preventDefault();const O=v.lastIndexOf(`
53
+ `},ly={onDragStart(i){let{active:f}=i;return"Picked up draggable item "+f.id+"."},onDragOver(i){let{active:f,over:o}=i;return o?"Draggable item "+f.id+" was moved over droppable area "+o.id+".":"Draggable item "+f.id+" is no longer over a droppable area."},onDragEnd(i){let{active:f,over:o}=i;return o?"Draggable item "+f.id+" was dropped over droppable area "+o.id:"Draggable item "+f.id+" was dropped."},onDragCancel(i){let{active:f}=i;return"Dragging was cancelled. Draggable item "+f.id+" was dropped."}};function ny(i){let{announcements:f=ly,container:o,hiddenTextDescribedById:s,screenReaderInstructions:d=ey}=i;const{announce:g,announcement:y}=Ig(),S=Du("DndLiveRegion"),[E,m]=x.useState(!1);if(x.useEffect(()=>{m(!0)},[]),Pg(x.useMemo(()=>({onDragStart(M){let{active:Y}=M;g(f.onDragStart({active:Y}))},onDragMove(M){let{active:Y,over:w}=M;f.onDragMove&&g(f.onDragMove({active:Y,over:w}))},onDragOver(M){let{active:Y,over:w}=M;g(f.onDragOver({active:Y,over:w}))},onDragEnd(M){let{active:Y,over:w}=M;g(f.onDragEnd({active:Y,over:w}))},onDragCancel(M){let{active:Y,over:w}=M;g(f.onDragCancel({active:Y,over:w}))}}),[g,f])),!E)return null;const _=ve.createElement(ve.Fragment,null,ve.createElement($g,{id:s,value:d.draggable}),ve.createElement(Fg,{id:S,announcement:y}));return o?hu.createPortal(_,o):_}var $t;(function(i){i.DragStart="dragStart",i.DragMove="dragMove",i.DragEnd="dragEnd",i.DragCancel="dragCancel",i.DragOver="dragOver",i.RegisterDroppable="registerDroppable",i.SetDroppableDisabled="setDroppableDisabled",i.UnregisterDroppable="unregisterDroppable"})($t||($t={}));function Vi(){}function Xh(i,f){return x.useMemo(()=>({sensor:i,options:f??{}}),[i,f])}function ay(){for(var i=arguments.length,f=new Array(i),o=0;o<i;o++)f[o]=arguments[o];return x.useMemo(()=>[...f].filter(s=>s!=null),[...f])}const nl=Object.freeze({x:0,y:0});function nv(i,f){return Math.sqrt(Math.pow(i.x-f.x,2)+Math.pow(i.y-f.y,2))}function av(i,f){let{data:{value:o}}=i,{data:{value:s}}=f;return o-s}function uy(i,f){let{data:{value:o}}=i,{data:{value:s}}=f;return s-o}function wh(i){let{left:f,top:o,height:s,width:d}=i;return[{x:f,y:o},{x:f+d,y:o},{x:f,y:o+s},{x:f+d,y:o+s}]}function uv(i,f){if(!i||i.length===0)return null;const[o]=i;return o[f]}function Gh(i,f,o){return f===void 0&&(f=i.left),o===void 0&&(o=i.top),{x:f+i.width*.5,y:o+i.height*.5}}const iy=i=>{let{collisionRect:f,droppableRects:o,droppableContainers:s}=i;const d=Gh(f,f.left,f.top),g=[];for(const y of s){const{id:S}=y,E=o.get(S);if(E){const m=nv(Gh(E),d);g.push({id:S,data:{droppableContainer:y,value:m}})}}return g.sort(av)},cy=i=>{let{collisionRect:f,droppableRects:o,droppableContainers:s}=i;const d=wh(f),g=[];for(const y of s){const{id:S}=y,E=o.get(S);if(E){const m=wh(E),_=d.reduce((Y,w,P)=>Y+nv(m[P],w),0),M=Number((_/4).toFixed(4));g.push({id:S,data:{droppableContainer:y,value:M}})}}return g.sort(av)};function fy(i,f){const o=Math.max(f.top,i.top),s=Math.max(f.left,i.left),d=Math.min(f.left+f.width,i.left+i.width),g=Math.min(f.top+f.height,i.top+i.height),y=d-s,S=g-o;if(s<d&&o<g){const E=f.width*f.height,m=i.width*i.height,_=y*S,M=_/(E+m-_);return Number(M.toFixed(4))}return 0}const sy=i=>{let{collisionRect:f,droppableRects:o,droppableContainers:s}=i;const d=[];for(const g of s){const{id:y}=g,S=o.get(y);if(S){const E=fy(S,f);E>0&&d.push({id:y,data:{droppableContainer:g,value:E}})}}return d.sort(uy)};function oy(i,f,o){return{...i,scaleX:f&&o?f.width/o.width:1,scaleY:f&&o?f.height/o.height:1}}function iv(i,f){return i&&f?{x:i.left-f.left,y:i.top-f.top}:nl}function ry(i){return function(o){for(var s=arguments.length,d=new Array(s>1?s-1:0),g=1;g<s;g++)d[g-1]=arguments[g];return d.reduce((y,S)=>({...y,top:y.top+i*S.y,bottom:y.bottom+i*S.y,left:y.left+i*S.x,right:y.right+i*S.x}),{...o})}}const dy=ry(1);function hy(i){if(i.startsWith("matrix3d(")){const f=i.slice(9,-1).split(/, /);return{x:+f[12],y:+f[13],scaleX:+f[0],scaleY:+f[5]}}else if(i.startsWith("matrix(")){const f=i.slice(7,-1).split(/, /);return{x:+f[4],y:+f[5],scaleX:+f[0],scaleY:+f[3]}}return null}function vy(i,f,o){const s=hy(f);if(!s)return i;const{scaleX:d,scaleY:g,x:y,y:S}=s,E=i.left-y-(1-d)*parseFloat(o),m=i.top-S-(1-g)*parseFloat(o.slice(o.indexOf(" ")+1)),_=d?i.width/d:i.width,M=g?i.height/g:i.height;return{width:_,height:M,top:m,right:E+_,bottom:m+M,left:E}}const gy={ignoreTransform:!1};function ba(i,f){f===void 0&&(f=gy);let o=i.getBoundingClientRect();if(f.ignoreTransform){const{transform:m,transformOrigin:_}=ze(i).getComputedStyle(i);m&&(o=vy(o,m,_))}const{top:s,left:d,width:g,height:y,bottom:S,right:E}=o;return{top:s,left:d,width:g,height:y,bottom:S,right:E}}function Lh(i){return ba(i,{ignoreTransform:!0})}function yy(i){const f=i.innerWidth,o=i.innerHeight;return{top:0,left:0,right:f,bottom:o,width:f,height:o}}function my(i,f){return f===void 0&&(f=ze(i).getComputedStyle(i)),f.position==="fixed"}function by(i,f){f===void 0&&(f=ze(i).getComputedStyle(i));const o=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(d=>{const g=f[d];return typeof g=="string"?o.test(g):!1})}function ki(i,f){const o=[];function s(d){if(f!=null&&o.length>=f||!d)return o;if(Cs(d)&&d.scrollingElement!=null&&!o.includes(d.scrollingElement))return o.push(d.scrollingElement),o;if(!Eu(d)||tv(d)||o.includes(d))return o;const g=ze(i).getComputedStyle(d);return d!==i&&by(d,g)&&o.push(d),my(d,g)?o:s(d.parentNode)}return i?s(i):o}function cv(i){const[f]=ki(i,1);return f??null}function bs(i){return!Wi||!i?null:ya(i)?i:xs(i)?Cs(i)||i===ma(i).scrollingElement?window:Eu(i)?i:null:null}function fv(i){return ya(i)?i.scrollX:i.scrollLeft}function sv(i){return ya(i)?i.scrollY:i.scrollTop}function Ds(i){return{x:fv(i),y:sv(i)}}var te;(function(i){i[i.Forward=1]="Forward",i[i.Backward=-1]="Backward"})(te||(te={}));function ov(i){return!Wi||!i?!1:i===document.scrollingElement}function rv(i){const f={x:0,y:0},o=ov(i)?{height:window.innerHeight,width:window.innerWidth}:{height:i.clientHeight,width:i.clientWidth},s={x:i.scrollWidth-o.width,y:i.scrollHeight-o.height},d=i.scrollTop<=f.y,g=i.scrollLeft<=f.x,y=i.scrollTop>=s.y,S=i.scrollLeft>=s.x;return{isTop:d,isLeft:g,isBottom:y,isRight:S,maxScroll:s,minScroll:f}}const py={x:.2,y:.2};function Sy(i,f,o,s,d){let{top:g,left:y,right:S,bottom:E}=o;s===void 0&&(s=10),d===void 0&&(d=py);const{isTop:m,isBottom:_,isLeft:M,isRight:Y}=rv(i),w={x:0,y:0},P={x:0,y:0},X={height:f.height*d.y,width:f.width*d.x};return!m&&g<=f.top+X.height?(w.y=te.Backward,P.y=s*Math.abs((f.top+X.height-g)/X.height)):!_&&E>=f.bottom-X.height&&(w.y=te.Forward,P.y=s*Math.abs((f.bottom-X.height-E)/X.height)),!Y&&S>=f.right-X.width?(w.x=te.Forward,P.x=s*Math.abs((f.right-X.width-S)/X.width)):!M&&y<=f.left+X.width&&(w.x=te.Backward,P.x=s*Math.abs((f.left+X.width-y)/X.width)),{direction:w,speed:P}}function Ey(i){if(i===document.scrollingElement){const{innerWidth:g,innerHeight:y}=window;return{top:0,left:0,right:g,bottom:y,width:g,height:y}}const{top:f,left:o,right:s,bottom:d}=i.getBoundingClientRect();return{top:f,left:o,right:s,bottom:d,width:i.clientWidth,height:i.clientHeight}}function dv(i){return i.reduce((f,o)=>ga(f,Ds(o)),nl)}function Ty(i){return i.reduce((f,o)=>f+fv(o),0)}function Dy(i){return i.reduce((f,o)=>f+sv(o),0)}function Ay(i,f){if(f===void 0&&(f=ba),!i)return;const{top:o,left:s,bottom:d,right:g}=f(i);cv(i)&&(d<=0||g<=0||o>=window.innerHeight||s>=window.innerWidth)&&i.scrollIntoView({block:"center",inline:"center"})}const zy=[["x",["left","right"],Ty],["y",["top","bottom"],Dy]];class _s{constructor(f,o){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 s=ki(o),d=dv(s);this.rect={...f},this.width=f.width,this.height=f.height;for(const[g,y,S]of zy)for(const E of y)Object.defineProperty(this,E,{get:()=>{const m=S(s),_=d[g]-m;return this.rect[E]+_},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class vu{constructor(f){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(o=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...o)})},this.target=f}add(f,o,s){var d;(d=this.target)==null||d.addEventListener(f,o,s),this.listeners.push([f,o,s])}}function My(i){const{EventTarget:f}=ze(i);return i instanceof f?i:ma(i)}function ps(i,f){const o=Math.abs(i.x),s=Math.abs(i.y);return typeof f=="number"?Math.sqrt(o**2+s**2)>f:"x"in f&&"y"in f?o>f.x&&s>f.y:"x"in f?o>f.x:"y"in f?s>f.y:!1}var $e;(function(i){i.Click="click",i.DragStart="dragstart",i.Keydown="keydown",i.ContextMenu="contextmenu",i.Resize="resize",i.SelectionChange="selectionchange",i.VisibilityChange="visibilitychange"})($e||($e={}));function Qh(i){i.preventDefault()}function Oy(i){i.stopPropagation()}var pt;(function(i){i.Space="Space",i.Down="ArrowDown",i.Right="ArrowRight",i.Left="ArrowLeft",i.Up="ArrowUp",i.Esc="Escape",i.Enter="Enter",i.Tab="Tab"})(pt||(pt={}));const hv={start:[pt.Space,pt.Enter],cancel:[pt.Esc],end:[pt.Space,pt.Enter,pt.Tab]},xy=(i,f)=>{let{currentCoordinates:o}=f;switch(i.code){case pt.Right:return{...o,x:o.x+25};case pt.Left:return{...o,x:o.x-25};case pt.Down:return{...o,y:o.y+25};case pt.Up:return{...o,y:o.y-25}}};class Us{constructor(f){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=f;const{event:{target:o}}=f;this.props=f,this.listeners=new vu(ma(o)),this.windowListeners=new vu(ze(o)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add($e.Resize,this.handleCancel),this.windowListeners.add($e.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add($e.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:f,onStart:o}=this.props,s=f.node.current;s&&Ay(s),o(nl)}handleKeyDown(f){if(Ns(f)){const{active:o,context:s,options:d}=this.props,{keyboardCodes:g=hv,coordinateGetter:y=xy,scrollBehavior:S="smooth"}=d,{code:E}=f;if(g.end.includes(E)){this.handleEnd(f);return}if(g.cancel.includes(E)){this.handleCancel(f);return}const{collisionRect:m}=s.current,_=m?{x:m.left,y:m.top}:nl;this.referenceCoordinates||(this.referenceCoordinates=_);const M=y(f,{active:o,context:s.current,currentCoordinates:_});if(M){const Y=bu(M,_),w={x:0,y:0},{scrollableAncestors:P}=s.current;for(const X of P){const Z=f.code,{isTop:V,isRight:at,isLeft:W,isBottom:et,maxScroll:it,minScroll:$}=rv(X),Q=Ey(X),nt={x:Math.min(Z===pt.Right?Q.right-Q.width/2:Q.right,Math.max(Z===pt.Right?Q.left:Q.left+Q.width/2,M.x)),y:Math.min(Z===pt.Down?Q.bottom-Q.height/2:Q.bottom,Math.max(Z===pt.Down?Q.top:Q.top+Q.height/2,M.y))},ot=Z===pt.Right&&!at||Z===pt.Left&&!W,Rt=Z===pt.Down&&!et||Z===pt.Up&&!V;if(ot&&nt.x!==M.x){const rt=X.scrollLeft+Y.x,Mt=Z===pt.Right&&rt<=it.x||Z===pt.Left&&rt>=$.x;if(Mt&&!Y.y){X.scrollTo({left:rt,behavior:S});return}Mt?w.x=X.scrollLeft-rt:w.x=Z===pt.Right?X.scrollLeft-it.x:X.scrollLeft-$.x,w.x&&X.scrollBy({left:-w.x,behavior:S});break}else if(Rt&&nt.y!==M.y){const rt=X.scrollTop+Y.y,Mt=Z===pt.Down&&rt<=it.y||Z===pt.Up&&rt>=$.y;if(Mt&&!Y.x){X.scrollTo({top:rt,behavior:S});return}Mt?w.y=X.scrollTop-rt:w.y=Z===pt.Down?X.scrollTop-it.y:X.scrollTop-$.y,w.y&&X.scrollBy({top:-w.y,behavior:S});break}}this.handleMove(f,ga(bu(M,this.referenceCoordinates),w))}}}handleMove(f,o){const{onMove:s}=this.props;f.preventDefault(),s(o)}handleEnd(f){const{onEnd:o}=this.props;f.preventDefault(),this.detach(),o()}handleCancel(f){const{onCancel:o}=this.props;f.preventDefault(),this.detach(),o()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Us.activators=[{eventName:"onKeyDown",handler:(i,f,o)=>{let{keyboardCodes:s=hv,onActivation:d}=f,{active:g}=o;const{code:y}=i.nativeEvent;if(s.start.includes(y)){const S=g.activatorNode.current;return S&&i.target!==S?!1:(i.preventDefault(),d==null||d({event:i.nativeEvent}),!0)}return!1}}];function Zh(i){return!!(i&&"distance"in i)}function Vh(i){return!!(i&&"delay"in i)}class js{constructor(f,o,s){var d;s===void 0&&(s=My(f.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=f,this.events=o;const{event:g}=f,{target:y}=g;this.props=f,this.events=o,this.document=ma(y),this.documentListeners=new vu(this.document),this.listeners=new vu(s),this.windowListeners=new vu(ze(y)),this.initialCoordinates=(d=Ts(g))!=null?d:nl,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:f,props:{options:{activationConstraint:o,bypassActivationConstraint:s}}}=this;if(this.listeners.add(f.move.name,this.handleMove,{passive:!1}),this.listeners.add(f.end.name,this.handleEnd),f.cancel&&this.listeners.add(f.cancel.name,this.handleCancel),this.windowListeners.add($e.Resize,this.handleCancel),this.windowListeners.add($e.DragStart,Qh),this.windowListeners.add($e.VisibilityChange,this.handleCancel),this.windowListeners.add($e.ContextMenu,Qh),this.documentListeners.add($e.Keydown,this.handleKeydown),o){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Vh(o)){this.timeoutId=setTimeout(this.handleStart,o.delay),this.handlePending(o);return}if(Zh(o)){this.handlePending(o);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(f,o){const{active:s,onPending:d}=this.props;d(s,f,this.initialCoordinates,o)}handleStart(){const{initialCoordinates:f}=this,{onStart:o}=this.props;f&&(this.activated=!0,this.documentListeners.add($e.Click,Oy,{capture:!0}),this.removeTextSelection(),this.documentListeners.add($e.SelectionChange,this.removeTextSelection),o(f))}handleMove(f){var o;const{activated:s,initialCoordinates:d,props:g}=this,{onMove:y,options:{activationConstraint:S}}=g;if(!d)return;const E=(o=Ts(f))!=null?o:nl,m=bu(d,E);if(!s&&S){if(Zh(S)){if(S.tolerance!=null&&ps(m,S.tolerance))return this.handleCancel();if(ps(m,S.distance))return this.handleStart()}if(Vh(S)&&ps(m,S.tolerance))return this.handleCancel();this.handlePending(S,m);return}f.cancelable&&f.preventDefault(),y(E)}handleEnd(){const{onAbort:f,onEnd:o}=this.props;this.detach(),this.activated||f(this.props.active),o()}handleCancel(){const{onAbort:f,onCancel:o}=this.props;this.detach(),this.activated||f(this.props.active),o()}handleKeydown(f){f.code===pt.Esc&&this.handleCancel()}removeTextSelection(){var f;(f=this.document.getSelection())==null||f.removeAllRanges()}}const Cy={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Hs extends js{constructor(f){const{event:o}=f,s=ma(o.target);super(f,Cy,s)}}Hs.activators=[{eventName:"onPointerDown",handler:(i,f)=>{let{nativeEvent:o}=i,{onActivation:s}=f;return!o.isPrimary||o.button!==0?!1:(s==null||s({event:o}),!0)}}];const Ry={move:{name:"mousemove"},end:{name:"mouseup"}};var As;(function(i){i[i.RightClick=2]="RightClick"})(As||(As={}));class Ny extends js{constructor(f){super(f,Ry,ma(f.event.target))}}Ny.activators=[{eventName:"onMouseDown",handler:(i,f)=>{let{nativeEvent:o}=i,{onActivation:s}=f;return o.button===As.RightClick?!1:(s==null||s({event:o}),!0)}}];const Ss={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class _y extends js{constructor(f){super(f,Ss)}static setup(){return window.addEventListener(Ss.move.name,f,{capture:!1,passive:!1}),function(){window.removeEventListener(Ss.move.name,f)};function f(){}}}_y.activators=[{eventName:"onTouchStart",handler:(i,f)=>{let{nativeEvent:o}=i,{onActivation:s}=f;const{touches:d}=o;return d.length>1?!1:(s==null||s({event:o}),!0)}}];var gu;(function(i){i[i.Pointer=0]="Pointer",i[i.DraggableRect=1]="DraggableRect"})(gu||(gu={}));var Ki;(function(i){i[i.TreeOrder=0]="TreeOrder",i[i.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ki||(Ki={}));function Uy(i){let{acceleration:f,activator:o=gu.Pointer,canScroll:s,draggingRect:d,enabled:g,interval:y=5,order:S=Ki.TreeOrder,pointerCoordinates:E,scrollableAncestors:m,scrollableAncestorRects:_,delta:M,threshold:Y}=i;const w=Hy({delta:M,disabled:!g}),[P,X]=Vg(),Z=x.useRef({x:0,y:0}),V=x.useRef({x:0,y:0}),at=x.useMemo(()=>{switch(o){case gu.Pointer:return E?{top:E.y,bottom:E.y,left:E.x,right:E.x}:null;case gu.DraggableRect:return d}},[o,d,E]),W=x.useRef(null),et=x.useCallback(()=>{const $=W.current;if(!$)return;const Q=Z.current.x*V.current.x,nt=Z.current.y*V.current.y;$.scrollBy(Q,nt)},[]),it=x.useMemo(()=>S===Ki.TreeOrder?[...m].reverse():m,[S,m]);x.useEffect(()=>{if(!g||!m.length||!at){X();return}for(const $ of it){if((s==null?void 0:s($))===!1)continue;const Q=m.indexOf($),nt=_[Q];if(!nt)continue;const{direction:ot,speed:Rt}=Sy($,nt,at,f,Y);for(const rt of["x","y"])w[rt][ot[rt]]||(Rt[rt]=0,ot[rt]=0);if(Rt.x>0||Rt.y>0){X(),W.current=$,P(et,y),Z.current=Rt,V.current=ot;return}}Z.current={x:0,y:0},V.current={x:0,y:0},X()},[f,et,s,X,g,y,JSON.stringify(at),JSON.stringify(w),P,m,it,_,JSON.stringify(Y)])}const jy={x:{[te.Backward]:!1,[te.Forward]:!1},y:{[te.Backward]:!1,[te.Forward]:!1}};function Hy(i){let{delta:f,disabled:o}=i;const s=Es(f);return Tu(d=>{if(o||!s||!d)return jy;const g={x:Math.sign(f.x-s.x),y:Math.sign(f.y-s.y)};return{x:{[te.Backward]:d.x[te.Backward]||g.x===-1,[te.Forward]:d.x[te.Forward]||g.x===1},y:{[te.Backward]:d.y[te.Backward]||g.y===-1,[te.Forward]:d.y[te.Forward]||g.y===1}}},[o,f,s])}function By(i,f){const o=f!=null?i.get(f):void 0,s=o?o.node.current:null;return Tu(d=>{var g;return f==null?null:(g=s??d)!=null?g:null},[s,f])}function qy(i,f){return x.useMemo(()=>i.reduce((o,s)=>{const{sensor:d}=s,g=d.activators.map(y=>({eventName:y.eventName,handler:f(y.handler,s)}));return[...o,...g]},[]),[i,f])}var Su;(function(i){i[i.Always=0]="Always",i[i.BeforeDragging=1]="BeforeDragging",i[i.WhileDragging=2]="WhileDragging"})(Su||(Su={}));var zs;(function(i){i.Optimized="optimized"})(zs||(zs={}));const Kh=new Map;function Yy(i,f){let{dragging:o,dependencies:s,config:d}=f;const[g,y]=x.useState(null),{frequency:S,measure:E,strategy:m}=d,_=x.useRef(i),M=Z(),Y=mu(M),w=x.useCallback(function(V){V===void 0&&(V=[]),!Y.current&&y(at=>at===null?V:at.concat(V.filter(W=>!at.includes(W))))},[Y]),P=x.useRef(null),X=Tu(V=>{if(M&&!o)return Kh;if(!V||V===Kh||_.current!==i||g!=null){const at=new Map;for(let W of i){if(!W)continue;if(g&&g.length>0&&!g.includes(W.id)&&W.rect.current){at.set(W.id,W.rect.current);continue}const et=W.node.current,it=et?new _s(E(et),et):null;W.rect.current=it,it&&at.set(W.id,it)}return at}return V},[i,g,o,M,E]);return x.useEffect(()=>{_.current=i},[i]),x.useEffect(()=>{M||w()},[o,M]),x.useEffect(()=>{g&&g.length>0&&y(null)},[JSON.stringify(g)]),x.useEffect(()=>{M||typeof S!="number"||P.current!==null||(P.current=setTimeout(()=>{w(),P.current=null},S))},[S,M,w,...s]),{droppableRects:X,measureDroppableContainers:w,measuringScheduled:g!=null};function Z(){switch(m){case Su.Always:return!1;case Su.BeforeDragging:return o;default:return!o}}}function vv(i,f){return Tu(o=>i?o||(typeof f=="function"?f(i):i):null,[f,i])}function Xy(i,f){return vv(i,f)}function wy(i){let{callback:f,disabled:o}=i;const s=Rs(f),d=x.useMemo(()=>{if(o||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:g}=window;return new g(s)},[s,o]);return x.useEffect(()=>()=>d==null?void 0:d.disconnect(),[d]),d}function $i(i){let{callback:f,disabled:o}=i;const s=Rs(f),d=x.useMemo(()=>{if(o||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:g}=window;return new g(s)},[o]);return x.useEffect(()=>()=>d==null?void 0:d.disconnect(),[d]),d}function Gy(i){return new _s(ba(i),i)}function Jh(i,f,o){f===void 0&&(f=Gy);const[s,d]=x.useState(null);function g(){d(E=>{if(!i)return null;if(i.isConnected===!1){var m;return(m=E??o)!=null?m:null}const _=f(i);return JSON.stringify(E)===JSON.stringify(_)?E:_})}const y=wy({callback(E){if(i)for(const m of E){const{type:_,target:M}=m;if(_==="childList"&&M instanceof HTMLElement&&M.contains(i)){g();break}}}}),S=$i({callback:g});return rl(()=>{g(),i?(S==null||S.observe(i),y==null||y.observe(document.body,{childList:!0,subtree:!0})):(S==null||S.disconnect(),y==null||y.disconnect())},[i]),s}function Ly(i){const f=vv(i);return iv(i,f)}const Wh=[];function Qy(i){const f=x.useRef(i),o=Tu(s=>i?s&&s!==Wh&&i&&f.current&&i.parentNode===f.current.parentNode?s:ki(i):Wh,[i]);return x.useEffect(()=>{f.current=i},[i]),o}function Zy(i){const[f,o]=x.useState(null),s=x.useRef(i),d=x.useCallback(g=>{const y=bs(g.target);y&&o(S=>S?(S.set(y,Ds(y)),new Map(S)):null)},[]);return x.useEffect(()=>{const g=s.current;if(i!==g){y(g);const S=i.map(E=>{const m=bs(E);return m?(m.addEventListener("scroll",d,{passive:!0}),[m,Ds(m)]):null}).filter(E=>E!=null);o(S.length?new Map(S):null),s.current=i}return()=>{y(i),y(g)};function y(S){S.forEach(E=>{const m=bs(E);m==null||m.removeEventListener("scroll",d)})}},[d,i]),x.useMemo(()=>i.length?f?Array.from(f.values()).reduce((g,y)=>ga(g,y),nl):dv(i):nl,[i,f])}function kh(i,f){f===void 0&&(f=[]);const o=x.useRef(null);return x.useEffect(()=>{o.current=null},f),x.useEffect(()=>{const s=i!==nl;s&&!o.current&&(o.current=i),!s&&o.current&&(o.current=null)},[i]),o.current?bu(i,o.current):nl}function Vy(i){x.useEffect(()=>{if(!Wi)return;const f=i.map(o=>{let{sensor:s}=o;return s.setup==null?void 0:s.setup()});return()=>{for(const o of f)o==null||o()}},i.map(f=>{let{sensor:o}=f;return o}))}function Ky(i,f){return x.useMemo(()=>i.reduce((o,s)=>{let{eventName:d,handler:g}=s;return o[d]=y=>{g(y,f)},o},{}),[i,f])}function gv(i){return x.useMemo(()=>i?yy(i):null,[i])}const $h=[];function Jy(i,f){f===void 0&&(f=ba);const[o]=i,s=gv(o?ze(o):null),[d,g]=x.useState($h);function y(){g(()=>i.length?i.map(E=>ov(E)?s:new _s(f(E),E)):$h)}const S=$i({callback:y});return rl(()=>{S==null||S.disconnect(),y(),i.forEach(E=>S==null?void 0:S.observe(E))},[i]),d}function Wy(i){if(!i)return null;if(i.children.length>1)return i;const f=i.children[0];return Eu(f)?f:i}function ky(i){let{measure:f}=i;const[o,s]=x.useState(null),d=x.useCallback(m=>{for(const{target:_}of m)if(Eu(_)){s(M=>{const Y=f(_);return M?{...M,width:Y.width,height:Y.height}:Y});break}},[f]),g=$i({callback:d}),y=x.useCallback(m=>{const _=Wy(m);g==null||g.disconnect(),_&&(g==null||g.observe(_)),s(_?f(_):null)},[f,g]),[S,E]=Zi(y);return x.useMemo(()=>({nodeRef:S,rect:o,setRef:E}),[o,S,E])}const $y=[{sensor:Hs,options:{}},{sensor:Us,options:{}}],Fy={current:{}},Qi={draggable:{measure:Lh},droppable:{measure:Lh,strategy:Su.WhileDragging,frequency:zs.Optimized},dragOverlay:{measure:ba}};class yu extends Map{get(f){var o;return f!=null&&(o=super.get(f))!=null?o:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(f=>{let{disabled:o}=f;return!o})}getNodeFor(f){var o,s;return(o=(s=this.get(f))==null?void 0:s.node.current)!=null?o:void 0}}const Iy={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new yu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Vi},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Qi,measureDroppableContainers:Vi,windowRect:null,measuringScheduled:!1},Py={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Vi,draggableNodes:new Map,over:null,measureDroppableContainers:Vi},Fi=x.createContext(Py),yv=x.createContext(Iy);function tm(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new yu}}}function em(i,f){switch(f.type){case $t.DragStart:return{...i,draggable:{...i.draggable,initialCoordinates:f.initialCoordinates,active:f.active}};case $t.DragMove:return i.draggable.active==null?i:{...i,draggable:{...i.draggable,translate:{x:f.coordinates.x-i.draggable.initialCoordinates.x,y:f.coordinates.y-i.draggable.initialCoordinates.y}}};case $t.DragEnd:case $t.DragCancel:return{...i,draggable:{...i.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $t.RegisterDroppable:{const{element:o}=f,{id:s}=o,d=new yu(i.droppable.containers);return d.set(s,o),{...i,droppable:{...i.droppable,containers:d}}}case $t.SetDroppableDisabled:{const{id:o,key:s,disabled:d}=f,g=i.droppable.containers.get(o);if(!g||s!==g.key)return i;const y=new yu(i.droppable.containers);return y.set(o,{...g,disabled:d}),{...i,droppable:{...i.droppable,containers:y}}}case $t.UnregisterDroppable:{const{id:o,key:s}=f,d=i.droppable.containers.get(o);if(!d||s!==d.key)return i;const g=new yu(i.droppable.containers);return g.delete(o),{...i,droppable:{...i.droppable,containers:g}}}default:return i}}function lm(i){let{disabled:f}=i;const{active:o,activatorEvent:s,draggableNodes:d}=x.useContext(Fi),g=Es(s),y=Es(o==null?void 0:o.id);return x.useEffect(()=>{if(!f&&!s&&g&&y!=null){if(!Ns(g)||document.activeElement===g.target)return;const S=d.get(y);if(!S)return;const{activatorNode:E,node:m}=S;if(!E.current&&!m.current)return;requestAnimationFrame(()=>{for(const _ of[E.current,m.current]){if(!_)continue;const M=Wg(_);if(M){M.focus();break}}})}},[s,f,d,y,g]),null}function nm(i,f){let{transform:o,...s}=f;return i!=null&&i.length?i.reduce((d,g)=>g({transform:d,...s}),o):o}function am(i){return x.useMemo(()=>({draggable:{...Qi.draggable,...i==null?void 0:i.draggable},droppable:{...Qi.droppable,...i==null?void 0:i.droppable},dragOverlay:{...Qi.dragOverlay,...i==null?void 0:i.dragOverlay}}),[i==null?void 0:i.draggable,i==null?void 0:i.droppable,i==null?void 0:i.dragOverlay])}function um(i){let{activeNode:f,measure:o,initialRect:s,config:d=!0}=i;const g=x.useRef(!1),{x:y,y:S}=typeof d=="boolean"?{x:d,y:d}:d;rl(()=>{if(!y&&!S||!f){g.current=!1;return}if(g.current||!s)return;const m=f==null?void 0:f.node.current;if(!m||m.isConnected===!1)return;const _=o(m),M=iv(_,s);if(y||(M.x=0),S||(M.y=0),g.current=!0,Math.abs(M.x)>0||Math.abs(M.y)>0){const Y=cv(m);Y&&Y.scrollBy({top:M.y,left:M.x})}},[f,y,S,s,o])}const mv=x.createContext({...nl,scaleX:1,scaleY:1});var cn;(function(i){i[i.Uninitialized=0]="Uninitialized",i[i.Initializing=1]="Initializing",i[i.Initialized=2]="Initialized"})(cn||(cn={}));const im=x.memo(function(f){var o,s,d,g;let{id:y,accessibility:S,autoScroll:E=!0,children:m,sensors:_=$y,collisionDetection:M=sy,measuring:Y,modifiers:w,...P}=f;const X=x.useReducer(em,void 0,tm),[Z,V]=X,[at,W]=ty(),[et,it]=x.useState(cn.Uninitialized),$=et===cn.Initialized,{draggable:{active:Q,nodes:nt,translate:ot},droppable:{containers:Rt}}=Z,rt=Q!=null?nt.get(Q):null,Mt=x.useRef({initial:null,translated:null}),Yt=x.useMemo(()=>{var Xt;return Q!=null?{id:Q,data:(Xt=rt==null?void 0:rt.data)!=null?Xt:Fy,rect:Mt}:null},[Q,rt]),Ht=x.useRef(null),[Qt,R]=x.useState(null),[T,q]=x.useState(null),G=mu(P,Object.values(P)),tt=Du("DndDescribedBy",y),v=x.useMemo(()=>Rt.getEnabled(),[Rt]),O=am(Y),{droppableRects:B,measureDroppableContainers:L,measuringScheduled:F}=Yy(v,{dragging:$,dependencies:[ot.x,ot.y],config:O.droppable}),k=By(nt,Q),ct=x.useMemo(()=>T?Ts(T):null,[T]),Dt=Rn(),mt=Xy(k,O.draggable.measure);um({activeNode:Q!=null?nt.get(Q):null,config:Dt.layoutShiftCompensation,initialRect:mt,measure:O.draggable.measure});const dt=Jh(k,O.draggable.measure,mt),je=Jh(k?k.parentElement:null),ce=x.useRef({activatorEvent:null,active:null,activeNode:k,collisionRect:null,collisions:null,droppableRects:B,draggableNodes:nt,draggingNode:null,draggingNodeRect:null,droppableContainers:Rt,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),dl=Rt.getNodeFor((o=ce.current.over)==null?void 0:o.id),ee=ky({measure:O.dragOverlay.measure}),al=(s=ee.nodeRef.current)!=null?s:k,ul=$?(d=ee.rect)!=null?d:dt:null,Au=!!(ee.nodeRef.current&&ee.rect),pa=Ly(Au?null:dt),fn=gv(al?ze(al):null),He=Qy($?dl??k:null),jl=Jy(He),xn=nm(w,{transform:{x:ot.x-pa.x,y:ot.y-pa.y,scaleX:1,scaleY:1},activatorEvent:T,active:Yt,activeNodeRect:dt,containerNodeRect:je,draggingNodeRect:ul,over:ce.current.over,overlayNodeRect:ee.rect,scrollableAncestors:He,scrollableAncestorRects:jl,windowRect:fn}),zu=ct?ga(ct,ot):null,fe=Zy(He),Ii=kh(fe),Mu=kh(fe,[dt]),hl=ga(xn,Ii),Fe=ul?dy(ul,xn):null,sn=Yt&&Fe?M({active:Yt,collisionRect:Fe,droppableRects:B,droppableContainers:v,pointerCoordinates:zu}):null,Sa=uv(sn,"id"),[il,Ou]=x.useState(null),on=Au?xn:ga(xn,Mu),de=oy(on,(g=il==null?void 0:il.rect)!=null?g:null,dt),Be=x.useRef(null),se=x.useCallback((Xt,wt)=>{let{sensor:Ft,options:ge}=wt;if(Ht.current==null)return;const ye=nt.get(Ht.current);if(!ye)return;const oe=Xt.nativeEvent,me=new Ft({active:Ht.current,activeNode:ye,event:oe,options:ge,context:ce,onAbort(Wt){if(!nt.get(Wt))return;const{onDragAbort:Me}=G.current,Ye={id:Wt};Me==null||Me(Ye),at({type:"onDragAbort",event:Ye})},onPending(Wt,Ie,Me,Ye){if(!nt.get(Wt))return;const{onDragPending:gl}=G.current,Pe={id:Wt,constraint:Ie,initialCoordinates:Me,offset:Ye};gl==null||gl(Pe),at({type:"onDragPending",event:Pe})},onStart(Wt){const Ie=Ht.current;if(Ie==null)return;const Me=nt.get(Ie);if(!Me)return;const{onDragStart:Ye}=G.current,vl={activatorEvent:oe,active:{id:Ie,data:Me.data,rect:Mt}};hu.unstable_batchedUpdates(()=>{Ye==null||Ye(vl),it(cn.Initializing),V({type:$t.DragStart,initialCoordinates:Wt,active:Ie}),at({type:"onDragStart",event:vl}),R(Be.current),q(oe)})},onMove(Wt){V({type:$t.DragMove,coordinates:Wt})},onEnd:qe($t.DragEnd),onCancel:qe($t.DragCancel)});Be.current=me;function qe(Wt){return async function(){const{active:Me,collisions:Ye,over:vl,scrollAdjustedTranslate:gl}=ce.current;let Pe=null;if(Me&&gl){const{cancelDrop:Hl}=G.current;Pe={activatorEvent:oe,active:Me,collisions:Ye,delta:gl,over:vl},Wt===$t.DragEnd&&typeof Hl=="function"&&await Promise.resolve(Hl(Pe))&&(Wt=$t.DragCancel)}Ht.current=null,hu.unstable_batchedUpdates(()=>{V({type:Wt}),it(cn.Uninitialized),Ou(null),R(null),q(null),Be.current=null;const Hl=Wt===$t.DragEnd?"onDragEnd":"onDragCancel";if(Pe){const Xe=G.current[Hl];Xe==null||Xe(Pe),at({type:Hl,event:Pe})}})}}},[nt]),Pi=x.useCallback((Xt,wt)=>(Ft,ge)=>{const ye=Ft.nativeEvent,oe=nt.get(ge);if(Ht.current!==null||!oe||ye.dndKit||ye.defaultPrevented)return;const me={active:oe};Xt(Ft,wt.options,me)===!0&&(ye.dndKit={capturedBy:wt.sensor},Ht.current=ge,se(Ft,wt))},[nt,se]),xu=qy(_,Pi);Vy(_),rl(()=>{dt&&et===cn.Initializing&&it(cn.Initialized)},[dt,et]),x.useEffect(()=>{const{onDragMove:Xt}=G.current,{active:wt,activatorEvent:Ft,collisions:ge,over:ye}=ce.current;if(!wt||!Ft)return;const oe={active:wt,activatorEvent:Ft,collisions:ge,delta:{x:hl.x,y:hl.y},over:ye};hu.unstable_batchedUpdates(()=>{Xt==null||Xt(oe),at({type:"onDragMove",event:oe})})},[hl.x,hl.y]),x.useEffect(()=>{const{active:Xt,activatorEvent:wt,collisions:Ft,droppableContainers:ge,scrollAdjustedTranslate:ye}=ce.current;if(!Xt||Ht.current==null||!wt||!ye)return;const{onDragOver:oe}=G.current,me=ge.get(Sa),qe=me&&me.rect.current?{id:me.id,rect:me.rect.current,data:me.data,disabled:me.disabled}:null,Wt={active:Xt,activatorEvent:wt,collisions:Ft,delta:{x:ye.x,y:ye.y},over:qe};hu.unstable_batchedUpdates(()=>{Ou(qe),oe==null||oe(Wt),at({type:"onDragOver",event:Wt})})},[Sa]),rl(()=>{ce.current={activatorEvent:T,active:Yt,activeNode:k,collisionRect:Fe,collisions:sn,droppableRects:B,draggableNodes:nt,draggingNode:al,draggingNodeRect:ul,droppableContainers:Rt,over:il,scrollableAncestors:He,scrollAdjustedTranslate:hl},Mt.current={initial:ul,translated:Fe}},[Yt,k,sn,Fe,nt,al,ul,B,Rt,il,He,hl]),Uy({...Dt,delta:ot,draggingRect:Fe,pointerCoordinates:zu,scrollableAncestors:He,scrollableAncestorRects:jl});const tc=x.useMemo(()=>({active:Yt,activeNode:k,activeNodeRect:dt,activatorEvent:T,collisions:sn,containerNodeRect:je,dragOverlay:ee,draggableNodes:nt,droppableContainers:Rt,droppableRects:B,over:il,measureDroppableContainers:L,scrollableAncestors:He,scrollableAncestorRects:jl,measuringConfiguration:O,measuringScheduled:F,windowRect:fn}),[Yt,k,dt,T,sn,je,ee,nt,Rt,B,il,L,He,jl,O,F,fn]),Cn=x.useMemo(()=>({activatorEvent:T,activators:xu,active:Yt,activeNodeRect:dt,ariaDescribedById:{draggable:tt},dispatch:V,draggableNodes:nt,over:il,measureDroppableContainers:L}),[T,xu,Yt,dt,V,tt,nt,il,L]);return ve.createElement(lv.Provider,{value:W},ve.createElement(Fi.Provider,{value:Cn},ve.createElement(yv.Provider,{value:tc},ve.createElement(mv.Provider,{value:de},m)),ve.createElement(lm,{disabled:(S==null?void 0:S.restoreFocus)===!1})),ve.createElement(ny,{...S,hiddenTextDescribedById:tt}));function Rn(){const Xt=(Qt==null?void 0:Qt.autoScrollEnabled)===!1,wt=typeof E=="object"?E.enabled===!1:E===!1,Ft=$&&!Xt&&!wt;return typeof E=="object"?{...E,enabled:Ft}:{enabled:Ft}}}),cm=x.createContext(null),Fh="button",fm="Draggable";function sm(i){let{id:f,data:o,disabled:s=!1,attributes:d}=i;const g=Du(fm),{activators:y,activatorEvent:S,active:E,activeNodeRect:m,ariaDescribedById:_,draggableNodes:M,over:Y}=x.useContext(Fi),{role:w=Fh,roleDescription:P="draggable",tabIndex:X=0}=d??{},Z=(E==null?void 0:E.id)===f,V=x.useContext(Z?mv:cm),[at,W]=Zi(),[et,it]=Zi(),$=Ky(y,f),Q=mu(o);rl(()=>(M.set(f,{id:f,key:g,node:at,activatorNode:et,data:Q}),()=>{const ot=M.get(f);ot&&ot.key===g&&M.delete(f)}),[M,f]);const nt=x.useMemo(()=>({role:w,tabIndex:X,"aria-disabled":s,"aria-pressed":Z&&w===Fh?!0:void 0,"aria-roledescription":P,"aria-describedby":_.draggable}),[s,w,X,Z,P,_.draggable]);return{active:E,activatorEvent:S,activeNodeRect:m,attributes:nt,isDragging:Z,listeners:s?void 0:$,node:at,over:Y,setNodeRef:W,setActivatorNodeRef:it,transform:V}}function om(){return x.useContext(yv)}const rm="Droppable",dm={timeout:25};function hm(i){let{data:f,disabled:o=!1,id:s,resizeObserverConfig:d}=i;const g=Du(rm),{active:y,dispatch:S,over:E,measureDroppableContainers:m}=x.useContext(Fi),_=x.useRef({disabled:o}),M=x.useRef(!1),Y=x.useRef(null),w=x.useRef(null),{disabled:P,updateMeasurementsFor:X,timeout:Z}={...dm,...d},V=mu(X??s),at=x.useCallback(()=>{if(!M.current){M.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{m(Array.isArray(V.current)?V.current:[V.current]),w.current=null},Z)},[Z]),W=$i({callback:at,disabled:P||!y}),et=x.useCallback((nt,ot)=>{W&&(ot&&(W.unobserve(ot),M.current=!1),nt&&W.observe(nt))},[W]),[it,$]=Zi(et),Q=mu(f);return x.useEffect(()=>{!W||!it.current||(W.disconnect(),M.current=!1,W.observe(it.current))},[it,W]),x.useEffect(()=>(S({type:$t.RegisterDroppable,element:{id:s,key:g,disabled:o,node:it,rect:Y,data:Q}}),()=>S({type:$t.UnregisterDroppable,key:g,id:s})),[s]),x.useEffect(()=>{o!==_.current.disabled&&(S({type:$t.SetDroppableDisabled,id:s,key:g,disabled:o}),_.current.disabled=o)},[s,g,o,S]),{active:y,rect:Y,isOver:(E==null?void 0:E.id)===s,node:it,over:E,setNodeRef:$}}function Bs(i,f,o){const s=i.slice();return s.splice(o<0?s.length+o:o,0,s.splice(f,1)[0]),s}function vm(i,f){return i.reduce((o,s,d)=>{const g=f.get(s);return g&&(o[d]=g),o},Array(i.length))}function Gi(i){return i!==null&&i>=0}function gm(i,f){if(i===f)return!0;if(i.length!==f.length)return!1;for(let o=0;o<i.length;o++)if(i[o]!==f[o])return!1;return!0}function ym(i){return typeof i=="boolean"?{draggable:i,droppable:i}:i}const bv=i=>{let{rects:f,activeIndex:o,overIndex:s,index:d}=i;const g=Bs(f,s,o),y=f[d],S=g[d];return!S||!y?null:{x:S.left-y.left,y:S.top-y.top,scaleX:S.width/y.width,scaleY:S.height/y.height}},Li={scaleX:1,scaleY:1},mm=i=>{var f;let{activeIndex:o,activeNodeRect:s,index:d,rects:g,overIndex:y}=i;const S=(f=g[o])!=null?f:s;if(!S)return null;if(d===o){const m=g[y];return m?{x:0,y:o<y?m.top+m.height-(S.top+S.height):m.top-S.top,...Li}:null}const E=bm(g,d,o);return d>o&&d<=y?{x:0,y:-S.height-E,...Li}:d<o&&d>=y?{x:0,y:S.height+E,...Li}:{x:0,y:0,...Li}};function bm(i,f,o){const s=i[f],d=i[f-1],g=i[f+1];return s?o<f?d?s.top-(d.top+d.height):g?g.top-(s.top+s.height):0:g?g.top-(s.top+s.height):d?s.top-(d.top+d.height):0:0}const pv="Sortable",Sv=ve.createContext({activeIndex:-1,containerId:pv,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:bv,disabled:{draggable:!1,droppable:!1}});function pm(i){let{children:f,id:o,items:s,strategy:d=bv,disabled:g=!1}=i;const{active:y,dragOverlay:S,droppableRects:E,over:m,measureDroppableContainers:_}=om(),M=Du(pv,o),Y=S.rect!==null,w=x.useMemo(()=>s.map($=>typeof $=="object"&&"id"in $?$.id:$),[s]),P=y!=null,X=y?w.indexOf(y.id):-1,Z=m?w.indexOf(m.id):-1,V=x.useRef(w),at=!gm(w,V.current),W=Z!==-1&&X===-1||at,et=ym(g);rl(()=>{at&&P&&_(w)},[at,w,P,_]),x.useEffect(()=>{V.current=w},[w]);const it=x.useMemo(()=>({activeIndex:X,containerId:M,disabled:et,disableTransforms:W,items:w,overIndex:Z,useDragOverlay:Y,sortedRects:vm(w,E),strategy:d}),[X,M,et.draggable,et.droppable,W,w,Z,E,Y,d]);return ve.createElement(Sv.Provider,{value:it},f)}const Sm=i=>{let{id:f,items:o,activeIndex:s,overIndex:d}=i;return Bs(o,s,d).indexOf(f)},Em=i=>{let{containerId:f,isSorting:o,wasDragging:s,index:d,items:g,newIndex:y,previousItems:S,previousContainerId:E,transition:m}=i;return!m||!s||S!==g&&d===y?!1:o?!0:y!==d&&f===E},Tm={duration:200,easing:"ease"},Ev="transform",Dm=pu.Transition.toString({property:Ev,duration:0,easing:"linear"}),Am={roleDescription:"sortable"};function zm(i){let{disabled:f,index:o,node:s,rect:d}=i;const[g,y]=x.useState(null),S=x.useRef(o);return rl(()=>{if(!f&&o!==S.current&&s.current){const E=d.current;if(E){const m=ba(s.current,{ignoreTransform:!0}),_={x:E.left-m.left,y:E.top-m.top,scaleX:E.width/m.width,scaleY:E.height/m.height};(_.x||_.y)&&y(_)}}o!==S.current&&(S.current=o)},[f,o,s,d]),x.useEffect(()=>{g&&y(null)},[g]),g}function Mm(i){let{animateLayoutChanges:f=Em,attributes:o,disabled:s,data:d,getNewIndex:g=Sm,id:y,strategy:S,resizeObserverConfig:E,transition:m=Tm}=i;const{items:_,containerId:M,activeIndex:Y,disabled:w,disableTransforms:P,sortedRects:X,overIndex:Z,useDragOverlay:V,strategy:at}=x.useContext(Sv),W=Om(s,w),et=_.indexOf(y),it=x.useMemo(()=>({sortable:{containerId:M,index:et,items:_},...d}),[M,d,et,_]),$=x.useMemo(()=>_.slice(_.indexOf(y)),[_,y]),{rect:Q,node:nt,isOver:ot,setNodeRef:Rt}=hm({id:y,data:it,disabled:W.droppable,resizeObserverConfig:{updateMeasurementsFor:$,...E}}),{active:rt,activatorEvent:Mt,activeNodeRect:Yt,attributes:Ht,setNodeRef:Qt,listeners:R,isDragging:T,over:q,setActivatorNodeRef:G,transform:tt}=sm({id:y,data:it,attributes:{...Am,...o},disabled:W.draggable}),v=Zg(Rt,Qt),O=!!rt,B=O&&!P&&Gi(Y)&&Gi(Z),L=!V&&T,F=L&&B?tt:null,ct=B?F??(S??at)({rects:X,activeNodeRect:Yt,activeIndex:Y,overIndex:Z,index:et}):null,Dt=Gi(Y)&&Gi(Z)?g({id:y,items:_,activeIndex:Y,overIndex:Z}):et,mt=rt==null?void 0:rt.id,dt=x.useRef({activeId:mt,items:_,newIndex:Dt,containerId:M}),je=_!==dt.current.items,ce=f({active:rt,containerId:M,isDragging:T,isSorting:O,id:y,index:et,items:_,newIndex:dt.current.newIndex,previousItems:dt.current.items,previousContainerId:dt.current.containerId,transition:m,wasDragging:dt.current.activeId!=null}),dl=zm({disabled:!ce,index:et,node:nt,rect:Q});return x.useEffect(()=>{O&&dt.current.newIndex!==Dt&&(dt.current.newIndex=Dt),M!==dt.current.containerId&&(dt.current.containerId=M),_!==dt.current.items&&(dt.current.items=_)},[O,Dt,M,_]),x.useEffect(()=>{if(mt===dt.current.activeId)return;if(mt!=null&&dt.current.activeId==null){dt.current.activeId=mt;return}const al=setTimeout(()=>{dt.current.activeId=mt},50);return()=>clearTimeout(al)},[mt]),{active:rt,activeIndex:Y,attributes:Ht,data:it,rect:Q,index:et,newIndex:Dt,items:_,isOver:ot,isSorting:O,isDragging:T,listeners:R,node:nt,overIndex:Z,over:q,setNodeRef:v,setActivatorNodeRef:G,setDroppableNodeRef:Rt,setDraggableNodeRef:Qt,transform:dl??ct,transition:ee()};function ee(){if(dl||je&&dt.current.newIndex===et)return Dm;if(!(L&&!Ns(Mt)||!m)&&(O||ce))return pu.Transition.toString({...m,property:Ev})}}function Om(i,f){var o,s;return typeof i=="boolean"?{draggable:i,droppable:!1}:{draggable:(o=i==null?void 0:i.draggable)!=null?o:f.draggable,droppable:(s=i==null?void 0:i.droppable)!=null?s:f.droppable}}function Ji(i){if(!i)return!1;const f=i.data.current;return!!(f&&"sortable"in f&&typeof f.sortable=="object"&&"containerId"in f.sortable&&"items"in f.sortable&&"index"in f.sortable)}const xm=[pt.Down,pt.Right,pt.Up,pt.Left],Cm=(i,f)=>{let{context:{active:o,collisionRect:s,droppableRects:d,droppableContainers:g,over:y,scrollableAncestors:S}}=f;if(xm.includes(i.code)){if(i.preventDefault(),!o||!s)return;const E=[];g.getEnabled().forEach(M=>{if(!M||M!=null&&M.disabled)return;const Y=d.get(M.id);if(Y)switch(i.code){case pt.Down:s.top<Y.top&&E.push(M);break;case pt.Up:s.top>Y.top&&E.push(M);break;case pt.Left:s.left>Y.left&&E.push(M);break;case pt.Right:s.left<Y.left&&E.push(M);break}});const m=cy({collisionRect:s,droppableRects:d,droppableContainers:E});let _=uv(m,"id");if(_===(y==null?void 0:y.id)&&m.length>1&&(_=m[1].id),_!=null){const M=g.get(o.id),Y=g.get(_),w=Y?d.get(Y.id):null,P=Y==null?void 0:Y.node.current;if(P&&w&&M&&Y){const Z=ki(P).some(($,Q)=>S[Q]!==$),V=Tv(M,Y),at=Rm(M,Y),W=Z||!V?{x:0,y:0}:{x:at?s.width-w.width:0,y:at?s.height-w.height:0},et={x:w.left,y:w.top};return W.x&&W.y?et:bu(et,W)}}}};function Tv(i,f){return!Ji(i)||!Ji(f)?!1:i.data.current.sortable.containerId===f.data.current.sortable.containerId}function Rm(i,f){return!Ji(i)||!Ji(f)||!Tv(i,f)?!1:i.data.current.sortable.index<f.data.current.sortable.index}function Nm(i){return i.normalize("NFC").replace(/[\s\u3000]+/g,"-").replace(/[^\p{L}\p{N}-]+/gu,"").replace(/^-+|-+$/g,"")||"untitled-task"}function Ms(i){return i?new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(i)):"-"}function du(i){return{originalPath:i.path,path:i.path,title:i.frontmatter.title,priority:i.frontmatter.priority,status:i.frontmatter.status,content:i.content,updatedAt:i.frontmatter.updatedAt,createdAt:i.frontmatter.createdAt,extraFrontmatter:i.extraFrontmatter}}function _m({task:i,selected:f,onSelect:o}){const{attributes:s,listeners:d,setNodeRef:g,transform:y,transition:S}=Mm({id:i.path}),E={transform:pu.Transform.toString(y),transition:S};return H.jsxs("button",{ref:g,style:E,type:"button",className:`task-row${f?" task-row-selected":""}`,onClick:()=>o(i.path),...s,...d,children:[H.jsxs("span",{className:"task-row-badges",children:[H.jsx("span",{className:`badge badge-${i.frontmatter.priority.toLowerCase()}`,children:i.frontmatter.priority}),H.jsx("span",{className:`badge badge-${i.frontmatter.status.toLowerCase()}`,children:i.frontmatter.status})]}),H.jsx("strong",{children:i.frontmatter.title}),H.jsx("small",{children:i.path}),H.jsxs("small",{children:["Updated ",Ms(i.frontmatter.updatedAt)]})]})}async function un(i,f){const o=new Headers(f==null?void 0:f.headers);(f==null?void 0:f.body)!==void 0&&!o.has("Content-Type")&&o.set("Content-Type","application/json");const s=await fetch(i,{headers:o,...f});if(!s.ok){const d=await s.json().catch(()=>null);throw new Error((d==null?void 0:d.error)??`Request failed: ${s.status}`)}if(s.status!==204)return await s.json()}function Um({taskDirs:i,ignorePaths:f,busy:o,onSave:s,onClose:d}){const[g,y]=x.useState(i),[S,E]=x.useState(f.length>0?f:[""]);function m(X,Z){const V=[...g];V[X]=Z,y(V)}function _(){y([...g,""])}function M(X){y(g.filter((Z,V)=>V!==X))}function Y(X,Z){const V=[...S];V[X]=Z,E(V)}function w(){E([...S,""])}function P(X){E(S.filter((Z,V)=>V!==X))}return H.jsx("div",{className:"settings-overlay",onClick:d,children:H.jsxs("div",{className:"settings-modal",onClick:X=>X.stopPropagation(),children:[H.jsxs("div",{className:"panel-header",children:[H.jsx("h2",{children:"Settings"}),H.jsx("button",{type:"button",className:"ghost-button",onClick:d,children:"Close"})]}),H.jsxs("div",{className:"settings-body",children:[H.jsxs("label",{children:[H.jsx("span",{className:"settings-label",children:"Task directories"}),H.jsx("small",{className:"settings-hint",children:"Directories to scan for .md task files (relative to root)"})]}),H.jsx("div",{className:"settings-dir-list",children:g.map((X,Z)=>H.jsxs("div",{className:"settings-dir-row",children:[H.jsx("input",{value:X,onChange:V=>m(Z,V.target.value),placeholder:"e.g. tasks"}),H.jsx("button",{type:"button",className:"ghost-button settings-remove-button",onClick:()=>M(Z),disabled:g.length<=1,title:"Remove",children:H.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:H.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},Z))}),H.jsx("button",{type:"button",className:"ghost-button",onClick:_,children:"+ Add directory"}),H.jsxs("label",{children:[H.jsx("span",{className:"settings-label",children:"Ignore patterns"}),H.jsx("small",{className:"settings-hint",children:"Glob patterns for paths to exclude (e.g. __done__/**, archived/**)"})]}),H.jsx("div",{className:"settings-dir-list",children:S.map((X,Z)=>H.jsxs("div",{className:"settings-dir-row",children:[H.jsx("input",{value:X,onChange:V=>Y(Z,V.target.value),placeholder:"e.g. __done__/**"}),H.jsx("button",{type:"button",className:"ghost-button settings-remove-button",onClick:()=>P(Z),disabled:S.length<=1,title:"Remove",children:H.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:H.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},Z))}),H.jsx("button",{type:"button",className:"ghost-button",onClick:w,children:"+ Add pattern"})]}),H.jsxs("div",{className:"form-actions",children:[H.jsx("button",{type:"button",className:"primary-button",disabled:o||g.every(X=>!X.trim()),onClick:()=>s(g.filter(X=>X.trim()),S.filter(X=>X.trim())),children:"Save"}),H.jsx("button",{type:"button",className:"ghost-button",onClick:d,children:"Cancel"})]})]})})}function jm(){const[i,f]=x.useState([]),[o,s]=x.useState([]),[d,g]=x.useState(null),[y,S]=x.useState(null),[E,m]=x.useState("Loading tasks..."),[_,M]=x.useState(!1),[Y,w]=x.useState(!1),[P,X]=x.useState(["."]),[Z,V]=x.useState([]),[at,W]=x.useState(!1),[et,it]=x.useState(!0),$=x.useMemo(()=>i.find(T=>T.path===d)??null,[d,i]),Q=x.useMemo(()=>et?i.filter(T=>T.frontmatter.status!=="DONE"):i,[i,et]),nt=ay(Xh(Hs,{activationConstraint:{distance:8}}),Xh(Us,{coordinateGetter:Cm}));async function ot(T){const q=await un("/api/tasks");f(q.tasks),s(q.errors),g(G=>{var tt;return G&&q.tasks.some(v=>v.path===G)?G:((tt=q.tasks[0])==null?void 0:tt.path)??null}),T!=null&&T.preserveDraft||S(G=>{if(G!=null&&G.originalPath){const tt=q.tasks.find(v=>v.path===G.originalPath);if(tt)return du(tt)}return null})}async function Rt(){try{const T=await un("/api/config");X(T.taskDirs),V(T.ignorePaths??[])}catch{}}async function rt(T,q){M(!0);try{const G=await un("/api/config",{method:"PUT",body:JSON.stringify({taskDirs:T,ignorePaths:q})});X(G.taskDirs),V(G.ignorePaths??[]),m("Settings saved."),await ot()}catch(G){m(G instanceof Error?G.message:"Failed to save settings.")}finally{M(!1)}}x.useEffect(()=>{Rt(),ot(),m("Tasks loaded.")},[]),x.useEffect(()=>{if(!$){y!=null&&y.originalPath||S(T=>T??null);return}S(T=>!T||T.originalPath!==$.path?du($):T)},[$]),x.useEffect(()=>{const T=new EventSource("/api/events");return T.onmessage=()=>{ot({preserveDraft:!0})},T.onerror=()=>{T.close()},()=>T.close()},[]);async function Mt(){if(y){M(!0),m("");try{if(y.originalPath){const T=await un(`/api/tasks/${encodeURIComponent(y.originalPath)}`,{method:"PATCH",body:JSON.stringify({path:y.path,title:y.title,priority:y.priority,status:y.status,content:y.content,extraFrontmatter:y.extraFrontmatter,baseUpdatedAt:y.updatedAt})});await ot(),g(T.path),S(du(T)),m("Task saved.")}else{const T=await un("/api/tasks",{method:"POST",body:JSON.stringify({path:y.path||void 0,title:y.title,priority:y.priority,status:y.status,content:y.content,extraFrontmatter:y.extraFrontmatter})});await ot(),g(T.path),S(du(T)),m("Task created.")}}catch(T){m(T instanceof Error?T.message:"Failed to save task.")}finally{M(!1)}}}async function Yt(){if(y!=null&&y.originalPath){M(!0),m("");try{await un(`/api/tasks/${encodeURIComponent(y.originalPath)}`,{method:"DELETE"}),S(null),await ot(),m("Task deleted.")}catch(T){m(T instanceof Error?T.message:"Failed to delete task.")}finally{M(!1)}}}async function Ht(T){const{active:q,over:G}=T;if(!G||q.id===G.id)return;const tt=i.findIndex(B=>B.path===q.id),v=i.findIndex(B=>B.path===G.id),O=Bs(i,tt,v);f(O);try{await un("/api/order",{method:"PUT",body:JSON.stringify({order:O.map(B=>B.path)})}),m("Task order updated.")}catch(B){m(B instanceof Error?B.message:"Failed to save order."),await ot()}}async function Qt(T,q){if(y!=null&&y.originalPath)try{const G=await un(`/api/task-fields/${encodeURIComponent(y.originalPath)}`,{method:"PATCH",body:JSON.stringify({[T]:q})});await ot(),g(G.path),S(tt=>tt&&{...tt,[T]:q,updatedAt:G.frontmatter.updatedAt})}catch(G){m(G instanceof Error?G.message:`Failed to update ${T}.`)}}const R=!!y&&(y.originalPath===null||y.path!==y.originalPath||y.title!==($==null?void 0:$.frontmatter.title)||y.content!==($==null?void 0:$.content));return H.jsxs("div",{className:"app-shell",children:[H.jsxs("header",{className:"app-header",children:[H.jsxs("div",{className:"app-header-left",children:[H.jsx("h1",{children:"Markdown Task Viewer"}),H.jsx("p",{className:"eyebrow",children:"v0"})]}),H.jsxs("div",{className:"app-header-actions",children:[H.jsx("button",{type:"button",className:"ghost-button settings-button",onClick:()=>w(!0),title:"Settings",children:H.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"currentColor",children:H.jsx("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.062 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})}),H.jsx("button",{type:"button",className:"primary-button",onClick:()=>{W(!1),S({originalPath:null,path:P[0]?`${P[0]}/`:"",title:"",priority:"MUST",status:"TODO",content:"",extraFrontmatter:{}})},children:"New Task"})]})]}),H.jsxs("main",{className:"layout-grid",children:[H.jsxs("section",{className:"panel",children:[H.jsxs("div",{className:"panel-header",children:[H.jsx("h2",{children:"Tasks"}),H.jsxs("span",{className:"panel-header-right",children:[H.jsxs("label",{className:"filter-toggle",children:[H.jsx("input",{type:"checkbox",checked:et,onChange:()=>it(!et)}),H.jsx("span",{children:"Hide DONE"})]}),H.jsxs("span",{children:[Q.length," items"]})]})]}),H.jsxs("div",{className:"sidebar-scroll",children:[H.jsx(im,{sensors:nt,collisionDetection:iy,onDragEnd:T=>void Ht(T),children:H.jsx(pm,{items:Q.map(T=>T.path),strategy:mm,children:H.jsxs("div",{className:"task-list",children:[Q.map(T=>H.jsx(_m,{task:T,selected:T.path===d,onSelect:q=>{g(q);const G=i.find(tt=>tt.path===q);G&&S(du(G))}},T.path)),Q.length===0?H.jsx("p",{className:"empty-list",children:et?"No active tasks.":"No tasks yet. Create your first markdown task."}):null]})})}),o.length>0?H.jsxs("div",{className:"error-panel",children:[H.jsx("h3",{children:"Unreadable Markdown"}),o.map(T=>H.jsxs("p",{children:[H.jsx("strong",{children:T.path}),H.jsx("span",{children:T.message})]},T.path))]}):null]})]}),H.jsxs("section",{className:"panel editor-panel",children:[H.jsxs("div",{className:"panel-header",children:[H.jsx("h2",{children:y!=null&&y.originalPath?"Edit Task":"Task Details"}),R?H.jsx("span",{className:"dirty-state",children:"Unsaved changes"}):null]}),y?H.jsxs("div",{className:"task-form",children:[H.jsxs("div",{className:"field-row field-row-top",children:[H.jsxs("label",{children:[H.jsx("span",{children:"Priority"}),H.jsxs("select",{value:y.priority,onChange:T=>{const q=T.target.value;S({...y,priority:q}),y.originalPath&&Qt("priority",q)},children:[H.jsx("option",{value:"MUST",children:"MUST"}),H.jsx("option",{value:"WANT",children:"WANT"})]})]}),H.jsxs("label",{children:[H.jsx("span",{children:"Status"}),H.jsxs("select",{value:y.status,onChange:T=>{const q=T.target.value;S({...y,status:q}),y.originalPath&&Qt("status",q)},children:[H.jsx("option",{value:"TODO",children:"TODO"}),H.jsx("option",{value:"WIP",children:"WIP"}),H.jsx("option",{value:"DONE",children:"DONE"})]})]})]}),H.jsxs("label",{children:[H.jsx("span",{children:"Title"}),H.jsx("input",{value:y.title,onChange:T=>{const q=T.target.value,G={title:q};if(!at&&y.originalPath===null){const tt=P[0]||"",v=tt?`${tt}/`:"";G.path=q.trim()?`${v}${Nm(q)}.md`:v}S({...y,...G})},placeholder:"Write release notes",required:!0})]}),H.jsxs("label",{children:[H.jsx("span",{children:"Relative path"}),H.jsx("input",{value:y.path,onChange:T=>{W(!0),S({...y,path:T.target.value})},placeholder:"planning/release-notes.md"})]}),H.jsxs("div",{className:"meta-strip",children:[H.jsxs("span",{children:["Created ",Ms(y.createdAt)]}),H.jsxs("span",{children:["Updated ",Ms(y.updatedAt)]})]}),H.jsxs("label",{className:"editor-label",children:[H.jsx("span",{children:"Markdown body"}),H.jsx("textarea",{value:y.content,onChange:T=>S({...y,content:T.target.value}),onKeyDown:T=>{if(T.nativeEvent.isComposing)return;const q=T.currentTarget,{selectionStart:G,selectionEnd:tt,value:v}=q;if(T.key==="Tab"){T.preventDefault();const O=v.lastIndexOf(`
54
54
  `,G-1)+1,B=v.indexOf(`
55
55
  `,tt),L=B===-1?v.length:B;if(G!==tt){const k=v.slice(O,L).split(`
56
56
  `).map(Dt=>T.shiftKey?Dt.startsWith(" ")?Dt.slice(2):Dt:" "+Dt).join(`
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Markdown Task Viewer</title>
7
- <script type="module" crossorigin src="/assets/index-1KFVs4-d.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-DTsDS3Ho.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-D8W_VwBM.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-task-viewer",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Launch a local task viewer/editor for markdown files with frontmatter",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -62,4 +62,4 @@
62
62
  "vite": "^6.2.1",
63
63
  "vitest": "^3.0.8"
64
64
  }
65
- }
65
+ }