@mdspl/mds-shared-ui 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -7,4 +7,4 @@ React keys must be passed directly to JSX without using spread:
7
7
  To pick up a draggable item, press the space bar.
8
8
  While dragging, use the arrow keys to move the item.
9
9
  Press space again to drop the item in its new position, or press escape to cancel.
10
- `},eo={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function to(e){let{announcements:t=eo,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Qr}=e;const{announce:s,announcement:i}=Kr(),l=nt("DndLiveRegion"),[u,f]=d.useState(!1);if(d.useEffect(()=>{f(!0)},[]),Jr(d.useMemo(()=>({onDragStart(p){let{active:S}=p;s(t.onDragStart({active:S}))},onDragMove(p){let{active:S,over:v}=p;t.onDragMove&&s(t.onDragMove({active:S,over:v}))},onDragOver(p){let{active:S,over:v}=p;s(t.onDragOver({active:S,over:v}))},onDragEnd(p){let{active:S,over:v}=p;s(t.onDragEnd({active:S,over:v}))},onDragCancel(p){let{active:S,over:v}=p;s(t.onDragCancel({active:S,over:v}))}}),[s,t])),!u)return null;const g=d.createElement(d.Fragment,null,d.createElement(Xr,{id:r,value:o.draggable}),d.createElement(qr,{id:l,announcement:i}));return n?Ue.createPortal(g,n):g}var F;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(F||(F={}));function vt(){}function no(e,t){return d.useMemo(()=>({sensor:e,options:{}}),[e,t])}function ro(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ae=Object.freeze({x:0,y:0});function oo(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function so(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function io(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function ao(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Sn(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const Hn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Sn(t,t.left,t.top),s=[];for(const i of r){const{id:l}=i,u=n.get(l);if(u){const f=oo(Sn(u),o);s.push({id:l,data:{droppableContainer:i,value:f}})}}return s.sort(so)};function lo(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),i=o-r,l=s-n;if(r<o&&n<s){const u=t.width*t.height,f=e.width*e.height,g=i*l,p=g/(u+f-g);return Number(p.toFixed(4))}return 0}const co=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:i}=s,l=n.get(i);if(l){const u=lo(l,t);u>0&&o.push({id:i,data:{droppableContainer:s,value:u}})}}return o.sort(io)};function uo(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Yn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ae}function fo(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];return o.reduce((i,l)=>({...i,top:i.top+e*l.y,bottom:i.bottom+e*l.y,left:i.left+e*l.x,right:i.right+e*l.x}),{...n})}}const ho=fo(1);function go(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function po(e,t,n){const r=go(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:l}=r,u=e.left-i-(1-o)*parseFloat(n),f=e.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),g=o?e.width/o:e.width,p=s?e.height/s:e.height;return{width:g,height:p,top:f,right:u+g,bottom:f+p,left:u}}const vo={ignoreTransform:!1};function Le(e,t){t===void 0&&(t=vo);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:g}=q(e).getComputedStyle(e);f&&(n=po(n,f,g))}const{top:r,left:o,width:s,height:i,bottom:l,right:u}=n;return{top:r,left:o,width:s,height:i,bottom:l,right:u}}function yn(e){return Le(e,{ignoreTransform:!0})}function bo(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function mo(e,t){return t===void 0&&(t=q(e).getComputedStyle(e)),t.position==="fixed"}function xo(e,t){t===void 0&&(t=q(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const s=t[o];return typeof s=="string"?n.test(s):!1})}function Gt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Yt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!et(o)||Fn(o)||n.includes(o))return n;const s=q(e).getComputedStyle(o);return o!==e&&xo(o,s)&&n.push(o),mo(o,s)?n:r(o.parentNode)}return e?r(e):n}function Wn(e){const[t]=Gt(e,1);return t??null}function kt(e){return!mt||!e?null:Ae(e)?e:Ht(e)?Yt(e)||e===Ne(e).scrollingElement?window:et(e)?e:null:null}function Un(e){return Ae(e)?e.scrollX:e.scrollLeft}function Gn(e){return Ae(e)?e.scrollY:e.scrollTop}function Ft(e){return{x:Un(e),y:Gn(e)}}var V;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(V||(V={}));function Xn(e){return!mt||!e?!1:e===document.scrollingElement}function qn(e){const t={x:0,y:0},n=Xn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,s=e.scrollLeft<=t.x,i=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:o,isLeft:s,isBottom:i,isRight:l,maxScroll:r,minScroll:t}}const So={x:.2,y:.2};function yo(e,t,n,r,o){let{top:s,left:i,right:l,bottom:u}=n;r===void 0&&(r=10),o===void 0&&(o=So);const{isTop:f,isBottom:g,isLeft:p,isRight:S}=qn(e),v={x:0,y:0},m={x:0,y:0},h={height:t.height*o.y,width:t.width*o.x};return!f&&s<=t.top+h.height?(v.y=V.Backward,m.y=r*Math.abs((t.top+h.height-s)/h.height)):!g&&u>=t.bottom-h.height&&(v.y=V.Forward,m.y=r*Math.abs((t.bottom-h.height-u)/h.height)),!S&&l>=t.right-h.width?(v.x=V.Forward,m.x=r*Math.abs((t.right-h.width-l)/h.width)):!p&&i<=t.left+h.width&&(v.x=V.Backward,m.x=r*Math.abs((t.left+h.width-i)/h.width)),{direction:v,speed:m}}function wo(e){if(e===document.scrollingElement){const{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Kn(e){return e.reduce((t,n)=>ke(t,Ft(n)),ae)}function Co(e){return e.reduce((t,n)=>t+Un(n),0)}function Ro(e){return e.reduce((t,n)=>t+Gn(n),0)}function Eo(e,t){if(t===void 0&&(t=Le),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);Wn(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Do=[["x",["left","right"],Co],["y",["top","bottom"],Ro]];class Xt{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Gt(n),o=Kn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,l]of Do)for(const u of i)Object.defineProperty(this,u,{get:()=>{const f=l(r),g=o[s]-f;return this.rect[u]+g},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ge{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function To(e){const{EventTarget:t}=q(e);return e instanceof t?e:Ne(e)}function Mt(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var se;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(se||(se={}));function wn(e){e.preventDefault()}function jo(e){e.stopPropagation()}var k;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(k||(k={}));const Jn={start:[k.Space,k.Enter],cancel:[k.Esc],end:[k.Space,k.Enter,k.Tab]},_o=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case k.Right:return{...n,x:n.x+25};case k.Left:return{...n,x:n.x-25};case k.Down:return{...n,y:n.y+25};case k.Up:return{...n,y:n.y-25}}};class Zn{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Ge(Ne(n)),this.windowListeners=new Ge(q(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(se.Resize,this.handleCancel),this.windowListeners.add(se.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(se.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&Eo(r),n(ae)}handleKeyDown(t){if(Ut(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=Jn,coordinateGetter:i=_o,scrollBehavior:l="smooth"}=o,{code:u}=t;if(s.end.includes(u)){this.handleEnd(t);return}if(s.cancel.includes(u)){this.handleCancel(t);return}const{collisionRect:f}=r.current,g=f?{x:f.left,y:f.top}:ae;this.referenceCoordinates||(this.referenceCoordinates=g);const p=i(t,{active:n,context:r.current,currentCoordinates:g});if(p){const S=pt(p,g),v={x:0,y:0},{scrollableAncestors:m}=r.current;for(const h of m){const x=t.code,{isTop:y,isRight:C,isLeft:R,isBottom:E,maxScroll:_,minScroll:T}=qn(h),j=wo(h),O={x:Math.min(x===k.Right?j.right-j.width/2:j.right,Math.max(x===k.Right?j.left:j.left+j.width/2,p.x)),y:Math.min(x===k.Down?j.bottom-j.height/2:j.bottom,Math.max(x===k.Down?j.top:j.top+j.height/2,p.y))},L=x===k.Right&&!C||x===k.Left&&!R,P=x===k.Down&&!E||x===k.Up&&!y;if(L&&O.x!==p.x){const N=h.scrollLeft+S.x,U=x===k.Right&&N<=_.x||x===k.Left&&N>=T.x;if(U&&!S.y){h.scrollTo({left:N,behavior:l});return}U?v.x=h.scrollLeft-N:v.x=x===k.Right?h.scrollLeft-_.x:h.scrollLeft-T.x,v.x&&h.scrollBy({left:-v.x,behavior:l});break}else if(P&&O.y!==p.y){const N=h.scrollTop+S.y,U=x===k.Down&&N<=_.y||x===k.Up&&N>=T.y;if(U&&!S.x){h.scrollTo({top:N,behavior:l});return}U?v.y=h.scrollTop-N:v.y=x===k.Down?h.scrollTop-_.y:h.scrollTop-T.y,v.y&&h.scrollBy({top:-v.y,behavior:l});break}}this.handleMove(t,ke(pt(p,this.referenceCoordinates),v))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Zn.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Jn,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const l=s.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Cn(e){return!!(e&&"distance"in e)}function Rn(e){return!!(e&&"delay"in e)}class qt{constructor(t,n,r){var o;r===void 0&&(r=To(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:i}=s;this.props=t,this.events=n,this.document=Ne(i),this.documentListeners=new Ge(this.document),this.listeners=new Ge(r),this.windowListeners=new Ge(q(i)),this.initialCoordinates=(o=zt(s))!=null?o:ae,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(se.Resize,this.handleCancel),this.windowListeners.add(se.DragStart,wn),this.windowListeners.add(se.VisibilityChange,this.handleCancel),this.windowListeners.add(se.ContextMenu,wn),this.documentListeners.add(se.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Rn(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Cn(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(se.Click,jo,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(se.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:s}=this,{onMove:i,options:{activationConstraint:l}}=s;if(!o)return;const u=(n=zt(t))!=null?n:ae,f=pt(o,u);if(!r&&l){if(Cn(l)){if(l.tolerance!=null&&Mt(f,l.tolerance))return this.handleCancel();if(Mt(f,l.distance))return this.handleStart()}if(Rn(l)&&Mt(f,l.tolerance))return this.handleCancel();this.handlePending(l,f);return}t.cancelable&&t.preventDefault(),i(u)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===k.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Oo={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Kt extends qt{constructor(t){const{event:n}=t,r=Ne(n.target);super(t,Oo,r)}}Kt.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const Io={move:{name:"mousemove"},end:{name:"mouseup"}};var Vt;(function(e){e[e.RightClick=2]="RightClick"})(Vt||(Vt={}));class ko extends qt{constructor(t){super(t,Io,Ne(t.event.target))}}ko.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Vt.RightClick?!1:(r?.({event:n}),!0)}}];const At={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Mo extends qt{constructor(t){super(t,At)}static setup(){return window.addEventListener(At.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(At.move.name,t)};function t(){}}}Mo.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Xe;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Xe||(Xe={}));var bt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(bt||(bt={}));function Ao(e){let{acceleration:t,activator:n=Xe.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:l=bt.TreeOrder,pointerCoordinates:u,scrollableAncestors:f,scrollableAncestorRects:g,delta:p,threshold:S}=e;const v=Lo({delta:p,disabled:!s}),[m,h]=Hr(),x=d.useRef({x:0,y:0}),y=d.useRef({x:0,y:0}),C=d.useMemo(()=>{switch(n){case Xe.Pointer:return u?{top:u.y,bottom:u.y,left:u.x,right:u.x}:null;case Xe.DraggableRect:return o}},[n,o,u]),R=d.useRef(null),E=d.useCallback(()=>{const T=R.current;if(!T)return;const j=x.current.x*y.current.x,O=x.current.y*y.current.y;T.scrollBy(j,O)},[]),_=d.useMemo(()=>l===bt.TreeOrder?[...f].reverse():f,[l,f]);d.useEffect(()=>{if(!s||!f.length||!C){h();return}for(const T of _){if(r?.(T)===!1)continue;const j=f.indexOf(T),O=g[j];if(!O)continue;const{direction:L,speed:P}=yo(T,O,C,t,S);for(const N of["x","y"])v[N][L[N]]||(P[N]=0,L[N]=0);if(P.x>0||P.y>0){h(),R.current=T,m(E,i),x.current=P,y.current=L;return}}x.current={x:0,y:0},y.current={x:0,y:0},h()},[t,E,r,h,s,i,JSON.stringify(C),JSON.stringify(v),m,f,_,g,JSON.stringify(S)])}const No={x:{[V.Backward]:!1,[V.Forward]:!1},y:{[V.Backward]:!1,[V.Forward]:!1}};function Lo(e){let{delta:t,disabled:n}=e;const r=Pt(t);return tt(o=>{if(n||!r||!o)return No;const s={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[V.Backward]:o.x[V.Backward]||s.x===-1,[V.Forward]:o.x[V.Forward]||s.x===1},y:{[V.Backward]:o.y[V.Backward]||s.y===-1,[V.Forward]:o.y[V.Forward]||s.y===1}}},[n,t,r])}function $o(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return tt(o=>{var s;return t==null?null:(s=r??o)!=null?s:null},[r,t])}function Po(e,t){return d.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,s=o.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,r)}));return[...n,...s]},[]),[e,t])}var Je;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Je||(Je={}));var Bt;(function(e){e.Optimized="optimized"})(Bt||(Bt={}));const En=new Map;function zo(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=d.useState(null),{frequency:l,measure:u,strategy:f}=o,g=d.useRef(e),p=x(),S=Ke(p),v=d.useCallback(function(y){y===void 0&&(y=[]),!S.current&&i(C=>C===null?y:C.concat(y.filter(R=>!C.includes(R))))},[S]),m=d.useRef(null),h=tt(y=>{if(p&&!n)return En;if(!y||y===En||g.current!==e||s!=null){const C=new Map;for(let R of e){if(!R)continue;if(s&&s.length>0&&!s.includes(R.id)&&R.rect.current){C.set(R.id,R.rect.current);continue}const E=R.node.current,_=E?new Xt(u(E),E):null;R.rect.current=_,_&&C.set(R.id,_)}return C}return y},[e,s,n,p,u]);return d.useEffect(()=>{g.current=e},[e]),d.useEffect(()=>{p||v()},[n,p]),d.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),d.useEffect(()=>{p||typeof l!="number"||m.current!==null||(m.current=setTimeout(()=>{v(),m.current=null},l))},[l,p,v,...r]),{droppableRects:h,measureDroppableContainers:v,measuringScheduled:s!=null};function x(){switch(f){case Je.Always:return!1;case Je.BeforeDragging:return n;default:return!n}}}function Qn(e,t){return tt(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Fo(e,t){return Qn(e,t)}function Vo(e){let{callback:t,disabled:n}=e;const r=Wt(t),o=d.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return d.useEffect(()=>()=>o?.disconnect(),[o]),o}function xt(e){let{callback:t,disabled:n}=e;const r=Wt(t),o=d.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return d.useEffect(()=>()=>o?.disconnect(),[o]),o}function Bo(e){return new Xt(Le(e),e)}function Dn(e,t,n){t===void 0&&(t=Bo);const[r,o]=d.useState(null);function s(){o(u=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=u??n)!=null?f:null}const g=t(e);return JSON.stringify(u)===JSON.stringify(g)?u:g})}const i=Vo({callback(u){if(e)for(const f of u){const{type:g,target:p}=f;if(g==="childList"&&p instanceof HTMLElement&&p.contains(e)){s();break}}}}),l=xt({callback:s});return fe(()=>{s(),e?(l?.observe(e),i?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),i?.disconnect())},[e]),r}function Ho(e){const t=Qn(e);return Yn(e,t)}const Tn=[];function Yo(e){const t=d.useRef(e),n=tt(r=>e?r&&r!==Tn&&e&&t.current&&e.parentNode===t.current.parentNode?r:Gt(e):Tn,[e]);return d.useEffect(()=>{t.current=e},[e]),n}function Wo(e){const[t,n]=d.useState(null),r=d.useRef(e),o=d.useCallback(s=>{const i=kt(s.target);i&&n(l=>l?(l.set(i,Ft(i)),new Map(l)):null)},[]);return d.useEffect(()=>{const s=r.current;if(e!==s){i(s);const l=e.map(u=>{const f=kt(u);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,Ft(f)]):null}).filter(u=>u!=null);n(l.length?new Map(l):null),r.current=e}return()=>{i(e),i(s)};function i(l){l.forEach(u=>{const f=kt(u);f?.removeEventListener("scroll",o)})}},[o,e]),d.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>ke(s,i),ae):Kn(e):ae,[e,t])}function jn(e,t){t===void 0&&(t=[]);const n=d.useRef(null);return d.useEffect(()=>{n.current=null},t),d.useEffect(()=>{const r=e!==ae;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?pt(e,n.current):ae}function Uo(e){d.useEffect(()=>{if(!mt)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Go(e,t){return d.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function er(e){return d.useMemo(()=>e?bo(e):null,[e])}const _n=[];function Xo(e,t){t===void 0&&(t=Le);const[n]=e,r=er(n?q(n):null),[o,s]=d.useState(_n);function i(){s(()=>e.length?e.map(u=>Xn(u)?r:new Xt(t(u),u)):_n)}const l=xt({callback:i});return fe(()=>{l?.disconnect(),i(),e.forEach(u=>l?.observe(u))},[e]),o}function qo(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return et(t)?t:e}function Ko(e){let{measure:t}=e;const[n,r]=d.useState(null),o=d.useCallback(f=>{for(const{target:g}of f)if(et(g)){r(p=>{const S=t(g);return p?{...p,width:S.width,height:S.height}:S});break}},[t]),s=xt({callback:o}),i=d.useCallback(f=>{const g=qo(f);s?.disconnect(),g&&s?.observe(g),r(g?t(g):null)},[t,s]),[l,u]=gt(i);return d.useMemo(()=>({nodeRef:l,rect:n,setRef:u}),[n,l,u])}const Jo=[{sensor:Kt,options:{}},{sensor:Zn,options:{}}],Zo={current:{}},ft={draggable:{measure:yn},droppable:{measure:yn,strategy:Je.WhileDragging,frequency:Bt.Optimized},dragOverlay:{measure:Le}};class qe extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Qo={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new qe,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:vt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ft,measureDroppableContainers:vt,windowRect:null,measuringScheduled:!1},es={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:vt,draggableNodes:new Map,over:null,measureDroppableContainers:vt},St=d.createContext(es),tr=d.createContext(Qo);function ts(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new qe}}}function ns(e,t){switch(t.type){case F.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case F.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case F.DragEnd:case F.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case F.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new qe(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case F.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new qe(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case F.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new qe(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function rs(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=d.useContext(St),s=Pt(r),i=Pt(n?.id);return d.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!Ut(s)||document.activeElement===s.target)return;const l=o.get(i);if(!l)return;const{activatorNode:u,node:f}=l;if(!u.current&&!f.current)return;requestAnimationFrame(()=>{for(const g of[u.current,f.current]){if(!g)continue;const p=Ur(g);if(p){p.focus();break}}})}},[r,t,o,i,s]),null}function os(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function ss(e){return d.useMemo(()=>({draggable:{...ft.draggable,...e?.draggable},droppable:{...ft.droppable,...e?.droppable},dragOverlay:{...ft.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function is(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=d.useRef(!1),{x:i,y:l}=typeof o=="boolean"?{x:o,y:o}:o;fe(()=>{if(!i&&!l||!t){s.current=!1;return}if(s.current||!r)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const g=n(f),p=Yn(g,r);if(i||(p.x=0),l||(p.y=0),s.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const S=Wn(f);S&&S.scrollBy({top:p.y,left:p.x})}},[t,i,l,r,n])}const nr=d.createContext({...ae,scaleX:1,scaleY:1});var we;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(we||(we={}));const rr=d.memo(function(t){var n,r,o,s;let{id:i,accessibility:l,autoScroll:u=!0,children:f,sensors:g=Jo,collisionDetection:p=co,measuring:S,modifiers:v,...m}=t;const h=d.useReducer(ns,void 0,ts),[x,y]=h,[C,R]=Zr(),[E,_]=d.useState(we.Uninitialized),T=E===we.Initialized,{draggable:{active:j,nodes:O,translate:L},droppable:{containers:P}}=x,N=j!=null?O.get(j):null,U=d.useRef({initial:null,translated:null}),X=d.useMemo(()=>{var W;return j!=null?{id:j,data:(W=N?.data)!=null?W:Zo,rect:U}:null},[j,N]),ne=d.useRef(null),[he,Re]=d.useState(null),[H,Ee]=d.useState(null),re=Ke(m,Object.values(m)),ve=nt("DndDescribedBy",i),b=d.useMemo(()=>P.getEnabled(),[P]),D=ss(S),{droppableRects:I,measureDroppableContainers:A,measuringScheduled:le}=zo(b,{dragging:T,dependencies:[L.x,L.y],config:D.droppable}),Y=$o(O,j),$=d.useMemo(()=>H?zt(H):null,[H]),G=Dr(),J=Fo(Y,D.draggable.measure);is({activeNode:j!=null?O.get(j):null,config:G.layoutShiftCompensation,initialRect:J,measure:D.draggable.measure});const M=Dn(Y,D.draggable.measure,J),$e=Dn(Y?Y.parentElement:null),ce=d.useRef({activatorEvent:null,active:null,activeNode:Y,collisionRect:null,collisions:null,droppableRects:I,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),De=P.getNodeFor((n=ce.current.over)==null?void 0:n.id),ge=Ko({measure:D.dragOverlay.measure}),Te=(r=ge.nodeRef.current)!=null?r:Y,je=T?(o=ge.rect)!=null?o:M:null,Qt=!!(ge.nodeRef.current&&ge.rect),en=Ho(Qt?null:M),Ct=er(Te?q(Te):null),be=Yo(T?De??Y:null),rt=Xo(be),ot=os(v,{transform:{x:L.x-en.x,y:L.y-en.y,scaleX:1,scaleY:1},activatorEvent:H,active:X,activeNodeRect:M,containerNodeRect:$e,draggingNodeRect:je,over:ce.current.over,overlayNodeRect:ge.rect,scrollableAncestors:be,scrollableAncestorRects:rt,windowRect:Ct}),tn=$?ke($,L):null,nn=Wo(be),xr=jn(nn),Sr=jn(nn,[M]),_e=ke(ot,xr),Oe=je?ho(je,ot):null,Pe=X&&Oe?p({active:X,collisionRect:Oe,droppableRects:I,droppableContainers:b,pointerCoordinates:tn}):null,rn=ao(Pe,"id"),[me,on]=d.useState(null),yr=Qt?ot:ke(ot,Sr),wr=uo(yr,(s=me?.rect)!=null?s:null,M),Rt=d.useRef(null),sn=d.useCallback((W,Z)=>{let{sensor:Q,options:xe}=Z;if(ne.current==null)return;const oe=O.get(ne.current);if(!oe)return;const ee=W.nativeEvent,ue=new Q({active:ne.current,activeNode:oe,event:ee,options:xe,context:ce,onAbort(B){if(!O.get(B))return;const{onDragAbort:de}=re.current,pe={id:B};de?.(pe),C({type:"onDragAbort",event:pe})},onPending(B,Se,de,pe){if(!O.get(B))return;const{onDragPending:Fe}=re.current,ye={id:B,constraint:Se,initialCoordinates:de,offset:pe};Fe?.(ye),C({type:"onDragPending",event:ye})},onStart(B){const Se=ne.current;if(Se==null)return;const de=O.get(Se);if(!de)return;const{onDragStart:pe}=re.current,ze={activatorEvent:ee,active:{id:Se,data:de.data,rect:U}};Ue.unstable_batchedUpdates(()=>{pe?.(ze),_(we.Initializing),y({type:F.DragStart,initialCoordinates:B,active:Se}),C({type:"onDragStart",event:ze}),Re(Rt.current),Ee(ee)})},onMove(B){y({type:F.DragMove,coordinates:B})},onEnd:Ie(F.DragEnd),onCancel:Ie(F.DragCancel)});Rt.current=ue;function Ie(B){return async function(){const{active:de,collisions:pe,over:ze,scrollAdjustedTranslate:Fe}=ce.current;let ye=null;if(de&&Fe){const{cancelDrop:Ve}=re.current;ye={activatorEvent:ee,active:de,collisions:pe,delta:Fe,over:ze},B===F.DragEnd&&typeof Ve=="function"&&await Promise.resolve(Ve(ye))&&(B=F.DragCancel)}ne.current=null,Ue.unstable_batchedUpdates(()=>{y({type:B}),_(we.Uninitialized),on(null),Re(null),Ee(null),Rt.current=null;const Ve=B===F.DragEnd?"onDragEnd":"onDragCancel";if(ye){const Et=re.current[Ve];Et?.(ye),C({type:Ve,event:ye})}})}}},[O]),Cr=d.useCallback((W,Z)=>(Q,xe)=>{const oe=Q.nativeEvent,ee=O.get(xe);if(ne.current!==null||!ee||oe.dndKit||oe.defaultPrevented)return;const ue={active:ee};W(Q,Z.options,ue)===!0&&(oe.dndKit={capturedBy:Z.sensor},ne.current=xe,sn(Q,Z))},[O,sn]),an=Po(g,Cr);Uo(g),fe(()=>{M&&E===we.Initializing&&_(we.Initialized)},[M,E]),d.useEffect(()=>{const{onDragMove:W}=re.current,{active:Z,activatorEvent:Q,collisions:xe,over:oe}=ce.current;if(!Z||!Q)return;const ee={active:Z,activatorEvent:Q,collisions:xe,delta:{x:_e.x,y:_e.y},over:oe};Ue.unstable_batchedUpdates(()=>{W?.(ee),C({type:"onDragMove",event:ee})})},[_e.x,_e.y]),d.useEffect(()=>{const{active:W,activatorEvent:Z,collisions:Q,droppableContainers:xe,scrollAdjustedTranslate:oe}=ce.current;if(!W||ne.current==null||!Z||!oe)return;const{onDragOver:ee}=re.current,ue=xe.get(rn),Ie=ue&&ue.rect.current?{id:ue.id,rect:ue.rect.current,data:ue.data,disabled:ue.disabled}:null,B={active:W,activatorEvent:Z,collisions:Q,delta:{x:oe.x,y:oe.y},over:Ie};Ue.unstable_batchedUpdates(()=>{on(Ie),ee?.(B),C({type:"onDragOver",event:B})})},[rn]),fe(()=>{ce.current={activatorEvent:H,active:X,activeNode:Y,collisionRect:Oe,collisions:Pe,droppableRects:I,draggableNodes:O,draggingNode:Te,draggingNodeRect:je,droppableContainers:P,over:me,scrollableAncestors:be,scrollAdjustedTranslate:_e},U.current={initial:je,translated:Oe}},[X,Y,Pe,Oe,O,Te,je,I,P,me,be,_e]),Ao({...G,delta:L,draggingRect:Oe,pointerCoordinates:tn,scrollableAncestors:be,scrollableAncestorRects:rt});const Rr=d.useMemo(()=>({active:X,activeNode:Y,activeNodeRect:M,activatorEvent:H,collisions:Pe,containerNodeRect:$e,dragOverlay:ge,draggableNodes:O,droppableContainers:P,droppableRects:I,over:me,measureDroppableContainers:A,scrollableAncestors:be,scrollableAncestorRects:rt,measuringConfiguration:D,measuringScheduled:le,windowRect:Ct}),[X,Y,M,H,Pe,$e,ge,O,P,I,me,A,be,rt,D,le,Ct]),Er=d.useMemo(()=>({activatorEvent:H,activators:an,active:X,activeNodeRect:M,ariaDescribedById:{draggable:ve},dispatch:y,draggableNodes:O,over:me,measureDroppableContainers:A}),[H,an,X,M,y,ve,O,me,A]);return d.createElement(Bn.Provider,{value:R},d.createElement(St.Provider,{value:Er},d.createElement(tr.Provider,{value:Rr},d.createElement(nr.Provider,{value:wr},f)),d.createElement(rs,{disabled:l?.restoreFocus===!1})),d.createElement(to,{...l,hiddenTextDescribedById:ve}));function Dr(){const W=he?.autoScrollEnabled===!1,Z=typeof u=="object"?u.enabled===!1:u===!1,Q=T&&!W&&!Z;return typeof u=="object"?{...u,enabled:Q}:{enabled:Q}}}),as=d.createContext(null),On="button",ls="Draggable";function cs(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=nt(ls),{activators:i,activatorEvent:l,active:u,activeNodeRect:f,ariaDescribedById:g,draggableNodes:p,over:S}=d.useContext(St),{role:v=On,roleDescription:m="draggable",tabIndex:h=0}=o??{},x=u?.id===t,y=d.useContext(x?nr:as),[C,R]=gt(),[E,_]=gt(),T=Go(i,t),j=Ke(n);fe(()=>(p.set(t,{id:t,key:s,node:C,activatorNode:E,data:j}),()=>{const L=p.get(t);L&&L.key===s&&p.delete(t)}),[p,t]);const O=d.useMemo(()=>({role:v,tabIndex:h,"aria-disabled":r,"aria-pressed":x&&v===On?!0:void 0,"aria-roledescription":m,"aria-describedby":g.draggable}),[r,v,h,x,m,g.draggable]);return{active:u,activatorEvent:l,activeNodeRect:f,attributes:O,isDragging:x,listeners:r?void 0:T,node:C,over:S,setNodeRef:R,setActivatorNodeRef:_,transform:y}}function us(){return d.useContext(tr)}const ds="Droppable",fs={timeout:25};function hs(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=nt(ds),{active:i,dispatch:l,over:u,measureDroppableContainers:f}=d.useContext(St),g=d.useRef({disabled:n}),p=d.useRef(!1),S=d.useRef(null),v=d.useRef(null),{disabled:m,updateMeasurementsFor:h,timeout:x}={...fs,...o},y=Ke(h??r),C=d.useCallback(()=>{if(!p.current){p.current=!0;return}v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{f(Array.isArray(y.current)?y.current:[y.current]),v.current=null},x)},[x]),R=xt({callback:C,disabled:m||!i}),E=d.useCallback((O,L)=>{R&&(L&&(R.unobserve(L),p.current=!1),O&&R.observe(O))},[R]),[_,T]=gt(E),j=Ke(t);return d.useEffect(()=>{!R||!_.current||(R.disconnect(),p.current=!1,R.observe(_.current))},[_,R]),d.useEffect(()=>(l({type:F.RegisterDroppable,element:{id:r,key:s,disabled:n,node:_,rect:S,data:j}}),()=>l({type:F.UnregisterDroppable,key:s,id:r})),[r]),d.useEffect(()=>{n!==g.current.disabled&&(l({type:F.SetDroppableDisabled,id:r,key:s,disabled:n}),g.current.disabled=n)},[r,s,n,l]),{active:i,rect:S,isOver:u?.id===r,node:_,over:u,setNodeRef:T}}function yt(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function gs(e,t){return e.reduce((n,r,o)=>{const s=t.get(r);return s&&(n[o]=s),n},Array(e.length))}function ct(e){return e!==null&&e>=0}function ps(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function vs(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const ut={scaleX:1,scaleY:1},bs=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:s,index:i}=e;const l=(t=n[o])!=null?t:r;if(!l)return null;const u=ms(n,i,o);if(i===o){const f=n[s];return f?{x:o<s?f.left+f.width-(l.left+l.width):f.left-l.left,y:0,...ut}:null}return i>o&&i<=s?{x:-l.width-u,y:0,...ut}:i<o&&i>=s?{x:l.width+u,y:0,...ut}:{x:0,y:0,...ut}};function ms(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return!r||!o&&!s?0:n<t?o?r.left-(o.left+o.width):s.left-(r.left+r.width):s?s.left-(r.left+r.width):r.left-(o.left+o.width)}const or=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=yt(t,r,n),i=t[o],l=s[o];return!l||!i?null:{x:l.left-i.left,y:l.top-i.top,scaleX:l.width/i.width,scaleY:l.height/i.height}},dt={scaleX:1,scaleY:1},xs=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const l=(t=s[n])!=null?t:r;if(!l)return null;if(o===n){const f=s[i];return f?{x:0,y:n<i?f.top+f.height-(l.top+l.height):f.top-l.top,...dt}:null}const u=Ss(s,o,n);return o>n&&o<=i?{x:0,y:-l.height-u,...dt}:o<n&&o>=i?{x:0,y:l.height+u,...dt}:{x:0,y:0,...dt}};function Ss(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return r?n<t?o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const sr="Sortable",ir=d.createContext({activeIndex:-1,containerId:sr,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:or,disabled:{draggable:!1,droppable:!1}});function ar(e){let{children:t,id:n,items:r,strategy:o=or,disabled:s=!1}=e;const{active:i,dragOverlay:l,droppableRects:u,over:f,measureDroppableContainers:g}=us(),p=nt(sr,n),S=l.rect!==null,v=d.useMemo(()=>r.map(T=>typeof T=="object"&&"id"in T?T.id:T),[r]),m=i!=null,h=i?v.indexOf(i.id):-1,x=f?v.indexOf(f.id):-1,y=d.useRef(v),C=!ps(v,y.current),R=x!==-1&&h===-1||C,E=vs(s);fe(()=>{C&&m&&g(v)},[C,v,m,g]),d.useEffect(()=>{y.current=v},[v]);const _=d.useMemo(()=>({activeIndex:h,containerId:p,disabled:E,disableTransforms:R,items:v,overIndex:x,useDragOverlay:S,sortedRects:gs(v,u),strategy:o}),[h,p,E.draggable,E.droppable,R,v,x,u,S,o]);return d.createElement(ir.Provider,{value:_},t)}const ys=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return yt(n,r,o).indexOf(t)},ws=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:l,previousContainerId:u,transition:f}=e;return!f||!r||l!==s&&o===i?!1:n?!0:i!==o&&t===u},Cs={duration:200,easing:"ease"},lr="transform",Rs=Me.Transition.toString({property:lr,duration:0,easing:"linear"}),Es={roleDescription:"sortable"};function Ds(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=d.useState(null),l=d.useRef(n);return fe(()=>{if(!t&&n!==l.current&&r.current){const u=o.current;if(u){const f=Le(r.current,{ignoreTransform:!0}),g={x:u.left-f.left,y:u.top-f.top,scaleX:u.width/f.width,scaleY:u.height/f.height};(g.x||g.y)&&i(g)}}n!==l.current&&(l.current=n)},[t,n,r,o]),d.useEffect(()=>{s&&i(null)},[s]),s}function cr(e){let{animateLayoutChanges:t=ws,attributes:n,disabled:r,data:o,getNewIndex:s=ys,id:i,strategy:l,resizeObserverConfig:u,transition:f=Cs}=e;const{items:g,containerId:p,activeIndex:S,disabled:v,disableTransforms:m,sortedRects:h,overIndex:x,useDragOverlay:y,strategy:C}=d.useContext(ir),R=Ts(r,v),E=g.indexOf(i),_=d.useMemo(()=>({sortable:{containerId:p,index:E,items:g},...o}),[p,o,E,g]),T=d.useMemo(()=>g.slice(g.indexOf(i)),[g,i]),{rect:j,node:O,isOver:L,setNodeRef:P}=hs({id:i,data:_,disabled:R.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...u}}),{active:N,activatorEvent:U,activeNodeRect:X,attributes:ne,setNodeRef:he,listeners:Re,isDragging:H,over:Ee,setActivatorNodeRef:re,transform:ve}=cs({id:i,data:_,attributes:{...Es,...n},disabled:R.draggable}),b=Br(P,he),D=!!N,I=D&&!m&&ct(S)&&ct(x),A=!y&&H,le=A&&I?ve:null,$=I?le??(l??C)({rects:h,activeNodeRect:X,activeIndex:S,overIndex:x,index:E}):null,G=ct(S)&&ct(x)?s({id:i,items:g,activeIndex:S,overIndex:x}):E,J=N?.id,M=d.useRef({activeId:J,items:g,newIndex:G,containerId:p}),$e=g!==M.current.items,ce=t({active:N,containerId:p,isDragging:H,isSorting:D,id:i,index:E,items:g,newIndex:M.current.newIndex,previousItems:M.current.items,previousContainerId:M.current.containerId,transition:f,wasDragging:M.current.activeId!=null}),De=Ds({disabled:!ce,index:E,node:O,rect:j});return d.useEffect(()=>{D&&M.current.newIndex!==G&&(M.current.newIndex=G),p!==M.current.containerId&&(M.current.containerId=p),g!==M.current.items&&(M.current.items=g)},[D,G,p,g]),d.useEffect(()=>{if(J===M.current.activeId)return;if(J!=null&&M.current.activeId==null){M.current.activeId=J;return}const Te=setTimeout(()=>{M.current.activeId=J},50);return()=>clearTimeout(Te)},[J]),{active:N,activeIndex:S,attributes:ne,data:_,rect:j,index:E,newIndex:G,items:g,isOver:L,isSorting:D,isDragging:H,listeners:Re,node:O,overIndex:x,over:Ee,setNodeRef:b,setActivatorNodeRef:re,setDroppableNodeRef:P,setDraggableNodeRef:he,transform:De??$,transition:ge()};function ge(){if(De||$e&&M.current.newIndex===E)return Rs;if(!(A&&!Ut(U)||!f)&&(D||ce))return Me.Transition.toString({...f,property:lr})}}function Ts(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}k.Down,k.Right,k.Up,k.Left;const js=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_s=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),In=e=>{const t=_s(e);return t.charAt(0).toUpperCase()+t.slice(1)},ur=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Os=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Is={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ks=d.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...l},u)=>d.createElement("svg",{ref:u,...Is,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ur("lucide",o),...!s&&!Os(l)&&{"aria-hidden":"true"},...l},[...i.map(([f,g])=>d.createElement(f,g)),...Array.isArray(s)?s:[s]]));const K=(e,t)=>{const n=d.forwardRef(({className:r,...o},s)=>d.createElement(ks,{ref:s,iconNode:t,className:ur(`lucide-${js(In(e))}`,`lucide-${e}`,r),...o}));return n.displayName=In(e),n};const Ms=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],As=K("arrow-down",Ms);const Ns=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ls=K("arrow-up-down",Ns);const $s=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ps=K("arrow-up",$s);const zs=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Fs=K("bookmark",zs);const Vs=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],kn=K("calendar",Vs);const Bs=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Hs=K("chevron-left",Bs);const Ys=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ws=K("chevron-right",Ys);const Us=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Gs=K("columns-2",Us);const Xs=[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]],qs=K("delete",Xs);const Ks=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Js=K("ellipsis",Ks);const Zs=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Qs=K("funnel",Zs);const ei=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],dr=K("grip-vertical",ei);const ti=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],ni=K("pen",ti);const ri=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],oi=K("settings",ri);function w(e){return d.forwardRef((t,n)=>{const{children:r,...o}=t;return a.jsx(e,{ref:n,...o,children:r})})}const fr=e=>`table_column_order_v1:${e}`,si=e=>{const{tableId:t}=te.state;localStorage.setItem(fr(t),JSON.stringify(e.map(n=>n.id))),te.setState(n=>({...n,columnOrder:e})),te.setState(n=>({...n,columnOrder:e}))},ii=e=>{te.setState(t=>({...t,visibility:{...t.visibility,[e]:!t.visibility[e]}}))};function ai(e){te.setState(t=>t.sortColumn===e?{...t,sortDirection:t.sortDirection==="asc"?"desc":"asc"}:{...t,sortColumn:e,sortDirection:"asc"})}const te=new zn({tableId:"",sortColumn:null,sortDirection:"asc",visibility:{},columnOrder:[],data:[],sortableColumns:[]});function hr(e,t){const n=e[0]??{},o=(t&&t.length?t:Object.keys(n).map(u=>({id:u,label:u}))).filter(u=>Object.prototype.hasOwnProperty.call(n,u.id)),{tableId:s}=te.state,i=JSON.parse(localStorage.getItem(fr(s))||"[]"),l=[...i.map(u=>o.find(f=>f.id===u)).filter(Boolean),...o.filter(u=>!i.includes(u.id))];te.setState(u=>({...u,data:e,columnOrder:l,visibility:l.reduce((f,g)=>(f[g.id]=!0,f),{}),sortableColumns:l.map(f=>({id:f.id,label:f.label,sortable:!0}))}))}function gr(e){te.setState(t=>({...t,tableId:e}))}const li=w(c.Menu.Trigger),ci=w(c.Menu.Positioner),ui=w(c.Menu.Content),di=w(c.Menu.Item),fi=w(c.Checkbox.Label),hi=w(c.Checkbox.HiddenInput),gi=w(c.Checkbox.Control);function pi({visibility:e,onToggle:t}){const{sortableColumns:n}=Qe(te);return a.jsxs(c.Menu.Root,{closeOnSelect:!1,children:[a.jsx(li,{asChild:!0,children:a.jsx(c.IconButton,{"aria-label":"Toggle columns",variant:"outline",size:"sm",ml:"1",children:a.jsx(Gs,{size:18})})}),a.jsx(c.Portal,{children:a.jsx(ci,{children:a.jsx(ui,{minW:"220px",children:n.map(r=>{const o=!!e[r.id];return a.jsx(di,{value:r.id,closeOnSelect:!1,children:a.jsxs(c.Checkbox.Root,{checked:o,onCheckedChange:()=>t(r.id),children:[a.jsx(hi,{}),a.jsx(gi,{}),a.jsx(fi,{children:r.label})]})},r.id)})})})})]})}function vi({id:e,children:t,onClick:n,cursor:r,borderRight:o,borderRightColor:s}){const{setNodeRef:i,attributes:l,listeners:u,transform:f,transition:g}=cr({id:e});return a.jsx(c.Table.ColumnHeader,{ref:i,onClick:n,w:e==="id"?"80px":void 0,style:{transform:Me.Transform.toString(f),transition:g,cursor:r,borderRight:o,borderRightColor:s},...l,children:a.jsxs(c.HStack,{justify:"space-between",children:[t,a.jsx("span",{...u,children:a.jsx(dr,{size:12})})]})})}function bi(){const{columnOrder:e,visibility:t,sortColumn:n,sortDirection:r,sortableColumns:o}=Qe(te),s=e.map(l=>o.find(u=>u.id===l.id)).filter(l=>l!==void 0).filter(l=>t[l.id]),i=l=>{const{active:u,over:f}=l;if(!f||u.id===f.id)return;const g=e.findIndex(v=>v.id===u.id),p=e.findIndex(v=>v.id===f.id),S=yt(e,g,p);si(S)};return a.jsx(c.Table.Header,{background:"gray.100",position:"sticky",top:0,p:"0",children:a.jsx(rr,{collisionDetection:Hn,onDragEnd:i,children:a.jsx(ar,{items:e.map(l=>l.id),strategy:bs,children:a.jsxs(c.Table.Row,{height:"28px",children:[s.map((l,u)=>{const f=n===l?.id;return a.jsx(vi,{id:l?.id,onClick:()=>l?.sortable&&ai(l?.id),cursor:l?.sortable?"pointer":"default",borderRight:"2px solid #dcdcdc",children:a.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,userSelect:"none"},children:[l?.label,l?.sortable&&(f?r==="asc"?a.jsx(Ps,{size:14}):a.jsx(As,{size:14}):a.jsx(Ls,{size:14,opacity:.4}))]})},l?.id)}),a.jsx(c.Table.ColumnHeader,{borderRight:"2px solid #dcdcdc",children:"Actions"}),a.jsx(c.Table.ColumnHeader,{boxSize:"0.5",children:a.jsx(pi,{visibility:t,onToggle:ii})})]})})})})}const Mn=c.createListCollection({items:[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}]}),mi=w(c.Select.Positioner),xi=w(c.Select.Content),Si=w(c.Select.Item),yi=w(c.Pagination.PrevTrigger),wi=w(c.Pagination.NextTrigger),Ci=w(c.Select.HiddenSelect),Ri=w(c.Select.Control),Ei=w(c.Select.Trigger),Di=w(c.Select.ValueText),Ti=w(c.Select.IndicatorGroup),ji=w(c.Select.Indicator);function _i({totalCount:e,pageSize:t,currentPage:n,onPageChange:r,onPageSizeChange:o,siblingCount:s=2}){return a.jsx(c.Box,{width:"100%",children:a.jsxs(c.HStack,{justify:"space-between",mx:"auto",flexWrap:"wrap",children:[a.jsxs(c.HStack,{children:[a.jsx(c.Text,{fontSize:"sm",color:"gray.600",_dark:{color:"gray.400"},children:"Rows per page:"}),a.jsxs(c.Select.Root,{collection:Mn,size:"sm",width:"60px",onValueChange:i=>o&&o(Number(i.items[0].value)),value:[String(t)],children:[a.jsx(Ci,{}),a.jsxs(Ri,{children:[a.jsx(Ei,{children:a.jsx(Di,{placeholder:""})}),a.jsx(Ti,{children:a.jsx(ji,{})})]}),a.jsx(c.Portal,{children:a.jsx(mi,{children:a.jsx(xi,{children:Mn.items.map(i=>a.jsxs(Si,{item:i.value,children:[i.label,a.jsx(c.Select.ItemIndicator,{})]},i.value))})})})]})]}),a.jsx(c.Pagination.Root,{count:e,pageSize:t,page:n,siblingCount:s,onPageChange:i=>r&&r(i.page),children:a.jsxs(c.ButtonGroup,{size:"sm",variant:"ghost",children:[a.jsx(yi,{asChild:!0,children:a.jsx(c.IconButton,{"aria-label":"Previous page",children:a.jsx(Hs,{size:18})})}),a.jsx(c.Pagination.Items,{render:i=>a.jsx(c.IconButton,{variant:i.type==="page"&&i.value===n?"outline":"ghost","aria-current":i.type==="page"&&i.value===n?"page":void 0,children:i.type==="page"?i.value:"…"},i.value??i.type)}),a.jsx(wi,{asChild:!0,children:a.jsx(c.IconButton,{"aria-label":"Next page",children:a.jsx(Ws,{size:18})})})]})})]})})}const Oi=w(c.Menu.Item),Ii=w(c.Menu.Content),ki=w(c.Menu.Positioner),Mi=w(c.Menu.Trigger);function Ai({data:e=[],actions:t=[]}){const{columnOrder:n,visibility:r}=Qe(te);return a.jsx(c.Table.Body,{children:e.map(o=>a.jsxs(c.Table.Row,{children:[n.filter(s=>r[s.id]).map(s=>a.jsx(c.Table.Cell,{children:o[s.id]},s.id)),a.jsx(c.Table.Cell,{textAlign:"center",display:"flex",gap:2,children:a.jsxs(c.Menu.Root,{children:[a.jsx(Mi,{asChild:!0,children:a.jsx(c.IconButton,{"aria-label":"Open",variant:"ghost",size:"sm",children:a.jsx(Js,{size:16})})}),a.jsx(c.Portal,{children:a.jsx(ki,{children:a.jsx(Ii,{children:t.map(s=>a.jsxs(Oi,{onClick:()=>s.onClick(o),colorScheme:s.colorScheme,value:s.label,children:[s.icon,s.label]},s.label))})})})]})})]},o.id))})}function Ni({tableId:e,data:t=[],headers:n=[],loading:r=!1,emptyMessage:o="No data",actions:s,page:i=1,pageSize:l=10,onPageChange:u,onPageSizeChange:f,density:g="sm",totalCount:p=0,paginationMode:S="client"}){d.useEffect(()=>{gr(e)},[e]),d.useEffect(()=>{hr(t,n)},[t,n]);const{sortColumn:v,sortDirection:m,data:h}=Qe(te),x=d.useMemo(()=>{const y=[...h];if(v&&y.sort((C,R)=>m==="asc"?String(C[v]).localeCompare(String(R[v])):String(R[v]).localeCompare(String(C[v]))),S==="client"){const C=i*l;return y.slice(C,C+l)}return y},[h,v,m,i,l,S]);return a.jsxs(c.Box,{h:"100%",display:"flex",flexDirection:"column",p:2,pt:2,minHeight:0,children:[a.jsx(c.Box,{flex:"1",minHeight:0,overflow:"auto",children:r?a.jsx(c.Box,{display:"flex",alignItems:"center",justifyContent:"center",h:"100%",color:"gray.500",children:"Loading..."}):x.length===0?a.jsx(c.Box,{display:"flex",alignItems:"center",justifyContent:"center",h:"100%",color:"gray.500",children:o}):a.jsxs(c.Table.Root,{variant:"outline",w:"100%",size:g,children:[a.jsx(bi,{}),a.jsx(Ai,{data:x,actions:s})]})}),a.jsx(c.Box,{mt:.5,children:a.jsx(_i,{totalCount:p,pageSize:l,currentPage:i,onPageChange:u,onPageSizeChange:y=>{f&&f(y),i>1&&u&&u(1)}})})]})}const Li=w(c.Checkbox.Root),$i=w(c.Checkbox.HiddenInput),Pi=w(c.Checkbox.Control),zi=w(c.Checkbox.Label),Fi=({value:e,onChange:t,size:n="sm",label:r,helperText:o,isDisabled:s,required:i,errorText:l})=>a.jsxs(Li,{value:e,onChange:t,size:n,children:[a.jsx($i,{}),a.jsx(Pi,{disabled:s,required:i,errorText:l,helperText:o}),r&&a.jsx(zi,{children:r})]}),z=" to ",An=10,Ce={DAY_MAX:31,MONTH_MAX:12,YEAR_MIN:1900,YEAR_MAX:2100},Jt=()=>{const e=new Date;return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}},Nn=()=>{const{year:e,month:t,day:n}=Jt();return`${String(n).padStart(2,"0")}-${String(t).padStart(2,"0")}-${e}`},Vi=()=>{const{year:e,month:t,day:n}=Jt();return`${e}-${String(t).padStart(2,"0")}-${String(n).padStart(2,"0")}`},Bi=(e,t)=>{const n=e.length,r=parseInt(e);if(!e||isNaN(r))return t;if(n===4)return r>=Ce.YEAR_MIN&&r<=Ce.YEAR_MAX?r:t;if(n>0&&n<4){const o=t.toString(),s=4-n,i=o.substring(0,s);return parseInt(i+e)}return t},Ye=e=>{if(!e?.trim())return null;const n=e.replace(/[^\d-]/g,"").split("-").filter(f=>f!=="");if(n.length===0)return null;const{year:r,month:o,day:s}=Jt();let i,l,u;return n.length===1?(i=parseInt(n[0])||s,l=o,u=r):n.length===2?(i=parseInt(n[0])||s,l=parseInt(n[1])||o,u=r):(i=parseInt(n[0])||s,l=parseInt(n[1])||o,u=Bi(n[2],r)),l=Math.max(1,Math.min(Ce.MONTH_MAX,l)),i=Math.max(1,Math.min(Ce.DAY_MAX,i)),`${u}-${String(l).padStart(2,"0")}-${String(i).padStart(2,"0")}`},ie=e=>{if(!e)return"";const[t,n,r]=e.split("-");return`${r}-${n}-${t}`},Hi=(e,t)=>{if(e[0]?.length>0){const n=parseInt(e[0]);if(isNaN(n)||n===0||e[0].length===2&&n>Ce.DAY_MAX)return t}if(e[1]?.length>0){const n=parseInt(e[1]);if(isNaN(n)||n===0||e[1].length===2&&n>Ce.MONTH_MAX)return t}if(e[2]?.length>0){const n=parseInt(e[2]),r=e[2].length===4;if(isNaN(n)||n===0||r&&(n<Ce.YEAR_MIN||n>Ce.YEAR_MAX))return t}return null},We=e=>{let t=e.replace(/[^\d-]/g,"").substring(0,An);if(t.length>=3&&t[2]!=="-"&&(t=t.substring(0,2)+"-"+t.substring(2).replace(/-/g,"")),t.length>=6&&t[5]!=="-"){const o=t.split("-");o.length>=2&&(t=`${o[0]}-${o[1].substring(0,2)}-${o[1].substring(2)}${o[2]||""}`)}const n=t.split("-");return n[0]=n[0]?.substring(0,2)||"",n[1]=n[1]?.substring(0,2)||"",n[2]=n[2]?.substring(0,4)||"",t=n.filter(o=>o!=="").join("-"),t=t.substring(0,An),Hi(n,e)||t},Yi=w(c.Popover.Root),Wi=w(c.Popover.Trigger),Ui=w(c.Popover.Content),Gi=w(c.Popover.Positioner);function Xi({value:e,onChange:t,disabled:n=!1}){const[r="",o=""]=e?e.split("|"):[],[s,i]=d.useState(()=>r&&o?`${ie(r)}${z}${ie(o)}`:r?ie(r):""),[l,u]=d.useState(!1),f=d.useRef(null);d.useEffect(()=>{const m=h=>{h.ctrlKey&&h.key==="d"&&!h.shiftKey&&!h.metaKey&&(h.preventDefault(),f.current?.focus())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[]);const g=m=>{let h=m;if(h.includes(z)){const[x,y=""]=h.split(z);h=`${We(x.trim())}${z}${We(y.trim())}`}else if(h.toLowerCase().includes(" to ")){const[x,y=""]=h.split(/\s+to\s+/i);h=`${We(x.trim())} to ${We(y.trim())}`}else h=We(h);i(h)},p=()=>{const m=s.trim();if(!m){t(void 0);return}if(m.includes(z)){const[h,x=""]=m.split(z).map(R=>R.trim()),y=Ye(h),C=x?Ye(x):null;if(y&&C){const[R,E]=C<y?[C,y]:[y,C],_=`${ie(R)}${z}${ie(E)}`;i(_),t(`${R}|${E}`)}else if(y&&!x)i(`${ie(y)}${z}`),t(void 0);else if(y&&x){const R=Vi(),[E,_]=R<y?[R,y]:[y,R],T=`${ie(E)}${z}${ie(_)}`;i(T),t(`${E}|${_}`)}else i(""),t(void 0)}else{const h=Ye(m);h?(i(`${ie(h)}${z}`),t(void 0)):(i(""),t(void 0))}},S=m=>{if(m.key!=="Enter")return;m.preventDefault();const h=f.current?.selectionStart||0,x=s.indexOf(z);if(!s.trim()){i(`${Nn()}${z}`);return}if(x===-1){const C=Ye(s.trim());C&&i(`${ie(C)}${z}`);return}if(h<=x+z.length){const C=s.substring(0,x).trim(),R=s.substring(x+z.length),E=Ye(C);E&&i(`${ie(E)}${z}${R}`);return}if(s.substring(x+z.length).trim())p(),f.current?.blur();else{const C=s.substring(0,x+z.length)+Nn();i(C),setTimeout(()=>{p(),f.current?.blur()},0)}},v=()=>{i(""),t(void 0)};return a.jsx(c.InputGroup,{children:a.jsx(a.Fragment,{children:a.jsxs(c.InputElement,{position:"revert",children:[a.jsxs(Yi,{open:l,onEscapeKeyDown:()=>{u(!1)},children:[a.jsx(Wi,{asChild:!0,children:a.jsx(c.IconButton,{size:"sm",variant:"ghost","aria-label":"Date range help",onClick:()=>u(m=>!m),children:a.jsx(kn,{size:16})})}),a.jsx(c.Portal,{children:a.jsx(Gi,{children:a.jsxs(Ui,{p:4,children:[a.jsx(c.PopoverArrow,{}),a.jsxs(c.VStack,{align:"start",gap:4,children:[a.jsxs(c.HStack,{children:[a.jsx(kn,{size:16}),a.jsx(c.Text,{fontWeight:"semibold",fontSize:"sm",children:"Date Range Filter"})]}),a.jsxs(c.VStack,{align:"start",gap:1,children:[a.jsx(c.Text,{fontSize:"sm",fontWeight:"medium",children:"Format:"}),a.jsxs(c.Text,{fontSize:"xs",color:"gray.600",children:["DD-MM-YYYY",z,"DD-MM-YYYY"]})]}),a.jsxs(c.VStack,{align:"start",gap:1,children:[a.jsx(c.Text,{fontSize:"sm",fontWeight:"medium",children:"Tips:"}),a.jsx(c.Text,{fontSize:"xs",children:'• "15 to 20" → assumes current month/year'}),a.jsx(c.Text,{fontSize:"xs",children:"• Leave end blank → up to today"}),a.jsx(c.Text,{fontSize:"xs",children:"• Dates auto-swapped if reversed"}),a.jsx(c.Text,{fontSize:"xs",children:"• Press Enter on empty end → fills today"})]}),a.jsxs(c.VStack,{align:"start",gap:1,children:[a.jsx(c.Text,{fontSize:"sm",fontWeight:"medium",children:"Shortcut:"}),a.jsxs(c.HStack,{children:[a.jsx(c.Kbd,{children:"Ctrl"}),a.jsx(c.Text,{children:"+"}),a.jsx(c.Kbd,{children:"D"})]})]})]})]})})})]}),a.jsx(c.Input,{ref:f,placeholder:"15-06-2025 to 20-06-2025",value:s,size:"sm",disabled:n,onChange:m=>g(m.target.value),onBlur:p,onKeyDown:S,pr:s?"10":void 0,w:"100%"}),s&&a.jsx(c.InputElement,{children:a.jsx(c.IconButton,{size:"sm",variant:"ghost","aria-label":"Clear date range",onClick:v,w:"100%"})})]})})})}const qi=w(c.Field.Root),Ki=w(c.Field.Label),Ji=w(c.Field.HelperText),Zi=w(c.Field.ErrorText),Ln=({icon:e,value:t,onChange:n,placeholder:r,size:o="xs",variant:s="outline",width:i="100%",label:l,helperText:u,isDisabled:f=!1,required:g=!1,errorText:p,visible:S})=>a.jsxs(qi,{width:i,children:[S&&a.jsx(Ki,{children:l}),a.jsx(c.InputGroup,{startElement:e,children:a.jsx(c.Input,{value:t,onChange:v=>n?.(v.target.value),placeholder:r,size:o,variant:s,disabled:f,required:g})}),p&&a.jsx(Zi,{fontSize:"xs",children:p}),u&&a.jsx(Ji,{fontSize:"xs",children:u})]}),Qi=w(c.Field.Root),ea=w(c.Field.HelperText),ta=w(c.Field.ErrorText),na=w(c.Select.Root),ra=w(c.Select.Label),oa=w(c.Select.Control),sa=w(c.Select.Trigger),ia=w(c.Select.ValueText),aa=w(c.Select.IndicatorGroup),la=w(c.Select.Indicator),ca=w(c.Select.Content),ua=w(c.Select.Item),da=w(c.Select.ItemIndicator),fa=w(c.Select.HiddenSelect),ha=w(c.Select.Positioner),ga=({options:e=[],label:t,value:n,onChange:r,placeholder:o,size:s="sm",width:i="100%",variant:l="outline",helperText:u,isDisabled:f,required:g,errorText:p,visible:S})=>{const v=c.createListCollection({items:e});return a.jsxs(Qi,{disabled:f,required:g,children:[a.jsxs(na,{collection:v,variant:l,size:s,width:i,value:n?[n]:[],onValueChange:m=>r?.(m.value[0]),children:[a.jsx(fa,{}),S&&a.jsx(ra,{children:t}),a.jsxs(oa,{children:[a.jsx(sa,{children:a.jsx(ia,{placeholder:o})}),a.jsx(aa,{children:a.jsx(la,{})})]}),a.jsx(ha,{children:a.jsx(ca,{children:v.items.map(m=>a.jsxs(ua,{item:m,children:[m.label,a.jsx(da,{})]},m.value))})})]}),u&&a.jsx(ea,{children:u}),p&&a.jsx(ta,{children:p})]})},pr=e=>`FILTER_PRESETS_${e??"default"}`;function pa(e){try{return JSON.parse(localStorage.getItem(pr(e))||"[]")}catch{return[]}}const Ze=new zn({}),wt=e=>{const t=Ze.state[e];if(t)return t;const n=pa(e);return Ze.setState(r=>({...r,[e]:n})),n},Zt=(e,t)=>{Ze.setState(n=>({...n,[e]:t})),localStorage.setItem(pr(e),JSON.stringify(t))},vr=(e,t)=>{const n=wt(e).filter(r=>r.id!==t);Zt(e,n)},br=(e,t)=>{const n=[t,...wt(e)];Zt(e,n)},va=w(c.Checkbox.Root),ba=w(c.Checkbox.HiddenInput),ma=w(c.Checkbox.Control),xa=w(c.Slider.Root),Sa=w(c.Slider.Track),ya=w(c.Slider.Range),wa=w(c.Slider.Thumbs),Ca=w(c.Slider.Control),Ra=({filter:e,onVisibilityChange:t,onSizeChange:n})=>{const{attributes:r,listeners:o,setNodeRef:s,transform:i,transition:l}=cr({id:e.id}),u={transform:Me.Transform.toString(i),transition:l};return a.jsxs(c.VStack,{ref:s,style:u,align:"stretch",border:"1px solid",borderColor:"gray.200",rounded:"md",p:3,mb:3,bg:"white",children:[a.jsxs(c.HStack,{...r,...o,cursor:"grab",userSelect:"none",gap:2,children:[a.jsx(dr,{size:16}),a.jsx(c.Text,{fontWeight:"bold",fontSize:"sm",children:e.label||e.id})]}),a.jsxs(c.HStack,{justify:"space-between",children:[a.jsx(c.Text,{fontSize:"sm",children:"Visible"}),a.jsxs(va,{checked:e.visible,size:"sm",onCheckedChange:f=>t?.(e.id,!!f.checked),children:[a.jsx(ba,{}),a.jsx(ma,{})]})]}),a.jsxs(c.VStack,{align:"stretch",gap:1,children:[a.jsx(c.Text,{fontSize:"sm",children:"Size"}),a.jsx(xa,{min:1,max:5,step:.5,value:[e.size??1],onValueChange:f=>n?.(e.id,f.value[0]),children:a.jsxs(Ca,{children:[a.jsx(Sa,{children:a.jsx(ya,{})}),a.jsx(wa,{})]})})]})]})},Ea=w(c.Drawer.Root),Da=w(c.Drawer.Trigger),Ta=w(c.Drawer.Backdrop),ja=w(c.Drawer.Positioner),_a=w(c.Drawer.Content),Oa=w(c.Drawer.Header),Ia=w(c.Drawer.Title),ka=w(c.Drawer.Body),Ma=w(c.Drawer.Footer),Aa=w(c.Drawer.CloseTrigger),Na=w(c.Tabs.Root),La=w(c.Tabs.List),Nt=w(c.Tabs.Trigger),Lt=w(c.Tabs.Content),mr=(e,t)=>{if(e.customComponent)return e.customComponent;switch(e.type){case"text":return a.jsx(Ln,{placeholder:e.label,value:e.value,onChange:e.onChange,label:e.label,visible:t});case"number":return a.jsx(Ln,{label:e.label,value:e.value,onChange:e.onChange});case"checkbox":return a.jsx(Fi,{label:e.label,value:e.value,onChange:e.onChange});case"select":return a.jsx(ga,{label:e.label,value:e.value,onChange:e.onChange,options:e.options??[],visible:t});case"date":return a.jsx(Xi,{value:e.value,onChange:e.onChange});default:return null}},$a=({filterDrawerSize:e="sm",onVisibilityChange:t,onSizeChange:n,onClear:r,filters:o,pageKey:s="default",currentFilters:i={},onLoadPreset:l,activePresetName:u,onReorder:f,open:g,onOpenChange:p})=>{const v=Qe(Ze)[s]??wt(s),m=()=>{const h=prompt("Preset name?");h&&br(s,{id:crypto.randomUUID(),name:h,date:new Date().toISOString(),filters:i})};return a.jsx(c.HStack,{wrap:"wrap",children:a.jsxs(Ea,{size:e,open:g,onOpenChange:p,children:[a.jsx(Da,{asChild:!0,children:a.jsxs(c.IconButton,{"aria-label":"Open filters",variant:"outline",size:"xs",ml:2,p:2,children:[a.jsx(Qs,{size:16}),"Filters"]})}),a.jsxs(c.Portal,{children:[a.jsx(Ta,{}),a.jsx(ja,{children:a.jsxs(_a,{children:[a.jsx(Oa,{children:a.jsx(Ia,{children:"Filters"})}),a.jsx(ka,{overflowY:"auto",pt:1,children:a.jsxs(Na,{defaultValue:"view",children:[a.jsxs(La,{mb:4,children:[a.jsxs(Nt,{value:"view",children:[a.jsx(ni,{size:16}),"Edit"]}),a.jsxs(Nt,{value:"settings",children:[a.jsx(oi,{size:16}),"Settings"]}),a.jsxs(Nt,{value:"presets",children:[a.jsx(Fs,{size:16}),"Presets"]})]}),a.jsx(Lt,{value:"view",children:o.filter(h=>h.visible).map(h=>a.jsx(c.VStack,{align:"stretch",border:"1px solid",borderColor:"gray.200",flex:h.size??1,minW:`${(h.size??1)*100}px`,rounded:"md",p:3,mb:3,children:mr(h,g)},h.id))}),a.jsx(Lt,{value:"settings",children:a.jsx(rr,{sensors:ro(no(Kt)),collisionDetection:Hn,onDragEnd:({active:h,over:x})=>{if(!x||h.id===x.id)return;const y=o.findIndex(E=>E.id===h.id),C=o.findIndex(E=>E.id===x.id),R=yt(o,y,C);f?.(R)},children:a.jsx(ar,{items:o.map(h=>h.id),strategy:xs,children:o.map(h=>a.jsx(Ra,{filter:h,onVisibilityChange:t,onSizeChange:n},h.id))})})}),a.jsx(Lt,{value:"presets",children:a.jsxs(c.VStack,{align:"stretch",mb:3,children:[a.jsx(c.Button,{size:"sm",colorScheme:"blue",onClick:m,children:"Save Current Filters"}),v.length===0&&a.jsx(c.Text,{fontSize:"xs",color:"gray.500",children:"No presets saved yet."}),v.map(h=>a.jsxs(c.HStack,{justify:"space-between",border:"1px solid",borderColor:u===h.name?"blue.300":"gray.200",rounded:"md",p:2,children:[a.jsxs(c.VStack,{align:"start",gap:0,children:[a.jsx(c.Text,{fontWeight:"bold",fontSize:"sm",children:h.name}),a.jsx(c.Text,{fontSize:"xs",color:"gray.500",children:new Date(h.date).toLocaleDateString()})]}),a.jsxs(c.HStack,{children:[a.jsx(c.Button,{size:"xs",variant:"ghost",onClick:()=>l?.(h.filters,h.name),children:"Load"}),a.jsx(c.IconButton,{size:"xs","aria-label":"Delete preset",variant:"ghost",onClick:()=>vr(s,h.id),children:a.jsx(qs,{size:14})})]})]},h.id))]})})]})}),a.jsxs(Ma,{justify:"space-between",children:[a.jsx(c.Button,{size:"sm",variant:"ghost",colorScheme:"red",onClick:()=>r&&r(),children:"Clear All"}),a.jsx(Aa,{asChild:!0,children:a.jsx(c.CloseButton,{})})]})]})})]})]})})},Pa=({title:e,filters:t,onVisibilityChange:n,onReorder:r,onSizeChange:o,onClear:s,maxToolbarUnits:i,pageKey:l,currentFilters:u,onLoadPreset:f,activePresetName:g,filterDrawerSize:p="sm"})=>{const[S,v]=d.useState(!1);return a.jsxs(c.HStack,{wrap:"wrap",pl:2,pr:2,width:"100%",justify:"space-between",children:[e,a.jsxs(c.HStack,{gapX:1,children:[t.filter(m=>m.visible!==!1).map(m=>a.jsx(c.HStack,{flex:m.size??1,minW:`${(m.size??1)*100}px`,alignItems:"center",children:mr(m)},m.id)),a.jsx($a,{filterDrawerSize:p,onVisibilityChange:n,onReorder:r,onSizeChange:o,onClear:s,maxToolbarUnits:i,pageKey:l,filters:t,currentFilters:u,onLoadPreset:f,activePresetName:g,open:S,onOpenChange:m=>{v(m.open)}})]})]})},za=(e,t)=>{localStorage.setItem(`FILTER_ORDER_${e}`,JSON.stringify(t))},Fa=e=>{try{return JSON.parse(localStorage.getItem(`FILTER_ORDER_${e}`)||"[]")}catch{return[]}},Va=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.DataTable=Ni;exports.Filters=Pa;exports.MdsSharedUi=Va;exports.addPreset=br;exports.deletePreset=vr;exports.getPresets=wt;exports.loadOrder=Fa;exports.presetStore=Ze;exports.saveOrder=za;exports.savePresets=Zt;exports.setData=hr;exports.setTableId=gr;exports.tableStore=te;exports.withChildren=w;
10
+ `},eo={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function to(e){let{announcements:t=eo,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Qr}=e;const{announce:s,announcement:i}=Kr(),l=nt("DndLiveRegion"),[u,f]=d.useState(!1);if(d.useEffect(()=>{f(!0)},[]),Jr(d.useMemo(()=>({onDragStart(p){let{active:S}=p;s(t.onDragStart({active:S}))},onDragMove(p){let{active:S,over:v}=p;t.onDragMove&&s(t.onDragMove({active:S,over:v}))},onDragOver(p){let{active:S,over:v}=p;s(t.onDragOver({active:S,over:v}))},onDragEnd(p){let{active:S,over:v}=p;s(t.onDragEnd({active:S,over:v}))},onDragCancel(p){let{active:S,over:v}=p;s(t.onDragCancel({active:S,over:v}))}}),[s,t])),!u)return null;const g=d.createElement(d.Fragment,null,d.createElement(Xr,{id:r,value:o.draggable}),d.createElement(qr,{id:l,announcement:i}));return n?Ue.createPortal(g,n):g}var F;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(F||(F={}));function vt(){}function no(e,t){return d.useMemo(()=>({sensor:e,options:{}}),[e,t])}function ro(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ae=Object.freeze({x:0,y:0});function oo(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function so(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function io(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function ao(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Sn(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const Hn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Sn(t,t.left,t.top),s=[];for(const i of r){const{id:l}=i,u=n.get(l);if(u){const f=oo(Sn(u),o);s.push({id:l,data:{droppableContainer:i,value:f}})}}return s.sort(so)};function lo(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),i=o-r,l=s-n;if(r<o&&n<s){const u=t.width*t.height,f=e.width*e.height,g=i*l,p=g/(u+f-g);return Number(p.toFixed(4))}return 0}const co=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:i}=s,l=n.get(i);if(l){const u=lo(l,t);u>0&&o.push({id:i,data:{droppableContainer:s,value:u}})}}return o.sort(io)};function uo(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Yn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ae}function fo(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];return o.reduce((i,l)=>({...i,top:i.top+e*l.y,bottom:i.bottom+e*l.y,left:i.left+e*l.x,right:i.right+e*l.x}),{...n})}}const ho=fo(1);function go(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function po(e,t,n){const r=go(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:l}=r,u=e.left-i-(1-o)*parseFloat(n),f=e.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),g=o?e.width/o:e.width,p=s?e.height/s:e.height;return{width:g,height:p,top:f,right:u+g,bottom:f+p,left:u}}const vo={ignoreTransform:!1};function Le(e,t){t===void 0&&(t=vo);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:g}=q(e).getComputedStyle(e);f&&(n=po(n,f,g))}const{top:r,left:o,width:s,height:i,bottom:l,right:u}=n;return{top:r,left:o,width:s,height:i,bottom:l,right:u}}function yn(e){return Le(e,{ignoreTransform:!0})}function bo(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function mo(e,t){return t===void 0&&(t=q(e).getComputedStyle(e)),t.position==="fixed"}function xo(e,t){t===void 0&&(t=q(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const s=t[o];return typeof s=="string"?n.test(s):!1})}function Gt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Yt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!et(o)||Fn(o)||n.includes(o))return n;const s=q(e).getComputedStyle(o);return o!==e&&xo(o,s)&&n.push(o),mo(o,s)?n:r(o.parentNode)}return e?r(e):n}function Wn(e){const[t]=Gt(e,1);return t??null}function kt(e){return!mt||!e?null:Ae(e)?e:Ht(e)?Yt(e)||e===Ne(e).scrollingElement?window:et(e)?e:null:null}function Un(e){return Ae(e)?e.scrollX:e.scrollLeft}function Gn(e){return Ae(e)?e.scrollY:e.scrollTop}function Ft(e){return{x:Un(e),y:Gn(e)}}var V;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(V||(V={}));function Xn(e){return!mt||!e?!1:e===document.scrollingElement}function qn(e){const t={x:0,y:0},n=Xn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,s=e.scrollLeft<=t.x,i=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:o,isLeft:s,isBottom:i,isRight:l,maxScroll:r,minScroll:t}}const So={x:.2,y:.2};function yo(e,t,n,r,o){let{top:s,left:i,right:l,bottom:u}=n;r===void 0&&(r=10),o===void 0&&(o=So);const{isTop:f,isBottom:g,isLeft:p,isRight:S}=qn(e),v={x:0,y:0},m={x:0,y:0},h={height:t.height*o.y,width:t.width*o.x};return!f&&s<=t.top+h.height?(v.y=V.Backward,m.y=r*Math.abs((t.top+h.height-s)/h.height)):!g&&u>=t.bottom-h.height&&(v.y=V.Forward,m.y=r*Math.abs((t.bottom-h.height-u)/h.height)),!S&&l>=t.right-h.width?(v.x=V.Forward,m.x=r*Math.abs((t.right-h.width-l)/h.width)):!p&&i<=t.left+h.width&&(v.x=V.Backward,m.x=r*Math.abs((t.left+h.width-i)/h.width)),{direction:v,speed:m}}function wo(e){if(e===document.scrollingElement){const{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Kn(e){return e.reduce((t,n)=>ke(t,Ft(n)),ae)}function Co(e){return e.reduce((t,n)=>t+Un(n),0)}function Ro(e){return e.reduce((t,n)=>t+Gn(n),0)}function Eo(e,t){if(t===void 0&&(t=Le),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);Wn(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Do=[["x",["left","right"],Co],["y",["top","bottom"],Ro]];class Xt{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Gt(n),o=Kn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,l]of Do)for(const u of i)Object.defineProperty(this,u,{get:()=>{const f=l(r),g=o[s]-f;return this.rect[u]+g},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ge{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function To(e){const{EventTarget:t}=q(e);return e instanceof t?e:Ne(e)}function Mt(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var se;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(se||(se={}));function wn(e){e.preventDefault()}function jo(e){e.stopPropagation()}var k;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(k||(k={}));const Jn={start:[k.Space,k.Enter],cancel:[k.Esc],end:[k.Space,k.Enter,k.Tab]},_o=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case k.Right:return{...n,x:n.x+25};case k.Left:return{...n,x:n.x-25};case k.Down:return{...n,y:n.y+25};case k.Up:return{...n,y:n.y-25}}};class Zn{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Ge(Ne(n)),this.windowListeners=new Ge(q(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(se.Resize,this.handleCancel),this.windowListeners.add(se.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(se.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&Eo(r),n(ae)}handleKeyDown(t){if(Ut(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=Jn,coordinateGetter:i=_o,scrollBehavior:l="smooth"}=o,{code:u}=t;if(s.end.includes(u)){this.handleEnd(t);return}if(s.cancel.includes(u)){this.handleCancel(t);return}const{collisionRect:f}=r.current,g=f?{x:f.left,y:f.top}:ae;this.referenceCoordinates||(this.referenceCoordinates=g);const p=i(t,{active:n,context:r.current,currentCoordinates:g});if(p){const S=pt(p,g),v={x:0,y:0},{scrollableAncestors:m}=r.current;for(const h of m){const x=t.code,{isTop:y,isRight:C,isLeft:R,isBottom:E,maxScroll:_,minScroll:T}=qn(h),j=wo(h),O={x:Math.min(x===k.Right?j.right-j.width/2:j.right,Math.max(x===k.Right?j.left:j.left+j.width/2,p.x)),y:Math.min(x===k.Down?j.bottom-j.height/2:j.bottom,Math.max(x===k.Down?j.top:j.top+j.height/2,p.y))},L=x===k.Right&&!C||x===k.Left&&!R,P=x===k.Down&&!E||x===k.Up&&!y;if(L&&O.x!==p.x){const N=h.scrollLeft+S.x,U=x===k.Right&&N<=_.x||x===k.Left&&N>=T.x;if(U&&!S.y){h.scrollTo({left:N,behavior:l});return}U?v.x=h.scrollLeft-N:v.x=x===k.Right?h.scrollLeft-_.x:h.scrollLeft-T.x,v.x&&h.scrollBy({left:-v.x,behavior:l});break}else if(P&&O.y!==p.y){const N=h.scrollTop+S.y,U=x===k.Down&&N<=_.y||x===k.Up&&N>=T.y;if(U&&!S.x){h.scrollTo({top:N,behavior:l});return}U?v.y=h.scrollTop-N:v.y=x===k.Down?h.scrollTop-_.y:h.scrollTop-T.y,v.y&&h.scrollBy({top:-v.y,behavior:l});break}}this.handleMove(t,ke(pt(p,this.referenceCoordinates),v))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Zn.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Jn,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const l=s.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Cn(e){return!!(e&&"distance"in e)}function Rn(e){return!!(e&&"delay"in e)}class qt{constructor(t,n,r){var o;r===void 0&&(r=To(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:i}=s;this.props=t,this.events=n,this.document=Ne(i),this.documentListeners=new Ge(this.document),this.listeners=new Ge(r),this.windowListeners=new Ge(q(i)),this.initialCoordinates=(o=zt(s))!=null?o:ae,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(se.Resize,this.handleCancel),this.windowListeners.add(se.DragStart,wn),this.windowListeners.add(se.VisibilityChange,this.handleCancel),this.windowListeners.add(se.ContextMenu,wn),this.documentListeners.add(se.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Rn(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Cn(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(se.Click,jo,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(se.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:s}=this,{onMove:i,options:{activationConstraint:l}}=s;if(!o)return;const u=(n=zt(t))!=null?n:ae,f=pt(o,u);if(!r&&l){if(Cn(l)){if(l.tolerance!=null&&Mt(f,l.tolerance))return this.handleCancel();if(Mt(f,l.distance))return this.handleStart()}if(Rn(l)&&Mt(f,l.tolerance))return this.handleCancel();this.handlePending(l,f);return}t.cancelable&&t.preventDefault(),i(u)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===k.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Oo={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Kt extends qt{constructor(t){const{event:n}=t,r=Ne(n.target);super(t,Oo,r)}}Kt.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const Io={move:{name:"mousemove"},end:{name:"mouseup"}};var Vt;(function(e){e[e.RightClick=2]="RightClick"})(Vt||(Vt={}));class ko extends qt{constructor(t){super(t,Io,Ne(t.event.target))}}ko.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Vt.RightClick?!1:(r?.({event:n}),!0)}}];const At={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Mo extends qt{constructor(t){super(t,At)}static setup(){return window.addEventListener(At.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(At.move.name,t)};function t(){}}}Mo.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Xe;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Xe||(Xe={}));var bt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(bt||(bt={}));function Ao(e){let{acceleration:t,activator:n=Xe.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:l=bt.TreeOrder,pointerCoordinates:u,scrollableAncestors:f,scrollableAncestorRects:g,delta:p,threshold:S}=e;const v=Lo({delta:p,disabled:!s}),[m,h]=Hr(),x=d.useRef({x:0,y:0}),y=d.useRef({x:0,y:0}),C=d.useMemo(()=>{switch(n){case Xe.Pointer:return u?{top:u.y,bottom:u.y,left:u.x,right:u.x}:null;case Xe.DraggableRect:return o}},[n,o,u]),R=d.useRef(null),E=d.useCallback(()=>{const T=R.current;if(!T)return;const j=x.current.x*y.current.x,O=x.current.y*y.current.y;T.scrollBy(j,O)},[]),_=d.useMemo(()=>l===bt.TreeOrder?[...f].reverse():f,[l,f]);d.useEffect(()=>{if(!s||!f.length||!C){h();return}for(const T of _){if(r?.(T)===!1)continue;const j=f.indexOf(T),O=g[j];if(!O)continue;const{direction:L,speed:P}=yo(T,O,C,t,S);for(const N of["x","y"])v[N][L[N]]||(P[N]=0,L[N]=0);if(P.x>0||P.y>0){h(),R.current=T,m(E,i),x.current=P,y.current=L;return}}x.current={x:0,y:0},y.current={x:0,y:0},h()},[t,E,r,h,s,i,JSON.stringify(C),JSON.stringify(v),m,f,_,g,JSON.stringify(S)])}const No={x:{[V.Backward]:!1,[V.Forward]:!1},y:{[V.Backward]:!1,[V.Forward]:!1}};function Lo(e){let{delta:t,disabled:n}=e;const r=Pt(t);return tt(o=>{if(n||!r||!o)return No;const s={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[V.Backward]:o.x[V.Backward]||s.x===-1,[V.Forward]:o.x[V.Forward]||s.x===1},y:{[V.Backward]:o.y[V.Backward]||s.y===-1,[V.Forward]:o.y[V.Forward]||s.y===1}}},[n,t,r])}function $o(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return tt(o=>{var s;return t==null?null:(s=r??o)!=null?s:null},[r,t])}function Po(e,t){return d.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,s=o.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,r)}));return[...n,...s]},[]),[e,t])}var Je;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Je||(Je={}));var Bt;(function(e){e.Optimized="optimized"})(Bt||(Bt={}));const En=new Map;function zo(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=d.useState(null),{frequency:l,measure:u,strategy:f}=o,g=d.useRef(e),p=x(),S=Ke(p),v=d.useCallback(function(y){y===void 0&&(y=[]),!S.current&&i(C=>C===null?y:C.concat(y.filter(R=>!C.includes(R))))},[S]),m=d.useRef(null),h=tt(y=>{if(p&&!n)return En;if(!y||y===En||g.current!==e||s!=null){const C=new Map;for(let R of e){if(!R)continue;if(s&&s.length>0&&!s.includes(R.id)&&R.rect.current){C.set(R.id,R.rect.current);continue}const E=R.node.current,_=E?new Xt(u(E),E):null;R.rect.current=_,_&&C.set(R.id,_)}return C}return y},[e,s,n,p,u]);return d.useEffect(()=>{g.current=e},[e]),d.useEffect(()=>{p||v()},[n,p]),d.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),d.useEffect(()=>{p||typeof l!="number"||m.current!==null||(m.current=setTimeout(()=>{v(),m.current=null},l))},[l,p,v,...r]),{droppableRects:h,measureDroppableContainers:v,measuringScheduled:s!=null};function x(){switch(f){case Je.Always:return!1;case Je.BeforeDragging:return n;default:return!n}}}function Qn(e,t){return tt(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Fo(e,t){return Qn(e,t)}function Vo(e){let{callback:t,disabled:n}=e;const r=Wt(t),o=d.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return d.useEffect(()=>()=>o?.disconnect(),[o]),o}function xt(e){let{callback:t,disabled:n}=e;const r=Wt(t),o=d.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return d.useEffect(()=>()=>o?.disconnect(),[o]),o}function Bo(e){return new Xt(Le(e),e)}function Dn(e,t,n){t===void 0&&(t=Bo);const[r,o]=d.useState(null);function s(){o(u=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=u??n)!=null?f:null}const g=t(e);return JSON.stringify(u)===JSON.stringify(g)?u:g})}const i=Vo({callback(u){if(e)for(const f of u){const{type:g,target:p}=f;if(g==="childList"&&p instanceof HTMLElement&&p.contains(e)){s();break}}}}),l=xt({callback:s});return fe(()=>{s(),e?(l?.observe(e),i?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),i?.disconnect())},[e]),r}function Ho(e){const t=Qn(e);return Yn(e,t)}const Tn=[];function Yo(e){const t=d.useRef(e),n=tt(r=>e?r&&r!==Tn&&e&&t.current&&e.parentNode===t.current.parentNode?r:Gt(e):Tn,[e]);return d.useEffect(()=>{t.current=e},[e]),n}function Wo(e){const[t,n]=d.useState(null),r=d.useRef(e),o=d.useCallback(s=>{const i=kt(s.target);i&&n(l=>l?(l.set(i,Ft(i)),new Map(l)):null)},[]);return d.useEffect(()=>{const s=r.current;if(e!==s){i(s);const l=e.map(u=>{const f=kt(u);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,Ft(f)]):null}).filter(u=>u!=null);n(l.length?new Map(l):null),r.current=e}return()=>{i(e),i(s)};function i(l){l.forEach(u=>{const f=kt(u);f?.removeEventListener("scroll",o)})}},[o,e]),d.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>ke(s,i),ae):Kn(e):ae,[e,t])}function jn(e,t){t===void 0&&(t=[]);const n=d.useRef(null);return d.useEffect(()=>{n.current=null},t),d.useEffect(()=>{const r=e!==ae;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?pt(e,n.current):ae}function Uo(e){d.useEffect(()=>{if(!mt)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Go(e,t){return d.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function er(e){return d.useMemo(()=>e?bo(e):null,[e])}const _n=[];function Xo(e,t){t===void 0&&(t=Le);const[n]=e,r=er(n?q(n):null),[o,s]=d.useState(_n);function i(){s(()=>e.length?e.map(u=>Xn(u)?r:new Xt(t(u),u)):_n)}const l=xt({callback:i});return fe(()=>{l?.disconnect(),i(),e.forEach(u=>l?.observe(u))},[e]),o}function qo(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return et(t)?t:e}function Ko(e){let{measure:t}=e;const[n,r]=d.useState(null),o=d.useCallback(f=>{for(const{target:g}of f)if(et(g)){r(p=>{const S=t(g);return p?{...p,width:S.width,height:S.height}:S});break}},[t]),s=xt({callback:o}),i=d.useCallback(f=>{const g=qo(f);s?.disconnect(),g&&s?.observe(g),r(g?t(g):null)},[t,s]),[l,u]=gt(i);return d.useMemo(()=>({nodeRef:l,rect:n,setRef:u}),[n,l,u])}const Jo=[{sensor:Kt,options:{}},{sensor:Zn,options:{}}],Zo={current:{}},ft={draggable:{measure:yn},droppable:{measure:yn,strategy:Je.WhileDragging,frequency:Bt.Optimized},dragOverlay:{measure:Le}};class qe extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Qo={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new qe,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:vt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ft,measureDroppableContainers:vt,windowRect:null,measuringScheduled:!1},es={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:vt,draggableNodes:new Map,over:null,measureDroppableContainers:vt},St=d.createContext(es),tr=d.createContext(Qo);function ts(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new qe}}}function ns(e,t){switch(t.type){case F.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case F.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case F.DragEnd:case F.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case F.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new qe(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case F.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new qe(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case F.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new qe(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function rs(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=d.useContext(St),s=Pt(r),i=Pt(n?.id);return d.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!Ut(s)||document.activeElement===s.target)return;const l=o.get(i);if(!l)return;const{activatorNode:u,node:f}=l;if(!u.current&&!f.current)return;requestAnimationFrame(()=>{for(const g of[u.current,f.current]){if(!g)continue;const p=Ur(g);if(p){p.focus();break}}})}},[r,t,o,i,s]),null}function os(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function ss(e){return d.useMemo(()=>({draggable:{...ft.draggable,...e?.draggable},droppable:{...ft.droppable,...e?.droppable},dragOverlay:{...ft.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function is(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=d.useRef(!1),{x:i,y:l}=typeof o=="boolean"?{x:o,y:o}:o;fe(()=>{if(!i&&!l||!t){s.current=!1;return}if(s.current||!r)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const g=n(f),p=Yn(g,r);if(i||(p.x=0),l||(p.y=0),s.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const S=Wn(f);S&&S.scrollBy({top:p.y,left:p.x})}},[t,i,l,r,n])}const nr=d.createContext({...ae,scaleX:1,scaleY:1});var we;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(we||(we={}));const rr=d.memo(function(t){var n,r,o,s;let{id:i,accessibility:l,autoScroll:u=!0,children:f,sensors:g=Jo,collisionDetection:p=co,measuring:S,modifiers:v,...m}=t;const h=d.useReducer(ns,void 0,ts),[x,y]=h,[C,R]=Zr(),[E,_]=d.useState(we.Uninitialized),T=E===we.Initialized,{draggable:{active:j,nodes:O,translate:L},droppable:{containers:P}}=x,N=j!=null?O.get(j):null,U=d.useRef({initial:null,translated:null}),X=d.useMemo(()=>{var W;return j!=null?{id:j,data:(W=N?.data)!=null?W:Zo,rect:U}:null},[j,N]),ne=d.useRef(null),[he,Re]=d.useState(null),[H,Ee]=d.useState(null),re=Ke(m,Object.values(m)),ve=nt("DndDescribedBy",i),b=d.useMemo(()=>P.getEnabled(),[P]),D=ss(S),{droppableRects:I,measureDroppableContainers:A,measuringScheduled:le}=zo(b,{dragging:T,dependencies:[L.x,L.y],config:D.droppable}),Y=$o(O,j),$=d.useMemo(()=>H?zt(H):null,[H]),G=Dr(),J=Fo(Y,D.draggable.measure);is({activeNode:j!=null?O.get(j):null,config:G.layoutShiftCompensation,initialRect:J,measure:D.draggable.measure});const M=Dn(Y,D.draggable.measure,J),$e=Dn(Y?Y.parentElement:null),ce=d.useRef({activatorEvent:null,active:null,activeNode:Y,collisionRect:null,collisions:null,droppableRects:I,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),De=P.getNodeFor((n=ce.current.over)==null?void 0:n.id),ge=Ko({measure:D.dragOverlay.measure}),Te=(r=ge.nodeRef.current)!=null?r:Y,je=T?(o=ge.rect)!=null?o:M:null,Qt=!!(ge.nodeRef.current&&ge.rect),en=Ho(Qt?null:M),Ct=er(Te?q(Te):null),be=Yo(T?De??Y:null),rt=Xo(be),ot=os(v,{transform:{x:L.x-en.x,y:L.y-en.y,scaleX:1,scaleY:1},activatorEvent:H,active:X,activeNodeRect:M,containerNodeRect:$e,draggingNodeRect:je,over:ce.current.over,overlayNodeRect:ge.rect,scrollableAncestors:be,scrollableAncestorRects:rt,windowRect:Ct}),tn=$?ke($,L):null,nn=Wo(be),xr=jn(nn),Sr=jn(nn,[M]),_e=ke(ot,xr),Oe=je?ho(je,ot):null,Pe=X&&Oe?p({active:X,collisionRect:Oe,droppableRects:I,droppableContainers:b,pointerCoordinates:tn}):null,rn=ao(Pe,"id"),[me,on]=d.useState(null),yr=Qt?ot:ke(ot,Sr),wr=uo(yr,(s=me?.rect)!=null?s:null,M),Rt=d.useRef(null),sn=d.useCallback((W,Z)=>{let{sensor:Q,options:xe}=Z;if(ne.current==null)return;const oe=O.get(ne.current);if(!oe)return;const ee=W.nativeEvent,ue=new Q({active:ne.current,activeNode:oe,event:ee,options:xe,context:ce,onAbort(B){if(!O.get(B))return;const{onDragAbort:de}=re.current,pe={id:B};de?.(pe),C({type:"onDragAbort",event:pe})},onPending(B,Se,de,pe){if(!O.get(B))return;const{onDragPending:Fe}=re.current,ye={id:B,constraint:Se,initialCoordinates:de,offset:pe};Fe?.(ye),C({type:"onDragPending",event:ye})},onStart(B){const Se=ne.current;if(Se==null)return;const de=O.get(Se);if(!de)return;const{onDragStart:pe}=re.current,ze={activatorEvent:ee,active:{id:Se,data:de.data,rect:U}};Ue.unstable_batchedUpdates(()=>{pe?.(ze),_(we.Initializing),y({type:F.DragStart,initialCoordinates:B,active:Se}),C({type:"onDragStart",event:ze}),Re(Rt.current),Ee(ee)})},onMove(B){y({type:F.DragMove,coordinates:B})},onEnd:Ie(F.DragEnd),onCancel:Ie(F.DragCancel)});Rt.current=ue;function Ie(B){return async function(){const{active:de,collisions:pe,over:ze,scrollAdjustedTranslate:Fe}=ce.current;let ye=null;if(de&&Fe){const{cancelDrop:Ve}=re.current;ye={activatorEvent:ee,active:de,collisions:pe,delta:Fe,over:ze},B===F.DragEnd&&typeof Ve=="function"&&await Promise.resolve(Ve(ye))&&(B=F.DragCancel)}ne.current=null,Ue.unstable_batchedUpdates(()=>{y({type:B}),_(we.Uninitialized),on(null),Re(null),Ee(null),Rt.current=null;const Ve=B===F.DragEnd?"onDragEnd":"onDragCancel";if(ye){const Et=re.current[Ve];Et?.(ye),C({type:Ve,event:ye})}})}}},[O]),Cr=d.useCallback((W,Z)=>(Q,xe)=>{const oe=Q.nativeEvent,ee=O.get(xe);if(ne.current!==null||!ee||oe.dndKit||oe.defaultPrevented)return;const ue={active:ee};W(Q,Z.options,ue)===!0&&(oe.dndKit={capturedBy:Z.sensor},ne.current=xe,sn(Q,Z))},[O,sn]),an=Po(g,Cr);Uo(g),fe(()=>{M&&E===we.Initializing&&_(we.Initialized)},[M,E]),d.useEffect(()=>{const{onDragMove:W}=re.current,{active:Z,activatorEvent:Q,collisions:xe,over:oe}=ce.current;if(!Z||!Q)return;const ee={active:Z,activatorEvent:Q,collisions:xe,delta:{x:_e.x,y:_e.y},over:oe};Ue.unstable_batchedUpdates(()=>{W?.(ee),C({type:"onDragMove",event:ee})})},[_e.x,_e.y]),d.useEffect(()=>{const{active:W,activatorEvent:Z,collisions:Q,droppableContainers:xe,scrollAdjustedTranslate:oe}=ce.current;if(!W||ne.current==null||!Z||!oe)return;const{onDragOver:ee}=re.current,ue=xe.get(rn),Ie=ue&&ue.rect.current?{id:ue.id,rect:ue.rect.current,data:ue.data,disabled:ue.disabled}:null,B={active:W,activatorEvent:Z,collisions:Q,delta:{x:oe.x,y:oe.y},over:Ie};Ue.unstable_batchedUpdates(()=>{on(Ie),ee?.(B),C({type:"onDragOver",event:B})})},[rn]),fe(()=>{ce.current={activatorEvent:H,active:X,activeNode:Y,collisionRect:Oe,collisions:Pe,droppableRects:I,draggableNodes:O,draggingNode:Te,draggingNodeRect:je,droppableContainers:P,over:me,scrollableAncestors:be,scrollAdjustedTranslate:_e},U.current={initial:je,translated:Oe}},[X,Y,Pe,Oe,O,Te,je,I,P,me,be,_e]),Ao({...G,delta:L,draggingRect:Oe,pointerCoordinates:tn,scrollableAncestors:be,scrollableAncestorRects:rt});const Rr=d.useMemo(()=>({active:X,activeNode:Y,activeNodeRect:M,activatorEvent:H,collisions:Pe,containerNodeRect:$e,dragOverlay:ge,draggableNodes:O,droppableContainers:P,droppableRects:I,over:me,measureDroppableContainers:A,scrollableAncestors:be,scrollableAncestorRects:rt,measuringConfiguration:D,measuringScheduled:le,windowRect:Ct}),[X,Y,M,H,Pe,$e,ge,O,P,I,me,A,be,rt,D,le,Ct]),Er=d.useMemo(()=>({activatorEvent:H,activators:an,active:X,activeNodeRect:M,ariaDescribedById:{draggable:ve},dispatch:y,draggableNodes:O,over:me,measureDroppableContainers:A}),[H,an,X,M,y,ve,O,me,A]);return d.createElement(Bn.Provider,{value:R},d.createElement(St.Provider,{value:Er},d.createElement(tr.Provider,{value:Rr},d.createElement(nr.Provider,{value:wr},f)),d.createElement(rs,{disabled:l?.restoreFocus===!1})),d.createElement(to,{...l,hiddenTextDescribedById:ve}));function Dr(){const W=he?.autoScrollEnabled===!1,Z=typeof u=="object"?u.enabled===!1:u===!1,Q=T&&!W&&!Z;return typeof u=="object"?{...u,enabled:Q}:{enabled:Q}}}),as=d.createContext(null),On="button",ls="Draggable";function cs(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=nt(ls),{activators:i,activatorEvent:l,active:u,activeNodeRect:f,ariaDescribedById:g,draggableNodes:p,over:S}=d.useContext(St),{role:v=On,roleDescription:m="draggable",tabIndex:h=0}=o??{},x=u?.id===t,y=d.useContext(x?nr:as),[C,R]=gt(),[E,_]=gt(),T=Go(i,t),j=Ke(n);fe(()=>(p.set(t,{id:t,key:s,node:C,activatorNode:E,data:j}),()=>{const L=p.get(t);L&&L.key===s&&p.delete(t)}),[p,t]);const O=d.useMemo(()=>({role:v,tabIndex:h,"aria-disabled":r,"aria-pressed":x&&v===On?!0:void 0,"aria-roledescription":m,"aria-describedby":g.draggable}),[r,v,h,x,m,g.draggable]);return{active:u,activatorEvent:l,activeNodeRect:f,attributes:O,isDragging:x,listeners:r?void 0:T,node:C,over:S,setNodeRef:R,setActivatorNodeRef:_,transform:y}}function us(){return d.useContext(tr)}const ds="Droppable",fs={timeout:25};function hs(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=nt(ds),{active:i,dispatch:l,over:u,measureDroppableContainers:f}=d.useContext(St),g=d.useRef({disabled:n}),p=d.useRef(!1),S=d.useRef(null),v=d.useRef(null),{disabled:m,updateMeasurementsFor:h,timeout:x}={...fs,...o},y=Ke(h??r),C=d.useCallback(()=>{if(!p.current){p.current=!0;return}v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{f(Array.isArray(y.current)?y.current:[y.current]),v.current=null},x)},[x]),R=xt({callback:C,disabled:m||!i}),E=d.useCallback((O,L)=>{R&&(L&&(R.unobserve(L),p.current=!1),O&&R.observe(O))},[R]),[_,T]=gt(E),j=Ke(t);return d.useEffect(()=>{!R||!_.current||(R.disconnect(),p.current=!1,R.observe(_.current))},[_,R]),d.useEffect(()=>(l({type:F.RegisterDroppable,element:{id:r,key:s,disabled:n,node:_,rect:S,data:j}}),()=>l({type:F.UnregisterDroppable,key:s,id:r})),[r]),d.useEffect(()=>{n!==g.current.disabled&&(l({type:F.SetDroppableDisabled,id:r,key:s,disabled:n}),g.current.disabled=n)},[r,s,n,l]),{active:i,rect:S,isOver:u?.id===r,node:_,over:u,setNodeRef:T}}function yt(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function gs(e,t){return e.reduce((n,r,o)=>{const s=t.get(r);return s&&(n[o]=s),n},Array(e.length))}function ct(e){return e!==null&&e>=0}function ps(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function vs(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const ut={scaleX:1,scaleY:1},bs=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:s,index:i}=e;const l=(t=n[o])!=null?t:r;if(!l)return null;const u=ms(n,i,o);if(i===o){const f=n[s];return f?{x:o<s?f.left+f.width-(l.left+l.width):f.left-l.left,y:0,...ut}:null}return i>o&&i<=s?{x:-l.width-u,y:0,...ut}:i<o&&i>=s?{x:l.width+u,y:0,...ut}:{x:0,y:0,...ut}};function ms(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return!r||!o&&!s?0:n<t?o?r.left-(o.left+o.width):s.left-(r.left+r.width):s?s.left-(r.left+r.width):r.left-(o.left+o.width)}const or=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=yt(t,r,n),i=t[o],l=s[o];return!l||!i?null:{x:l.left-i.left,y:l.top-i.top,scaleX:l.width/i.width,scaleY:l.height/i.height}},dt={scaleX:1,scaleY:1},xs=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const l=(t=s[n])!=null?t:r;if(!l)return null;if(o===n){const f=s[i];return f?{x:0,y:n<i?f.top+f.height-(l.top+l.height):f.top-l.top,...dt}:null}const u=Ss(s,o,n);return o>n&&o<=i?{x:0,y:-l.height-u,...dt}:o<n&&o>=i?{x:0,y:l.height+u,...dt}:{x:0,y:0,...dt}};function Ss(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return r?n<t?o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const sr="Sortable",ir=d.createContext({activeIndex:-1,containerId:sr,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:or,disabled:{draggable:!1,droppable:!1}});function ar(e){let{children:t,id:n,items:r,strategy:o=or,disabled:s=!1}=e;const{active:i,dragOverlay:l,droppableRects:u,over:f,measureDroppableContainers:g}=us(),p=nt(sr,n),S=l.rect!==null,v=d.useMemo(()=>r.map(T=>typeof T=="object"&&"id"in T?T.id:T),[r]),m=i!=null,h=i?v.indexOf(i.id):-1,x=f?v.indexOf(f.id):-1,y=d.useRef(v),C=!ps(v,y.current),R=x!==-1&&h===-1||C,E=vs(s);fe(()=>{C&&m&&g(v)},[C,v,m,g]),d.useEffect(()=>{y.current=v},[v]);const _=d.useMemo(()=>({activeIndex:h,containerId:p,disabled:E,disableTransforms:R,items:v,overIndex:x,useDragOverlay:S,sortedRects:gs(v,u),strategy:o}),[h,p,E.draggable,E.droppable,R,v,x,u,S,o]);return d.createElement(ir.Provider,{value:_},t)}const ys=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return yt(n,r,o).indexOf(t)},ws=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:l,previousContainerId:u,transition:f}=e;return!f||!r||l!==s&&o===i?!1:n?!0:i!==o&&t===u},Cs={duration:200,easing:"ease"},lr="transform",Rs=Me.Transition.toString({property:lr,duration:0,easing:"linear"}),Es={roleDescription:"sortable"};function Ds(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=d.useState(null),l=d.useRef(n);return fe(()=>{if(!t&&n!==l.current&&r.current){const u=o.current;if(u){const f=Le(r.current,{ignoreTransform:!0}),g={x:u.left-f.left,y:u.top-f.top,scaleX:u.width/f.width,scaleY:u.height/f.height};(g.x||g.y)&&i(g)}}n!==l.current&&(l.current=n)},[t,n,r,o]),d.useEffect(()=>{s&&i(null)},[s]),s}function cr(e){let{animateLayoutChanges:t=ws,attributes:n,disabled:r,data:o,getNewIndex:s=ys,id:i,strategy:l,resizeObserverConfig:u,transition:f=Cs}=e;const{items:g,containerId:p,activeIndex:S,disabled:v,disableTransforms:m,sortedRects:h,overIndex:x,useDragOverlay:y,strategy:C}=d.useContext(ir),R=Ts(r,v),E=g.indexOf(i),_=d.useMemo(()=>({sortable:{containerId:p,index:E,items:g},...o}),[p,o,E,g]),T=d.useMemo(()=>g.slice(g.indexOf(i)),[g,i]),{rect:j,node:O,isOver:L,setNodeRef:P}=hs({id:i,data:_,disabled:R.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...u}}),{active:N,activatorEvent:U,activeNodeRect:X,attributes:ne,setNodeRef:he,listeners:Re,isDragging:H,over:Ee,setActivatorNodeRef:re,transform:ve}=cs({id:i,data:_,attributes:{...Es,...n},disabled:R.draggable}),b=Br(P,he),D=!!N,I=D&&!m&&ct(S)&&ct(x),A=!y&&H,le=A&&I?ve:null,$=I?le??(l??C)({rects:h,activeNodeRect:X,activeIndex:S,overIndex:x,index:E}):null,G=ct(S)&&ct(x)?s({id:i,items:g,activeIndex:S,overIndex:x}):E,J=N?.id,M=d.useRef({activeId:J,items:g,newIndex:G,containerId:p}),$e=g!==M.current.items,ce=t({active:N,containerId:p,isDragging:H,isSorting:D,id:i,index:E,items:g,newIndex:M.current.newIndex,previousItems:M.current.items,previousContainerId:M.current.containerId,transition:f,wasDragging:M.current.activeId!=null}),De=Ds({disabled:!ce,index:E,node:O,rect:j});return d.useEffect(()=>{D&&M.current.newIndex!==G&&(M.current.newIndex=G),p!==M.current.containerId&&(M.current.containerId=p),g!==M.current.items&&(M.current.items=g)},[D,G,p,g]),d.useEffect(()=>{if(J===M.current.activeId)return;if(J!=null&&M.current.activeId==null){M.current.activeId=J;return}const Te=setTimeout(()=>{M.current.activeId=J},50);return()=>clearTimeout(Te)},[J]),{active:N,activeIndex:S,attributes:ne,data:_,rect:j,index:E,newIndex:G,items:g,isOver:L,isSorting:D,isDragging:H,listeners:Re,node:O,overIndex:x,over:Ee,setNodeRef:b,setActivatorNodeRef:re,setDroppableNodeRef:P,setDraggableNodeRef:he,transform:De??$,transition:ge()};function ge(){if(De||$e&&M.current.newIndex===E)return Rs;if(!(A&&!Ut(U)||!f)&&(D||ce))return Me.Transition.toString({...f,property:lr})}}function Ts(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}k.Down,k.Right,k.Up,k.Left;const js=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_s=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),In=e=>{const t=_s(e);return t.charAt(0).toUpperCase()+t.slice(1)},ur=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Os=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Is={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ks=d.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...l},u)=>d.createElement("svg",{ref:u,...Is,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ur("lucide",o),...!s&&!Os(l)&&{"aria-hidden":"true"},...l},[...i.map(([f,g])=>d.createElement(f,g)),...Array.isArray(s)?s:[s]]));const K=(e,t)=>{const n=d.forwardRef(({className:r,...o},s)=>d.createElement(ks,{ref:s,iconNode:t,className:ur(`lucide-${js(In(e))}`,`lucide-${e}`,r),...o}));return n.displayName=In(e),n};const Ms=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],As=K("arrow-down",Ms);const Ns=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ls=K("arrow-up-down",Ns);const $s=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ps=K("arrow-up",$s);const zs=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Fs=K("bookmark",zs);const Vs=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],kn=K("calendar",Vs);const Bs=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Hs=K("chevron-left",Bs);const Ys=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ws=K("chevron-right",Ys);const Us=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Gs=K("columns-2",Us);const Xs=[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]],qs=K("delete",Xs);const Ks=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Js=K("ellipsis",Ks);const Zs=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Qs=K("funnel",Zs);const ei=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],dr=K("grip-vertical",ei);const ti=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],ni=K("pen",ti);const ri=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],oi=K("settings",ri);function w(e){return d.forwardRef((t,n)=>{const{children:r,...o}=t;return a.jsx(e,{ref:n,...o,children:r})})}const fr=e=>`table_column_order_v1:${e}`,si=e=>{const{tableId:t}=te.state;localStorage.setItem(fr(t),JSON.stringify(e.map(n=>n.id))),te.setState(n=>({...n,columnOrder:e})),te.setState(n=>({...n,columnOrder:e}))},ii=e=>{te.setState(t=>({...t,visibility:{...t.visibility,[e]:!t.visibility[e]}}))};function ai(e){te.setState(t=>t.sortColumn===e?{...t,sortDirection:t.sortDirection==="asc"?"desc":"asc"}:{...t,sortColumn:e,sortDirection:"asc"})}const te=new zn({tableId:"",sortColumn:null,sortDirection:"asc",visibility:{},columnOrder:[],data:[],sortableColumns:[]});function hr(e,t){const n=e[0]??{},o=(t&&t.length?t:Object.keys(n).map(u=>({id:u,label:u}))).filter(u=>Object.prototype.hasOwnProperty.call(n,u.id)),{tableId:s}=te.state,i=JSON.parse(localStorage.getItem(fr(s))||"[]"),l=[...i.map(u=>o.find(f=>f.id===u)).filter(Boolean),...o.filter(u=>!i.includes(u.id))];te.setState(u=>({...u,data:e,columnOrder:l,visibility:l.reduce((f,g)=>(f[g.id]=!0,f),{}),sortableColumns:l.map(f=>({id:f.id,label:f.label,sortable:!0}))}))}function gr(e){te.setState(t=>({...t,tableId:e}))}const li=w(c.Menu.Trigger),ci=w(c.Menu.Positioner),ui=w(c.Menu.Content),di=w(c.Menu.Item),fi=w(c.Checkbox.Label),hi=w(c.Checkbox.HiddenInput),gi=w(c.Checkbox.Control);function pi({visibility:e,onToggle:t}){const{sortableColumns:n}=Qe(te);return a.jsxs(c.Menu.Root,{closeOnSelect:!1,children:[a.jsx(li,{asChild:!0,children:a.jsx(c.IconButton,{"aria-label":"Toggle columns",variant:"outline",size:"sm",ml:"1",children:a.jsx(Gs,{size:18})})}),a.jsx(c.Portal,{children:a.jsx(ci,{children:a.jsx(ui,{minW:"220px",children:n.map(r=>{const o=!!e[r.id];return a.jsx(di,{value:r.id,closeOnSelect:!1,children:a.jsxs(c.Checkbox.Root,{checked:o,onCheckedChange:()=>t(r.id),children:[a.jsx(hi,{}),a.jsx(gi,{}),a.jsx(fi,{children:r.label})]})},r.id)})})})})]})}function vi({id:e,children:t,onClick:n,cursor:r,borderRight:o,borderRightColor:s}){const{setNodeRef:i,attributes:l,listeners:u,transform:f,transition:g}=cr({id:e});return a.jsx(c.Table.ColumnHeader,{ref:i,onClick:n,w:e==="id"?"80px":void 0,style:{transform:Me.Transform.toString(f),transition:g,cursor:r,borderRight:o,borderRightColor:s},...l,children:a.jsxs(c.HStack,{justify:"space-between",children:[t,a.jsx("span",{...u,children:a.jsx(dr,{size:12})})]})})}function bi(){const{columnOrder:e,visibility:t,sortColumn:n,sortDirection:r,sortableColumns:o}=Qe(te),s=e.map(l=>o.find(u=>u.id===l.id)).filter(l=>l!==void 0).filter(l=>t[l.id]),i=l=>{const{active:u,over:f}=l;if(!f||u.id===f.id)return;const g=e.findIndex(v=>v.id===u.id),p=e.findIndex(v=>v.id===f.id),S=yt(e,g,p);si(S)};return a.jsx(c.Table.Header,{background:"gray.100",position:"sticky",top:0,p:"0",children:a.jsx(rr,{collisionDetection:Hn,onDragEnd:i,children:a.jsx(ar,{items:e.map(l=>l.id),strategy:bs,children:a.jsxs(c.Table.Row,{height:"28px",children:[s.map((l,u)=>{const f=n===l?.id;return a.jsx(vi,{id:l?.id,onClick:()=>l?.sortable&&ai(l?.id),cursor:l?.sortable?"pointer":"default",borderRight:"2px solid #dcdcdc",children:a.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,userSelect:"none"},children:[l?.label,l?.sortable&&(f?r==="asc"?a.jsx(Ps,{size:14}):a.jsx(As,{size:14}):a.jsx(Ls,{size:14,opacity:.4}))]})},l?.id)}),a.jsx(c.Table.ColumnHeader,{borderRight:"2px solid #dcdcdc",children:"Actions"}),a.jsx(c.Table.ColumnHeader,{boxSize:"0.5",children:a.jsx(pi,{visibility:t,onToggle:ii})})]})})})})}const Mn=c.createListCollection({items:[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}]}),mi=w(c.Select.Positioner),xi=w(c.Select.Content),Si=w(c.Select.Item),yi=w(c.Pagination.PrevTrigger),wi=w(c.Pagination.NextTrigger),Ci=w(c.Select.HiddenSelect),Ri=w(c.Select.Control),Ei=w(c.Select.Trigger),Di=w(c.Select.ValueText),Ti=w(c.Select.IndicatorGroup),ji=w(c.Select.Indicator);function _i({totalCount:e,pageSize:t,currentPage:n,onPageChange:r,onPageSizeChange:o,siblingCount:s=2}){return a.jsx(c.Box,{width:"100%",children:a.jsxs(c.HStack,{justify:"space-between",mx:"auto",flexWrap:"wrap",children:[a.jsxs(c.HStack,{children:[a.jsx(c.Text,{fontSize:"sm",color:"gray.600",_dark:{color:"gray.400"},children:"Rows per page:"}),a.jsxs(c.Select.Root,{collection:Mn,size:"sm",width:"60px",onValueChange:i=>o&&o(Number(i.items[0].value)),value:[String(t)],children:[a.jsx(Ci,{}),a.jsxs(Ri,{children:[a.jsx(Ei,{children:a.jsx(Di,{placeholder:""})}),a.jsx(Ti,{children:a.jsx(ji,{})})]}),a.jsx(c.Portal,{children:a.jsx(mi,{children:a.jsx(xi,{children:Mn.items.map(i=>a.jsxs(Si,{item:i.value,children:[i.label,a.jsx(c.Select.ItemIndicator,{})]},i.value))})})})]})]}),a.jsx(c.Pagination.Root,{count:e,pageSize:t,page:n,siblingCount:s,onPageChange:i=>r&&r(i.page),children:a.jsxs(c.ButtonGroup,{size:"sm",variant:"ghost",children:[a.jsx(yi,{asChild:!0,children:a.jsx(c.IconButton,{"aria-label":"Previous page",children:a.jsx(Hs,{size:18})})}),a.jsx(c.Pagination.Items,{render:i=>a.jsx(c.IconButton,{variant:i.type==="page"&&i.value===n?"outline":"ghost","aria-current":i.type==="page"&&i.value===n?"page":void 0,children:i.type==="page"?i.value:"…"},i.value??i.type)}),a.jsx(wi,{asChild:!0,children:a.jsx(c.IconButton,{"aria-label":"Next page",children:a.jsx(Ws,{size:18})})})]})})]})})}const Oi=w(c.Menu.Item),Ii=w(c.Menu.Content),ki=w(c.Menu.Positioner),Mi=w(c.Menu.Trigger);function Ai({data:e=[],actions:t=[]}){const{columnOrder:n,visibility:r}=Qe(te);return a.jsx(c.Table.Body,{children:e.map(o=>a.jsxs(c.Table.Row,{children:[n.filter(s=>r[s.id]).map(s=>a.jsx(c.Table.Cell,{children:o[s.id]},s.id)),a.jsx(c.Table.Cell,{textAlign:"center",display:"flex",gap:2,children:a.jsxs(c.Menu.Root,{children:[a.jsx(Mi,{asChild:!0,children:a.jsx(c.IconButton,{"aria-label":"Open",variant:"ghost",size:"sm",children:a.jsx(Js,{size:16})})}),a.jsx(c.Portal,{children:a.jsx(ki,{children:a.jsx(Ii,{children:t.map(s=>a.jsxs(Oi,{onClick:()=>s.onClick(o),colorScheme:s.colorScheme,value:s.label,children:[s.icon,s.label]},s.label))})})})]})})]},o.id))})}function Ni({tableId:e,data:t=[],headers:n=[],loading:r=!1,emptyMessage:o="No data",actions:s,page:i=1,pageSize:l=10,onPageChange:u,onPageSizeChange:f,density:g="sm",totalCount:p=0,paginationMode:S="client"}){d.useEffect(()=>{gr(e)},[e]),d.useEffect(()=>{hr(t,n)},[t,n]);const{sortColumn:v,sortDirection:m,data:h}=Qe(te),x=d.useMemo(()=>{const y=[...h];if(v&&y.sort((C,R)=>m==="asc"?String(C[v]).localeCompare(String(R[v])):String(R[v]).localeCompare(String(C[v]))),S==="client"){const C=i*l;return y.slice(C,C+l)}return y},[h,v,m,i,l,S]);return a.jsxs(c.Box,{h:"100%",display:"flex",flexDirection:"column",p:2,pt:2,minHeight:0,children:[a.jsx(c.Box,{flex:"1",minHeight:0,overflow:"auto",children:r?a.jsx(c.Box,{display:"flex",alignItems:"center",justifyContent:"center",h:"100%",color:"gray.500",children:"Loading..."}):x.length===0?a.jsx(c.Box,{display:"flex",alignItems:"center",justifyContent:"center",h:"100%",color:"gray.500",children:o}):a.jsxs(c.Table.Root,{variant:"outline",w:"100%",size:g,children:[a.jsx(bi,{}),a.jsx(Ai,{data:x,actions:s})]})}),a.jsx(c.Box,{mt:.5,children:a.jsx(_i,{totalCount:p,pageSize:l,currentPage:i,onPageChange:u,onPageSizeChange:y=>{f&&f(y),i>1&&u&&u(1)}})})]})}const Li=w(c.Checkbox.Root),$i=w(c.Checkbox.HiddenInput),Pi=w(c.Checkbox.Control),zi=w(c.Checkbox.Label),Fi=({value:e,onChange:t,size:n="sm",label:r,helperText:o,isDisabled:s,required:i,errorText:l})=>a.jsxs(Li,{value:e,onChange:t,size:n,children:[a.jsx($i,{}),a.jsx(Pi,{disabled:s,required:i,errorText:l,helperText:o}),r&&a.jsx(zi,{children:r})]}),z=" to ",An=10,Ce={DAY_MAX:31,MONTH_MAX:12,YEAR_MIN:1900,YEAR_MAX:2100},Jt=()=>{const e=new Date;return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}},Nn=()=>{const{year:e,month:t,day:n}=Jt();return`${String(n).padStart(2,"0")}-${String(t).padStart(2,"0")}-${e}`},Vi=()=>{const{year:e,month:t,day:n}=Jt();return`${e}-${String(t).padStart(2,"0")}-${String(n).padStart(2,"0")}`},Bi=(e,t)=>{const n=e.length,r=parseInt(e);if(!e||isNaN(r))return t;if(n===4)return r>=Ce.YEAR_MIN&&r<=Ce.YEAR_MAX?r:t;if(n>0&&n<4){const o=t.toString(),s=4-n,i=o.substring(0,s);return parseInt(i+e)}return t},Ye=e=>{if(!e?.trim())return null;const n=e.replace(/[^\d-]/g,"").split("-").filter(f=>f!=="");if(n.length===0)return null;const{year:r,month:o,day:s}=Jt();let i,l,u;return n.length===1?(i=parseInt(n[0])||s,l=o,u=r):n.length===2?(i=parseInt(n[0])||s,l=parseInt(n[1])||o,u=r):(i=parseInt(n[0])||s,l=parseInt(n[1])||o,u=Bi(n[2],r)),l=Math.max(1,Math.min(Ce.MONTH_MAX,l)),i=Math.max(1,Math.min(Ce.DAY_MAX,i)),`${u}-${String(l).padStart(2,"0")}-${String(i).padStart(2,"0")}`},ie=e=>{if(!e)return"";const[t,n,r]=e.split("-");return`${r}-${n}-${t}`},Hi=(e,t)=>{if(e[0]?.length>0){const n=parseInt(e[0]);if(isNaN(n)||n===0||e[0].length===2&&n>Ce.DAY_MAX)return t}if(e[1]?.length>0){const n=parseInt(e[1]);if(isNaN(n)||n===0||e[1].length===2&&n>Ce.MONTH_MAX)return t}if(e[2]?.length>0){const n=parseInt(e[2]),r=e[2].length===4;if(isNaN(n)||n===0||r&&(n<Ce.YEAR_MIN||n>Ce.YEAR_MAX))return t}return null},We=e=>{let t=e.replace(/[^\d-]/g,"").substring(0,An);if(t.length>=3&&t[2]!=="-"&&(t=t.substring(0,2)+"-"+t.substring(2).replace(/-/g,"")),t.length>=6&&t[5]!=="-"){const o=t.split("-");o.length>=2&&(t=`${o[0]}-${o[1].substring(0,2)}-${o[1].substring(2)}${o[2]||""}`)}const n=t.split("-");return n[0]=n[0]?.substring(0,2)||"",n[1]=n[1]?.substring(0,2)||"",n[2]=n[2]?.substring(0,4)||"",t=n.filter(o=>o!=="").join("-"),t=t.substring(0,An),Hi(n,e)||t},Yi=w(c.Popover.Root),Wi=w(c.Popover.Trigger),Ui=w(c.Popover.Content),Gi=w(c.Popover.Positioner);function Xi({value:e,onChange:t,disabled:n=!1}){const[r="",o=""]=e?e.split("|"):[],[s,i]=d.useState(()=>r&&o?`${ie(r)}${z}${ie(o)}`:r?ie(r):""),[l,u]=d.useState(!1),f=d.useRef(null);d.useEffect(()=>{const m=h=>{h.ctrlKey&&h.key==="d"&&!h.shiftKey&&!h.metaKey&&(h.preventDefault(),f.current?.focus())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[]);const g=m=>{let h=m;if(h.includes(z)){const[x,y=""]=h.split(z);h=`${We(x.trim())}${z}${We(y.trim())}`}else if(h.toLowerCase().includes(" to ")){const[x,y=""]=h.split(/\s+to\s+/i);h=`${We(x.trim())} to ${We(y.trim())}`}else h=We(h);i(h)},p=()=>{const m=s.trim();if(!m){t(void 0);return}if(m.includes(z)){const[h,x=""]=m.split(z).map(R=>R.trim()),y=Ye(h),C=x?Ye(x):null;if(y&&C){const[R,E]=C<y?[C,y]:[y,C],_=`${ie(R)}${z}${ie(E)}`;i(_),t(`${R}|${E}`)}else if(y&&!x)i(`${ie(y)}${z}`),t(void 0);else if(y&&x){const R=Vi(),[E,_]=R<y?[R,y]:[y,R],T=`${ie(E)}${z}${ie(_)}`;i(T),t(`${E}|${_}`)}else i(""),t(void 0)}else{const h=Ye(m);h?(i(`${ie(h)}${z}`),t(void 0)):(i(""),t(void 0))}},S=m=>{if(m.key!=="Enter")return;m.preventDefault();const h=f.current?.selectionStart||0,x=s.indexOf(z);if(!s.trim()){i(`${Nn()}${z}`);return}if(x===-1){const C=Ye(s.trim());C&&i(`${ie(C)}${z}`);return}if(h<=x+z.length){const C=s.substring(0,x).trim(),R=s.substring(x+z.length),E=Ye(C);E&&i(`${ie(E)}${z}${R}`);return}if(s.substring(x+z.length).trim())p(),f.current?.blur();else{const C=s.substring(0,x+z.length)+Nn();i(C),setTimeout(()=>{p(),f.current?.blur()},0)}},v=()=>{i(""),t(void 0)};return a.jsx(c.InputGroup,{children:a.jsx(a.Fragment,{children:a.jsxs(c.InputElement,{position:"revert",children:[a.jsxs(Yi,{open:l,onEscapeKeyDown:()=>{u(!1)},children:[a.jsx(Wi,{asChild:!0,children:a.jsx(c.IconButton,{size:"sm",variant:"ghost","aria-label":"Date range help",onClick:()=>u(m=>!m),children:a.jsx(kn,{size:16})})}),a.jsx(c.Portal,{children:a.jsx(Gi,{children:a.jsxs(Ui,{p:4,children:[a.jsx(c.PopoverArrow,{}),a.jsxs(c.VStack,{align:"start",gap:4,children:[a.jsxs(c.HStack,{children:[a.jsx(kn,{size:16}),a.jsx(c.Text,{fontWeight:"semibold",fontSize:"sm",children:"Date Range Filter"})]}),a.jsxs(c.VStack,{align:"start",gap:1,children:[a.jsx(c.Text,{fontSize:"sm",fontWeight:"medium",children:"Format:"}),a.jsxs(c.Text,{fontSize:"xs",color:"gray.600",children:["DD-MM-YYYY",z,"DD-MM-YYYY"]})]}),a.jsxs(c.VStack,{align:"start",gap:1,children:[a.jsx(c.Text,{fontSize:"sm",fontWeight:"medium",children:"Tips:"}),a.jsx(c.Text,{fontSize:"xs",children:'• "15 to 20" → assumes current month/year'}),a.jsx(c.Text,{fontSize:"xs",children:"• Leave end blank → up to today"}),a.jsx(c.Text,{fontSize:"xs",children:"• Dates auto-swapped if reversed"}),a.jsx(c.Text,{fontSize:"xs",children:"• Press Enter on empty end → fills today"})]}),a.jsxs(c.VStack,{align:"start",gap:1,children:[a.jsx(c.Text,{fontSize:"sm",fontWeight:"medium",children:"Shortcut:"}),a.jsxs(c.HStack,{children:[a.jsx(c.Kbd,{children:"Ctrl"}),a.jsx(c.Text,{children:"+"}),a.jsx(c.Kbd,{children:"D"})]})]})]})]})})})]}),a.jsx(c.Input,{ref:f,placeholder:"15-06-2025 to 20-06-2025",value:s,size:"sm",disabled:n,onChange:m=>g(m.target.value),onBlur:p,onKeyDown:S,pr:s?"10":void 0,w:"100%"}),s&&a.jsx(c.InputElement,{children:a.jsx(c.IconButton,{size:"sm",variant:"ghost","aria-label":"Clear date range",onClick:v,w:"100%"})})]})})})}const qi=w(c.Field.Root),Ki=w(c.Field.Label),Ji=w(c.Field.HelperText),Zi=w(c.Field.ErrorText),Ln=({icon:e,value:t,onChange:n,placeholder:r,size:o="xs",variant:s="outline",width:i="100%",label:l,helperText:u,isDisabled:f=!1,required:g=!1,errorText:p,visible:S})=>a.jsxs(qi,{width:i,children:[S&&a.jsx(Ki,{children:l}),a.jsx(c.InputGroup,{startElement:e,children:a.jsx(c.Input,{value:t,onChange:v=>n?.(v.target.value),placeholder:r,size:o,variant:s,disabled:f,required:g})}),p&&a.jsx(Zi,{fontSize:"xs",children:p}),u&&a.jsx(Ji,{fontSize:"xs",children:u})]}),Qi=w(c.Field.Root),ea=w(c.Field.HelperText),ta=w(c.Field.ErrorText),na=w(c.Select.Root),ra=w(c.Select.Label),oa=w(c.Select.Control),sa=w(c.Select.Trigger),ia=w(c.Select.ValueText),aa=w(c.Select.IndicatorGroup),la=w(c.Select.Indicator),ca=w(c.Select.Content),ua=w(c.Select.Item),da=w(c.Select.ItemIndicator),fa=w(c.Select.HiddenSelect),ha=w(c.Select.Positioner),ga=({options:e=[],label:t,value:n,onChange:r,placeholder:o,size:s="xs",width:i="100%",variant:l="outline",helperText:u,isDisabled:f,required:g,errorText:p,visible:S})=>{const v=c.createListCollection({items:e});return a.jsxs(Qi,{disabled:f,required:g,children:[a.jsxs(na,{collection:v,variant:l,size:s,width:i,value:n?[n]:[],onValueChange:m=>r?.(m.value[0]),children:[a.jsx(fa,{}),S&&a.jsx(ra,{children:t}),a.jsxs(oa,{children:[a.jsx(sa,{children:a.jsx(ia,{placeholder:o})}),a.jsx(aa,{children:a.jsx(la,{})})]}),a.jsx(ha,{children:a.jsx(ca,{children:v.items.map(m=>a.jsxs(ua,{item:m,children:[m.label,a.jsx(da,{})]},m.value))})})]}),u&&a.jsx(ea,{children:u}),p&&a.jsx(ta,{children:p})]})},pr=e=>`FILTER_PRESETS_${e??"default"}`;function pa(e){try{return JSON.parse(localStorage.getItem(pr(e))||"[]")}catch{return[]}}const Ze=new zn({}),wt=e=>{const t=Ze.state[e];if(t)return t;const n=pa(e);return Ze.setState(r=>({...r,[e]:n})),n},Zt=(e,t)=>{Ze.setState(n=>({...n,[e]:t})),localStorage.setItem(pr(e),JSON.stringify(t))},vr=(e,t)=>{const n=wt(e).filter(r=>r.id!==t);Zt(e,n)},br=(e,t)=>{const n=[t,...wt(e)];Zt(e,n)},va=w(c.Checkbox.Root),ba=w(c.Checkbox.HiddenInput),ma=w(c.Checkbox.Control),xa=w(c.Slider.Root),Sa=w(c.Slider.Track),ya=w(c.Slider.Range),wa=w(c.Slider.Thumbs),Ca=w(c.Slider.Control),Ra=({filter:e,onVisibilityChange:t,onSizeChange:n})=>{const{attributes:r,listeners:o,setNodeRef:s,transform:i,transition:l}=cr({id:e.id}),u={transform:Me.Transform.toString(i),transition:l};return a.jsxs(c.VStack,{ref:s,style:u,align:"stretch",border:"1px solid",borderColor:"gray.200",rounded:"md",p:3,mb:3,bg:"white",children:[a.jsxs(c.HStack,{...r,...o,cursor:"grab",userSelect:"none",gap:2,children:[a.jsx(dr,{size:16}),a.jsx(c.Text,{fontWeight:"bold",fontSize:"sm",children:e.label||e.id})]}),a.jsxs(c.HStack,{justify:"space-between",children:[a.jsx(c.Text,{fontSize:"sm",children:"Visible"}),a.jsxs(va,{checked:e.visible,size:"sm",onCheckedChange:f=>t?.(e.id,!!f.checked),children:[a.jsx(ba,{}),a.jsx(ma,{})]})]}),a.jsxs(c.VStack,{align:"stretch",gap:1,children:[a.jsx(c.Text,{fontSize:"sm",children:"Size"}),a.jsx(xa,{min:1,max:5,step:.5,value:[e.size??1],onValueChange:f=>n?.(e.id,f.value[0]),children:a.jsxs(Ca,{children:[a.jsx(Sa,{children:a.jsx(ya,{})}),a.jsx(wa,{})]})})]})]})},Ea=w(c.Drawer.Root),Da=w(c.Drawer.Trigger),Ta=w(c.Drawer.Backdrop),ja=w(c.Drawer.Positioner),_a=w(c.Drawer.Content),Oa=w(c.Drawer.Header),Ia=w(c.Drawer.Title),ka=w(c.Drawer.Body),Ma=w(c.Drawer.Footer),Aa=w(c.Drawer.CloseTrigger),Na=w(c.Tabs.Root),La=w(c.Tabs.List),Nt=w(c.Tabs.Trigger),Lt=w(c.Tabs.Content),mr=(e,t)=>{if(e.customComponent)return e.customComponent;switch(e.type){case"text":return a.jsx(Ln,{placeholder:e.label,value:e.value,onChange:e.onChange,label:e.label,visible:t});case"number":return a.jsx(Ln,{label:e.label,value:e.value,onChange:e.onChange});case"checkbox":return a.jsx(Fi,{label:e.label,value:e.value,onChange:e.onChange});case"select":return a.jsx(ga,{label:e.label,value:e.value,onChange:e.onChange,options:e.options??[],visible:t});case"date":return a.jsx(Xi,{value:e.value,onChange:e.onChange});default:return null}},$a=({filterDrawerSize:e="sm",onVisibilityChange:t,onSizeChange:n,onClear:r,filters:o,pageKey:s="default",currentFilters:i={},onLoadPreset:l,activePresetName:u,onReorder:f,open:g,onOpenChange:p})=>{const v=Qe(Ze)[s]??wt(s),m=()=>{const h=prompt("Preset name?");h&&br(s,{id:crypto.randomUUID(),name:h,date:new Date().toISOString(),filters:i})};return a.jsx(c.HStack,{wrap:"wrap",children:a.jsxs(Ea,{size:e,open:g,onOpenChange:p,children:[a.jsx(Da,{asChild:!0,children:a.jsxs(c.IconButton,{"aria-label":"Open filters",variant:"outline",size:"xs",ml:2,p:2,children:[a.jsx(Qs,{size:16}),"Filters"]})}),a.jsxs(c.Portal,{children:[a.jsx(Ta,{}),a.jsx(ja,{children:a.jsxs(_a,{children:[a.jsx(Oa,{children:a.jsx(Ia,{children:"Filters"})}),a.jsx(ka,{overflowY:"auto",pt:1,children:a.jsxs(Na,{defaultValue:"view",children:[a.jsxs(La,{mb:4,children:[a.jsxs(Nt,{value:"view",children:[a.jsx(ni,{size:16}),"Edit"]}),a.jsxs(Nt,{value:"settings",children:[a.jsx(oi,{size:16}),"Settings"]}),a.jsxs(Nt,{value:"presets",children:[a.jsx(Fs,{size:16}),"Presets"]})]}),a.jsx(Lt,{value:"view",children:o.filter(h=>h.visible).map(h=>a.jsx(c.VStack,{align:"stretch",border:"1px solid",borderColor:"gray.200",flex:h.size??1,minW:`${(h.size??1)*100}px`,rounded:"md",p:3,mb:3,children:mr(h,g)},h.id))}),a.jsx(Lt,{value:"settings",children:a.jsx(rr,{sensors:ro(no(Kt)),collisionDetection:Hn,onDragEnd:({active:h,over:x})=>{if(!x||h.id===x.id)return;const y=o.findIndex(E=>E.id===h.id),C=o.findIndex(E=>E.id===x.id),R=yt(o,y,C);f?.(R)},children:a.jsx(ar,{items:o.map(h=>h.id),strategy:xs,children:o.map(h=>a.jsx(Ra,{filter:h,onVisibilityChange:t,onSizeChange:n},h.id))})})}),a.jsx(Lt,{value:"presets",children:a.jsxs(c.VStack,{align:"stretch",mb:3,children:[a.jsx(c.Button,{size:"sm",colorScheme:"blue",onClick:m,children:"Save Current Filters"}),v.length===0&&a.jsx(c.Text,{fontSize:"xs",color:"gray.500",children:"No presets saved yet."}),v.map(h=>a.jsxs(c.HStack,{justify:"space-between",border:"1px solid",borderColor:u===h.name?"blue.300":"gray.200",rounded:"md",p:2,children:[a.jsxs(c.VStack,{align:"start",gap:0,children:[a.jsx(c.Text,{fontWeight:"bold",fontSize:"sm",children:h.name}),a.jsx(c.Text,{fontSize:"xs",color:"gray.500",children:new Date(h.date).toLocaleDateString()})]}),a.jsxs(c.HStack,{children:[a.jsx(c.Button,{size:"xs",variant:"ghost",onClick:()=>l?.(h.filters,h.name),children:"Load"}),a.jsx(c.IconButton,{size:"xs","aria-label":"Delete preset",variant:"ghost",onClick:()=>vr(s,h.id),children:a.jsx(qs,{size:14})})]})]},h.id))]})})]})}),a.jsxs(Ma,{justify:"space-between",children:[a.jsx(c.Button,{size:"sm",variant:"ghost",colorScheme:"red",onClick:()=>r&&r(),children:"Clear All"}),a.jsx(Aa,{asChild:!0,children:a.jsx(c.CloseButton,{})})]})]})})]})]})})},Pa=({title:e,filters:t,onVisibilityChange:n,onReorder:r,onSizeChange:o,onClear:s,maxToolbarUnits:i,pageKey:l,currentFilters:u,onLoadPreset:f,activePresetName:g,filterDrawerSize:p="sm"})=>{const[S,v]=d.useState(!1);return a.jsxs(c.HStack,{wrap:"wrap",pl:2,pr:2,width:"100%",justify:"space-between",children:[e,a.jsxs(c.HStack,{gapX:1,children:[t.filter(m=>m.visible!==!1).map(m=>a.jsx(c.HStack,{flex:m.size??1,minW:`${(m.size??1)*100}px`,alignItems:"center",children:mr(m)},m.id)),a.jsx($a,{filterDrawerSize:p,onVisibilityChange:n,onReorder:r,onSizeChange:o,onClear:s,maxToolbarUnits:i,pageKey:l,filters:t,currentFilters:u,onLoadPreset:f,activePresetName:g,open:S,onOpenChange:m=>{v(m.open)}})]})]})},za=(e,t)=>{localStorage.setItem(`FILTER_ORDER_${e}`,JSON.stringify(t))},Fa=e=>{try{return JSON.parse(localStorage.getItem(`FILTER_ORDER_${e}`)||"[]")}catch{return[]}},Va=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.DataTable=Ni;exports.Filters=Pa;exports.MdsSharedUi=Va;exports.addPreset=br;exports.deletePreset=vr;exports.getPresets=wt;exports.loadOrder=Fa;exports.presetStore=Ze;exports.saveOrder=za;exports.savePresets=Zt;exports.setData=hr;exports.setTableId=gr;exports.tableStore=te;exports.withChildren=w;
package/dist/index.d.ts CHANGED
@@ -93,6 +93,20 @@ export declare interface IMainFilterType {
93
93
  activePresetName?: string | null;
94
94
  }
95
95
 
96
+ declare interface IMDSButtonTypes {
97
+ onClick?: () => void;
98
+ size?: 'sm' | 'md' | 'lg';
99
+ variant?: ConditionalValue<'subtle' | 'solid' | 'outline' | 'ghost' | 'plain'>;
100
+ label?: string;
101
+ leftIcon?: React.ReactNode;
102
+ rightIcon?: React.ReactNode;
103
+ isDisabled?: boolean;
104
+ colorScheme?: 'blue' | 'red' | 'green' | 'yellow' | 'gray' | 'cyan' | 'orange' | 'purple';
105
+ loading?: boolean;
106
+ loadingText?: string;
107
+ rounded?: 'sm' | 'md' | 'lg' | 'xl' | 'full';
108
+ }
109
+
96
110
  declare interface IMDSCheckboxTypes {
97
111
  value?: boolean;
98
112
  onChange?: (value: boolean) => void;
@@ -128,7 +142,7 @@ declare interface IMDSSelectBoxTypes {
128
142
  value?: string;
129
143
  onChange?: (value: string) => void;
130
144
  placeholder?: string;
131
- size?: 'sm' | 'md' | 'lg';
145
+ size?: 'sm' | 'md' | 'lg' | 'xs';
132
146
  width?: string;
133
147
  variant?: ConditionalValue<'subtle' | 'outline' | undefined>;
134
148
  label?: string;
@@ -145,7 +159,8 @@ export declare namespace MdsSharedUi {
145
159
  export {
146
160
  IMDSCheckboxTypes,
147
161
  IMDSInputTypes,
148
- IMDSSelectBoxTypes
162
+ IMDSSelectBoxTypes,
163
+ IMDSButtonTypes
149
164
  }
150
165
  }
151
166
 
package/dist/index.js CHANGED
@@ -4246,7 +4246,7 @@ const Oa = y(Fe.Root), Ta = y(Fe.Label), Ia = y(Fe.HelperText), Aa = y(Fe.ErrorT
4246
4246
  value: n,
4247
4247
  onChange: r,
4248
4248
  placeholder: o,
4249
- size: s = "sm",
4249
+ size: s = "xs",
4250
4250
  width: i = "100%",
4251
4251
  variant: l = "outline",
4252
4252
  helperText: c,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdspl/mds-shared-ui",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Chakra UI v3 DataTable with sorting, pagination, column visibility & drag reorder",
5
5
  "author": "magadh",
6
6
  "license": "MIT",