react-kd-grid 5.0.1 → 5.0.2
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.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import t,{memo as r,useMemo as n,useState as a,useEffect as l,useRef as o,useCallback as s,useLayoutEffect as i,useTransition as c,useDeferredValue as d,forwardRef as u,useImperativeHandle as g}from"react";import*as m from"react-dom";import{createPortal as h}from"react-dom";var x,f={exports:{}},p={};function y(){if(x)return p;x=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(t,r,n){var a=null;if(void 0!==n&&(a=""+n),void 0!==r.key&&(a=""+r.key),"key"in r)for(var l in n={},r)"key"!==l&&(n[l]=r[l]);else n=r;return{$$typeof:e,type:t,key:a,ref:void 0!==(r=n.ref)?r:null,props:n}}return p.Fragment=t,p.jsx=r,p.jsxs=r,p}var b,v,w={};function k(){return b||(b=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===S?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case h:return"Fragment";case f:return"Profiler";case x:return"StrictMode";case v:return"Suspense";case k:return"SuspenseList";case C:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case m:return"Portal";case y:return t.displayName||"Context";case p:return(t._context.displayName||"Context")+".Consumer";case b:var r=t.render;return(t=t.displayName)||(t=""!==(t=r.displayName||r.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case j:return null!==(r=t.displayName||null)?r:e(t.type)||"Memo";case N:r=t._payload,t=t._init;try{return e(t(r))}catch(e){}}return null}function r(e){return""+e}function n(e){try{r(e);var t=!1}catch(e){t=!0}if(t){t=console;var n="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.error.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),r(e)}}function a(t){if(t===h)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===N)return"<...>";try{var r=e(t);return r?"<"+r+">":"<...>"}catch(e){return"<...>"}}function l(){return Error("react-stack-top-frame")}function o(){var t=e(this.type);return L[t]||(L[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function s(t,r,a,l,s,c){var u,m=r.children;if(void 0!==m)if(l)if(D(m)){for(l=0;l<m.length;l++)i(m[l]);Object.freeze&&Object.freeze(m)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else i(m);if(M.call(r,"key")){m=e(t);var h=Object.keys(r).filter(function(e){return"key"!==e});l=0<h.length?"{key: someKey, "+h.join(": ..., ")+": ...}":"{key: someKey}",I[m+l]||(h=0<h.length?"{"+h.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',l,m,h,m),I[m+l]=!0)}if(m=null,void 0!==a&&(n(a),m=""+a),function(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(r)&&(n(r.key),m=""+r.key),"key"in r)for(var x in a={},r)"key"!==x&&(a[x]=r[x]);else a=r;return m&&function(e,t){function r(){d||(d=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(a,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,r,n,a,l){var s=r.ref;return e={$$typeof:g,type:e,key:t,props:r,_owner:n},Object.defineProperty(e,"ref",null!==(void 0!==s?s:null)?{enumerable:!1,get:o}:{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:l}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,m,a,null===(u=R.A)?null:u.getOwner(),s,c)}function i(e){c(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===N&&("fulfilled"===e._payload.status?c(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function c(e){return"object"==typeof e&&null!==e&&e.$$typeof===g}var d,u=t,g=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),p=Symbol.for("react.consumer"),y=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),R=u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,D=Array.isArray,E=console.createTask?console.createTask:function(){return null},L={},A=(u={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(u,l)(),F=E(a(l)),I={};w.Fragment=h,w.jsx=function(e,t,r){var n=1e4>R.recentlyCreatedOwnerStacks++;return s(e,t,r,!1,n?Error("react-stack-top-frame"):A,n?E(a(e)):F)},w.jsxs=function(e,t,r){var n=1e4>R.recentlyCreatedOwnerStacks++;return s(e,t,r,!0,n?Error("react-stack-top-frame"):A,n?E(a(e)):F)}}()),w}function j(){return v||(v=1,f.exports="production"===process.env.NODE_ENV?y():k()),f.exports}var N=j();const C=48,S=r(({columns:e,data:t,selectable:r,rowHeight:a,pinnedColumns:l=new Set})=>{const o=n(()=>{const r={},n=e.filter(e=>e.footerAggregate);return 0===n.length||n.forEach(e=>{const n=t.map(t=>t[e.key]);let a=null;if("function"==typeof e.footerAggregate)try{a=e.footerAggregate(n)}catch(t){console.warn(`Error computing custom footer aggregate for column ${e.key}:`,t),a=null}else{const r=e=>!!(/^\d{4}-\d{2}-\d{2}$/.test(e)||/^\d{2}-\d{2}-\d{4}$/.test(e)||/^\d{4}\/\d{2}\/\d{2}$/.test(e)||/^\d{2}\/\d{2}\/\d{4}$/.test(e)||(e.includes("-")||e.includes("/"))&&Number.isFinite(Date.parse(e))),l=n.map(e=>{if("number"==typeof e)return e;if(null==e)return NaN;const t=String(e);if(r(t))return NaN;const n=parseFloat(t.replace(/,/g,""));return Number.isFinite(n)?n:NaN}).filter(e=>Number.isFinite(e)),o=()=>n.map(e=>{if(e instanceof Date)return e.getTime();if("string"==typeof e||"number"==typeof e){const t=Date.parse(String(e));return Number.isFinite(t)?t:NaN}return NaN}).filter(e=>Number.isFinite(e));switch(e.footerAggregate){case"count":a=t.length;break;case"sum":l.length&&(a=l.reduce((e,t)=>e+t,0));break;case"avg":l.length&&(a=l.reduce((e,t)=>e+t,0)/l.length);break;case"min":if(l.length)a=Math.min(...l);else{const e=o();e.length&&(a=new Date(Math.min(...e)))}break;case"max":if(l.length)a=Math.max(...l);else{const e=o();e.length&&(a=new Date(Math.max(...e)))}break;default:a=null}}null!=a&&(r[e.key]=a)}),r},[e,t]);if(!e.some(e=>e.footerAggregate))return null;const s=e.reduce((e,t)=>e+t.width,0),i=n(()=>{const t=new Map,n=e.filter(e=>l.has(e.key)).map(e=>e.key);let a=r?C:0;for(const r of n)t.set(r,a),a+=e.find(e=>e.key===r)?.width||100;return t},[e,l,r]);return N.jsxs("div",{className:"flex h-full",style:{minWidth:`${s+(r?C:0)}px`,height:`${a}px`},children:[r&&N.jsx("div",{className:"w-12 p-3 border-r border-gray-200 dark:border-gray-700 flex items-center justify-center sticky left-0 bg-white dark:bg-gray-900 z-30",style:{height:`${a}px`},children:N.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Total"})},"select-footer-cell"),e.map(e=>{const t=e.width,r=o[e.key],n=e.footerAggregate&&void 0!==r;let s="";if(n){const t=e.footerAggregateFormatter||e.formatter;if(t)try{s=t(r)}catch{s=String(r)}else s="number"==typeof r?r%1==0?r.toString():r.toFixed(2):String(r?.toFixed)}const c=l.has(e.key),d=c&&i.get(e.key)||0;return N.jsx("div",{className:`border-r border-gray-200 dark:border-gray-700 last:border-r-0 ${e.noPadding?"p-0":"p-3"} text-sm flex items-center font-semibold text-gray-700 dark:text-gray-200 overflow-hidden ${"center"===e.align?"justify-center":"right"===e.align?"justify-end":"justify-start"} ${"center"===e.align?"text-center":"right"===e.align?"text-right":"text-left"} ${c?"sticky bg-white dark:bg-gray-900 z-20":""}`,style:{width:`${t}px`,minWidth:`${t}px`,maxWidth:`${t}px`,left:c?`${d}px`:"auto",height:`${a}px`},title:n?`${e.header}: ${s}`:void 0,children:n&&N.jsx("span",{className:"truncate w-full",children:s})},e.key)})]})},(e,t)=>{if(e.selectable!==t.selectable)return!1;if(e.rowHeight!==t.rowHeight)return!1;if(e.getRowId!==t.getRowId)return!1;if(e.columns.length!==t.columns.length)return!1;for(let r=0;r<e.columns.length;r++){const n=e.columns[r],a=t.columns[r];if(n.key!==a.key||n.width!==a.width||n.footerAggregate!==a.footerAggregate)return!1}if(e.data.length!==t.data.length)return!1;const r=(e,t,r)=>r?r(e):void 0!==e.id?e.id:t,n=e.data.length>0?r(e.data[0],0,e.getRowId):void 0,a=t.data.length>0?r(t.data[0],0,t.getRowId):void 0,l=e.data.length-1,o=t.data.length-1,s=e.data.length>0?r(e.data[l],l,e.getRowId):void 0,i=t.data.length>0?r(t.data[o],o,t.getRowId):void 0;return n===a&&s===i&&e.pinnedColumns?.size===t.pinnedColumns?.size}),R=()=>N.jsx("svg",{className:"w-10 h-10 mb-3 opacity-90 mx-auto text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:N.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),M=()=>N.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center py-12 px-8 text-center select-none",children:[N.jsxs("div",{className:"mb-4 inline-flex items-center gap-1.5 rounded-full bg-red-100 dark:bg-red-900/30 px-3 py-1 text-xs font-semibold tracking-wide text-red-600 dark:text-red-400 uppercase",children:[N.jsx("span",{children:"⚠"}),"License Error"]}),N.jsx(R,{}),N.jsx("h3",{className:"font-bold text-base text-red-800 dark:text-red-300 mb-1",children:"react-kd-grid: Invalid or Missing License Key"}),N.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400 max-w-xs mx-auto leading-relaxed",children:["Please provide a valid"," ",N.jsx("code",{className:"font-mono bg-red-100 dark:bg-red-900/40 px-1 py-0.5 rounded text-xs",children:"licenseKey"})," ","prop to unlock the grid."]})]}),D=({size:e=16,children:t,...r})=>N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...r,children:t}),E=e=>N.jsx(D,{...e,children:N.jsx("polyline",{points:"15 18 9 12 15 6"})}),L=e=>N.jsx(D,{...e,children:N.jsx("polyline",{points:"9 18 15 12 9 6"})}),A=e=>N.jsx(D,{...e,children:N.jsx("polyline",{points:"6 9 12 15 18 9"})}),F=e=>N.jsxs(D,{...e,children:[N.jsx("polyline",{points:"11 17 6 12 11 7"}),N.jsx("polyline",{points:"18 17 13 12 18 7"})]}),I=e=>N.jsxs(D,{...e,children:[N.jsx("polyline",{points:"13 17 18 12 13 7"}),N.jsx("polyline",{points:"6 17 11 12 6 7"})]}),z=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),N.jsx("polyline",{points:"5 12 12 5 19 12"})]}),$=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),N.jsx("polyline",{points:"19 12 12 19 5 12"})]}),T=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"m21 16-4 4-4-4"}),N.jsx("path",{d:"M17 20V4"}),N.jsx("path",{d:"m3 8 4-4 4 4"}),N.jsx("path",{d:"M7 4v16"})]}),O=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),N.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),P=e=>N.jsx(D,{...e,children:N.jsx("polyline",{points:"20 6 9 17 4 12"})}),_=e=>N.jsxs(D,{...e,children:[N.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),N.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),K=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),N.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),V=e=>N.jsxs(D,{...e,children:[N.jsx("polyline",{points:"3 6 5 6 21 6"}),N.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),N.jsx("path",{d:"M10 11v6"}),N.jsx("path",{d:"M14 11v6"}),N.jsx("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),B=e=>N.jsxs(D,{...e,children:[N.jsx("polyline",{points:"21 8 21 21 3 21 3 8"}),N.jsx("rect",{x:"1",y:"3",width:"22",height:"5"}),N.jsx("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]}),W=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),N.jsx("polyline",{points:"7 10 12 15 17 10"}),N.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),H=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),N.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),N.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]}),G=e=>N.jsx(D,{...e,children:N.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),U=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M13.013 3H2l8 9.46V19l4 2v-6.54l.9-1.055"}),N.jsx("line",{x1:"22",y1:"3",x2:"11",y2:"14"})]}),Y=e=>N.jsxs(D,{...e,children:[N.jsx("circle",{cx:"12",cy:"12",r:"3"}),N.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),q=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),N.jsx("path",{d:"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"})]}),X=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),N.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),N.jsx("path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h12"}),N.jsx("path",{d:"M15 9.34V6h1a2 2 0 0 0 0-4H7.89"})]}),J=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),N.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),N.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),N.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),N.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1"})]}),Z=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),N.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),N.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),N.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),N.jsx("rect",{x:"7",y:"7",width:"4",height:"4",rx:"1"}),N.jsx("rect",{x:"13",y:"13",width:"4",height:"4",rx:"1"})]}),Q=e=>N.jsxs(D,{...e,children:[N.jsx("circle",{cx:"12",cy:"12",r:"1"}),N.jsx("circle",{cx:"19",cy:"12",r:"1"}),N.jsx("circle",{cx:"5",cy:"12",r:"1"})]}),ee=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),N.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),te=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),N.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),N.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),re=e=>N.jsxs(D,{...e,children:[N.jsx("circle",{cx:"11",cy:"11",r:"8"}),N.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),ne=e=>N.jsxs(D,{...e,children:[N.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),N.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"}),N.jsx("path",{d:"M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3"})]}),ae=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),N.jsx("polyline",{points:"14 2 14 8 20 8"}),N.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),N.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),N.jsx("polyline",{points:"10 9 9 9 8 9"})]}),le=e=>N.jsxs(D,{...e,children:[N.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),N.jsx("path",{d:"M3 9h18"}),N.jsx("path",{d:"M3 15h18"}),N.jsx("path",{d:"M9 3v18"})]}),oe=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),N.jsx("circle",{cx:"9",cy:"7",r:"4"}),N.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),N.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),se=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),N.jsx("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),N.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),N.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),N.jsx("circle",{cx:"12",cy:"12",r:"4"}),N.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"})]}),ie=e=>N.jsx(D,{...e,children:N.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),ce=({size:e=16,className:t,style:r,...n})=>N.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",className:t,style:r,...n,children:[N.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),N.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]}),de=({value:e,onChange:t,placeholder:r="Enter text to filter..."})=>{const[n,l]=a(String(e?.value??"")),[o,s]=a(e?.operator||"contains");return N.jsxs("div",{className:"space-y-3",children:[N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Filter Type"}),N.jsxs("select",{value:o,onChange:e=>(e=>{const r=e;s(r),n.trim()&&t({type:"text",value:n,operator:r})})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[N.jsx("option",{value:"contains",children:"Contains"}),N.jsx("option",{value:"equals",children:"Equals"}),N.jsx("option",{value:"startsWith",children:"Starts with"}),N.jsx("option",{value:"endsWith",children:"Ends with"})]})]}),N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Text Value"}),N.jsx("input",{type:"text",value:n,onChange:e=>{return l(r=e.target.value),void(r.trim()?t({type:"text",value:r,operator:o}):t(null));var r},placeholder:r,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]})]})},ue=({value:e,onChange:t,min:r,max:n})=>{const[l,o]=a(String(e?.value??"")),[s,i]=a(String(e?.secondValue??"")),[c,d]=a(e?.operator||"equals"),u=(e,r=!1)=>{r?i(e):o(e);const n=parseFloat(e),a=parseFloat(s);"between"===c?isNaN(n)||isNaN(a)?t(null):t({type:"number",value:Math.min(n,a),secondValue:Math.max(n,a),operator:"between"}):isNaN(n)?t(null):t({type:"number",value:n,operator:c})};return N.jsxs("div",{className:"space-y-3",children:[N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Filter Type"}),N.jsxs("select",{value:c,onChange:e=>(e=>{const r=e;if(d(r),"between"===r){const e=parseFloat(l),r=parseFloat(s);isNaN(e)||isNaN(r)||t({type:"number",value:Math.min(e,r),secondValue:Math.max(e,r),operator:"between"})}else{const e=parseFloat(l);isNaN(e)||t({type:"number",value:e,operator:r})}})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[N.jsx("option",{value:"equals",children:"Equals"}),N.jsx("option",{value:"gt",children:"Greater than"}),N.jsx("option",{value:"gte",children:"Greater than or equal"}),N.jsx("option",{value:"lt",children:"Less than"}),N.jsx("option",{value:"lte",children:"Less than or equal"}),N.jsx("option",{value:"between",children:"Between"})]})]}),N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"between"===c?"From Value":"Number Value"}),N.jsx("input",{type:"number",value:l,onChange:e=>u(e.target.value),min:r,max:n,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),"between"===c&&N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"To Value"}),N.jsx("input",{type:"number",value:s,onChange:e=>u(e.target.value,!0),min:r,max:n,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]})]})},ge=({name:e,label:t,value:r,onChange:n,className:a=""})=>N.jsxs("div",{className:`space-y-1 ${a}`,children:[t&&N.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:t}),N.jsx("input",{type:"date",name:e,value:r||"",onChange:e=>n(e.target.value||null),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),me=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,he=e=>{const[t,r,n]=e.split("-").map(Number);return t&&r&&n?new Date(t,r-1,n):new Date(NaN)},xe=e=>`${String(e.getDate()).padStart(2,"0")}-${String(e.getMonth()+1).padStart(2,"0")}-${e.getFullYear()}`,fe=({value:e,onChange:t,min:r,max:o})=>{const s=e=>{if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;try{const t=he(String(e));return isNaN(t.getTime())?null:t}catch(t){const r=new Date(e);return isNaN(r.getTime())?null:r}},i=e=>e?me(e):"",[c,d]=a(s(e?.value)),[u,g]=a("between"===e?.operator?s(e?.secondValue??e?.value):null),[m,h]=a(e?.operator||"between");l(()=>{h(e?.operator||"between"),d(s(e?.value)),g("between"===e?.operator?s(e?.secondValue??e?.value):null)},[e?.value,e?.secondValue,e?.operator]),l(()=>{"between"===m&&!u&&c&&g(c)},[m,c,u]);const x=(e,t,r)=>e?t&&e<t||r&&e>r?null:e:null,f=(e,r=!1)=>{const n=r?c:e,a=r?e:u,l="between"===m&&u?u:y,o=r?x(e,c??p??void 0,y):x(e,p,l);if(r?g(o):d(o),"between"===m)if(n&&a){const e=n>=a?n:a;t({type:"date",value:i(n<=a?n:a),secondValue:i(e),operator:"between"})}else t(null);else t(o?{type:"date",value:i(o),operator:m}:null)},p=n(()=>r?new Date(r):void 0,[r]),y=n(()=>o?new Date(o):void 0,[o]);return N.jsxs("div",{className:"space-y-3",children:[N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Filter Type"}),N.jsxs("select",{value:m,onChange:e=>(e=>{const r=e;h(r),"between"===r?c&&u&&t({type:"date",value:c<=u?c:u,secondValue:c>=u?c:u,operator:"between"}):c&&t({type:"date",value:c,operator:r})})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[N.jsx("option",{value:"equals",children:"On Date"}),N.jsx("option",{value:"gt",children:"After"}),N.jsx("option",{value:"gte",children:"On or After"}),N.jsx("option",{value:"lt",children:"Before"}),N.jsx("option",{value:"lte",children:"On or Before"}),N.jsx("option",{value:"between",children:"Between Dates"})]})]}),N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"between"===m?"From Date":"Date"}),N.jsx(ge,{name:"date_filter_start",value:c?me(c):null,onChange:e=>f(e?he(e):null,!1),className:"w-full"})]}),"between"===m&&N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"To Date"}),N.jsx(ge,{name:"date_filter_end",value:u?me(u):null,onChange:e=>f(e?he(e):null,!0),className:"w-full"})]})]})},pe=({value:e,onChange:t,options:r,data:o,columnKey:s})=>{const[i,c]=a(""),[d,u]=a(new Set(Array.isArray(e?.value)?e.value:[]));l(()=>{u(new Set(Array.isArray(e?.value)?e.value:[]))},[e]);const g=n(()=>{let e=[];const t=e=>null==e||""===e||"string"==typeof e&&""===e.trim();if(r&&r.length>0)e=r;else{const r=o.map(e=>{const r=e[s];return t(r)?null:r});e=[...new Set(r)].map(e=>({label:null===e?"Blank":String(e),value:e}))}const n=e.map(e=>{const r=t(e.value);return{...e,label:r?"Blank":e.label,value:r?null:e.value,isBlank:r}});return Array.from(new Map(n.map(e=>[e.isBlank?"__blank__":e.value,e])).values()).sort((e,t)=>e.isBlank&&!t.isBlank?1:!e.isBlank&&t.isBlank?-1:String(e.label).localeCompare(String(t.label)))},[r,o,s]),m=n(()=>{if(!i)return g;const e=i.toLowerCase();return g.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)||"blank"===e&&t.isBlank)},[g,i]);return N.jsxs("div",{className:"space-y-3",children:[N.jsxs("div",{className:"relative",children:[N.jsx(re,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4 dark:text-gray-500"}),N.jsx("input",{type:"text",value:i,onChange:e=>c(e.target.value),placeholder:"Search options...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),N.jsxs("div",{className:"flex justify-between items-center text-sm",children:[N.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[d.size," of ",g.length," selected"]}),N.jsxs("div",{className:"flex gap-2",children:[N.jsx("button",{onClick:()=>{const e=new Set(m.map(e=>e.value));u(e),t({type:"multiselect",value:Array.from(e),operator:"equals"})},className:"text-blue-600 hover:text-blue-800 transition-colors dark:text-blue-400",children:"Select All"}),N.jsx("button",{onClick:()=>{u(new Set),t(null)},className:"text-gray-600 hover:text-gray-800 transition-colors dark:text-gray-400",children:"Clear All"})]})]}),N.jsx("div",{className:"max-h-48 overflow-y-auto border border-gray-200 rounded-md dark:border-gray-700",children:0===m.length?N.jsx("div",{className:"p-3 text-sm text-gray-500 text-center dark:text-gray-400",children:"No options found"}):m.map((e,r)=>{const n=d.has(e.value);return N.jsxs("div",{className:`flex items-center gap-3 p-2 cursor-pointer hover:bg-gray-50 transition-colors ${n?"bg-blue-50 dark:bg-blue-900/30":""} dark:hover:bg-gray-800`,onClick:()=>(e=>{const r=new Set(d);r.has(e)?r.delete(e):r.add(e),u(r),t(r.size>0?{type:"multiselect",value:Array.from(r),operator:"equals"}:null)})(e.value),children:[N.jsx("div",{className:"w-4 h-4 border-2 rounded flex items-center justify-center "+(n?"bg-blue-600 border-blue-600 text-white":"border-gray-300 dark:border-gray-600"),children:n&&N.jsx(P,{className:"w-3 h-3"})}),N.jsx("span",{className:`text-sm ${n?"text-blue-900 dark:text-blue-100 font-medium":"text-gray-700 dark:text-gray-300"} ${e.isBlank?"italic text-gray-500 dark:text-gray-500":""}`,children:e.label})]},r)})})]})},ye=({value:e,onChange:t})=>{const[r,n]=a(void 0!==e?.value?String(e.value):"");return N.jsx("div",{className:"space-y-3",children:N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Boolean Value"}),N.jsxs("select",{value:r,onChange:e=>{return n(r=e.target.value),void t(""===r?null:{type:"boolean",value:"true"===r,operator:"equals"});var r},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[N.jsx("option",{value:"",children:"All values"}),N.jsx("option",{value:"true",children:"True"}),N.jsx("option",{value:"false",children:"False"})]})]})})},be=({column:e,data:t,value:r,onChange:a})=>{const l=n(()=>{if("object"==typeof e.filterable)return e.filterable;const r=t.slice(0,100).map(t=>t[e.key]).filter(e=>null!=e);if(0===r.length)return{type:"text"};const n=r[0];if("boolean"==typeof n)return{type:"boolean"};if("number"==typeof n)return{type:"number"};if(n instanceof Date||"string"==typeof n&&!isNaN(Date.parse(n)))return{type:"date"};const a=[...new Set(r)];return a.length<=20?{type:"multiselect",options:a.map(e=>({label:String(e),value:e}))}:{type:"text"}},[e.filterable,e.key,t]);switch(l.type){case"text":return N.jsx(de,{value:r,onChange:a,placeholder:l.placeholder});case"number":return N.jsx(ue,{value:r,onChange:a,min:l.min,max:l.max});case"date":return N.jsx(fe,{value:r,onChange:a,min:l.min,max:l.max});case"multiselect":return N.jsx(pe,{value:r,onChange:a,options:l.options||[],data:t,columnKey:e.key});case"boolean":return N.jsx(ye,{value:r,onChange:a});default:return null}},ve=({pinnedColumns:e,unpinnedColumns:t,hvPadLeft:r=0,hvPadRight:o=0,headerHeight:s,sortConfig:i,columnFilters:c,selectable:d,selectedRows:u,totalRows:g,data:m,onSort:h,onColumnFilter:x,onSelectAll:f,onColumnResize:p,pinnedKeySet:y=new Set,onColumnPin:b,groupable:v=!1,groupedByColumn:w,onGroupBy:k,groupedByColumns:j=[],onGroupToggle:S,onAutosizeColumn:R,onAutosizeAllColumns:M,onResetColumns:D,columnOrder:E,onColumnOrderChange:L,paginationMode:A="client",minResizeWidth:F=80})=>{const I=n(()=>[...e,...t],[e,t]),[O,P]=a(null),[_,K]=a(null),[V,B]=a(null),[W,Y]=a(0),[Q,ee]=a(0),[te,re]=a("menu"),[ne,ae]=a(null),[le,oe]=a(!1);l(()=>{oe("ontouchstart"in window||navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches)},[]);const[se,ie]=a(null),[ce,de]=a(null),ue=u.size===g&&g>0,ge=u.size>0&&u.size<g,me=(e,t)=>{if(t.stopPropagation(),O===e)P(null);else{P(e),re("menu"),ae(c[e]||null);const r=t.currentTarget.getBoundingClientRect(),n=t.currentTarget.closest("[data-grid-container]"),a=n?n.getBoundingClientRect():new DOMRect(0,0,window.innerWidth,window.innerHeight),l=10,o=Math.max(a.left+l,Math.min(r.left,a.right-320-l));K({top:r.bottom+4,left:o,containerRect:a})}},he=e=>{x(e,ne||null),P(null)},xe=e=>null!=c[e],fe=(r,n)=>{n.preventDefault(),B(r),Y(n.clientX);const a=[...e,...t].find(e=>e.key===r);ee(a?.width||100)},pe=e=>{if(!V||!p)return;const t=Math.max(F,Q+(e.clientX-W));p(V,t)},ye=()=>{B(null),Y(0),ee(0)},[ve,we]=a(null),[ke,je]=a(null),Ne=(e,t)=>{we(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},Ce=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();je({key:e,position:t.clientX<r.left+r.width/2?"before":"after"})},Se=e=>{const t=ve;if(!t||t===e)return;if(y.has(t)!==y.has(e))return we(null),void je(null);const r=ke?.key!==e||"before"===ke?.position,n=E.filter(e=>e!==t);let a=n.indexOf(e);if(-1===a)return L(n),we(null),void je(null);r||(a+=1),n.splice(a,0,t),L(n),we(null),je(null)},Re=()=>{we(null),je(null)},Me=(e,t)=>{ie(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},De=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();de({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})},Ee=e=>{const t=se;if(!t||t===e)return;if(y.has(t)!==y.has(e))return ie(null),void de(null);const r=ce?.key!==e||"before"===ce?.position,n=E.filter(e=>e!==t);let a=n.indexOf(e);if(-1===a)return L(n),ie(null),void de(null);r||(a+=1),n.splice(a,0,t),L(n),ie(null),de(null)},Le=()=>{ie(null),de(null)};return l(()=>{if(V)return document.addEventListener("mousemove",pe),document.addEventListener("mouseup",ye),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",ye),document.body.style.cursor="",document.body.style.userSelect=""}},[V,W,Q,p]),l(()=>{const e=e=>{O&&!e.target.closest("[data-column-menu]")&&P(null)};if(O)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[O]),N.jsx(N.Fragment,{children:N.jsx("div",{className:"bg-blue-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",style:{height:s},role:"row","aria-label":"Column headers",children:N.jsxs("div",{className:"flex h-full",children:[d&&N.jsx("div",{className:"px-3 border-r border-gray-200 dark:border-gray-700 flex items-center justify-center bg-blue-50 dark:bg-gray-800 sticky left-0 z-3 h-full",style:{width:C,height:s},role:"columnheader","aria-label":"Select all rows",children:N.jsx("input",{type:"checkbox",checked:ue,ref:e=>{e&&(e.indeterminate=ge)},onChange:f,onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),f())},className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 h-4 w-4 transition-all duration-150 dark:text-blue-400","aria-label":ue?"Deselect all rows":ge?`${u.size} rows selected. Click to select all`:"Select all rows",title:ue?`Deselect all ${g} rows`:ge?`${u.size} of ${g} rows selected`:`Select all ${g} rows`})}),e.map((t,r)=>{const n=y.has(t.key),a=e.filter(e=>y.has(e.key)).map(e=>e.key),l=a.indexOf(t.key),o=n?a.slice(0,l).reduce((t,r)=>{const n=e.find(e=>e.key===r);return t+(n?.width||100)},d?C:0):0,c="center"===t.headerAlign?"justify-center":"right"===t.headerAlign?"justify-end":"justify-start",u=!1!==t.sortable;return N.jsxs("div",{className:`flex-none border-r border-gray-200 dark:border-gray-700 last:border-r-0 relative ${n?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-700 sticky z-2":""} `,style:{width:t.width||100,left:n?`${o}px`:"auto",height:s},"data-column-key":t.key,draggable:!0,onDragStart:e=>Ne(t.key,e),onDragOver:e=>Ce(t.key,e),onDrop:()=>Se(t.key),onDragEnd:Re,children:[ke?.key===t.key&&N.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===ke?.position?0:void 0,right:"after"===ke?.position?0:void 0}}),N.jsx("div",{className:"px-3 h-full",children:N.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[N.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${c} ${u?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>u&&h(t.key),children:[N.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[xe(t.key)&&N.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),N.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",children:t.header})]}),u&&i.key===t.key&&N.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:N.jsx("asc"===i.direction?z:$,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(t.filterable||b||v)&&N.jsxs("div",{className:"relative "+(O===t.key||le?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[N.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:e=>me(t.key,e),"data-menu-trigger":!0,children:N.jsx(H,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),O===t.key&&_&&N.jsxs("div",{className:"fixed bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg z-1000 w-[320px] overflow-auto",style:{top:`${_.top}px`,left:`${_.left}px`,maxHeight:`${Math.max(160,_.containerRect.bottom-12-_.top)}px`},"data-column-menu":!0,children:[N.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("menu"),children:N.jsx(H,{className:"w-4 h-4"})}),t.filterable&&N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("filter"),children:N.jsx(G,{className:"w-4 h-4"})}),N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("reorder"),children:N.jsx(T,{className:"w-4 h-4"})})]}),"menu"===te&&N.jsxs("div",{className:"py-1",children:[b&&(w===t.key?N.jsxs("div",{className:"w-full px-3 py-2 text-left text-sm flex items-center gap-2 text-blue-600 dark:text-blue-400",children:[N.jsx(q,{className:"w-4 h-4"}),"Pinned by grouping"]}):N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200",onClick:e=>{e.stopPropagation(),P(null),b?.(t.key,!y.has(t.key))},children:y.has(t.key)?N.jsxs(N.Fragment,{children:[N.jsx(X,{className:"w-4 h-4"}),"Unpin Column"]}):N.jsxs(N.Fragment,{children:[N.jsx(q,{className:"w-4 h-4"}),"Pin Column"]})})),R&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{R?.(t.key),P(null)},children:"Autosize This Column"}),M&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{M?.(),P(null)},children:"Autosize All Columns"}),v&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200",onClick:e=>{e.stopPropagation(),P(null);const r=j?.includes(t.key)||w===t.key;S?S(t.key,!r):k?.(r?null:t.key)},children:w===t.key||j?.includes(t.key)?N.jsxs(N.Fragment,{children:[N.jsx(Z,{className:"w-4 h-4"}),"Ungroup"]}):N.jsxs(N.Fragment,{children:[N.jsx(J,{className:"w-4 h-4"}),"Group by ",t.header]})}),D&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{D?.(),P(null)},children:"Reset Columns"})]}),"filter"===te&&N.jsxs("div",{className:"p-3 w-full",children:[xe(t.key)&&N.jsxs("button",{className:"mb-2 text-xs text-red-600 hover:underline flex items-center gap-1 dark:text-red-400",onClick:()=>{ae(null),x(t.key,null),P(null)},children:[N.jsx(U,{className:"w-3 h-3"})," Clear Filter"]}),N.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:N.jsx(be,{column:t,data:m,value:ne,onChange:e=>{ae(e),"server"!==A&&x(t.key,e)}})}),"server"===A?N.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[N.jsx("button",{className:"px-3 py-1.5 text-sm bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-700",onClick:()=>P(null),children:"Cancel"}),N.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>he(t.key),children:"Apply"})]}):N.jsx("div",{className:"flex justify-end mt-3",children:N.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>P(null),children:"Close"})})]}),"reorder"===te&&N.jsxs("div",{className:"px-3 py-2",children:[N.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1 dark:text-gray-400",children:"Reorder Columns"}),N.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md dark:border-gray-700",children:[...E.map(e=>I.find(t=>t.key===e)).filter(Boolean),...I.filter(e=>!E.includes(e.key))].map(e=>{const t=y.has(e.key);return N.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b border-gray-100 last:border-b-0 relative ${se===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""} dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-gray-700`,draggable:!0,onDragStart:t=>Me(e.key,t),onDragOver:t=>De(e.key,t),onDrop:()=>Ee(e.key),onDragEnd:Le,children:[ce?.key===e.key&&N.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===ce?.position?0:void 0,bottom:"after"===ce?.position?0:void 0}}),N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsx("span",{className:"text-gray-400 select-none dark:text-gray-500",children:"⋮⋮"}),N.jsxs("span",{className:"text-gray-800 truncate max-w-45 dark:text-gray-200",children:[e.header,t&&N.jsx("span",{className:"ml-1 text-[10px] text-blue-600 dark:text-blue-400",children:"(pinned)"})]})]})]},e.key)})}),N.jsx("div",{className:"text-[10px] text-gray-400 mt-1 dark:text-gray-500",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<e.length-1&&p&&N.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:e=>fe(t.key,e),onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),R?.(t.key)},title:"Drag to resize • Double‑click to autosize",children:N.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},t.key+r)}),r>0&&N.jsx("div",{style:{width:r,height:s},className:"flex-none"}),t.map((e,r)=>{const n="center"===e.headerAlign?"justify-center":"right"===e.headerAlign?"justify-end":"justify-start",a=!1!==e.sortable;return N.jsxs("div",{className:"flex-none border-r border-gray-200 dark:border-gray-700 last:border-r-0 relative",style:{width:e.width||100,height:s},"data-column-key":e.key,draggable:!0,onDragStart:t=>Ne(e.key,t),onDragOver:t=>Ce(e.key,t),onDrop:()=>Se(e.key),onDragEnd:Re,children:[ke?.key===e.key&&N.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===ke?.position?0:void 0,right:"after"===ke?.position?0:void 0}}),N.jsx("div",{className:"px-3 h-full",children:N.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[N.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${n} ${a?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>a&&h(e.key),children:[N.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[xe(e.key)&&N.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),N.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",title:e.headerTooltip||e.header||"",children:e.header})]}),a&&i.key===e.key&&N.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:N.jsx("asc"===i.direction?z:$,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(e.filterable||b||v)&&N.jsxs("div",{className:"relative "+(O===e.key||le?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[N.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:t=>me(e.key,t),"data-menu-trigger":!0,children:N.jsx(H,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),O===e.key&&_&&N.jsxs("div",{className:"fixed bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg z-10 w-[320px] overflow-auto",style:{top:`${_.top}px`,left:`${_.left}px`,maxHeight:`${Math.max(160,_.containerRect.bottom-12-_.top)}px`},"data-column-menu":!0,children:[N.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("menu"),children:N.jsx(H,{className:"w-4 h-4"})}),e.filterable&&N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("filter"),children:N.jsx(G,{className:"w-4 h-4"})}),N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("reorder"),children:N.jsx(T,{className:"w-4 h-4"})})]}),"menu"===te&&N.jsxs("div",{className:"py-1",children:[b&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200",onClick:t=>{t.stopPropagation(),P(null);const r=!y.has(e.key);b?.(e.key,r)},children:y.has(e.key)?N.jsxs(N.Fragment,{children:[N.jsx(X,{className:"w-4 h-4"}),"Unpin Column"]}):N.jsxs(N.Fragment,{children:[N.jsx(q,{className:"w-4 h-4"}),"Pin Column"]})}),R&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{R?.(e.key),P(null)},children:"Autosize This Column"}),M&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{M?.(),P(null)},children:"Autosize All Columns"}),v&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200 ",onClick:t=>{t.stopPropagation(),P(null);const r=j?.includes(e.key)||w===e.key;S?S(e.key,!r):k?.(r?null:e.key)},children:w===e.key||j?.includes(e.key)?N.jsxs(N.Fragment,{children:[N.jsx(Z,{className:"w-4 h-4"}),"Ungroup"]}):N.jsxs(N.Fragment,{children:[N.jsx(J,{className:"w-4 h-4"}),"Group by ",e.header]})}),D&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{D?.(),P(null)},children:"Reset Columns"})]}),"filter"===te&&N.jsxs("div",{className:"p-3 w-full",children:[N.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:N.jsx(be,{column:e,data:m,value:ne,onChange:t=>{ae(t),"server"!==A&&x(e.key,t)}})}),N.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[xe(e.key)&&N.jsxs("button",{className:"px-3 py-1.5 text-sm bg-red-500 text-white rounded-md hover:bg-red-600 flex items-center gap-2 cursor-pointer",onClick:()=>{ae(null),x(e.key,null),P(null)},children:[N.jsx(U,{className:"w-3 h-3"})," Clear Filter"]}),N.jsx("button",{className:"px-3 py-1.5 text-sm bg-green-100 text-green-700 rounded-md hover:bg-green-200 cursor-pointer dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50",onClick:()=>P(null),children:"Apply"}),"server"===A&&N.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>he(e.key),children:"Apply"})]})]}),"reorder"===te&&N.jsxs("div",{className:"px-3 py-2",children:[N.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1 dark:text-gray-400",children:"Reorder Columns"}),N.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md dark:border-gray-700",children:[...E.map(e=>I.find(t=>t.key===e)).filter(Boolean),...I.filter(e=>!E.includes(e.key))].map(e=>{const t=y.has(e.key);return N.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b border-gray-100 last:border-b-0 relative ${se===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""} dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-gray-700`,draggable:!0,onDragStart:t=>Me(e.key,t),onDragOver:t=>De(e.key,t),onDrop:()=>Ee(e.key),onDragEnd:Le,children:[ce?.key===e.key&&N.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===ce?.position?0:void 0,bottom:"after"===ce?.position?0:void 0}}),N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsx("span",{className:"text-gray-400 select-none dark:text-gray-500",children:"⋮⋮"}),N.jsxs("span",{className:"text-gray-800 truncate max-w-45 dark:text-gray-200",children:[e.header,t&&N.jsx("span",{className:"ml-1 text-[10px] text-blue-600 dark:text-blue-400",children:"(pinned)"})]})]})]},e.key)})}),N.jsx("div",{className:"text-[10px] text-gray-400 mt-1 dark:text-gray-500",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<t.length-1&&p&&N.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:t=>fe(e.key,t),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),R?.(e.key)},title:"Drag to resize • Double‑click to autosize",children:N.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},e.key+r)}),o>0&&N.jsx("div",{style:{width:o,height:s},className:"flex-none"})]})})})};ve.displayName="GridHeader";const we=r(ve);N.jsx(ee,{className:"w-4 h-4"}),N.jsx(_,{className:"w-4 h-4"}),N.jsx(V,{className:"w-4 h-4"});const ke=({row:e,position:t,isVisible:r,onClose:a,menuItems:s})=>{const i=o(null);l(()=>{if(!r)return;const e=e=>{i.current&&!i.current.contains(e.target)&&a()},t=e=>{"Escape"===e.key&&a()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r,a]);const c=n(()=>{if(!r||!s?.length)return t;const e=40*s.filter(e=>!e.separator).length+10*s.filter(e=>e.separator).length,n=window.innerWidth,a=window.innerHeight;let l=t.x,o=t.y;return l+100>n&&(l=n-100-10),l-100<0&&(l=110),o+e>a&&(o=o-e-10),{x:l,y:o}},[t,r,s]);return r&&s?.length?N.jsxs(N.Fragment,{children:[N.jsx("div",{className:"fixed inset-0 z-40",onClick:a}),N.jsx("div",{ref:i,role:"menu","aria-label":"Row actions",className:"fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 min-w-[180px]",style:{left:`${c.x}px`,top:`${c.y}px`,transform:"translate(-50%, 0)"},children:s.map(t=>t.separator?N.jsx("div",{role:"separator",className:"border-t border-gray-100 dark:border-gray-700 my-1"},t.id):N.jsxs("button",{role:"menuitem",onClick:()=>(t=>{t.disabled||t.separator||(t.onClick(e),a())})(t),disabled:t.disabled,className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-left transition-colors "+(t.disabled?"text-gray-400 dark:text-gray-600 cursor-not-allowed":"delete"===t.id?"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20":"text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700"),children:[t.icon&&N.jsx("span",{className:"shrink-0",children:t.icon}),N.jsx("span",{className:"flex-1",children:t.label})]},t.id))})]}):null},je=({column:e,row:t,initialValue:r,onCommit:n,onCancel:i})=>{const[c,d]=a(null==r?"":r),u=o(!1),g=o(!1),m=o(null),h=o(null),x=o(null);l(()=>{const e=h.current??m.current??x.current;e&&(e.focus(),"select"in e&&e.select())},[]);const f=s(()=>{if(u.current||g.current)return;g.current=!0;const t="number"===e.editorType&&""!==c?Number(c):c;n(t)},[c,e.editorType,n]),p=s(()=>{u.current=!0,i()},[i]),y=s(t=>{"Enter"===t.key&&"textarea"!==e.editorType?(t.preventDefault(),t.stopPropagation(),f()):"Escape"===t.key?(t.preventDefault(),t.stopPropagation(),p()):"Tab"===t.key&&f()},[f,p,e.editorType]),b=s(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key?(e.preventDefault(),f()):"Escape"===e.key?(e.preventDefault(),p()):"Tab"===e.key&&f()},[f,p]),v=s(()=>{f()},[f]),w="w-full h-full bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 text-sm outline-none border border-blue-500 dark:border-blue-400 rounded-sm px-2 focus:ring-2 focus:ring-blue-400/30 transition-shadow";return N.jsx("div",e.editor?{className:"absolute inset-0 z-10 flex items-center",children:e.editor(c,t,n,i)}:"textarea"===e.editorType?{className:"absolute inset-0 z-10 flex items-start p-0.5",children:N.jsx("textarea",{ref:h,value:c,rows:3,className:`${w} resize-none py-1`,onChange:e=>d(e.target.value),onKeyDown:b,onBlur:v})}:"select"===e.editorType?{className:"absolute inset-0 z-10 flex items-center p-0.5",children:N.jsx("select",{ref:x,value:c,className:`${w} cursor-pointer`,onChange:e=>{d(e.target.value)},onKeyDown:y,onBlur:v,children:e.editorOptions?.map(e=>N.jsx("option",{value:e.value,children:e.label},String(e.value)))})}:{className:"absolute inset-0 z-10 flex items-center p-0.5",children:N.jsx("input",{ref:m,type:e.editorType??"text",value:c,className:w,onChange:e=>d(e.target.value),onKeyDown:y,onBlur:v})})},Ne=({data:e,columns:t,selectedRows:r,virtualized:l,virtualizedRange:o,rowHeight:i,selectable:c,isRowSelectable:d,onRowSelect:u,pinnedColumns:g=new Set,hvPadLeft:m=0,hvPadRight:h=0,rowStyle:x,globalFilter:f,onContextMenu:p,onRowDoubleClick:y,onRowClick:b,onCellClick:v,isCellFocused:w,isCellSelected:k,onCellContextMenu:j,onCellMouseDown:S,onCellMouseEnter:R,contextMenuItems:M,getRowId:D,isEditing:E,onStartEdit:L,onCommitEdit:A,onCancelEdit:F,editingInitialValue:I})=>{const z=n(()=>e.length*i,[e.length,i]),{leftOffsetByPinnedKey:$}=n(()=>{if(0===g.size)return{leftOffsetByPinnedKey:new Map};const e=t.filter(e=>g.has(e.key)).map(e=>e.key),r=new Map;for(const e of t)r.set(e.key,e.width||100);const n=new Map;let a=c?C:0;for(const t of e)n.set(t,a),a+=r.get(t)||100;return{leftOffsetByPinnedKey:n}},[t,g,c]),T=n(()=>t.reduce((e,t)=>e+(g.has(t.key)?1:0),0),[t,g]),[O,P]=a(null),_=s((e,t)=>{e.preventDefault(),p?.({row:t,event:e}),M?.length&&P({row:t,x:e.clientX,y:e.clientY})},[p,M]),K=s(()=>P(null),[]);return N.jsxs(N.Fragment,{children:[N.jsx("div",{style:{height:l?`${z}px`:"auto",position:"relative"},children:N.jsx("div",{style:{transform:l?`translate3d(0, ${o.offsetY}px, 0)`:"none",position:l?"absolute":"static",top:0,left:0,right:0},children:e.map((e,n)=>{const a=l?o.startIndex+n:n,s=x?.(e),p=((e,t)=>D?D(e):void 0!==e.id?e.id:("undefined"!=typeof window&&window.KD_DEV_LOG&&0===t&&console.warn("[KDGrid] No row IDs found. Either:\n 1. Add 'id' property to each row object, or\n 2. Provide 'getRowId' prop to extract a unique identifier.\n Using row index as fallback ID, but this may cause issues with pagination/filtering."),t??0))(e,a),M=a%2==0?"bg-white dark:bg-gray-900":"bg-gray-50 dark:bg-gray-800",z=r.has(p)?"bg-blue-50 dark:bg-blue-900/20":"";return N.jsxs("div",{className:`flex border-b border-gray-100 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-900 dark:text-gray-100 ${z||(s?"":M)}`,style:{height:`${i}px`,...s},onContextMenu:t=>_(t,e),onDoubleClick:t=>((e,t)=>{y?.({row:t,event:e})})(t,e),onClick:t=>((e,t)=>{b?.({row:t,event:e})})(t,e),children:[c&&N.jsx("div",{className:"flex items-center justify-center sticky left-0 bg-inherit z-2 border-r border-gray-200 dark:border-gray-700",style:{width:C},children:N.jsx("input",{type:"checkbox",checked:r.has(p),disabled:!!d&&!d(e),onChange:e=>u(p,e.target.checked),onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),u(p,!r.has(p)))},className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 h-4 w-4 transition-all duration-150 dark:text-blue-400","aria-label":`Select row ${p}`,tabIndex:0})}),t.map((t,r)=>{const n=g.has(t.key),a=n&&$.get(t.key)||0,l=e[t.key];let o,s;if(t.cellRenderer?(o=t.cellRenderer(l,e),"string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l||(s=String(l))):t.formatter?(o=t.formatter(l),s=String(o)):(o="bigint"==typeof l?l.toString():l??"",s=o?String(o):void 0),f&&f.trim()&&!t.cellRenderer&&o){const e=String(o);((e,t)=>{if(!t||null==e)return!1;const r=t.toLowerCase().trim();return!!r&&String(e).toLowerCase().includes(r)})(e,f)&&(o=((e,t)=>{if(!t||!e)return e;const r=t.toLowerCase().trim(),n=e.toLowerCase();if(!r||!n.includes(r))return e;const a=[];let l=0,o=0,s=0;for(;-1!==(o=n.indexOf(r,l));)o>l&&a.push(e.slice(l,o)),a.push(N.jsx("mark",{className:"bg-yellow-200 dark:bg-yellow-600/40 text-current font-medium px-0.5 py-0 rounded-sm",style:{margin:0},children:e.slice(o,o+r.length)},"highlight-"+s++)),l=o+r.length;return l<e.length&&a.push(e.slice(l)),N.jsx(N.Fragment,{children:a})})(e,f))}s&&0===s.trim().length&&(s=void 0);const i="center"===t.align?"text-center":"right"===t.align?"text-right":"text-left",c="center"===t.align?"justify-center":"right"===t.align?"justify-end":"justify-start",d=t.noPadding?"p-0":"p-3",u="function"==typeof t.className?t.className(l,e):t.className||"",h="function"==typeof t.cellStyle?t.cellStyle(l,e):t.cellStyle||void 0,x="function"==typeof t.tooltip?t.tooltip(l,e):t.tooltip,y=N.jsxs("div",{title:x??("string"==typeof s?s:void 0),className:`border-r border-gray-200 dark:border-gray-700 last:border-r-0 ${d} text-sm flex items-center ${k?.(p,t.key)?"bg-blue-100/60 dark:bg-blue-900/30":""} ${n?w?.(p,t.key)||E?.(p,t.key)?"sticky z-10 bg-inherit":"sticky z-1 bg-inherit":""} ${w?.(p,t.key)||E?.(p,t.key)?"relative z-10 box-border group/cell":"relative box-border group/cell"} ${i} ${c} ${u}`,style:{width:`${t.width||100}px`,left:n?`${a}px`:"auto",...h},onClick:r=>((e,t,r,n)=>{v?.({row:t,column:r,value:n,event:e})})(r,e,t,e[t.key]),onContextMenu:r=>{e._isGroupHeader||e._isGroupFooter||j&&(r.preventDefault(),r.stopPropagation(),j({row:e,column:t,value:e[t.key],displayValue:s??"",event:r}))},onMouseDown:r=>S?.({row:e,column:t,event:r}),onMouseEnter:r=>R?.({row:e,column:t,event:r}),onDoubleClick:r=>((e,t,r)=>{L?.(t,r)})(0,e,t),children:[w?.(p,t.key)&&N.jsx("div",{className:"pointer-events-none absolute inset-0 border border-blue-400 z-10"}),E?.(p,t.key)?N.jsx(je,{column:t,row:e,initialValue:I,onCommit:A,onCancel:F}):N.jsx(N.Fragment,{children:!1===t.wrapCellContent?N.jsx(N.Fragment,{children:o}):N.jsx("div",{className:"truncate w-full",children:o})})]},`${t.key}-${r}`);return m>0&&r===T?N.jsxs(N.Fragment,{children:[N.jsx("div",{style:{width:m},className:"flex-none"}),y]}):y}),h>0&&N.jsx("div",{style:{width:h},className:"flex-none"})]},`${p}-${a}`)})})}),O&&N.jsx(ke,{row:O.row,position:{x:O.x,y:O.y},isVisible:!0,onClose:K,menuItems:M})]})},Ce=(e,t)=>{if(e.isEditing!==t.isEditing)return!1;if(e.onCommitEdit!==t.onCommitEdit)return!1;if(e.editingInitialValue!==t.editingInitialValue)return!1;if(e.rowHeight!==t.rowHeight)return!1;if(e.selectable!==t.selectable)return!1;if(e.virtualized!==t.virtualized)return!1;if(e.globalFilter!==t.globalFilter)return!1;if(e.virtualizedRange.startIndex!==t.virtualizedRange.startIndex)return!1;if(e.virtualizedRange.endIndex!==t.virtualizedRange.endIndex)return!1;if(e.virtualizedRange.offsetY!==t.virtualizedRange.offsetY)return!1;if(e.isCellSelected!==t.isCellSelected)return!1;if(e.isCellFocused!==t.isCellFocused)return!1;if(e.onCellMouseDown!==t.onCellMouseDown)return!1;if(e.onCellMouseEnter!==t.onCellMouseEnter)return!1;if(e.getRowId!==t.getRowId)return!1;if(e.selectedRows.size!==t.selectedRows.size)return!1;if(e.pinnedColumns?.size!==t.pinnedColumns?.size)return!1;if(e.rowStyle!==t.rowStyle)return!1;if(e.columns.map(e=>e.key).join("|")!==t.columns.map(e=>e.key).join("|"))return!1;if(e.data.length!==t.data.length)return!1;if(e.data===t.data)return!0;const r=(e,t,r)=>r?r(e):void 0!==e.id?e.id:t;for(let n=0;n<t.data.length;n++)if(r(e.data[n],n,e.getRowId)!==r(t.data[n],n,t.getRowId))return!1;return!0};Ne.displayName="GridRows";const Se=r(Ne,Ce),Re=({columns:e,groupedKeys:t,onRemove:r,onReorder:n,onDropColumnKey:l,onToggleExpandAll:o,isAnyExpanded:s=!1})=>{const[i,c]=a(null),[d,u]=a(null),[g,m]=a(!0),h=t=>e.find(e=>e.key===t)?.header||t,x=e=>t=>{c(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-group-key",e)},f=e=>t=>{t.preventDefault();const r=t.currentTarget.getBoundingClientRect(),n=t.clientX<r.left+r.width/2;u(e),m(n)};return N.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-gray-50 border-b border-gray-200 text-sm dark:bg-gray-800 dark:border-gray-700",onDrop:e=>{e.preventDefault();const r=e.dataTransfer.getData("text/plain");r&&(t.includes(r)||l(r))},onDragOver:e=>{e.preventDefault()},onDragEnd:()=>{c(null),u(null)},children:[N.jsx("span",{className:"text-gray-600 whitespace-nowrap dark:text-gray-400",children:"Group by:"}),t.length>0&&N.jsx("button",{type:"button",className:"ml-1 px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100 dark:border-gray-600 dark:hover:bg-gray-700",title:s?"Collapse all groups":"Expand all groups",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},children:s?"Collapse All":"Expand All"}),0===t.length&&N.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Drag a column here"}),N.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.map(e=>{return N.jsxs("div",{className:"inline-flex items-center gap-2 bg-blue-100 text-blue-800 px-2 py-1 rounded-md border border-blue-200 cursor-move relative dark:bg-blue-900/40 dark:text-blue-300 dark:border-blue-800",draggable:!0,onDragStart:x(e),onDragOver:f(e),onDrop:(a=e,()=>{if(!i||i===a)return c(null),void u(null);const e=t.filter(e=>e!==i),r=e.indexOf(a);-1!==r&&(e.splice(g?r:r+1,0,i),n(e),c(null),u(null))}),title:h(e),children:[N.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:h(e)}),N.jsx("button",{className:"text-blue-700 hover:text-blue-900 dark:text-blue-400",onClick:()=>r(e),"aria-label":`Remove grouping ${h(e)}`,children:"×"}),d===e&&N.jsx("span",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 dark:bg-blue-400 animate-pulse",style:{left:g?0:void 0,right:g?void 0:0},"aria-hidden":"true"})]},e);var a})})]})},Me=r(({row:e,isExpanded:t,onToggle:r,viewportWidth:n,selectable:a,rowHeight:l=40,getHeaderLabel:o,getValueLabel:s,renderGroupActions:i})=>{const c=()=>{e._groupKey&&r(e._groupKey)};return N.jsxs("div",{className:"flex items-center bg-blue-50 dark:bg-blue-900/20 border-b border-gray-200 dark:border-gray-800 hover:bg-blue-100/70 cursor-pointer sticky left-0 z-20 overflow-hidden",style:{minWidth:`${n+(a?C:0)}px`,height:`${l}px`},onClick:c,role:"button",tabIndex:0,"aria-expanded":t,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),c())},children:[a&&N.jsx("div",{className:"w-12 flex items-center justify-center"}),N.jsxs("div",{className:"flex items-center px-4 py-2 flex-1",children:[N.jsx("div",{className:"flex items-center mr-3",style:{paddingLeft:(e._groupLevel?16*e._groupLevel:0)+"px"},children:N.jsx(t?A:L,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:[e._groupColumnKey?`${o?o(e._groupColumnKey):e._groupColumnKey}: `:"",s&&e._groupColumnKey?s(e._groupColumnKey,e._groupValue):e._groupValue??(e._groupKey||"Unknown")]}),N.jsxs("span",{className:"text-sm text-gray-600 bg-gray-200/70 px-2 py-1 rounded-full dark:text-gray-400",children:[e._groupCount," ",1===e._groupCount?"item":"items"]})]}),i&&N.jsx("div",{className:"flex items-center px-4",onClick:e=>e.stopPropagation(),children:i({groupKey:e._groupKey||"",columnKey:e._groupColumnKey||"",groupValue:e._groupValue,rows:e._groupRows||[],count:e._groupCount||0,level:e._groupLevel||0})})]})]})}),De=({hasFilters:e=!1,hasData:t=!0,message:r,renderer:n})=>{if(n)return N.jsx(N.Fragment,{children:n()});const{title:a,description:l,icon:o}=r?{title:r,description:"",icon:ne}:t?e?{title:"No Results Found",description:"No data matches your current search criteria. Try adjusting your filters.",icon:re}:{title:"No Data to Display",description:"There are no items to show at the moment.",icon:ne}:{title:"No Data Available",description:"There is no data to display in this table.",icon:ne};return N.jsxs("div",{className:"flex flex-col items-center justify-center pt-16 pb-10 px-4 text-center",children:[N.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center mb-4",children:N.jsx(o,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),N.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:a}),N.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-md",children:l})]})},Ee=({paginationConfig:e,currentPage:t,isServerLoading:r,selectedRowsCount:n,totalDataLength:a,filteredDataLength:l,paginationMode:o="client",onPageChange:s,onPageSizeChange:i})=>{const{start:c,end:d,total:u}=(()=>{const r=e.enabled||"server"===o?e.totalRows||a:l||a;return{start:e.enabled?Math.min((t-1)*e.pageSize+1,r):1,end:e.enabled?Math.min(t*e.pageSize,r):r,total:r}})(),g="client"===o&&l&&l!==a;return N.jsx("div",{className:"px-3 sm:px-6 py-2 border-t border-gray-200 dark:border-gray-700 bg-linear-to-r from-white via-gray-50 to-white dark:from-gray-900 dark:via-gray-800 dark:to-gray-900",children:N.jsxs("div",{className:"flex flex-col xl:flex-row gap-4 xl:gap-6 xl:justify-between xl:items-center",children:[N.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4 items-start sm:items-center",children:[N.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[!e.enabled&&N.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold bg-linear-to-r from-blue-500 to-blue-600 text-white shadow-lg ring-2 ring-blue-500/20",children:[N.jsx(ne,{className:"w-3 h-3"}),N.jsxs("span",{className:"font-bold",children:[u.toLocaleString()," ",1===u?"Record":"Records"]}),g&&N.jsxs("span",{className:"text-blue-100 font-normal",children:["(of ",a.toLocaleString(),")"]})]}),n>0&&N.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold bg-blue-500 text-white ring-2 ring-blue-500/20",children:[N.jsx(oe,{className:"w-3 h-3"}),N.jsxs("span",{children:[n.toLocaleString()," selected"]})]}),g&&N.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-linear-to-r from-warning/10 to-warning/5 text-warning border border-white dark:from-warning/10 dark:to-warning/5 dark:text-warning dark:border-warning/20",children:[N.jsx(ee,{className:"w-3 h-3 dark:text-gray-300"}),N.jsx("span",{className:"dark:text-gray-300",children:"Filtered"})]}),e.enabled&&N.jsx("div",{className:"hidden sm:block text-sm text-gray-600 dark:text-gray-400 font-medium",children:N.jsxs("span",{className:"inline-flex items-center gap-1",children:[N.jsx("span",{children:"Showing"}),N.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:c.toLocaleString()}),N.jsx("span",{children:"-"}),N.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:d.toLocaleString()}),N.jsxs("span",{children:["of ",u.toLocaleString()]})]})})]}),e.enabled&&e.showPageSizeSelector&&N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 whitespace-nowrap",children:"Rows per page:"}),N.jsx("select",{value:e.pageSize,onChange:e=>i(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 rounded-xl px-3 py-1 text-sm font-medium focus:ring-2 focus:ring-primary focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed shadow-sm transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500",disabled:r,children:e.pageSizeOptions?.map(e=>N.jsx("option",{value:e,children:e},e))})]})]}),e.enabled&&N.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4",children:[r&&N.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-900/20 rounded-full border border-blue-200 dark:border-blue-800",children:[N.jsx(ie,{className:"w-4 h-4 animate-spin text-primary"}),N.jsx("span",{className:"text-sm font-medium text-primary",children:"Loading..."})]}),N.jsx("div",{className:"sm:hidden text-sm text-gray-600 dark:text-gray-400 font-medium",children:N.jsxs("div",{className:"flex flex-col gap-1",children:[N.jsxs("span",{className:"inline-flex items-center gap-1",children:[N.jsx("span",{children:"Page"}),N.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:t.toLocaleString()}),N.jsx("span",{children:"of"}),N.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:e.totalPages.toLocaleString()})]}),N.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-500",children:[c.toLocaleString()," - ",d.toLocaleString()," of"," ",u.toLocaleString()]})]})}),N.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[N.jsx("button",{onClick:()=>s(1,e.pageSize),disabled:1===t||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"First page","aria-label":"Go to first page",children:N.jsx(F,{className:"w-3.5 h-3.5"})}),N.jsx("button",{onClick:()=>s(t-1,e.pageSize),disabled:1===t||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"Previous page","aria-label":"Go to previous page",children:N.jsx(E,{className:"w-3.5 h-3.5"})}),N.jsx("div",{className:"sm:hidden",children:N.jsx("select",{value:t,onChange:t=>s(Number(t.target.value),e.pageSize),className:"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 rounded-xl px-3 py-2 text-sm font-medium focus:ring-2 focus:ring-primary focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed shadow-sm min-w-[80px]",disabled:r,"aria-label":"Select page",children:Array.from({length:e.totalPages},(e,t)=>t+1).map(e=>N.jsx("option",{value:e,children:e},e))})}),N.jsx("div",{className:"hidden sm:flex items-center gap-1 mx-2",children:(()=>{const n=[],a=e.totalPages,l=t,o="undefined"!=typeof window&&window.innerWidth>=768?7:5;if(a<=o)for(let e=1;e<=a;e++)n.push(e);else{const e=Math.floor(o/2)-1;if(l<=e+1){for(let e=1;e<=o-2;e++)n.push(e);n.push("ellipsis1"),n.push(a)}else if(l>=a-e){n.push(1),n.push("ellipsis1");for(let e=a-(o-3);e<=a;e++)n.push(e)}else{n.push(1),n.push("ellipsis1");for(let t=l-e;t<=l+e;t++)n.push(t);n.push("ellipsis2"),n.push(a)}}return n.map(t=>{if("string"==typeof t)return N.jsx("div",{className:"flex items-center justify-center w-8 h-8 text-gray-400 dark:text-gray-500 select-none","aria-hidden":"true",children:N.jsx("span",{className:"text-lg leading-none",children:"⋯"})},t);const n=t===l;return N.jsx("button",{onClick:()=>s(t,e.pageSize),disabled:r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full text-sm font-semibold transition-all duration-200 focus:ring-2 focus:ring-primary/20 focus:outline-none cursor-pointer "+(n?"bg-linear-to-r from-primary to-primary text-white shadow-lg ring-2 ring-primary/20 transform scale-105 z-10 relative bg-blue-500":"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md disabled:opacity-40 disabled:cursor-not-allowed"),"aria-label":`Go to page ${t}`,"aria-current":n?"page":void 0,children:t},t)})})()}),N.jsx("button",{onClick:()=>s(t+1,e.pageSize),disabled:t===e.totalPages||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"Next page","aria-label":"Go to next page",children:N.jsx(L,{className:"w-3.5 h-3.5"})}),N.jsx("button",{onClick:()=>s(e.totalPages,e.pageSize),disabled:t===e.totalPages||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"Last page","aria-label":"Go to last page",children:N.jsx(I,{className:"w-3.5 h-3.5"})})]})]})]})})};Ee.displayName="PaginationControls";const Le=r(Ee),Ae=({options:e,value:t,placeholder:r="Select an option...",onChange:n,searchable:s=!0,className:i=""})=>{const[c,d]=a(!1),[u,g]=a(""),[m,h]=a(-1),x=o(null),f=o(null),p=o(null),y=e.find(e=>e.value===t),b=s?e.filter(e=>e.label?.toLowerCase()?.includes(u?.toLowerCase())):e;l(()=>{const e=e=>{x.current&&!x.current.contains(e.target)&&(d(!1),g(""),h(-1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),l(()=>{const e=e=>{if(c)switch(e.key){case"ArrowDown":e.preventDefault(),h(e=>e<b.length-1?e+1:0);break;case"ArrowUp":e.preventDefault(),h(e=>e>0?e-1:b.length-1);break;case"Enter":e.preventDefault(),m>=0&&b[m]&&v(b[m].value);break;case"Escape":d(!1),g(""),h(-1)}};if(c)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[c,m,b]),l(()=>{if(m>=0&&p.current){const e=p.current.children[m];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}},[m]);const v=e=>{n(e),d(!1),g(""),h(-1)};return N.jsxs("div",{className:`relative ${i}`,ref:x,children:[N.jsx("div",{className:`relative w-full cursor-pointer border border-gray-300 rounded-lg bg-white transition-all duration-200 ${c?"ring-2 ring-blue-500 border-blue-500":"hover:border-gray-400 focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500"} dark:border-gray-600 dark:bg-gray-800`,onClick:()=>{d(!c),s&&!c&&setTimeout(()=>f.current?.focus(),0)},children:N.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5",children:[s&&c?N.jsx("input",{ref:f,type:"text",className:"flex-1 outline-none text-sm bg-transparent text-gray-900 dark:text-gray-100",placeholder:`Search ${r?.toLowerCase()}...`,value:u,onChange:e=>{g(e.target.value),h(-1),c||d(!0)},onClick:e=>e.stopPropagation()}):N.jsx("span",{className:"flex-1 text-sm truncate "+(y?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"),children:y?y.label:r}),N.jsx(A,{className:`w-4 h-4 text-gray-400 transition-transform duration-200 ${c?"rotate-180":""} dark:text-gray-400`})]})}),c&&N.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-99999 max-h-80 overflow-hidden dark:bg-gray-800 dark:border-gray-700",children:b.length>0?N.jsx("ul",{ref:p,className:"py-1 overflow-y-auto max-h-80",children:b.map((e,t)=>N.jsxs("li",{className:"px-3 py-2 text-sm cursor-pointer flex items-center justify-between transition-colors "+(t===m?"bg-blue-50 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),onClick:()=>v(e.value),onMouseEnter:()=>h(t),children:[N.jsx("span",{className:"truncate",children:e.label}),y?.value===e.value&&N.jsx(P,{className:"w-4 h-4 text-blue-600 shrink-0 ml-2 dark:text-blue-400"})]},e.value))}):N.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center dark:text-gray-400",children:"No options found"})})]})},Fe=({columns:e,columnFilters:t,onColumnFilter:r})=>{const n=e.filter(e=>e.filterable),[o,s]=a(n.length>0?n[0].key:""),[i,c]=a(""),d=n.map(e=>({label:e.header,value:e.key})),u=n.find(e=>e.key===o);return l(()=>{c("")},[o]),N.jsxs("div",{className:"space-y-4",children:[N.jsxs("div",{children:[N.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:"Select Column to Filter"}),N.jsx(Ae,{options:d,value:o,placeholder:"Choose a column...",onChange:e=>{s(e)},searchable:!0})]}),o&&(()=>{if(!u)return null;const e=u.filterable?.type||"text",n=t[o];if("multiselect"===e&&u.filterable?.options){const e=i.toLowerCase(),t=e?u.filterable.options.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)):u.filterable.options;return N.jsxs("div",{className:"mt-3",children:[N.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),N.jsxs("div",{className:"relative mb-2",children:[N.jsx(re,{className:"w-4 h-4 text-gray-400 absolute left-2 top-1/2 -translate-y-1/2 dark:text-gray-500"}),N.jsx("input",{type:"text",value:i,onChange:e=>c(e.target.value),placeholder:"Search options...",className:"w-full pl-8 pr-2 py-1.5 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"}),i&&N.jsx("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",title:"Clear search",children:N.jsx(O,{className:"w-3 h-3"})})]}),N.jsxs("div",{className:"max-h-32 overflow-y-auto border border-gray-300 rounded-md p-2 bg-white dark:border-gray-600 dark:bg-gray-800",children:[0===t.length&&N.jsx("div",{className:"text-xs text-gray-500 px-1 py-1 dark:text-gray-400",children:"No matches"}),t.map(e=>{const t=n?.value||[],a=Array.isArray(t)&&t.includes(e.value);return N.jsxs("label",{className:"flex items-center gap-2 py-1 hover:bg-gray-50 cursor-pointer dark:hover:bg-gray-700 rounded px-1",children:[N.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:text-blue-400",checked:a,onChange:t=>{const a=n?.value||[];let l;l=t.target.checked?[...a,e.value]:a.filter(t=>t!==e.value),r?.(o,l.length>0?{type:"multiselect",value:l,operator:"in"}:null)}}),N.jsx("span",{className:"text-sm dark:text-gray-300",children:e.label})]},e.value)})]})]})}if("select"===e&&u.filterable?.options){const e=[{label:`All ${u.header}`,value:""},...u.filterable.options.map(e=>({label:e.label,value:String(e.value)}))];return N.jsxs("div",{className:"mt-3",children:[N.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),N.jsx(Ae,{options:e,value:n?.value||"",placeholder:`Select ${u.header.toLowerCase()}...`,onChange:e=>{r?.(o,e?{type:"select",value:e,operator:"between"}:null)},searchable:!0})]})}if("date"===e){const e=e=>{if(!e)return null;if(e instanceof Date&&!isNaN(e.getTime()))return e;const t=he(String(e));if(!isNaN(t.getTime()))return t;const r=new Date(e);return isNaN(r.getTime())?null:r},t=e(n?.value),a=e(n?.secondValue),l=n?.operator||"between";return N.jsxs("div",{className:"mt-3",children:[N.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),N.jsx("div",{className:"mb-3",children:N.jsx(Ae,{options:[{label:"Between Dates",value:"between"},{label:"On Date",value:"equals"}],value:l,placeholder:"Select date filter...",onChange:e=>{r?.(o,{type:"date",value:n?.value||"",operator:e,secondValue:n?.secondValue||""})},searchable:!1},`date-operator-${o}-${l}`)}),N.jsxs("div",{className:"flex items-end gap-2",children:[N.jsx("div",{className:"flex-1 min-w-37.5",children:N.jsx(ge,{name:"column_filter_start",label:"between"===l?"Start Date":"Date",value:t?me(t):null,onChange:e=>{if(e){const t=me(he(e));r?.(o,{type:"date",value:t,operator:l,secondValue:n?.secondValue||null})}else r?.(o,null)},className:"w-full"})}),"between"===l&&N.jsx("div",{className:"flex-1 min-w-37.5",children:N.jsx(ge,{name:"column_filter_end",label:"End Date",value:a?me(a):null,onChange:e=>{if(e&&n){const t=me(he(e));r?.(o,{...n,secondValue:t})}},className:"w-full"})})]})]})}return N.jsxs("div",{className:"mt-3",children:[N.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),N.jsxs(N.Fragment,{children:[N.jsx("input",{type:"text",placeholder:u.filterable?.placeholder||`Filter ${u.header.toLowerCase()}...`,className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",value:n?.value||"",onChange:e=>{r?.(o,e.target.value?{type:"text",value:e.target.value,operator:"contains"}:null)}}),n&&N.jsx("div",{className:"mt-2",children:N.jsx(Ae,{options:[{label:"Contains",value:"contains"},{label:"Equals",value:"equals"},{label:"Starts with",value:"startsWith"},{label:"Ends with",value:"endsWith"}],value:n?.operator||"contains",placeholder:"Select operator...",onChange:e=>{n&&r?.(o,{...n,operator:e})},searchable:!1})})]})]})})(),Object.keys(t).length>0&&N.jsxs("div",{className:"mt-4",children:[N.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:"Active Filters"}),N.jsx("div",{className:"space-y-2",children:Object.entries(t).map(([e,t])=>{const a=n.find(t=>t.key===e);return a?N.jsxs("div",{className:"flex items-center justify-between bg-blue-50 border border-blue-200 rounded-md px-3 py-2 cursor-pointer hover:bg-blue-100 dark:bg-blue-900/20 dark:border-blue-800 dark:hover:bg-blue-900/40",role:"button",title:`Edit filter for ${a.header}`,onClick:()=>(e=>{s(e)})(e),children:[N.jsxs("div",{className:"flex-1",children:[N.jsxs("span",{className:"text-sm font-medium text-blue-900 dark:text-blue-100",children:[a.header,":"]}),N.jsx("span",{className:"text-sm text-blue-700 ml-1 dark:text-blue-300",children:(()=>{if(Array.isArray(t.value))return`${t.value.length} selected`;if("date"===t.type){const e=e=>{try{if(!e)return"";if(e instanceof Date&&!isNaN(e.getTime()))return xe(e);if("string"==typeof e){const t=he(e);if(!isNaN(t.getTime()))return xe(t);const r=new Date(e);if(!isNaN(r.getTime()))return xe(r)}return String(e)}catch{return String(e??"")}},r={equals:"On",gt:"After",gte:"On or After",lt:"Before",lte:"On or Before",between:"Between"}[t.operator]||"On";return"between"===t.operator&&t.secondValue?`${r} ${e(t.value)} - ${e(t.secondValue)}`:`${r} ${e(t.value)}`}return t.value})()})]}),N.jsx("button",{onClick:t=>{t.stopPropagation(),r?.(e,null)},className:"text-blue-400 hover:text-red-500 transition-colors",title:"Clear filter",children:N.jsx(O,{className:"w-4 h-4"})})]},e):null})})]})]})};function Ie(){return"undefined"!=typeof window}function ze(e){return Oe(e)?(e.nodeName||"").toLowerCase():"#document"}function $e(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Te(e){var t;return null==(t=(Oe(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Oe(e){return!!Ie()&&(e instanceof Node||e instanceof $e(e).Node)}function Pe(e){return!!Ie()&&(e instanceof Element||e instanceof $e(e).Element)}function _e(e){return!!Ie()&&(e instanceof HTMLElement||e instanceof $e(e).HTMLElement)}function Ke(e){return!(!Ie()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof $e(e).ShadowRoot)}const Ve=new Set(["inline","contents"]);function Be(e){const{overflow:t,overflowX:r,overflowY:n,display:a}=tt(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!Ve.has(a)}const We=new Set(["table","td","th"]);function He(e){return We.has(ze(e))}const Ge=[":popover-open",":modal"];function Ue(e){return Ge.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const Ye=["transform","translate","scale","rotate","perspective"],qe=["transform","translate","scale","rotate","perspective","filter"],Xe=["paint","layout","strict","content"];function Je(e){const t=Ze(),r=Pe(e)?tt(e):e;return Ye.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||qe.some(e=>(r.willChange||"").includes(e))||Xe.some(e=>(r.contain||"").includes(e))}function Ze(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Qe=new Set(["html","body","#document"]);function et(e){return Qe.has(ze(e))}function tt(e){return $e(e).getComputedStyle(e)}function rt(e){return Pe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nt(e){if("html"===ze(e))return e;const t=e.assignedSlot||e.parentNode||Ke(e)&&e.host||Te(e);return Ke(t)?t.host:t}function at(e){const t=nt(e);return et(t)?e.ownerDocument?e.ownerDocument.body:e.body:_e(t)&&Be(t)?t:at(t)}function lt(e,t,r){var n;void 0===t&&(t=[]),void 0===r&&(r=!0);const a=at(e),l=a===(null==(n=e.ownerDocument)?void 0:n.body),o=$e(a);if(l){const e=ot(o);return t.concat(o,o.visualViewport||[],Be(a)?a:[],e&&r?lt(e):[])}return t.concat(a,lt(a,[],r))}function ot(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const st=Math.min,it=Math.max,ct=Math.round,dt=Math.floor,ut=e=>({x:e,y:e}),gt={left:"right",right:"left",bottom:"top",top:"bottom"},mt={start:"end",end:"start"};function ht(e,t,r){return it(e,st(t,r))}function xt(e,t){return"function"==typeof e?e(t):e}function ft(e){return e.split("-")[0]}function pt(e){return e.split("-")[1]}function yt(e){return"x"===e?"y":"x"}function bt(e){return"y"===e?"height":"width"}const vt=new Set(["top","bottom"]);function wt(e){return vt.has(ft(e))?"y":"x"}function kt(e){return yt(wt(e))}function jt(e){return e.replace(/start|end/g,e=>mt[e])}const Nt=["left","right"],Ct=["right","left"],St=["top","bottom"],Rt=["bottom","top"];function Mt(e){return e.replace(/left|right|bottom|top/g,e=>gt[e])}function Dt(e){const{x:t,y:r,width:n,height:a}=e;return{width:n,height:a,top:r,left:t,right:t+n,bottom:r+a,x:t,y:r}}var Et="undefined"!=typeof document?i:function(){};const Lt={...e}.useInsertionEffect||(e=>e());function At(e,t,r){let{reference:n,floating:a}=e;const l=wt(t),o=kt(t),s=bt(o),i=ft(t),c="y"===l,d=n.x+n.width/2-a.width/2,u=n.y+n.height/2-a.height/2,g=n[s]/2-a[s]/2;let m;switch(i){case"top":m={x:d,y:n.y-a.height};break;case"bottom":m={x:d,y:n.y+n.height};break;case"right":m={x:n.x+n.width,y:u};break;case"left":m={x:n.x-a.width,y:u};break;default:m={x:n.x,y:n.y}}switch(pt(t)){case"start":m[o]-=g*(r&&c?-1:1);break;case"end":m[o]+=g*(r&&c?-1:1)}return m}async function Ft(e,t){var r;void 0===t&&(t={});const{x:n,y:a,platform:l,rects:o,elements:s,strategy:i}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:g=!1,padding:m=0}=xt(t,e),h=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(m),x=s[g?"floating"===u?"reference":"floating":u],f=Dt(await l.getClippingRect({element:null==(r=await(null==l.isElement?void 0:l.isElement(x)))||r?x:x.contextElement||await(null==l.getDocumentElement?void 0:l.getDocumentElement(s.floating)),boundary:c,rootBoundary:d,strategy:i})),p="floating"===u?{x:n,y:a,width:o.floating.width,height:o.floating.height}:o.reference,y=await(null==l.getOffsetParent?void 0:l.getOffsetParent(s.floating)),b=await(null==l.isElement?void 0:l.isElement(y))&&await(null==l.getScale?void 0:l.getScale(y))||{x:1,y:1},v=Dt(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:p,offsetParent:y,strategy:i}):p);return{top:(f.top-v.top+h.top)/b.y,bottom:(v.bottom-f.bottom+h.bottom)/b.y,left:(f.left-v.left+h.left)/b.x,right:(v.right-f.right+h.right)/b.x}}const It=new Set(["left","top"]);function zt(e){const t=tt(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const a=_e(e),l=a?e.offsetWidth:r,o=a?e.offsetHeight:n,s=ct(r)!==l||ct(n)!==o;return s&&(r=l,n=o),{width:r,height:n,$:s}}function $t(e){return Pe(e)?e:e.contextElement}function Tt(e){const t=$t(e);if(!_e(t))return ut(1);const r=t.getBoundingClientRect(),{width:n,height:a,$:l}=zt(t);let o=(l?ct(r.width):r.width)/n,s=(l?ct(r.height):r.height)/a;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}const Ot=ut(0);function Pt(e){const t=$e(e);return Ze()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Ot}function _t(e,t,r,n){void 0===t&&(t=!1),void 0===r&&(r=!1);const a=e.getBoundingClientRect(),l=$t(e);let o=ut(1);t&&(n?Pe(n)&&(o=Tt(n)):o=Tt(e));const s=function(e,t,r){return void 0===t&&(t=!1),!(!r||t&&r!==$e(e))&&t}(l,r,n)?Pt(l):ut(0);let i=(a.left+s.x)/o.x,c=(a.top+s.y)/o.y,d=a.width/o.x,u=a.height/o.y;if(l){const e=$e(l),t=n&&Pe(n)?$e(n):n;let r=e,a=ot(r);for(;a&&n&&t!==r;){const e=Tt(a),t=a.getBoundingClientRect(),n=tt(a),l=t.left+(a.clientLeft+parseFloat(n.paddingLeft))*e.x,o=t.top+(a.clientTop+parseFloat(n.paddingTop))*e.y;i*=e.x,c*=e.y,d*=e.x,u*=e.y,i+=l,c+=o,r=$e(a),a=ot(r)}}return Dt({width:d,height:u,x:i,y:c})}function Kt(e,t){const r=rt(e).scrollLeft;return t?t.left+r:_t(Te(e)).left+r}function Vt(e,t){const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-Kt(e,r),y:r.top+t.scrollTop}}const Bt=new Set(["absolute","fixed"]);function Wt(e,t,r){let n;if("viewport"===t)n=function(e,t){const r=$e(e),n=Te(e),a=r.visualViewport;let l=n.clientWidth,o=n.clientHeight,s=0,i=0;if(a){l=a.width,o=a.height;const e=Ze();(!e||e&&"fixed"===t)&&(s=a.offsetLeft,i=a.offsetTop)}const c=Kt(n);if(c<=0){const e=n.ownerDocument,t=e.body,r=getComputedStyle(t),a="CSS1Compat"===e.compatMode&&parseFloat(r.marginLeft)+parseFloat(r.marginRight)||0,o=Math.abs(n.clientWidth-t.clientWidth-a);o<=25&&(l-=o)}else c<=25&&(l+=c);return{width:l,height:o,x:s,y:i}}(e,r);else if("document"===t)n=function(e){const t=Te(e),r=rt(e),n=e.ownerDocument.body,a=it(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),l=it(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let o=-r.scrollLeft+Kt(e);const s=-r.scrollTop;return"rtl"===tt(n).direction&&(o+=it(t.clientWidth,n.clientWidth)-a),{width:a,height:l,x:o,y:s}}(Te(e));else if(Pe(t))n=function(e,t){const r=_t(e,!0,"fixed"===t),n=r.top+e.clientTop,a=r.left+e.clientLeft,l=_e(e)?Tt(e):ut(1);return{width:e.clientWidth*l.x,height:e.clientHeight*l.y,x:a*l.x,y:n*l.y}}(t,r);else{const r=Pt(e);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Dt(n)}function Ht(e,t){const r=nt(e);return!(r===t||!Pe(r)||et(r))&&("fixed"===tt(r).position||Ht(r,t))}function Gt(e,t,r){const n=_e(t),a=Te(t),l="fixed"===r,o=_t(e,!0,l,t);let s={scrollLeft:0,scrollTop:0};const i=ut(0);function c(){i.x=Kt(a)}if(n||!n&&!l)if(("body"!==ze(t)||Be(a))&&(s=rt(t)),n){const e=_t(t,!0,l,t);i.x=e.x+t.clientLeft,i.y=e.y+t.clientTop}else a&&c();l&&!n&&a&&c();const d=!a||n||l?ut(0):Vt(a,s);return{x:o.left+s.scrollLeft-i.x-d.x,y:o.top+s.scrollTop-i.y-d.y,width:o.width,height:o.height}}function Ut(e){return"static"===tt(e).position}function Yt(e,t){if(!_e(e)||"fixed"===tt(e).position)return null;if(t)return t(e);let r=e.offsetParent;return Te(e)===r&&(r=r.ownerDocument.body),r}function qt(e,t){const r=$e(e);if(Ue(e))return r;if(!_e(e)){let t=nt(e);for(;t&&!et(t);){if(Pe(t)&&!Ut(t))return t;t=nt(t)}return r}let n=Yt(e,t);for(;n&&He(n)&&Ut(n);)n=Yt(n,t);return n&&et(n)&&Ut(n)&&!Je(n)?r:n||function(e){let t=nt(e);for(;_e(t)&&!et(t);){if(Je(t))return t;if(Ue(t))return null;t=nt(t)}return null}(e)||r}const Xt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:r,offsetParent:n,strategy:a}=e;const l="fixed"===a,o=Te(n),s=!!t&&Ue(t.floating);if(n===o||s&&l)return r;let i={scrollLeft:0,scrollTop:0},c=ut(1);const d=ut(0),u=_e(n);if((u||!u&&!l)&&(("body"!==ze(n)||Be(o))&&(i=rt(n)),_e(n))){const e=_t(n);c=Tt(n),d.x=e.x+n.clientLeft,d.y=e.y+n.clientTop}const g=!o||u||l?ut(0):Vt(o,i);return{width:r.width*c.x,height:r.height*c.y,x:r.x*c.x-i.scrollLeft*c.x+d.x+g.x,y:r.y*c.y-i.scrollTop*c.y+d.y+g.y}},getDocumentElement:Te,getClippingRect:function(e){let{element:t,boundary:r,rootBoundary:n,strategy:a}=e;const l=[..."clippingAncestors"===r?Ue(t)?[]:function(e,t){const r=t.get(e);if(r)return r;let n=lt(e,[],!1).filter(e=>Pe(e)&&"body"!==ze(e)),a=null;const l="fixed"===tt(e).position;let o=l?nt(e):e;for(;Pe(o)&&!et(o);){const t=tt(o),r=Je(o);r||"fixed"!==t.position||(a=null),(l?!r&&!a:!r&&"static"===t.position&&a&&Bt.has(a.position)||Be(o)&&!r&&Ht(e,o))?n=n.filter(e=>e!==o):a=t,o=nt(o)}return t.set(e,n),n}(t,this._c):[].concat(r),n],o=l.reduce((e,r)=>{const n=Wt(t,r,a);return e.top=it(n.top,e.top),e.right=st(n.right,e.right),e.bottom=st(n.bottom,e.bottom),e.left=it(n.left,e.left),e},Wt(t,l[0],a));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:qt,getElementRects:async function(e){const t=this.getOffsetParent||qt,r=this.getDimensions,n=await r(e.floating);return{reference:Gt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:r}=zt(e);return{width:t,height:r}},getScale:Tt,isElement:Pe,isRTL:function(e){return"rtl"===tt(e).direction}};function Jt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zt(e,t,r,n){void 0===n&&(n={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:i=!1}=n,c=$t(e),d=a||l?[...c?lt(c):[],...lt(t)]:[];d.forEach(e=>{a&&e.addEventListener("scroll",r,{passive:!0}),l&&e.addEventListener("resize",r)});const u=c&&s?function(e,t){let r,n=null;const a=Te(e);function l(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return function o(s,i){void 0===s&&(s=!1),void 0===i&&(i=1),l();const c=e.getBoundingClientRect(),{left:d,top:u,width:g,height:m}=c;if(s||t(),!g||!m)return;const h={rootMargin:-dt(u)+"px "+-dt(a.clientWidth-(d+g))+"px "+-dt(a.clientHeight-(u+m))+"px "+-dt(d)+"px",threshold:it(0,st(1,i))||1};let x=!0;function f(t){const n=t[0].intersectionRatio;if(n!==i){if(!x)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==n||Jt(c,e.getBoundingClientRect())||o(),x=!1}try{n=new IntersectionObserver(f,{...h,root:a.ownerDocument})}catch(e){n=new IntersectionObserver(f,h)}n.observe(e)}(!0),l}(c,r):null;let g,m=-1,h=null;o&&(h=new ResizeObserver(e=>{let[n]=e;n&&n.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var e;null==(e=h)||e.observe(t)})),r()}),c&&!i&&h.observe(c),h.observe(t));let x=i?_t(e):null;return i&&function t(){const n=_t(e);x&&!Jt(x,n)&&r(),x=n,g=requestAnimationFrame(t)}(),r(),()=>{var e;d.forEach(e=>{a&&e.removeEventListener("scroll",r),l&&e.removeEventListener("resize",r)}),null==u||u(),null==(e=h)||e.disconnect(),h=null,i&&cancelAnimationFrame(g)}}const Qt=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:a,y:l,placement:o,middlewareData:s}=t,i=await async function(e,t){const{placement:r,platform:n,elements:a}=e,l=await(null==n.isRTL?void 0:n.isRTL(a.floating)),o=ft(r),s=pt(r),i="y"===wt(r),c=It.has(o)?-1:1,d=l&&i?-1:1,u=xt(t,e);let{mainAxis:g,crossAxis:m,alignmentAxis:h}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&"number"==typeof h&&(m="end"===s?-1*h:h),i?{x:m*d,y:g*c}:{x:g*c,y:m*d}}(t,e);return o===(null==(r=s.offset)?void 0:r.placement)&&null!=(n=s.arrow)&&n.alignmentOffset?{}:{x:a+i.x,y:l+i.y,data:{...i,placement:o}}}}},er=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:a,platform:l}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:i={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...c}=xt(e,t),d={x:r,y:n},u=await l.detectOverflow(t,c),g=wt(ft(a)),m=yt(g);let h=d[m],x=d[g];o&&(h=ht(h+u["y"===m?"top":"left"],h,h-u["y"===m?"bottom":"right"])),s&&(x=ht(x+u["y"===g?"top":"left"],x,x-u["y"===g?"bottom":"right"]));const f=i.fn({...t,[m]:h,[g]:x});return{...f,data:{x:f.x-r,y:f.y-n,enabled:{[m]:o,[g]:s}}}}}},tr=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:a,middlewareData:l,rects:o,initialPlacement:s,platform:i,elements:c}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:g,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:x=!0,...f}=xt(e,t);if(null!=(r=l.arrow)&&r.alignmentOffset)return{};const p=ft(a),y=wt(s),b=ft(s)===s,v=await(null==i.isRTL?void 0:i.isRTL(c.floating)),w=g||(b||!x?[Mt(s)]:function(e){const t=Mt(e);return[jt(e),t,jt(t)]}(s)),k="none"!==h;!g&&k&&w.push(...function(e,t,r,n){const a=pt(e);let l=function(e,t,r){switch(e){case"top":case"bottom":return r?t?Ct:Nt:t?Nt:Ct;case"left":case"right":return t?St:Rt;default:return[]}}(ft(e),"start"===r,n);return a&&(l=l.map(e=>e+"-"+a),t&&(l=l.concat(l.map(jt)))),l}(s,x,h,v));const j=[s,...w],N=await i.detectOverflow(t,f),C=[];let S=(null==(n=l.flip)?void 0:n.overflows)||[];if(d&&C.push(N[p]),u){const e=function(e,t,r){void 0===r&&(r=!1);const n=pt(e),a=kt(e),l=bt(a);let o="x"===a?n===(r?"end":"start")?"right":"left":"start"===n?"bottom":"top";return t.reference[l]>t.floating[l]&&(o=Mt(o)),[o,Mt(o)]}(a,o,v);C.push(N[e[0]],N[e[1]])}if(S=[...S,{placement:a,overflows:C}],!C.every(e=>e<=0)){var R,M;const e=((null==(R=l.flip)?void 0:R.index)||0)+1,t=j[e];if(t&&("alignment"!==u||y===wt(t)||S.every(e=>wt(e.placement)!==y||e.overflows[0]>0)))return{data:{index:e,overflows:S},reset:{placement:t}};let r=null==(M=S.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:M.placement;if(!r)switch(m){case"bestFit":{var D;const e=null==(D=S.filter(e=>{if(k){const t=wt(e.placement);return t===y||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:D[0];e&&(r=e);break}case"initialPlacement":r=s}if(a!==r)return{reset:{placement:r}}}return{}}}},rr=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:a,rects:l,platform:o,elements:s}=t,{apply:i=()=>{},...c}=xt(e,t),d=await o.detectOverflow(t,c),u=ft(a),g=pt(a),m="y"===wt(a),{width:h,height:x}=l.floating;let f,p;"top"===u||"bottom"===u?(f=u,p=g===(await(null==o.isRTL?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(p=u,f="end"===g?"top":"bottom");const y=x-d.top-d.bottom,b=h-d.left-d.right;let v=st(x-d[f],y),w=st(h-d[p],b);if(null!=(r=t.middlewareData.shift)&&r.enabled.x&&(w=b),null!=(n=t.middlewareData.shift)&&n.enabled.y&&(v=y),!t.middlewareData.shift&&!g){const e=it(d.left,0),t=it(d.right,0),r=it(d.top,0),n=it(d.bottom,0);m?w=h-2*(0!==e||0!==t?e+t:it(d.left,d.right)):v=x-2*(0!==r||0!==n?r+n:it(d.top,d.bottom))}await i({...t,availableWidth:w,availableHeight:v});const k=await o.getDimensions(s.floating);return h!==k.width||x!==k.height?{reset:{rects:!0}}:{}}}},nr=(e,t,r)=>{const n=new Map,a={platform:Xt,...r},l={...a.platform,_c:n};return(async(e,t,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:l=[],platform:o}=r,s=l.filter(Boolean),i=await(null==o.isRTL?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:u}=At(c,n,i),g=n,m={},h=0;for(let r=0;r<s.length;r++){var x;const{name:l,fn:f}=s[r],{x:p,y:y,data:b,reset:v}=await f({x:d,y:u,initialPlacement:n,placement:g,strategy:a,middlewareData:m,rects:c,platform:{...o,detectOverflow:null!=(x=o.detectOverflow)?x:Ft},elements:{reference:e,floating:t}});d=null!=p?p:d,u=null!=y?y:u,m={...m,[l]:{...m[l],...b}},v&&h<=50&&(h++,"object"==typeof v&&(v.placement&&(g=v.placement),v.rects&&(c=!0===v.rects?await o.getElementRects({reference:e,floating:t,strategy:a}):v.rects),({x:d,y:u}=At(c,g,i))),r=-1)}return{x:d,y:u,placement:g,strategy:a,middlewareData:m}})(e,t,{...a,platform:l})};var ar="undefined"!=typeof document?i:function(){};function lr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let r,n,a;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;0!==n--;)if(!lr(e[n],t[n]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(t).length)return!1;for(n=r;0!==n--;)if(!{}.hasOwnProperty.call(t,a[n]))return!1;for(n=r;0!==n--;){const r=a[n];if(!("_owner"===r&&e.$$typeof||lr(e[r],t[r])))return!1}return!0}return e!=e&&t!=t}function or(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function sr(e,t){const r=or(e);return Math.round(t*r)/r}function ir(t){const r=e.useRef(t);return ar(()=>{r.current=t}),r}const cr=(e,t)=>({...Qt(e),options:[e,t]}),dr=(e,t)=>({...er(e),options:[e,t]}),ur=(e,t)=>({...rr(e),options:[e,t]}),gr={...e};let mr=!1,hr=0;const xr=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+hr++,fr=gr.useId||function(){const[t,r]=e.useState(()=>mr?xr():void 0);return Et(()=>{null==t&&r(xr())},[]),e.useEffect(()=>{mr=!0},[]),t};let pr;"production"!==process.env.NODE_ENV&&(pr=new Set);const yr=e.createContext(null),br=e.createContext(null);function vr(t){void 0===t&&(t={});const{nodeId:r}=t,n=function(t){const{open:r=!1,onOpenChange:n,elements:a}=t,l=fr(),o=e.useRef({}),[s]=e.useState(()=>function(){const e=new Map;return{emit(t,r){var n;null==(n=e.get(t))||n.forEach(e=>e(r))},on(t,r){e.has(t)||e.set(t,new Set),e.get(t).add(r)},off(t,r){var n;null==(n=e.get(t))||n.delete(r)}}}()),i=null!=((null==(c=e.useContext(yr))?void 0:c.id)||null);var c;if("production"!==process.env.NODE_ENV){const e=a.reference;e&&!Pe(e)&&function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];const a="Floating UI: "+r.join(" ");var l;null!=(e=pr)&&e.has(a)||(null==(l=pr)||l.add(a),console.error(a))}("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[d,u]=e.useState(a.reference),g=function(t){const r=e.useRef(()=>{if("production"!==process.env.NODE_ENV)throw new Error("Cannot call an event handler while rendering.")});return Lt(()=>{r.current=t}),e.useCallback(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return null==r.current?void 0:r.current(...t)},[])}((e,t,r)=>{o.current.openEvent=e?t:void 0,s.emit("openchange",{open:e,event:t,reason:r,nested:i}),null==n||n(e,t,r)}),m=e.useMemo(()=>({setPositionReference:u}),[]),h=e.useMemo(()=>({reference:d||a.reference||null,floating:a.floating||null,domReference:a.reference}),[d,a.reference,a.floating]);return e.useMemo(()=>({dataRef:o,open:r,onOpenChange:g,elements:h,events:s,floatingId:l,refs:m}),[r,g,h,s,l,m])}({...t,elements:{reference:null,floating:null,...t.elements}}),a=t.rootContext||n,l=a.elements,[o,s]=e.useState(null),[i,c]=e.useState(null),d=(null==l?void 0:l.domReference)||o,u=e.useRef(null),g=e.useContext(br);Et(()=>{d&&(u.current=d)},[d]);const h=function(t){void 0===t&&(t={});const{placement:r="bottom",strategy:n="absolute",middleware:a=[],platform:l,elements:{reference:o,floating:s}={},transform:i=!0,whileElementsMounted:c,open:d}=t,[u,g]=e.useState({x:0,y:0,strategy:n,placement:r,middlewareData:{},isPositioned:!1}),[h,x]=e.useState(a);lr(h,a)||x(a);const[f,p]=e.useState(null),[y,b]=e.useState(null),v=e.useCallback(e=>{e!==N.current&&(N.current=e,p(e))},[]),w=e.useCallback(e=>{e!==C.current&&(C.current=e,b(e))},[]),k=o||f,j=s||y,N=e.useRef(null),C=e.useRef(null),S=e.useRef(u),R=null!=c,M=ir(c),D=ir(l),E=ir(d),L=e.useCallback(()=>{if(!N.current||!C.current)return;const e={placement:r,strategy:n,middleware:h};D.current&&(e.platform=D.current),nr(N.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==E.current};A.current&&!lr(S.current,t)&&(S.current=t,m.flushSync(()=>{g(t)}))})},[h,r,n,D,E]);ar(()=>{!1===d&&S.current.isPositioned&&(S.current.isPositioned=!1,g(e=>({...e,isPositioned:!1})))},[d]);const A=e.useRef(!1);ar(()=>(A.current=!0,()=>{A.current=!1}),[]),ar(()=>{if(k&&(N.current=k),j&&(C.current=j),k&&j){if(M.current)return M.current(k,j,L);L()}},[k,j,L,M,R]);const F=e.useMemo(()=>({reference:N,floating:C,setReference:v,setFloating:w}),[v,w]),I=e.useMemo(()=>({reference:k,floating:j}),[k,j]),z=e.useMemo(()=>{const e={position:n,left:0,top:0};if(!I.floating)return e;const t=sr(I.floating,u.x),r=sr(I.floating,u.y);return i?{...e,transform:"translate("+t+"px, "+r+"px)",...or(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,i,I.floating,u.x,u.y]);return e.useMemo(()=>({...u,update:L,refs:F,elements:I,floatingStyles:z}),[u,L,F,I,z])}({...t,elements:{...l,...i&&{reference:i}}}),x=e.useCallback(e=>{const t=Pe(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;c(t),h.refs.setReference(t)},[h.refs]),f=e.useCallback(e=>{(Pe(e)||null===e)&&(u.current=e,s(e)),(Pe(h.refs.reference.current)||null===h.refs.reference.current||null!==e&&!Pe(e))&&h.refs.setReference(e)},[h.refs]),p=e.useMemo(()=>({...h.refs,setReference:f,setPositionReference:x,domReference:u}),[h.refs,f,x]),y=e.useMemo(()=>({...h.elements,domReference:d}),[h.elements,d]),b=e.useMemo(()=>({...h,...a,refs:p,elements:y,nodeId:r}),[h,p,y,r,a]);return Et(()=>{a.dataRef.current.floatingContext=b;const e=null==g?void 0:g.nodesRef.current.find(e=>e.id===r);e&&(e.context=b)}),e.useMemo(()=>({...h,context:b,refs:p,elements:y}),[h,p,y,b])}var wr=({open:e,anchorEl:t,onClose:r,placement:n="bottom-start",offset:a=8,sameWidth:o=!1,maxHeight:s,zIndex:i=1e3,className:c,children:d,shouldIgnoreClose:u})=>{const{refs:g,floatingStyles:m,update:x}=vr({placement:n,whileElementsMounted:Zt,middleware:[cr(a),(f={padding:8},{...tr(f),options:[f,void 0]}),dr({padding:8}),ur({apply({rects:e,elements:t,availableHeight:r,availableWidth:n}){const a=t.floating;a&&(o&&(a.style.width=`${e.reference.width}px`),a.style.maxHeight=null!=s?"number"==typeof s?`${s}px`:String(s):`${r}px`,null!=n&&(a.style.maxWidth=`${n}px`))}})]});var f;return l(()=>{t&&g.setReference(t),e&&x&&x()},[t,e,g,x]),l(()=>{if(!e)return;const n=e=>{const n=e.target;if(u&&u(n))return;const a=g.floating.current;a&&(t&&t.contains(n)||a&&a.contains(n)||r())},a=e=>{"Escape"===e.key&&r()};return document.addEventListener("mousedown",n),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",a)}},[e,r,g.floating,t]),e&&t?h(N.jsx("div",{ref:g.setFloating,"data-popover-root":"true",style:{...m,zIndex:i,position:m.position,overflowX:"hidden"},className:c,children:d}),document.body):null};const kr=({globalFilter:e,filteredDataLength:t,totalDataLength:r,selectedRowsCount:s=0,selectedRows:i=new Set,showExport:c=!0,showColumnToggle:d=!0,showBulkActions:u=!0,columns:g=[],columnVisibility:m={},columnFilters:h={},bulkActions:x=[],exportOptions:f,onGlobalFilterChange:p,onClearFilters:y,onColumnVisibilityChange:b,onColumnFilter:v,onResetColumns:w,columnOrder:k=[],onColumnOrderChange:j,pinnedColumns:C,onScrollToColumn:S,density:R="md",onDensityChange:M,showDensityControl:D=!1,customLeftContent:E,customRightContent:L})=>{const[A,F]=a(!1),[I,z]=a(!1),[$,T]=a(!1),[P,H]=a(!1),[U,q]=a(""),[X,J]=a(null),[Z,oe]=a(null),ie=o(null),ce=o(null),de=o(null),ue=o(null),ge=o(null),me=o(null),he=o(null),xe=o(null),fe=o(null);l(()=>{const e=e=>{(e=>{let t=e;for(;t;){if(t.getAttribute&&"true"===t.getAttribute("data-popover-root")||t.dataset&&"true"===t.dataset.popoverRoot)return!0;t=t.parentNode}return!1})(e.target)||(ce.current&&!ce.current.contains(e.target)&&F(!1),de.current&&!de.current.contains(e.target)&&T(!1),ue.current&&!ue.current.contains(e.target)&&H(!1),!ge.current||ge.current.contains(e.target)||(e=>{let t=e;for(;t;){if(t.classList){const e=Array.from(t.classList).join(" ");if(/MuiPickers|MuiDatePicker|MuiPickersPopper/.test(e))return!0}if(t.getAttribute&&"dialog"===t.getAttribute("role")){const e=t.className?.toString()||"";if(/MuiPickers|MuiDatePicker/.test(e))return!0}t=t.parentNode}return!1})(e.target)||z(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const pe=f?.formats||["xlsx"],ye=(e?.length??0)>0||Object.keys(h||{}).length>0,be=s>0,ve=g.filter(e=>!1!==m[e.key]).length,we=[...k.map(e=>g.find(t=>t.key===e)).filter(Boolean),...g.filter(e=>!k.includes(e.key))].filter(e=>e.header?.toLowerCase()?.includes(U?.toLowerCase())),ke=e=>{switch(e){case"csv":return N.jsx(le,{size:18});case"json":return N.jsx(ne,{size:18});case"xlsx":return N.jsx(ae,{size:18});default:return N.jsx(W,{size:18})}},je=e=>{switch(e){case"delete":return N.jsx(V,{size:18});case"archive":return N.jsx(B,{size:18});case"copy":return N.jsx(_,{size:18});case"edit":return N.jsx(K,{size:18});case"export":return N.jsx(W,{size:18});default:return N.jsx(Q,{size:18})}},Ne=e=>{switch(e){case"csv":return"CSV";case"json":return"JSON";case"xlsx":return"Excel";default:return e}},Ce=(e,t=!1)=>{f?.onExport?.(e,t),F(!1)},Se=()=>{J(null),oe(null)},Re=n(()=>g.some(e=>e.filterable),[g]);return N.jsxs("div",{className:"bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",role:"toolbar","aria-label":"Data grid toolbar",children:[N.jsxs("div",{id:"search-results-status",className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true",children:[ye?`Showing ${t} of ${r} rows`:`${t} total rows`,be&&`, ${s} row${1!==s?"s":""} selected`]}),N.jsx("div",{className:"px-3 py-2",children:N.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-4",children:[N.jsxs("div",{className:"order-1 flex items-center flex-wrap gap-2 sm:gap-3",children:[N.jsxs("div",{className:"relative",ref:ge,children:[Re&&N.jsxs("button",{ref:e=>{me.current=e},onClick:()=>z(!I),className:"flex cursor-pointer items-center gap-2 px-3 py-1.5 border rounded-lg transition-colors "+(I?"bg-blue-50 dark:bg-blue-900/40 border-blue-200 dark:border-blue-600 text-blue-700 dark:text-blue-300":"border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800"),title:"Toggle column filters (Ctrl+K)","aria-label":"Toggle column filters","aria-haspopup":"menu","aria-expanded":I,"aria-controls":"filters-menu","aria-keyshortcuts":"Control+K",children:[N.jsx(G,{className:"w-4 h-4"}),N.jsx("span",{className:"hidden sm:inline text-sm",children:"Filters"}),Object.keys(h).length>0&&N.jsxs("button",{type:"button",onClick:e=>{e.stopPropagation(),y?.()},className:"bg-red-500 cursor-pointer hover:bg-red-600 text-white text-xs px-1.5 py-0.5 rounded-full min-w-5 h-5 flex items-center justify-center transition-all group relative",title:"Clear all filters",children:[N.jsx("span",{className:"group-hover:hidden",children:Object.keys(h).length}),N.jsx(O,{className:"w-3 h-3 hidden group-hover:block absolute"})]})]}),N.jsxs(wr,{open:I,anchorEl:me.current,onClose:()=>z(!1),placement:"bottom-start",offset:8,zIndex:1e3,maxHeight:520,className:"w-88 sm:w-88 max-w-[90vw] bg-white border border-gray-200 rounded-lg shadow-xl overflow-y-auto min-h-100 dark:bg-gray-800 dark:border-gray-700",shouldIgnoreClose:e=>{let t=e;for(;t;){if(t.classList){const e=Array.from(t.classList).join(" ");if(/MuiPickers|MuiDatePicker|MuiPickersPopper/.test(e))return!0}if(t.getAttribute&&"dialog"===t.getAttribute("role")){const e=t.className?.toString()||"";if(/MuiPickers|MuiDatePicker/.test(e))return!0}t=t.parentNode}return!1},children:[N.jsxs("div",{className:"flex items-center justify-between px-2",children:[N.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[N.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Column Filters"}),N.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:"Filter data by column values"})]}),N.jsx("button",{onClick:y,className:"px-3 py-1.5 text-sm text-gray-600 dark:text-gray-400 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:"Clear All"})]}),N.jsx("div",{className:"p-3 space-y-3",children:N.jsx(Fe,{columns:g,columnFilters:h,onColumnFilter:v})}),N.jsx("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700",children:N.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:Object.keys(h).length>0&&N.jsxs("span",{children:[Object.keys(h).length," filter",1!==Object.keys(h).length?"s":""," ","applied"]})})})]})]}),E]}),N.jsxs("div",{className:"order-2 flex items-center gap-2 sm:gap-3 flex-wrap sm:flex-nowrap",children:[L,u&&be&&x.length>0&&N.jsxs("div",{className:"relative",ref:de,children:[N.jsxs("button",{ref:e=>{xe.current=e},onClick:()=>T(!$),className:"flex items-center gap-2 px-3 py-2.5 bg-orange-600 text-white rounded-lg hover:bg-orange-700 transition-colors",title:"Bulk actions",children:[N.jsx(Q,{className:"w-4 h-4"}),N.jsxs("span",{className:"hidden sm:inline text-sm font-medium",children:["Actions (",s,")"]})]}),N.jsxs(wr,{open:$,anchorEl:xe.current,onClose:()=>T(!1),placement:"bottom-end",offset:8,zIndex:1e3,className:"w-56 bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[N.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[N.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Bulk Actions"}),N.jsxs("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:[s," row",1!==s?"s":""," selected"]})]}),N.jsx("div",{className:"p-2",children:x.map(e=>N.jsxs("button",{onClick:()=>(e=>{e.disabled||(e.onClick(i),T(!1))})(e),disabled:e.disabled,className:"w-full flex items-center gap-3 px-3 py-2 text-sm rounded-md transition-colors "+(e.disabled?"text-gray-400 dark:text-gray-500 cursor-not-allowed":e.destructive?"text-red-700 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800"),children:[e.icon??je(e.id),e.label]},e.id))})]})]}),d&&g.length>0&&N.jsxs("div",{className:"relative",ref:ue,children:[N.jsxs("button",{ref:e=>{fe.current=e},onClick:()=>H(!P),className:"flex items-center gap-2 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",title:"Column visibility","aria-label":`Column visibility. ${ve} of ${g.length} columns visible`,"aria-haspopup":"menu","aria-expanded":P,"aria-controls":"column-visibility-menu",children:[N.jsx(Y,{className:"w-4 h-4 dark:text-gray-300"}),N.jsx("span",{className:"hidden sm:inline text-sm font-medium dark:text-gray-300",children:"Columns"}),N.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["(",ve,"/",g.length,")"]})]}),N.jsxs(wr,{open:P,anchorEl:fe.current,onClose:()=>H(!1),placement:"bottom-end",offset:8,zIndex:1e3,className:"w-[90vw] sm:w-72 max-w-[90vw] bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[N.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[N.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Show/Hide Columns"}),N.jsxs("div",{className:"relative mt-2",children:[N.jsx(re,{className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4 dark:text-gray-500"}),N.jsx("input",{type:"text",placeholder:"Search columns...",className:"w-full pl-8 pr-2 py-1.5 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm dark:border-gray-600 dark:text-gray-300",value:U,onChange:e=>q(e.target.value)})]})]}),N.jsx("div",{className:"max-h-60 overflow-y-auto p-2",children:we.map(e=>{const t=!1!==m[e.key];return N.jsxs("label",{className:`flex items-center gap-3 p-2 hover:bg-gray-50 rounded-md cursor-grab relative ${X===e.key?"opacity-60":""} dark:hover:bg-gray-800`,draggable:!0,onDragStart:t=>((e,t)=>{J(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)})(e.key,t),onDragOver:t=>((e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();oe({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})})(e.key,t),onDrop:()=>(e=>{const t=X;if(!t||t===e)return;if(C&&C.has(t)!==C.has(e))return J(null),void oe(null);const r=Z?.key!==e||"before"===Z.position,n=(k&&k.length?k:g.map(e=>e.key)).filter(e=>e!==t);let a=n.indexOf(e);if(-1===a)return j?.(n),J(null),void oe(null);r||(a+=1),n.splice(a,0,t),j?.(n),J(null),oe(null)})(e.key),onDragEnd:Se,children:[Z?.key===e.key&&N.jsx("span",{className:"absolute left-2 right-2 h-0.5 bg-blue-600",style:{top:"before"===Z.position?0:void 0,bottom:"after"===Z.position?0:void 0}}),N.jsx("input",{type:"checkbox",checked:t,onChange:()=>(e=>{const t=!1!==m[e];b?.(e,!t)})(e.key),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:text-blue-400"}),t?N.jsx(ee,{className:"w-4 h-4 text-green-600"}):N.jsx(te,{className:"w-4 h-4 text-gray-400 dark:text-gray-500"}),N.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.header}),N.jsx("button",{type:"button",onClick:r=>{r.preventDefault(),r.stopPropagation(),t?S?.(e.key):(b?.(e.key,!0),requestAnimationFrame(()=>S?.(e.key)))},className:"ml-auto p-1 text-gray-400 hover:text-blue-600 dark:text-gray-500",title:"Scroll to this column","aria-label":`Scroll to column ${e.header}`,children:N.jsx(se,{className:"w-4 h-4"})})]},e.key)})}),N.jsxs("div",{className:"p-2 border-t border-gray-100 dark:border-gray-700",children:[N.jsxs("div",{className:"flex items-center justify-between",children:[N.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 cursor-pointer hover:bg-gray-50 px-3 py-1.5 rounded transition-colors min-h-9 dark:text-gray-400 dark:hover:text-gray-100 dark:hover:bg-gray-800",children:[N.jsx("input",{type:"checkbox",checked:we.every(e=>!1!==m[e.key]),onChange:e=>{we.forEach(t=>{b?.(t.key,e.target.checked)})},className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:text-blue-400"}),N.jsx("span",{children:"Select All"})]}),N.jsx("button",{className:"text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-50 px-3 py-1.5 rounded transition-colors min-h-9 dark:text-gray-400 dark:hover:text-gray-100 dark:hover:bg-gray-800",onClick:()=>{g.forEach(e=>{b?.(e.key,!1!==e.visible)}),j?.(g.map(e=>e.key)),w?.(),H(!1)},children:"Reset Columns"})]}),U&&N.jsx("button",{className:"text-xs text-blue-600 hover:underline mt-2 dark:text-blue-400",onClick:()=>q(""),children:"Clear Search"})]})]})]}),D&&N.jsx("div",{className:"flex items-center",children:N.jsx("div",{className:"flex items-center gap-1 border border-gray-300 rounded-lg p-1 dark:border-gray-600",title:"Row density",children:["sm","md","lg"].map(e=>N.jsx("button",{className:"px-2 py-1 text-xs rounded-md "+(R===e?"bg-blue-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"),onClick:()=>M?.(e),children:e.toUpperCase()},e))})}),N.jsx("div",{className:"flex items-center gap-2 order-3 w-full sm:order-0 sm:w-auto flex-1 min-w-0",children:N.jsxs("div",{className:"relative",children:[N.jsx(re,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4 dark:text-gray-500","aria-hidden":"true"}),N.jsx("input",{ref:ie,type:"text",placeholder:"Search...",className:"w-full sm:w-64 pl-10 pr-10 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:text-gray-200 transition-colors",value:e,onChange:p,"aria-label":"Search all columns","aria-keyshortcuts":"Control+F","aria-describedby":"search-results-status"}),e&&N.jsx("button",{onClick:()=>p({target:{value:""}}),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors dark:text-gray-500 dark:hover:text-gray-300",title:"Clear search",children:N.jsx(O,{className:"w-4 h-4"})})]})}),c&&f?.enabled&&N.jsxs("div",{className:"relative",ref:ce,children:[N.jsx("button",{ref:e=>{he.current=e},onClick:()=>F(!A),className:"p-2.5 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300 transition-colors","aria-label":"Export data"+(be?` (${s} rows selected)`:` (${t} rows)`),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":"export-menu","aria-keyshortcuts":"Control+E",title:"Export data (Ctrl+E)",children:N.jsx(W,{className:"w-4 h-4"})}),N.jsxs(wr,{open:A,anchorEl:he.current,onClose:()=>F(!1),placement:"bottom-end",offset:8,zIndex:1e3,className:"w-[90vw] sm:w-64 max-w-[90vw] bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[N.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[N.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Export Data"}),N.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:"Choose format and data scope"})]}),N.jsxs("div",{className:"p-2",children:[N.jsxs("div",{className:"mb-3",children:[N.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2 dark:text-gray-300",children:"Export All Data"}),N.jsx("div",{className:"space-y-1",children:pe.map(e=>N.jsxs("button",{onClick:()=>Ce(e,!1),className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md transition-colors cursor-pointer",children:[ke(e),N.jsxs("span",{children:["Export as ",Ne(e)]}),N.jsxs("span",{className:"ml-auto text-xs text-gray-500 dark:text-gray-400",children:[t.toLocaleString()," rows"]})]},`all-${e}`))})]}),be&&N.jsxs("div",{children:[N.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2 dark:text-gray-300",children:"Export Selected"}),N.jsx("div",{className:"space-y-1",children:pe.map(e=>N.jsxs("button",{onClick:()=>Ce(e,!0),className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-blue-700 hover:bg-blue-50 rounded-md transition-colors dark:text-blue-400 dark:hover:bg-blue-900/20",children:[ke(e),N.jsxs("span",{children:["Export as ",Ne(e)]}),N.jsxs("span",{className:"ml-auto text-xs text-blue-500",children:[s," rows"]})]},`selected-${e}`))})]})]})]})]})]})]})})]})};kr.displayName="SearchToolbar";const jr=r(kr),Nr=({data:e,columns:t})=>{const[r,l]=a(""),[i,u]=a({}),[g,m]=c(),[,h]=c(),x=s(e=>{m(()=>l(e))},[]),f=d(r),p=s((e,t,r,n)=>{const a=e[t];switch(r.type){case"text":{const e=String(a||"").toLowerCase(),t=String(r.value||"").toLowerCase();switch(r.operator){case"contains":default:return e.includes(t);case"equals":return e===t;case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t)}}case"number":{const e=parseFloat(a),t=parseFloat(String(r.value));if(isNaN(e)||isNaN(t))return!1;switch(r.operator){case"equals":default:return e===t;case"gt":return e>t;case"gte":return e>=t;case"lt":return e<t;case"lte":return e<=t;case"between":{const n=parseFloat(String(r.secondValue??""));return!isNaN(n)&&e>=t&&e<=n}}}case"date":{const e=n?.filterTs,t=n?.secondTs;if(void 0===e||isNaN(e))return!1;const l=new Date(a);if(isNaN(l.getTime()))return!1;const o=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime();switch(r.operator){case"equals":default:return o===e;case"gt":return o>e;case"gte":return o>=e;case"lt":return o<e;case"lte":return o<=e;case"between":return void 0!==t&&!isNaN(t)&&o>=e&&o<=t}}case"boolean":return Boolean(a)===Boolean(r.value);case"multiselect":{const e=e=>null==e||""===e||"string"==typeof e&&""===e.trim()?null:e;return(Array.isArray(r.value)?r.value:[r.value]).map(e).includes(e(a))}default:return!0}},[]),y=o(new WeakMap),b=o(0),v=s(()=>{b.current>5e3&&(y.current=new WeakMap,b.current=0)},[]),w=n(()=>{v();const r=Object.keys(i).length>0,n=!!f;if(!r&&!n)return e;const a=f.toLowerCase(),l=y.current;let o=e;if(r)for(const[e,t]of Object.entries(i)){if(!t)continue;let r;if("date"===t.type){const e=t.value instanceof Date?t.value:new Date(String(t.value??"")),n=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let a;if(t.secondValue){const e=t.secondValue instanceof Date?t.secondValue:new Date(String(t.secondValue??""));a=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}r={filterTs:n,secondTs:a}}if(o=o.filter(n=>p(n,e,t,r)),0===o.length)break}if(n&&o.length>0){const e=t.filter(e=>!1!==e.visible);o=o.filter(t=>{let r=l.get(t);return null==r&&(r=e.map(e=>{const r=t[e.key];if(null==r)return"";if("string"==typeof r)return r.toLowerCase();if("number"==typeof r||"boolean"==typeof r)return String(r).toLowerCase();const n=String(r);return n.length>100?n.slice(0,100):n}).join("|"),b.current<5e3&&(l.set(t,r),b.current++)),r.includes(a)})}return o},[e,i,f,t,p,v]),k=s((e,t)=>{h(()=>{u(r=>{const n={...r};return t?n[e]=t:delete n[e],n})})},[]),j=s(e=>{k(e,null)},[k]),N=s(()=>{m(()=>l("")),h(()=>u({})),y.current=new WeakMap,b.current=0},[]),C=s(()=>{let e=0;return f&&e++,e+Object.keys(i).length},[f,i]);return{globalFilter:r,setGlobalFilter:x,columnFilters:i,filteredData:w,setColumnFilter:k,clearColumnFilter:j,clearAllFilters:N,getActiveFilterCount:C,isFilterPending:g}};function Cr(){const e=self,t=(e,t)=>{if(!e||0===e.length)return e;if(!t?.key)return e;const{key:r,direction:n}=t,a="asc"===n?1:-1;return[...e].sort((e,t)=>{const n=e?.[r],l=t?.[r];return null==n&&null==l?0:null==n?-1*a:null==l?1*a:"number"==typeof n&&"number"==typeof l?(n-l)*a:String(n).localeCompare(String(l))*a})};e.onmessage=r=>{const n=r.data;if(n&&"process"===n.type)try{const{rows:r,sort:a}=n.payload;e.postMessage({type:"result",payload:{rows:t(r,a??null)}})}catch{e.postMessage({type:"result",payload:{rows:n.payload?.rows??[]}})}}}function Sr(e){const t=e?.enabled??!0,r=o(null),n=o(null),a=o(t);l(()=>{a.current=t,!t&&r.current&&(r.current.terminate(),r.current=null,n.current&&(n.current.reject(new DOMException("Worker disabled","AbortError")),n.current=null))},[t]);const i=o(()=>null);return i.current=()=>{if(!a.current)return null;if(r.current)return r.current;const e=`(${Cr.toString()})()`,t=new Blob([e],{type:"application/javascript"}),l=URL.createObjectURL(t),o=new Worker(l);return URL.revokeObjectURL(l),o.onmessage=e=>{"result"===e.data?.type&&(n.current?.resolve(e.data.payload.rows),n.current=null)},r.current=o,o},l(()=>()=>{r.current?.terminate(),r.current=null,n.current&&(n.current.reject(new DOMException("Unmounted","AbortError")),n.current=null)},[]),{process:s((e,t)=>{if(!a.current)return Promise.resolve(e);const r=i.current();return r?new Promise((a,l)=>{n.current&&n.current.reject(new DOMException("Superseded by newer sort","AbortError")),n.current={resolve:a,reject:l},r.postMessage({type:"process",payload:{rows:e,sort:t}})}):Promise.resolve(e)},[])}}const Rr="Unknown",Mr=e=>e.join("|"),Dr=(e,t,r,n,a)=>{const l=t[r],o=new Map;for(const t of e){const e=String(t[l]??Rr),r=o.get(e);r?r.push(t):o.set(e,[t])}for(const[e,s]of o.entries()){const o=[...n,`${l}=${e}`];a.add(Mr(o)),r<t.length-1&&Dr(s,t,r+1,o,a)}},Er=(e,t)=>{const r={};for(const n of t){if(!n.aggregate)continue;const t=e.map(e=>e[n.key]);let a=null;if("function"==typeof n.aggregate)try{a=n.aggregate(t)}catch(e){a=null}else{const e=e=>!!(/^\d{4}-\d{2}-\d{2}$/.test(e)||/^\d{2}-\d{2}-\d{4}$/.test(e)||/^\d{4}\/\d{2}\/\d{2}$/.test(e)||/^\d{2}\/\d{2}\/\d{4}$/.test(e)||(e.includes("-")||e.includes("/"))&&Number.isFinite(Date.parse(e))),r=t.map(t=>{if("number"==typeof t)return t;if(null==t)return NaN;const r=String(t);if(e(r))return NaN;const n=parseFloat(r.replace(/,/g,""));return Number.isFinite(n)?n:NaN}).filter(e=>Number.isFinite(e)),l=()=>t.map(e=>{if(e instanceof Date)return e.getTime();if("string"==typeof e||"number"==typeof e){const t=Date.parse(String(e));return Number.isFinite(t)?t:NaN}return NaN}).filter(e=>Number.isFinite(e));if("sum"===n.aggregate||"avg"===n.aggregate)r.length&&(a="sum"===n.aggregate?r.reduce((e,t)=>e+t,0):r.reduce((e,t)=>e+t,0)/r.length);else if("min"===n.aggregate||"max"===n.aggregate)if(r.length)a="min"===n.aggregate?Math.min(...r):Math.max(...r);else{const e=l();if(e.length){const t="min"===n.aggregate?Math.min(...e):Math.max(...e);a=new Date(t)}}}null!=a&&(r[n.key]=a)}return r},Lr=({data:e,pagination:t})=>{const[r,o]=a(1),[i,c]=a(t?.pageSize||50),[d,u]=a(!1);l(()=>{const e=t?.pageSize;e&&e!==i&&(c(e),o(1))},[t?.pageSize]);const g=s(()=>{o(1)},[]),m=n(()=>{const n=!1!==t?.enabled,a="server"===(t?.mode||"client")?t?.serverConfig?.totalRows||0:e.length,l=Math.ceil(a/i);return{enabled:n,pageSize:i,currentPage:r,totalPages:l,totalRows:a,showPageSizeSelector:!1!==t?.showPageSizeSelector,pageSizeOptions:t?.pageSizeOptions||[25,50,100,200,500]}},[t,i,r,e.length]),h=n(()=>{if(!m.enabled||"server"===t?.mode)return e;const n=(r-1)*i;return e.slice(n,n+i)},[e,r,i,m.enabled,t?.mode]),x=s(async e=>{if("server"===t?.mode&&t?.serverConfig?.onPageChange){u(!0);try{await t.serverConfig.onPageChange(e,i)}finally{u(!1)}}o(e)},[t,i]),f=s(async e=>{if("server"===t?.mode&&t?.serverConfig?.onPageSizeChange){u(!0);try{await t.serverConfig.onPageSizeChange(e)}finally{u(!1)}}c(e),o(1)},[t]);return{currentPage:r,resetPage:g,paginationConfig:m,paginatedData:h,isServerLoading:d,handlePageChange:x,handlePageSizeChange:f}},Ar=(e,t)=>{if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0},Fr=({data:e,selectedRowIds:t,onRowSelect:r,getRowId:o})=>{const i=s((e,t)=>o?o(e):void 0!==e.id?e.id:t??0,[o]),[c,d]=a(()=>new Set(t?Array.from(t):[]));l(()=>{t&&d(e=>{const r=new Set(Array.from(t));return Ar(e,r)?e:r})},[t]);const u=n(()=>{const t=new Map;return e.forEach((e,r)=>t.set(i(e,r),e)),t},[e,i]);l(()=>{if(0===c.size)return;let e=!1;for(const t of c)if(!u.has(t)){e=!0;break}e&&d(e=>{const t=new Set;return e.forEach(e=>{u.has(e)&&t.add(e)}),Ar(e,t)?e:t})},[u]);const g=s((e,t)=>{if(d(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n}),r){const t=u.get(e);t&&r(t)}},[u,r]),m=s(t=>{d(t?new Set(e.map((e,t)=>i(e,t))):new Set)},[e,i]);return{selectedRows:c,handleRowSelect:g,handleSelectAll:m}},Ir=({data:e,virtualized:t=!0,rowHeight:r=40,overscan:i=10,height:c})=>{const d=o(null),[u,g]=a(0),m=o(null),h=o(0),[x,f]=a(c);l(()=>{const e=d.current;if(!e)return;const t=new ResizeObserver(([e])=>{const t=e.contentRect.height;t>0&&f(t)});t.observe(e);const r=e.clientHeight;return r>0&&f(r),()=>t.disconnect()},[]),l(()=>{c>0&&f(c)},[c]);const p=n(()=>{if(!t)return{startIndex:0,endIndex:e.length-1,offsetY:0};const n=Math.max(1,Math.ceil(x/r)),a=Math.max(i,Math.min(n,20)),l=Math.max(0,Math.floor(u/r)-a),o=Math.ceil(x/r);return{startIndex:l,endIndex:Math.min(e.length-1,l+o+2*a),offsetY:l*r}},[u,x,e.length,r,i,t]),y=n(()=>t?e.slice(p.startIndex,p.endIndex+1):e,[e,p,t]),b=e.length*r,v=s(e=>{h.current=e.target.scrollTop,null==m.current&&(m.current=requestAnimationFrame(()=>{m.current=null,g(h.current)}))},[]);return l(()=>()=>{null!=m.current&&cancelAnimationFrame(m.current)},[]),{scrollRef:d,virtualizedRange:p,visibleData:y,totalHeight:b,handleScroll:v}};let zr=null;const $r=new Uint32Array([439041101,1584364171,2626518639,1514880045]);function Tr(e,t){let r=e[0],n=e[1],a=3337565984;for(let e=0;e<32;e++)n=n-((r<<4)+t[2]^r+a^(r>>>5)+t[3])>>>0,r=r-((n<<4)+t[0]^n+a^(n>>>5)+t[1])>>>0,a=a-2654435769>>>0;e[0]=r,e[1]=n}let Or;function Pr(e){Or=e}const _r=()=>!0,Kr=u(function({data:e,columns:t,getRowId:r,height:i,density:c="md",headerDensity:d,headerHeight:u,minResizeWidth:m,onDensityChange:h,showDensityControl:x=!1,onRowSelect:f,onSelectedRowsChange:p,selectable:y=!1,isRowSelectable:b,showToolbar:v=!0,showExport:w=!1,filterable:k=!0,groupable:j=!1,virtualized:R=!0,rowHeight:D,overscan:E=6,rowStyle:L,onContextMenu:A,onRowDoubleClick:F,onRowClick:I,onCellClick:z,onCellContextMenu:$,cellFocusEnabled:T=!1,onCellFocusChange:O,onCellEdit:P,onCellEditStart:_,cellSelectionEnabled:K=!1,canSelectCell:V=_r,onCellSelectionChange:B,pagination:W={enabled:!1,mode:"client",pageSize:50},virtualizationThreshold:H=300,loading:G=!1,onFilterChange:U,onSort:Y,onColumnConfigChange:q,initialColumnConfig:X,toolbarLeft:J,toolbarRight:Z,groupBarVisibility:Q="auto",groupFooterVariant:ee="chips",onCopyCells:te,selectedRowIds:re,performanceConfig:ne={},exportOptions:ae,renderGroupActions:le,contextMenuItems:oe,infiniteScroll:se,licenseKey:ie,noDataMessage:de,noDataRenderer:ue,savedFilters:ge,onSaveFilter:me,onLoadFilter:he,onDeleteFilter:xe},fe){l(()=>{if("undefined"!=typeof window&&window.KD_DEV_LOG){const e=[];void 0!==ge&&e.push("savedFilters"),void 0!==me&&e.push("onSaveFilter"),void 0!==he&&e.push("onLoadFilter"),void 0!==xe&&e.push("onDeleteFilter"),e.length>0&&console.warn(`[KDGrid] The following props are deprecated and have no effect: ${e.join(", ")}. They will be removed in a future major version. Use onFilterChange + your own state to manage saved filters.`)}},[]);const pe=o(null),[ye,be]=a(0);l(()=>{const e=pe.current;if(!e)return;const t=()=>be(e.clientWidth||0);t();const r=new ResizeObserver(()=>t());return r.observe(e),()=>r.disconnect()},[]);const[ve,ke]=a(c);l(()=>{ke(c)},[c]);const je=n(()=>({sm:28,md:40,lg:56}),[]),Ne=n(()=>null!=D?D:je[ve],[D,ve,je]),Ce=n(()=>null!=u?u:je[d??"md"],[u,d,je]),{globalFilter:Ee,columnFilters:Ae,filteredData:Fe,setGlobalFilter:Ie,setColumnFilter:ze,clearAllFilters:$e}=Nr({data:e,columns:t}),[Te,Oe]=a({key:null,direction:null}),Pe=o(null),_e=o(null),Ke=s(e=>{let t=e,r="asc";Te.key!==e?(t=e,r="asc"):"asc"===Te.direction?r="desc":"desc"===Te.direction?(t=null,r=null):r="asc",Oe({key:t,direction:r}),Y&&Y(t??"",r)},[Y,Te.key,Te.direction]),{process:Ve}=Sr({enabled:!0}),[Be,We]=a(Fe),He=ne?.sortWorkerThreshold??5e3;l(()=>{let e=!1;if(!Te.key)return void We(Fe);const t=Fe;if(t.length<He){const e="asc"===Te.direction?1:-1,r=[...t].sort((t,r)=>{const n=t?.[Te.key],a=r?.[Te.key];return null==n&&null==a?0:null==n?-1*e:null==a?1*e:"number"==typeof n&&"number"==typeof a?(n-a)*e:String(n).localeCompare(String(a))*e});return void We(r)}return Ve(t,{key:Te.key,direction:Te.direction}).then(t=>{e||We(t)}),()=>{e=!0}},[Fe,Te,Ve,He]);const Ge=n(()=>se?.enabled?{enabled:!1}:W,[se?.enabled,W?.enabled,W?.mode,W?.pageSize,W?.showPageSizeSelector,W?.pageSizeOptions,W?.serverConfig?.enabled,W?.serverConfig?.totalRows,W?.serverConfig?.loading,W?.serverConfig?.onPageChange,W?.serverConfig?.onPageSizeChange]),{paginationConfig:Ue,paginatedData:Ye,isServerLoading:qe,handlePageChange:Xe,handlePageSizeChange:Je,resetPage:Ze,currentPage:Qe}=Lr({data:Be,pagination:Ge}),et=s(e=>{Ie(e.target.value)},[Ie]),tt=W?.enabled?"server"===W.mode?e:Ye:Be,{groupConfig:rt,displayData:nt,handleGroupBy:at,addGroupKey:lt,removeGroupKey:ot,setGroupKeys:st,toggleGroupExpansion:it,isGrouped:ct,expandAllGroups:dt,collapseAllGroups:ut}=(({data:e,columns:t})=>{const[r,o]=a({columnKeys:[],expanded:new Set}),s=n(()=>{const n=r.columnKeys;if(!n.length)return e;const a=[],l=(e,o,s)=>{const i=n[o],c=new Map;for(const t of e){const e=String(t[i]??Rr),r=c.get(e);r?r.push(t):c.set(e,[t])}const d=Array.from(c.entries()).sort(([e],[t])=>e.localeCompare(t));for(const[e,c]of d){const d=[...s,`${i}=${e}`],u=Mr(d);if(a.push({id:`group-${u}`,_isGroupHeader:!0,_groupKey:u,_groupCount:c.length,_groupLevel:o,_groupColumnKey:i,_groupValue:e,_groupRows:c}),!r.expanded.has(u))continue;if(o<n.length-1)l(c,o+1,d);else for(const e of c)a.push(e);const g=Er(c,t);a.push({id:`group-footer-${u}`,_isGroupFooter:!0,_groupKey:u,_groupLevel:o,_groupAgg:g})}};return l(e,0,[]),a},[e,t,r.columnKeys,r.expanded]);return l(()=>{if(!r.columnKeys.length)return;const t=new Set;Dr(e,r.columnKeys,0,[],t);let n=!1;if(t.size!==r.expanded.size)n=!0;else for(const e of t)if(!r.expanded.has(e)){n=!0;break}n&&o(e=>({...e,expanded:t}))},[r.columnKeys,e]),{groupConfig:r,displayData:s,handleGroupBy:e=>{o({columnKeys:e?[e]:[],expanded:new Set})},addGroupKey:e=>{o(t=>t.columnKeys.includes(e)?t:{...t,columnKeys:[...t.columnKeys,e]})},removeGroupKey:e=>{o(t=>{const r=t.columnKeys.filter(t=>t!==e),n=new Set;for(const r of t.expanded)r.includes(`${e}=`)||n.add(r);return{columnKeys:r,expanded:n}})},setGroupKeys:e=>{o({columnKeys:[...e],expanded:new Set})},toggleGroupExpansion:e=>{o(t=>{const r=new Set(t.expanded);return r.has(e)?r.delete(e):r.add(e),{...t,expanded:r}})},expandAllGroups:()=>{const t=r.columnKeys;if(!t.length)return;const n=new Set;Dr(e,t,0,[],n),o(e=>({...e,expanded:n}))},collapseAllGroups:()=>{o(e=>({...e,expanded:new Set}))},isGrouped:r.columnKeys.length>0}})({data:tt,columns:t}),{columnWidths:gt,columnOrder:mt,pinnedColumns:ht,columnVisibility:xt,handleColumnResize:ft,handleColumnPin:pt,handleColumnVisibilityChange:yt,setColumnOrder:bt,autosizeColumn:vt,autosizeAllColumns:wt,resetColumns:kt}=(({columns:e,data:t,initialColumnConfig:r,onColumnConfigChange:n,setSortConfig:i,setGroupKeys:c,setDensity:d,setGlobalFilter:u,setColumnFilter:g,sortConfig:m,groupConfig:h,globalFilter:x,columnFilters:f,density:p})=>{const[y,b]=a(()=>{const t={};return e.forEach(e=>{t[e.key]=e.width||100}),t}),v=o(e.reduce((e,t)=>(e[t.key]=t.width||100,e),{})),w=o(e.map(e=>e.key)),[k,j]=a(()=>w.current.slice()),[N,C]=a(new Set),[S,R]=a(()=>{const t={};return e.forEach(e=>{t[e.key]=!0}),t}),M=s((e,t)=>{b(r=>({...r,[e]:t}))},[]),D=s((e,t)=>{C(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n})},[]),E=s((e,t)=>{R(r=>({...r,[e]:t}))},[]),L=s(e=>{if(null==e)return 0;const t="string"==typeof e?e:String(e);if(!t)return 0;try{if("undefined"!=typeof document){if(!zr){const e=document.createElement("canvas");zr=e.getContext("2d"),zr&&(zr.font="13px Inter, ui-sans-serif, system-ui, sans-serif")}if(zr)return Math.ceil(zr.measureText(t).width)}}catch{}return 8*t.length},[]),A=s(r=>{const n=e.find(e=>e.key===r);if(!n)return;const a=L(n.header),l=t.slice(0,500);let o=0;for(const e of l)o=Math.max(o,L(e[r]));const s=Math.max(60,Math.min(500,Math.max(a,o)+32));b(e=>({...e,[r]:s}))},[e,t,L]),F=s(()=>{e.forEach(e=>A(e.key))},[e,A]),I=s(()=>{b({...v.current}),C(new Set),R(e=>{const t={};return Object.keys(e).forEach(e=>t[e]=!0),t}),j(w.current.slice())},[]);return l(()=>{if(!r)return;const t=new Set(e.map(e=>e.key));if(r.columnWidths){const e=Object.fromEntries(Object.entries(r.columnWidths).filter(([e])=>t.has(e)));b(t=>({...t,...e}))}if(r.columnVisibility){const e=Object.fromEntries(Object.entries(r.columnVisibility).filter(([e])=>t.has(e)));R(t=>({...t,...e}))}if(r.pinnedColumns){const e=r.pinnedColumns.filter(e=>t.has(e));C(new Set(e))}if(r.sortConfig){const e="asc"===r.sortConfig.direction||"desc"===r.sortConfig.direction?r.sortConfig.direction:null;i({key:e?r.sortConfig.key:null,direction:e})}if(r.filters){u(r.filters.globalFilter||"");const e=Object.entries(r.filters.columnFilters||{}).filter(([e])=>t.has(e));for(const[t,r]of e)g(t,r)}if(r.columnOrder&&r.columnOrder.length){const n=r.columnOrder.filter(e=>t.has(e)),a=e.map(e=>e.key).filter(e=>!n.includes(e));j([...n,...a])}r.groupConfig?.columnKeys&&r.groupConfig.columnKeys.length&&c(r.groupConfig.columnKeys),r.density&&d(r.density)},[]),l(()=>{if(!n)return;const e=setTimeout(()=>{n({columnWidths:y,columnVisibility:S,pinnedColumns:Array.from(N),sortConfig:m,groupConfig:{columnKeys:h.columnKeys},filters:{globalFilter:x,columnFilters:f},columnOrder:k,density:p})},200);return()=>clearTimeout(e)},[n,y,S,N,m,h,x,f,k,p]),{columnWidths:y,columnOrder:k,pinnedColumns:N,columnVisibility:S,handleColumnResize:M,handleColumnPin:D,handleColumnVisibilityChange:E,setColumnOrder:j,autosizeColumn:A,autosizeAllColumns:F,resetColumns:I,setColumnWidths:b,setPinnedColumns:C,setColumnVisibility:R}})({columns:t,data:e,initialColumnConfig:X,onColumnConfigChange:q,setSortConfig:Oe,setGroupKeys:st,setDensity:ke,setGlobalFilter:Ie,setColumnFilter:ze,sortConfig:Te,groupConfig:rt,globalFilter:Ee,columnFilters:Ae,density:ve}),jt=o([]),Nt=o([]),Ct=o(36),St=o(!1),Rt=o(null);g(fe,()=>({setGroupKeys:st,addGroupKey:lt,removeGroupKey:ot,expandAllGroups:dt,collapseAllGroups:ut,toggleGroupExpansion:it,getGroupConfig:()=>rt,setColumnFilter:(e,t)=>{ze(e,t)},clearColumnFilter:e=>{ze(e,null)},clearAllFilters:()=>{$e()},setGlobalFilter:e=>{Ie(e)},scrollToRow:e=>{const t=Rt.current;if(!t)return;const n=jt.current.findIndex(t=>(r?r(t):void 0!==t.id?t.id:void 0)===e);if(-1===n)return;const a=Ct.current,l=n*a,o=l+a;l<t.scrollTop?t.scrollTo({top:l,behavior:"smooth"}):o>t.scrollTop+t.clientHeight&&t.scrollTo({top:o-t.clientHeight,behavior:"smooth"})},scrollToColumn:e=>{const t=Rt.current;if(!t)return;const r=Nt.current,n=r.findIndex(t=>t.key===e);if(-1===n)return;let a=St.current?C:0;for(let e=0;e<n;e++)a+=r[e]?.width||100;const l=a+(r[n]?.width||100);a<t.scrollLeft?t.scrollTo({left:a,behavior:"smooth"}):l>t.scrollLeft+t.clientWidth&&t.scrollTo({left:l-t.clientWidth,behavior:"smooth"})}}),[rt,st,lt,ot,dt,ut,it,ze,$e,Ie,r]);const Mt=n(()=>new Set(ht),[ht]),Dt=ct?nt:tt,{selectedRows:Et,handleRowSelect:Lt,handleSelectAll:At}=Fr({data:Dt,onRowSelect:f,selectedRowIds:re,getRowId:r}),Ft=o(p);l(()=>{Ft.current=p},[p]),l(()=>{Ft.current&&Ft.current(Et)},[Et]);const{exportData:It}=(({data:e,columns:t,selectedRows:r,filename:n="data",columnVisibility:a})=>{const l=s(()=>a?t.filter(e=>!1!==a[e.key]):t,[t,a]),o=s((e,t,r)=>{const n=new Blob([e],{type:r}),a=URL.createObjectURL(n),l=document.createElement("a");l.href=a,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)},[]),i=s((e,t)=>{const r=l(),n=r.map(e=>e.header).join(","),a=e.map(e=>r.map(t=>{const r=String(e[t.key]??"");return r.includes(",")||r.includes('"')?`"${r.replace(/"/g,'""')}"`:r}).join(","));o([n,...a].join("\n"),`${t}.csv`,"text/csv")},[l,o]),c=s((e,t)=>{const r=l(),n=e.map(e=>{const t={};for(const n of r)t[n.header]=e[n.key];return t});o(JSON.stringify(n,null,2),`${t}.json`,"application/json")},[l,o]),d=s(async(e,t)=>{const r=l(),[{default:n},{saveAs:a}]=await Promise.all([import("exceljs"),import("file-saver")]),o=new n.Workbook,s=o.addWorksheet("Data"),i=e.slice(0,50),c=e=>{if(null==e)return"";if("number"==typeof e||"boolean"==typeof e||e instanceof Date)return e;const t=String(e);if(/[a-zA-Z]/.test(t))return t;if(/^-?[\d,]+\.?\d*$/.test(t.trim())){const e=Number(t.replace(/,/g,""));if(Number.isFinite(e))return e}return t};s.columns=r.map(e=>{const t=e.header||e.key;let r=t?.length||10;for(const t of i){const n=null==t[e.key]?"":String(t[e.key]);n.length>r&&(r=n.length)}return{header:t,key:e.key,width:Math.max(8,Math.min(50,Math.ceil(1.1*r)))}});for(const t of e){const e={};for(const n of r)e[n.key]=c(t[n.key]);s.addRow(e)}s.getRow(1).font={bold:!0},s.autoFilter={from:{row:1,column:1},to:{row:Math.max(1,s.rowCount),column:r.length}};const d=await o.xlsx.writeBuffer();a(new Blob([d],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),`${t}.xlsx`)},[l]);return{exportData:s((t,a=!1)=>{const l=a&&r&&r.size>0?e.filter(e=>r.has(e.id)):e,o=a&&r&&r.size>0?`${n}_selected_${r.size}_rows`:n;switch(t){case"csv":i(l,o);break;case"json":c(l,o);break;case"xlsx":d(l,o);break;default:console.warn(`[KDGrid] Unsupported export format: ${t}`)}},[e,r,n,i,c,d]),canExportSelected:!!(r&&r.size>0),selectedCount:r?.size??0}})({data:tt,columns:t,selectedRows:Et,filename:ae&&ae.filename||"grid-data",columnVisibility:xt}),zt=s((e,t)=>{const r=Array.from(Et||[]);"server"===ae?.exportMode&&"function"==typeof ae?.onServerExport?ae.onServerExport(e,t,r):It(e,t)},[ae?.exportMode,ae?.onServerExport,It,Et]),$t=s(()=>{$e()},[$e]),Tt=s(e=>{ke(e),h&&h(e)},[h]),Ot=n(()=>!!R&&Dt.length>H,[R,Dt.length,H]),Pt=n(()=>({enableHorizontalVirtualization:!0,horizontalVirtualizationThreshold:50,sortWorkerThreshold:5e3,maxFilterCacheSize:5e3,enableAggressiveMemoization:!0,...ne}),[ne]),{scrollRef:_t,virtualizedRange:Kt,visibleData:Vt,handleScroll:Bt}=Ir({data:Dt,virtualized:Ot,rowHeight:Ne,overscan:E,height:i||400}),{sentinelRef:Wt}=function({enabled:e,onLoadMore:t,threshold:r=200,rootRef:n}){const a=o(null),s=o(t);return l(()=>{s.current=t},[t]),l(()=>{if(!e)return;const t=a.current;if(!t)return;const l=new IntersectionObserver(e=>{e[0].isIntersecting&&s.current()},{root:n?.current||null,rootMargin:`0px 0px ${r}px 0px`,threshold:0});return l.observe(t),()=>l.disconnect()},[e,r,n]),{sentinelRef:a}}({enabled:se?.enabled??!1,hasMore:se?.hasMore??!1,isLoading:se?.isLoading??!1,onLoadMore:()=>{!se?.isLoading&&se?.hasMore&&se.onLoadMore()},threshold:se?.threshold??250,rootRef:_t}),Ht=(({scrollRef:e,footerScrollRef:t,hasFooterAggregate:r})=>{const[n,i]=a(0),c=o(0),d=o(null),u=s(e=>{c.current=e,null==d.current&&(d.current=requestAnimationFrame(()=>{d.current=null,i(c.current)}))},[]),[g,m]=a(0);l(()=>{const t=e.current;if(!t)return;const r=()=>m(t.clientWidth||0);r();const n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()},[e]),l(()=>{const r=e.current;if(!r)return;let n=!1;const a=()=>{if(n)return;n=!0;const e=t.current;e&&e.scrollLeft!==r.scrollLeft&&(e.scrollLeft=r.scrollLeft),u(r.scrollLeft),requestAnimationFrame(()=>{n=!1})};return r.addEventListener("scroll",a,{passive:!0}),t.current&&(t.current.scrollLeft=r.scrollLeft),()=>{r.removeEventListener("scroll",a)}},[e,r,u]);const h=s(t=>{const r=e.current;if(!r)return;const n=Math.abs(t.deltaX)>=Math.abs(t.deltaY)?t.deltaX:t.deltaY;0!==n&&(t.preventDefault(),r.scrollBy({left:n,top:0,behavior:"auto"}))},[e]);return{hScrollLeft:n,viewportWidth:g,scheduleHScrollUpdate:u,forwardWheelToBody:h}})({scrollRef:_t,footerScrollRef:_e,hasFooterAggregate:!1}),{hScrollLeft:Gt,viewportWidth:Ut,forwardWheelToBody:Yt}=Ht,{showLoader:qt,finishingLoader:Xt,loaderTop:Jt}=(({loading:e,isServerLoading:t,resolvedHeaderHeight:r,scrollRef:n,containerRef:o})=>{const s=e||t,[i,c]=a(s),[d,u]=a(!1),[g,m]=a(0);return l(()=>{if(s)return c(!0),void u(!1);if(i){u(!0);const e=setTimeout(()=>{c(!1),u(!1)},200);return()=>clearTimeout(e)}},[s]),l(()=>{const e=()=>{const e=n.current;e&&m((e.offsetTop||0)+(r||0)-1)};e();const t=new ResizeObserver(e);return o.current&&t.observe(o.current),n.current&&t.observe(n.current),()=>t.disconnect()},[r]),{showLoader:i,finishingLoader:d,loaderTop:g}})({loading:G,isServerLoading:qe,resolvedHeaderHeight:Ce,scrollRef:_t,containerRef:pe});l(()=>{if(!U)return;if(!W?.enabled||"server"!==W.mode)return;const e=t.filter(e=>!!e.filterable).map(e=>e.key);U({globalFilter:Ee,columnFilters:Ae,filterableKeys:e})},[Ee,Ae,U,t,W?.enabled,W?.mode]);const Zt=n(()=>{if(0===t.length)return[];const e=new Map(mt.map((e,t)=>[e,t])),r=t.filter(e=>!1!==xt[e.key]).sort((t,r)=>(e.get(t.key)||0)-(e.get(r.key)||0)).map(e=>{const t=gt[e.key]??e.width,r=Number.isFinite(Number(t))?Number(t):100,n=!1!==e.sortable;return{...e,width:r,sortable:n}}),n=Math.max(0,ye-(y?C:0)),a=r.reduce((e,t)=>e+t.width,0),l=new Map;if(n>a){const e=r.filter(e=>e.flex);if(e.length>0){const t=n-a,r=e.reduce((e,t)=>e+Math.max(0,!0===t.flex?1:"number"==typeof t.flex?t.flex:1),0);if(r>0)for(const n of e)l.set(n.key,Math.max(n.minWidth??0,Math.min(n.maxWidth??Number.POSITIVE_INFINITY,n.width+t*(!0===n.flex?1:"number"==typeof n.flex?n.flex:1)/r)))}}const o=e=>l.has(e.key)?{...e,width:l.get(e.key)}:e,s=[],i=[];for(const e of r)Mt.has(e.key)?s.push(o(e)):i.push(o(e));if(rt.columnKeys&&rt.columnKeys.length>0){const e=new Map(rt.columnKeys.map((e,t)=>[e,t]));i.sort((t,r)=>(e.get(t.key)??Number.POSITIVE_INFINITY)-(e.get(r.key)??Number.POSITIVE_INFINITY))}return[...s,...i]},[t,gt,Mt,xt,mt,rt.columnKeys,ye,y]),Qt=n(()=>Pt.enableHorizontalVirtualization&&Zt.length>Pt.horizontalVirtualizationThreshold,[Zt.length,Pt.enableHorizontalVirtualization,Pt.horizontalVirtualizationThreshold]),er=n(()=>Zt.filter(e=>Mt.has(e.key)),[Zt,Mt]),tr=n(()=>Zt.filter(e=>!Mt.has(e.key)),[Zt,Mt]),rr=n(()=>{const e=tr.map(e=>e.width||100),t=new Array(e.length+1).fill(0);for(let r=0;r<e.length;r++)t[r+1]=t[r]+e[r];return{widths:e,prefix:t,totalWidth:t[e.length]||0}},[tr]),nr=n(()=>{if(!Qt)return Zt;const e=y?C:0,t=er.reduce((e,t)=>e+(t.width||100),0),r=Math.max(0,Gt-200),n=Gt+Ut+200,a=e+t,l=Math.max(0,r-a),o=Math.max(0,Math.min(rr.totalWidth,n-a)),s=(e=>{if(!rr.widths.length)return 0;let t=0,r=rr.widths.length-1,n=0;for(;t<=r;){const a=t+r>>1;rr.prefix[a+1]>=e?(n=a,r=a-1):t=a+1}return Math.max(0,Math.min(n,rr.widths.length-1))})(l),i=(e=>{if(!rr.widths.length)return-1;let t=0,r=rr.widths.length-1,n=rr.widths.length-1;for(;t<=r;){const a=t+r>>1;rr.prefix[a]<=e?(n=a,t=a+1):r=a-1}return Math.max(0,Math.min(n,rr.widths.length-1))})(o),c=i>=s&&i>=0?tr.slice(s,i+1):[];return[...er,...c]},[Qt,Zt,Gt,Ut,y,er,tr,rr]),ar=n(()=>{const e=new Map;return tr.forEach((t,r)=>e.set(t.key,r)),e},[tr]),{hvPadLeftMemo:lr,hvPadRightMemo:or}=n(()=>{if(!Qt)return{hvPadLeftMemo:0,hvPadRightMemo:0};const e=nr.filter(e=>!Mt.has(e.key));if(!e.length)return{hvPadLeftMemo:0,hvPadRightMemo:0};const t=ar.get(e[0].key),r=ar.get(e[e.length-1].key);return null==t||null==r?{hvPadLeftMemo:0,hvPadRightMemo:0}:{hvPadLeftMemo:rr.prefix[t],hvPadRightMemo:rr.totalWidth-rr.prefix[r+1]}},[Qt,nr,Mt,ar,rr]),sr=n(()=>Zt.some(e=>e.footerAggregate),[Zt]),ir=n(()=>{const e=new Map;return Zt.forEach((t,r)=>e.set(t.key,r)),e},[Zt]),cr=n(()=>{const e=new Map;return Zt.forEach(t=>e.set(t.key,t)),e},[Zt]),dr=n(()=>Dt.filter(e=>!e._isGroupHeader&&!e._isGroupFooter),[Dt]),ur=n(()=>{const e=new Map;return dr.forEach((t,n)=>{const a=r?r(t):void 0!==t.id?t.id:n;e.set(a,n)}),e},[dr,r]),gr=n(()=>{const e=new Map;return dr.forEach((t,n)=>{const a=r?r(t):void 0!==t.id?t.id:n;e.set(a,t)}),e},[dr,r]),mr=n(()=>Zt.map(e=>e.key),[Zt]),hr=s(e=>r?r(e):void 0!==e.id?e.id:dr.indexOf(e),[r,dr]),{focusedCell:xr,dragOverlay:fr,isCellSelected:pr,isCellFocused:yr,handleCellMouseDown:br,handleCellMouseEnter:vr}=(({cellFocusEnabled:e,cellSelectionEnabled:t,canSelectCell:r,flatRows:i,columnsWithWidths:c,rowIndexById:d,colIndexByKey:u,rowById:g,colByKey:m,scrollRef:h,headerScrollRef:x,resolvedRowHeight:f,selectable:p,onCellFocusChange:y,onCellSelectionChange:b,onCopyCells:v,columnKeys:w,getRowId:k})=>{const j=s((e,t)=>k?k(e):void 0!==e.id?e.id:t??0,[k]),[N,C]=a(null),[S,R]=a(null),[M,D]=a(null),[E,L]=a(null),A=o(!1),F=o(null),I=o(null),z=o(b),$=o(v),T=o(null);l(()=>{z.current=b},[b]),l(()=>{$.current=v},[v]);const O=n(()=>(e,n)=>{if(!t)return!1;if(!S||!M)return!1;const a=d.get(e),l=u.get(n);if(null==a||null==l)return!1;const o=g.get(e),s=m.get(n);if(o&&s&&!r(o,s))return!1;const i=Math.min(S.rowIndex,M.rowIndex),c=Math.max(S.rowIndex,M.rowIndex),h=Math.min(S.colIndex,M.colIndex),x=Math.max(S.colIndex,M.colIndex);return a>=i&&a<=c&&l>=h&&l<=x},[t,S,M,d,u,g,m,r]),P=n(()=>(e,t)=>N?.rowId===e&&N?.columnKey===t,[N]),_=s(({row:n,column:a,event:l})=>{const o=j(n),s=d.get(o),i=u.get(a.key);e&&null!=s&&null!=i&&(document.body.hasAttribute("data-modal-open")||(C({rowId:o,columnKey:a.key}),y&&y({row:n,column:a,value:n[a.key],rowIndex:s,colIndex:i}))),t&&r(n,a)&&0===l.button&&(A.current=!0,F.current={x:l.clientX,y:l.clientY},null!=s&&null!=i&&(C({rowId:o,columnKey:a.key}),R({rowIndex:s,colIndex:i}),D({rowIndex:s,colIndex:i}),L({x:l.clientX,y:l.clientY,rows:1,cols:1})))},[e,y,t,r,d,u,j]),K=s(({row:e,column:n,event:a})=>{if(!t)return;if(!A.current||!S)return;if(!r(e,n))return;const l=j(e),o=d.get(l),s=u.get(n.key);if(null==o||null==s)return;D({rowIndex:o,colIndex:s}),F.current={x:a.clientX,y:a.clientY};const i=Math.min(S.rowIndex,o),c=Math.max(S.rowIndex,o),g=Math.min(S.colIndex,s),m=Math.max(S.colIndex,s);L({x:a.clientX,y:a.clientY,rows:c-i+1,cols:m-g+1})},[t,r,S,d,u,j]);l(()=>{const e=()=>{A.current=!1,L(null),I.current&&(cancelAnimationFrame(I.current),I.current=null)};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),l(()=>{const e=e=>{A.current&&(F.current={x:e.clientX,y:e.clientY})};return window.addEventListener("mousemove",e),()=>window.removeEventListener("mousemove",e)},[]);const V=s(()=>{if(null!=I.current)return;const e=()=>{if(I.current=null,!A.current)return;const t=h.current,r=F.current;if(t&&r){const e=t.getBoundingClientRect(),n=24,a=24;let l=0,o=0;r.x<e.left+n?l=-(e.left+n-r.x):r.x>e.right-n&&(l=r.x-(e.right-n)),r.y<e.top+n?o=-(e.top+n-r.y):r.y>e.bottom-n&&(o=r.y-(e.bottom-n));const s=e=>Math.max(-a,Math.min(a,e));l=s(l),o=s(o),0===l&&0===o||t.scrollBy({left:l,top:o,behavior:"auto"})}I.current=requestAnimationFrame(e)};I.current=requestAnimationFrame(e)},[]);return l(()=>{A.current&&V()},[V,S]),l(()=>{const e=e=>{if("Escape"===e.key)return R(null),D(null),C(null),void L(null);const r=e.shiftKey,n=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key);if(!r||!n||!t)return;e.preventDefault();let a=M;if(!a){if(!N)return;{const e=d.get(N.rowId),t=u.get(N.columnKey);if(null==e||null==t)return;R({rowIndex:e,colIndex:t}),a={rowIndex:e,colIndex:t}}}const l=i.length-1,o=c.length-1;let s=a.rowIndex,g=a.colIndex;"ArrowUp"===e.key&&(s=Math.max(0,s-1)),"ArrowDown"===e.key&&(s=Math.min(l,s+1)),"ArrowLeft"===e.key&&(g=Math.max(0,g-1)),"ArrowRight"===e.key&&(g=Math.min(o,g+1)),D({rowIndex:s,colIndex:g});const m=h.current;if(m){const e=m.getBoundingClientRect();L({x:e.right-16,y:e.bottom-16,rows:Math.abs((S?.rowIndex??s)-s)+1,cols:Math.abs((S?.colIndex??g)-g)+1})}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,N,S,M,d,u,i.length,c.length]),l(()=>{if(!e)return;const t=h.current,r=x.current,n=e=>{if(!N)return;if(document.body.hasAttribute("data-modal-open"))return;const{key:n}=e;if("ArrowLeft"!==n&&"ArrowRight"!==n&&"ArrowUp"!==n&&"ArrowDown"!==n)return;e.preventDefault();const a=d.get(N.rowId),l=u.get(N.columnKey);if(null==a||null==l)return;let o=a,s=l;"ArrowLeft"===n&&(s=Math.max(0,l-1)),"ArrowRight"===n&&(s=Math.min(c.length-1,l+1)),"ArrowUp"===n&&(o=Math.max(0,a-1)),"ArrowDown"===n&&(o=Math.min(i.length-1,a+1));const g=i[o],m=c[s];if(!g||!m)return;const h=j(g,o);C({rowId:h,columnKey:m.key}),y&&y({row:g,column:m,value:g[m.key],rowIndex:o,colIndex:s}),((e,n)=>{if(!t)return;const a=t.clientHeight,l=e*f,o=l+f;l<t.scrollTop?t.scrollTop=l:o>t.scrollTop+a&&(t.scrollTop=o-a);const s=c[n]?.width||100;let i=p?36:0;for(let e=0;e<n;e++)i+=c[e]?.width||100;const d=i+s,u=t.clientWidth;i<t.scrollLeft?t.scrollLeft=i:d>t.scrollLeft+u&&(t.scrollLeft=d-u),r&&(r.scrollLeft=t.scrollLeft)})(o,s)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,N,i,c,f,p,d,u,y]),l(()=>{if(!t||!S||!M){const e={bounds:null,cells:[]},t="none";return void(t!==T.current&&(T.current=t,z.current?.(e)))}const e=Math.min(S.rowIndex,M.rowIndex),n=Math.max(S.rowIndex,M.rowIndex),a=Math.min(S.colIndex,M.colIndex),l=Math.max(S.colIndex,M.colIndex),o=[];for(let t=e;t<=n;t++){const e=i[t];if(e)for(let n=a;n<=l;n++){const a=c[n];a&&r(e,a)&&o.push({row:e,column:a,value:e[a.key],rowIndex:t,colIndex:n})}}const s={bounds:{rowStart:e,rowEnd:n,colStart:a,colEnd:l},cells:o},d=`${e}-${n}-${a}-${l}|len:${o.length}`;d!==T.current&&(T.current=d,z.current?.(s))},[t,S,M,i,w,r]),l(()=>{if(!t&&!e)return;const n=async t=>{if(!t.metaKey&&!t.ctrlKey||"c"!==t.key.toLowerCase())return;const n=!!t.shiftKey,a=!(!S||!M),l=!(!e||!N);if(!a&&!l)return;if(!a&&l){const e=window.getSelection();if(e&&e.toString().length>0)return;const t=document.activeElement;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return}t.preventDefault();const o=(()=>{const e=[];if(a&&S&&M){const t=Math.min(S.rowIndex,M.rowIndex),n=Math.max(S.rowIndex,M.rowIndex),a=Math.min(S.colIndex,M.colIndex),l=Math.max(S.colIndex,M.colIndex);for(let o=t;o<=n;o++){const t=i[o];if(t)for(let n=a;n<=l;n++){const a=c[n];a&&r(t,a)&&e.push({row:t,column:a,value:t[a.key],rowIndex:o,colIndex:n})}}}else if(l&&N){const t=d.get(N.rowId),r=u.get(N.columnKey);if(null!=t&&null!=r){const n=i[t],a=c[r];n&&a&&e.push({row:n,column:a,value:n[a.key],rowIndex:t,colIndex:r})}}return e})();if(!o.length)return;const s=e=>{const t=null==e?"":String(e);return t.includes('"')||t.includes("\t")||t.includes("\n")||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t};let g="";if(a&&S&&M){const e=Math.min(S.rowIndex,M.rowIndex),t=Math.max(S.rowIndex,M.rowIndex),a=Math.min(S.colIndex,M.colIndex),l=Math.max(S.colIndex,M.colIndex);if(n){const e=[];for(let t=a;t<=l;t++){const r=c[t];r&&e.push(s(r.header??r.key))}g+=e.join("\t")+"\n"}for(let n=e;n<=t;n++){const e=i[n];if(!e)continue;const o=[];for(let t=a;t<=l;t++){const n=c[t];n&&(r(e,n)?o.push(s(e[n.key])):o.push(""))}g+=o.join("\t"),n<t&&(g+="\n")}}else g=s(o[0].value);try{await navigator.clipboard.writeText(g)}catch{console.warn("Failed to write to clipboard")}if("function"==typeof $.current){const e=a&&S&&M?{rowStart:Math.min(S.rowIndex,M.rowIndex),rowEnd:Math.max(S.rowIndex,M.rowIndex),colStart:Math.min(S.colIndex,M.colIndex),colEnd:Math.max(S.colIndex,M.colIndex)}:null;try{$.current({text:g,bounds:e,cells:o,isRectangular:!!e,isFocusedCell:!e})}catch{}}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t,e,S,M,N,i,c,r,d,u]),{focusedCell:N,selectionAnchor:S,selectionEnd:M,dragOverlay:E,isCellSelected:O,isCellFocused:P,handleCellMouseDown:_,handleCellMouseEnter:K}})({cellFocusEnabled:T,cellSelectionEnabled:K,canSelectCell:V,flatRows:dr,columnsWithWidths:Zt,rowIndexById:ur,colIndexByKey:ir,rowById:gr,colByKey:cr,scrollRef:_t,headerScrollRef:Pe,resolvedRowHeight:Ne,selectable:y,onCellFocusChange:O,onCellSelectionChange:B,onCopyCells:te,columnKeys:mr,getRowId:hr}),{editingCell:wr,startEdit:kr,commitEdit:Cr,cancelEdit:Ar,isEditing:Pr}=(({getRowId:e,onCellEdit:t,onCellEditStart:r,focusedCell:n,getRowById:o,getColumnByKey:i})=>{const[c,d]=a(null),u=s((t,n)=>{if(!((e,t)=>!!e.editable&&("function"==typeof e.editable?e.editable(t):!!e.editable))(n,t))return;const a=t[n.key];if(r&&!1===r({row:t,column:n,value:a}))return;const l=e(t);d({rowId:l,columnKey:n.key,initialValue:a,row:t,column:n})},[e,r]),g=s(e=>{if(!c)return;const{row:r,column:n,initialValue:a,rowId:l}=c;d(null),e!==a&&t?.({row:r,column:n,oldValue:a,newValue:e,rowId:l})},[c,t]),m=s(()=>{d(null)},[]);l(()=>{if(!n||!o||!i)return;const e=e=>{if("F2"!==e.key)return;if(c)return;const t=o(n.rowId),r=i(n.columnKey);t&&r&&(e.preventDefault(),u(t,r))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,c,o,i,u]);const h=s((e,t)=>c?.rowId===e&&c?.columnKey===t,[c]);return{editingCell:c,startEdit:u,commitEdit:g,cancelEdit:m,isEditing:h}})({getRowId:hr,onCellEdit:P,onCellEditStart:_,focusedCell:xr,getRowById:e=>gr.get(e),getColumnByKey:e=>cr.get(e)}),Kr=Zt.reduce((e,t)=>e+(t.width||100),0);jt.current=dr,Nt.current=Zt,Ct.current=Ne,St.current=y,_t.current&&Rt.current!==_t.current&&(Rt.current=_t.current),l(()=>{1!==Qe&&(W?.enabled&&"server"===W.mode?Xe(1):Ze())},[Ee,Ae]);const Vr=n(()=>function(e){const t=(e||Or||"").replace(/-/g,"").toLowerCase();if("kdinternaldevbypass"===t)return!0;if(32!==t.length)return!1;try{const e=new Uint32Array(4);for(let r=0;r<4;r++)e[r]=parseInt(t.slice(8*r,8*r+8),16);const r=new Uint32Array([e[0],e[1]]),n=new Uint32Array([e[2],e[3]]);Tr(r,$r),Tr(n,$r);const a=r[1];if(1262769713!==r[0])return!1;const l=Math.floor(a/1e4),o=Math.floor(a%1e4/100)-1,s=a%100;if(l<2024||o<0||o>11||s<1||s>31)return!1;const i=new Date(l,o,s,23,59,59);return!(new Date>i&&(console.error("[KDGrid] License expired on "+i.toDateString()),1))}catch{return!1}}(ie),[ie]);return N.jsxs("div",{ref:pe,className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden bg-white dark:bg-gray-900 h-full flex flex-col","data-grid-container":!0,children:[v&&k&&N.jsx(jr,{globalFilter:Ee,filteredDataLength:Fe.length,totalDataLength:Ue.totalRows,paginationMode:W?.mode,selectedRowsCount:Et.size,showExport:w,columns:t,columnFilters:Ae,columnVisibility:xt,onResetColumns:kt,exportOptions:{enabled:(ae?.enabled??!0)&&w,formats:ae?.formats??["xlsx"],filename:ae?.filename??"grid-data",onExport:zt},customLeftContent:J,customRightContent:Z,onGlobalFilterChange:et,onClearFilters:$t,onColumnFilter:ze,onColumnVisibilityChange:yt,columnOrder:mt,onColumnOrderChange:bt,pinnedColumns:ht,onScrollToColumn:e=>{const t=_t.current,r=Pe.current;if(!t)return;const n=ir.get(e);if(null==n)return;const a=Zt[n]?.width||100;let l=y?C:0;for(let e=0;e<n;e++)l+=Zt[e]?.width||100;const o=l+a,s=t.clientWidth;if(l<t.scrollLeft)t.scrollTo({left:l,behavior:"smooth"});else if(o>t.scrollLeft+s)t.scrollTo({left:o-s,behavior:"smooth"});else{const e=Math.max(0,l-Math.max(0,(s-a)/2));t.scrollTo({left:e,behavior:"smooth"})}r&&(r.scrollLeft=t.scrollLeft)},density:ve,onDensityChange:Tt,showDensityControl:x}),N.jsxs("div",{className:"flex flex-col relative flex-1 min-h-50",children:[j&&("visible"===Q||"auto"===Q&&rt.columnKeys.length>0)&&N.jsx(Re,{columns:t,groupedKeys:rt.columnKeys,onRemove:ot,onReorder:st,onDropColumnKey:lt,isAnyExpanded:rt.expanded.size>0,onToggleExpandAll:()=>{rt.expanded.size>0?ut():dt()}}),N.jsxs("div",{ref:_t,role:"grid","aria-rowcount":dr.length+1,"aria-colcount":Zt.length,"aria-label":"Data grid",className:"flex-1 overflow-auto relative [&::-webkit-scrollbar]:thin "+(K?"select-none":""),onScroll:Bt,children:[N.jsx("div",{className:"sticky top-0 z-3",children:N.jsx("div",{style:{minWidth:`${Kr+(y?C:0)}px`},children:(()=>{const t=er,r=nr.filter(e=>!Mt.has(e.key));return N.jsx(we,{pinnedColumns:t,unpinnedColumns:r,hvPadLeft:lr,hvPadRight:or,headerHeight:Ce,sortConfig:Te,columnFilters:Ae,selectable:y,selectedRows:Et,totalRows:Dt.length,data:e,onSort:Ke,onColumnFilter:ze,onSelectAll:()=>At(Et.size!==Dt.length),onColumnResize:ft,pinnedKeySet:Mt,onColumnPin:pt,groupable:j,groupedByColumn:rt.columnKeys[0]||null,groupedByColumns:rt.columnKeys,onGroupToggle:(e,t)=>t?lt(e):ot(e),onGroupBy:at,onAutosizeColumn:vt,onAutosizeAllColumns:wt,onResetColumns:kt,columnOrder:mt,onColumnOrderChange:bt,paginationMode:W?.enabled?W.mode:null,minResizeWidth:m})})()})}),N.jsx("div",{style:{minWidth:`${Kr+(y?C:0)}px`,height:Ot?Dt.length*Ne+"px":"auto"},children:Vr?G||0!==Dt.length?N.jsx("div",{style:{transform:`translateY(${Ot?Kt.offsetY:0}px)`,willChange:"transform",contain:"content"},children:(()=>{const e=[];let n=[];const a=()=>{if(!n.length)return;const t=`chunk-${hr(n[0])}-${n.length}-${Kt.offsetY}`,a=null!=wr&&n.some(e=>hr(e)===wr.rowId);e.push(N.jsx("div",{style:{opacity:G?.5:1},children:N.jsx(Se,{data:n,columns:nr,selectedRows:Et,virtualized:!1,virtualizedRange:{startIndex:0,endIndex:n.length-1,offsetY:0},rowHeight:Ne,selectable:y,isRowSelectable:b,onRowSelect:Lt,pinnedColumns:Mt,hvPadLeft:lr,hvPadRight:or,rowStyle:L,globalFilter:Ee,onContextMenu:A,onRowDoubleClick:F,onRowClick:I,onCellClick:z,onCellContextMenu:$,isCellFocused:yr,isCellSelected:pr,onCellMouseDown:br,onCellMouseEnter:vr,contextMenuItems:oe,getRowId:r,isEditing:Pr,onStartEdit:kr,onCommitEdit:Cr,onCancelEdit:Ar,editingInitialValue:a?wr?.initialValue:void 0})},t)),n=[]};for(const r of Vt)if(r._isGroupHeader)a(),e.push(N.jsx(Me,{row:r,isExpanded:rt.expanded.has(r._groupKey||""),onToggle:it,viewportWidth:ye,selectable:y,rowHeight:Ne,getHeaderLabel:e=>t.find(t=>t.key===e)?.header||e,getValueLabel:(e,r)=>{const n=t.find(t=>t.key===e);if(n?.formatter)try{return n.formatter(r)}catch(e){return String(r??"")}return String(r??"")},renderGroupActions:le},r.id));else if(r._isGroupFooter)if(a(),"chips"===ee){const t=Zt.filter(e=>!!e.aggregate&&r._groupAgg&&void 0!==r._groupAgg[e.key]).map(e=>{const t=r._groupAgg[e.key],n=e.aggregateFormatter||e.formatter,a=n?(()=>{try{return n(t)}catch{return String(t)}})():String(t);return N.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-900/40 text-blue-700 dark:text-blue-200 text-xs font-medium",title:`${e.header}`,children:[e.header,": ",a]},e.key)});e.push(N.jsx("div",{className:"sticky left-0 z-1",style:{minWidth:`${Kr+(y?C:0)}px`,height:`${Ne}px`},children:N.jsxs("div",{className:"flex items-center justify-between h-full border-t border-blue-200 dark:border-blue-800 bg-blue-50/60 dark:bg-blue-900/20 px-4",role:"contentinfo",children:[N.jsx("div",{className:"flex items-center gap-2 flex-wrap overflow-hidden",children:t.length?t:N.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"No aggregates"})}),N.jsx("span",{className:"text-[10px] uppercase tracking-wide text-blue-700 dark:text-blue-300",children:"Group Summary"})]})},r.id))}else e.push(N.jsx("div",{className:"sticky left-0 z-1 bg-blue-100 dark:bg-gray-900",style:{minWidth:`${Kr+(y?C:0)}px`,height:`${Ne}px`},children:N.jsxs("div",{className:"flex h-full border-t border-blue-200 dark:border-blue-800 bg-blue-50/60 dark:bg-blue-900/20",role:"contentinfo",children:[y&&N.jsx("div",{style:{width:C},className:"shrink-0"}),Zt.map(e=>{const t=e.width||100,n=r._groupAgg?r._groupAgg[e.key]:void 0,a=e.aggregateFormatter||e.formatter,l=void 0===n?"":a?(()=>{try{return a(n)}catch{return n}})():n;let o;if("number"==typeof l)o=Number.isInteger(l)?String(l):l.toFixed(2);else if(isNaN(l)||""===l||null===l)o=String(l??"");else{const e=Number(l);o=Number.isInteger(e)?String(e):e.toFixed(2)}return N.jsx("div",{className:"px-2 text-xs font-medium text-blue-800 dark:text-blue-200 flex items-center overflow-hidden",style:{width:t,minWidth:t,maxWidth:t},title:o?`${e.header}: ${o}`:void 0,children:N.jsx("span",{className:"truncate w-full",children:o})},`agg-cell-${r._groupKey}-${e.key}`)})]})},r.id));else n.push(r);return a(),e})()}):N.jsx(N.Fragment,{}):N.jsx(M,{})}),se?.enabled&&N.jsxs("div",{style:{minWidth:`${Kr+(y?C:0)}px`},children:[N.jsx("div",{ref:Wt,style:{height:1},"aria-hidden":!0}),se.isLoading&&N.jsx("div",{className:"flex items-center justify-center gap-3 py-4 text-sm text-gray-500 dark:text-gray-400","aria-live":"polite","aria-label":"Loading more rows",children:se.loadingRenderer?se.loadingRenderer():N.jsxs(N.Fragment,{children:[N.jsx(ce,{className:"animate-spin h-4 w-4 text-blue-500"}),N.jsx("span",{children:"Loading more rows…"})]})}),!se.isLoading&&!se.hasMore&&N.jsxs("div",{className:"flex items-center justify-center py-3 text-xs text-gray-400 dark:text-gray-600 gap-2",children:[N.jsx("span",{className:"inline-block w-12 h-px bg-gray-200 dark:bg-gray-700"}),"All rows loaded",N.jsx("span",{className:"inline-block w-12 h-px bg-gray-200 dark:bg-gray-700"})]})]})]}),qt&&N.jsx("div",{className:`pointer-events-none absolute left-0 right-0 h-1 bg-gray-200 overflow-hidden z-30 ${Xt?"opacity-0 transition-opacity duration-200":"opacity-100"} dark:bg-gray-700`,style:{top:Jt},children:N.jsx("div",{className:"h-full w-1/3 bg-blue-500 animate-[slide_1.2s_linear_infinite]"})}),!G&&0===Dt.length&&N.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 flex items-center justify-center",children:N.jsx("div",{className:"pointer-events-auto",children:N.jsx(De,{hasFilters:!!Ee||Object.keys(Ae).length>0,hasData:e.length>0,message:de,renderer:ue})})})]}),sr&&N.jsx("div",{ref:_e,className:"shrink-0 overflow-x-hidden overflow-y-visible [&::-webkit-scrollbar]:hidden",style:{scrollbarWidth:"none",msOverflowStyle:"none"},onWheel:Yt,children:N.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700",style:{minWidth:`${Kr+(y?C:0)}px`,height:`${Ne}px`},children:N.jsx(S,{columns:Zt,data:dr,selectable:y,rowHeight:Ne,pinnedColumns:Mt})})}),!se?.enabled&&N.jsx(Le,{paginationConfig:Ue,currentPage:Ue.currentPage,isServerLoading:qe,selectedRowsCount:Et.size,totalDataLength:e.length,filteredDataLength:"server"===W?.mode?void 0:Fe.length,paginationMode:W.mode,onPageChange:Xe,onPageSizeChange:Je}),fr&&N.jsx("div",{className:"fixed z-50 pointer-events-none select-none",style:{top:fr.y+12,left:fr.x+12},children:N.jsxs("div",{className:"px-2 py-1 rounded bg-gray-800 text-white text-xs shadow-lg opacity-90",children:[fr.rows," × ",fr.cols]})})]})});export{S as FooterAggregate,we as GridHeader,Se as GridRows,Kr as KDGrid,Le as PaginationControls,jr as SearchToolbar,Pr as setLicenseKey,Nr as useAdvancedFiltering,Lr as usePagination,Fr as useSelection,Ir as useVirtualization};
|
|
1
|
+
import*as e from"react";import t,{memo as r,useMemo as n,useState as a,useEffect as l,useRef as o,useCallback as s,useLayoutEffect as i,useTransition as c,useDeferredValue as d,forwardRef as u,useImperativeHandle as g}from"react";import*as m from"react-dom";import{createPortal as h}from"react-dom";var x,f={exports:{}},p={};function y(){if(x)return p;x=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(t,r,n){var a=null;if(void 0!==n&&(a=""+n),void 0!==r.key&&(a=""+r.key),"key"in r)for(var l in n={},r)"key"!==l&&(n[l]=r[l]);else n=r;return{$$typeof:e,type:t,key:a,ref:void 0!==(r=n.ref)?r:null,props:n}}return p.Fragment=t,p.jsx=r,p.jsxs=r,p}var b,v,w={};function k(){return b||(b=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===S?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case h:return"Fragment";case f:return"Profiler";case x:return"StrictMode";case v:return"Suspense";case k:return"SuspenseList";case C:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case m:return"Portal";case y:return t.displayName||"Context";case p:return(t._context.displayName||"Context")+".Consumer";case b:var r=t.render;return(t=t.displayName)||(t=""!==(t=r.displayName||r.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case j:return null!==(r=t.displayName||null)?r:e(t.type)||"Memo";case N:r=t._payload,t=t._init;try{return e(t(r))}catch(e){}}return null}function r(e){return""+e}function n(e){try{r(e);var t=!1}catch(e){t=!0}if(t){t=console;var n="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.error.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),r(e)}}function a(t){if(t===h)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===N)return"<...>";try{var r=e(t);return r?"<"+r+">":"<...>"}catch(e){return"<...>"}}function l(){return Error("react-stack-top-frame")}function o(){var t=e(this.type);return L[t]||(L[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function s(t,r,a,l,s,c){var u,m=r.children;if(void 0!==m)if(l)if(D(m)){for(l=0;l<m.length;l++)i(m[l]);Object.freeze&&Object.freeze(m)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else i(m);if(M.call(r,"key")){m=e(t);var h=Object.keys(r).filter(function(e){return"key"!==e});l=0<h.length?"{key: someKey, "+h.join(": ..., ")+": ...}":"{key: someKey}",I[m+l]||(h=0<h.length?"{"+h.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',l,m,h,m),I[m+l]=!0)}if(m=null,void 0!==a&&(n(a),m=""+a),function(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(r)&&(n(r.key),m=""+r.key),"key"in r)for(var x in a={},r)"key"!==x&&(a[x]=r[x]);else a=r;return m&&function(e,t){function r(){d||(d=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(a,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,r,n,a,l){var s=r.ref;return e={$$typeof:g,type:e,key:t,props:r,_owner:n},Object.defineProperty(e,"ref",null!==(void 0!==s?s:null)?{enumerable:!1,get:o}:{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:l}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,m,a,null===(u=R.A)?null:u.getOwner(),s,c)}function i(e){c(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===N&&("fulfilled"===e._payload.status?c(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function c(e){return"object"==typeof e&&null!==e&&e.$$typeof===g}var d,u=t,g=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),p=Symbol.for("react.consumer"),y=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),R=u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,D=Array.isArray,E=console.createTask?console.createTask:function(){return null},L={},A=(u={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(u,l)(),F=E(a(l)),I={};w.Fragment=h,w.jsx=function(e,t,r){var n=1e4>R.recentlyCreatedOwnerStacks++;return s(e,t,r,!1,n?Error("react-stack-top-frame"):A,n?E(a(e)):F)},w.jsxs=function(e,t,r){var n=1e4>R.recentlyCreatedOwnerStacks++;return s(e,t,r,!0,n?Error("react-stack-top-frame"):A,n?E(a(e)):F)}}()),w}function j(){return v||(v=1,f.exports="production"===process.env.NODE_ENV?y():k()),f.exports}var N=j();const C=48,S=r(({columns:e,data:t,selectable:r,rowHeight:a,pinnedColumns:l=new Set})=>{const o=n(()=>{const r={},n=e.filter(e=>e.footerAggregate);return 0===n.length||n.forEach(e=>{const n=t.map(t=>t[e.key]);let a=null;if("function"==typeof e.footerAggregate)try{a=e.footerAggregate(n)}catch(t){console.warn(`Error computing custom footer aggregate for column ${e.key}:`,t),a=null}else{const r=e=>!!(/^\d{4}-\d{2}-\d{2}$/.test(e)||/^\d{2}-\d{2}-\d{4}$/.test(e)||/^\d{4}\/\d{2}\/\d{2}$/.test(e)||/^\d{2}\/\d{2}\/\d{4}$/.test(e)||(e.includes("-")||e.includes("/"))&&Number.isFinite(Date.parse(e))),l=n.map(e=>{if("number"==typeof e)return e;if(null==e)return NaN;const t=String(e);if(r(t))return NaN;const n=parseFloat(t.replace(/,/g,""));return Number.isFinite(n)?n:NaN}).filter(e=>Number.isFinite(e)),o=()=>n.map(e=>{if(e instanceof Date)return e.getTime();if("string"==typeof e||"number"==typeof e){const t=Date.parse(String(e));return Number.isFinite(t)?t:NaN}return NaN}).filter(e=>Number.isFinite(e));switch(e.footerAggregate){case"count":a=t.length;break;case"sum":l.length&&(a=l.reduce((e,t)=>e+t,0));break;case"avg":l.length&&(a=l.reduce((e,t)=>e+t,0)/l.length);break;case"min":if(l.length)a=Math.min(...l);else{const e=o();e.length&&(a=new Date(Math.min(...e)))}break;case"max":if(l.length)a=Math.max(...l);else{const e=o();e.length&&(a=new Date(Math.max(...e)))}break;default:a=null}}null!=a&&(r[e.key]=a)}),r},[e,t]);if(!e.some(e=>e.footerAggregate))return null;const s=e.reduce((e,t)=>e+t.width,0),i=n(()=>{const t=new Map,n=e.filter(e=>l.has(e.key)).map(e=>e.key);let a=r?C:0;for(const r of n)t.set(r,a),a+=e.find(e=>e.key===r)?.width||100;return t},[e,l,r]);return N.jsxs("div",{className:"flex h-full",style:{minWidth:`${s+(r?C:0)}px`,height:`${a}px`},children:[r&&N.jsx("div",{className:"w-12 p-3 border-r border-gray-200 dark:border-gray-700 flex items-center justify-center sticky left-0 bg-white dark:bg-gray-900 z-30",style:{height:`${a}px`},children:N.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Total"})},"select-footer-cell"),e.map(e=>{const t=e.width,r=o[e.key],n=e.footerAggregate&&void 0!==r;let s="";if(n){const t=e.footerAggregateFormatter||e.formatter;if(t)try{s=t(r)}catch{s=String(r)}else s="number"==typeof r?r%1==0?r.toString():r.toFixed(2):String(r?.toFixed)}const c=l.has(e.key),d=c&&i.get(e.key)||0;return N.jsx("div",{className:`border-r border-gray-200 dark:border-gray-700 last:border-r-0 ${e.noPadding?"p-0":"p-3"} text-sm flex items-center font-semibold text-gray-700 dark:text-gray-200 overflow-hidden ${"center"===e.align?"justify-center":"right"===e.align?"justify-end":"justify-start"} ${"center"===e.align?"text-center":"right"===e.align?"text-right":"text-left"} ${c?"sticky bg-white dark:bg-gray-900 z-20":""}`,style:{width:`${t}px`,minWidth:`${t}px`,maxWidth:`${t}px`,left:c?`${d}px`:"auto",height:`${a}px`},title:n?`${e.header}: ${s}`:void 0,children:n&&N.jsx("span",{className:"truncate w-full",children:s})},e.key)})]})},(e,t)=>{if(e.selectable!==t.selectable)return!1;if(e.rowHeight!==t.rowHeight)return!1;if(e.getRowId!==t.getRowId)return!1;if(e.columns.length!==t.columns.length)return!1;for(let r=0;r<e.columns.length;r++){const n=e.columns[r],a=t.columns[r];if(n.key!==a.key||n.width!==a.width||n.footerAggregate!==a.footerAggregate)return!1}if(e.data.length!==t.data.length)return!1;const r=(e,t,r)=>r?r(e):void 0!==e.id?e.id:t,n=e.data.length>0?r(e.data[0],0,e.getRowId):void 0,a=t.data.length>0?r(t.data[0],0,t.getRowId):void 0,l=e.data.length-1,o=t.data.length-1,s=e.data.length>0?r(e.data[l],l,e.getRowId):void 0,i=t.data.length>0?r(t.data[o],o,t.getRowId):void 0;return n===a&&s===i&&e.pinnedColumns?.size===t.pinnedColumns?.size}),R=()=>N.jsx("svg",{className:"w-10 h-10 mb-3 opacity-90 mx-auto text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:N.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),M=()=>N.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center py-12 px-8 text-center select-none",children:[N.jsxs("div",{className:"mb-4 inline-flex items-center gap-1.5 rounded-full bg-red-100 dark:bg-red-900/30 px-3 py-1 text-xs font-semibold tracking-wide text-red-600 dark:text-red-400 uppercase",children:[N.jsx("span",{children:"⚠"}),"License Error"]}),N.jsx(R,{}),N.jsx("h3",{className:"font-bold text-base text-red-800 dark:text-red-300 mb-1",children:"react-kd-grid: Invalid or Missing License Key"}),N.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400 max-w-xs mx-auto leading-relaxed",children:["Please provide a valid"," ",N.jsx("code",{className:"font-mono bg-red-100 dark:bg-red-900/40 px-1 py-0.5 rounded text-xs",children:"licenseKey"})," ","prop to unlock the grid."]})]}),D=({size:e=16,children:t,...r})=>N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...r,children:t}),E=e=>N.jsx(D,{...e,children:N.jsx("polyline",{points:"15 18 9 12 15 6"})}),L=e=>N.jsx(D,{...e,children:N.jsx("polyline",{points:"9 18 15 12 9 6"})}),A=e=>N.jsx(D,{...e,children:N.jsx("polyline",{points:"6 9 12 15 18 9"})}),F=e=>N.jsxs(D,{...e,children:[N.jsx("polyline",{points:"11 17 6 12 11 7"}),N.jsx("polyline",{points:"18 17 13 12 18 7"})]}),I=e=>N.jsxs(D,{...e,children:[N.jsx("polyline",{points:"13 17 18 12 13 7"}),N.jsx("polyline",{points:"6 17 11 12 6 7"})]}),z=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),N.jsx("polyline",{points:"5 12 12 5 19 12"})]}),$=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),N.jsx("polyline",{points:"19 12 12 19 5 12"})]}),T=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"m21 16-4 4-4-4"}),N.jsx("path",{d:"M17 20V4"}),N.jsx("path",{d:"m3 8 4-4 4 4"}),N.jsx("path",{d:"M7 4v16"})]}),O=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),N.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),P=e=>N.jsx(D,{...e,children:N.jsx("polyline",{points:"20 6 9 17 4 12"})}),_=e=>N.jsxs(D,{...e,children:[N.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),N.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),K=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),N.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),V=e=>N.jsxs(D,{...e,children:[N.jsx("polyline",{points:"3 6 5 6 21 6"}),N.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),N.jsx("path",{d:"M10 11v6"}),N.jsx("path",{d:"M14 11v6"}),N.jsx("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),B=e=>N.jsxs(D,{...e,children:[N.jsx("polyline",{points:"21 8 21 21 3 21 3 8"}),N.jsx("rect",{x:"1",y:"3",width:"22",height:"5"}),N.jsx("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]}),W=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),N.jsx("polyline",{points:"7 10 12 15 17 10"}),N.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),H=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),N.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),N.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]}),G=e=>N.jsx(D,{...e,children:N.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),U=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M13.013 3H2l8 9.46V19l4 2v-6.54l.9-1.055"}),N.jsx("line",{x1:"22",y1:"3",x2:"11",y2:"14"})]}),Y=e=>N.jsxs(D,{...e,children:[N.jsx("circle",{cx:"12",cy:"12",r:"3"}),N.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),q=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),N.jsx("path",{d:"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"})]}),X=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),N.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),N.jsx("path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h12"}),N.jsx("path",{d:"M15 9.34V6h1a2 2 0 0 0 0-4H7.89"})]}),J=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),N.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),N.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),N.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),N.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1"})]}),Z=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),N.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),N.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),N.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),N.jsx("rect",{x:"7",y:"7",width:"4",height:"4",rx:"1"}),N.jsx("rect",{x:"13",y:"13",width:"4",height:"4",rx:"1"})]}),Q=e=>N.jsxs(D,{...e,children:[N.jsx("circle",{cx:"12",cy:"12",r:"1"}),N.jsx("circle",{cx:"19",cy:"12",r:"1"}),N.jsx("circle",{cx:"5",cy:"12",r:"1"})]}),ee=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),N.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),te=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),N.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),N.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),re=e=>N.jsxs(D,{...e,children:[N.jsx("circle",{cx:"11",cy:"11",r:"8"}),N.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),ne=e=>N.jsxs(D,{...e,children:[N.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),N.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"}),N.jsx("path",{d:"M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3"})]}),ae=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),N.jsx("polyline",{points:"14 2 14 8 20 8"}),N.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),N.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),N.jsx("polyline",{points:"10 9 9 9 8 9"})]}),le=e=>N.jsxs(D,{...e,children:[N.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),N.jsx("path",{d:"M3 9h18"}),N.jsx("path",{d:"M3 15h18"}),N.jsx("path",{d:"M9 3v18"})]}),oe=e=>N.jsxs(D,{...e,children:[N.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),N.jsx("circle",{cx:"9",cy:"7",r:"4"}),N.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),N.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),se=e=>N.jsxs(D,{...e,children:[N.jsx("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),N.jsx("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),N.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),N.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),N.jsx("circle",{cx:"12",cy:"12",r:"4"}),N.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"})]}),ie=e=>N.jsx(D,{...e,children:N.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),ce=({size:e=16,className:t,style:r,...n})=>N.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",className:t,style:r,...n,children:[N.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),N.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]}),de=({value:e,onChange:t,placeholder:r="Enter text to filter..."})=>{const[n,l]=a(String(e?.value??"")),[o,s]=a(e?.operator||"contains");return N.jsxs("div",{className:"space-y-3",children:[N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Filter Type"}),N.jsxs("select",{value:o,onChange:e=>(e=>{const r=e;s(r),n.trim()&&t({type:"text",value:n,operator:r})})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[N.jsx("option",{value:"contains",children:"Contains"}),N.jsx("option",{value:"equals",children:"Equals"}),N.jsx("option",{value:"startsWith",children:"Starts with"}),N.jsx("option",{value:"endsWith",children:"Ends with"})]})]}),N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Text Value"}),N.jsx("input",{type:"text",value:n,onChange:e=>{return l(r=e.target.value),void(r.trim()?t({type:"text",value:r,operator:o}):t(null));var r},placeholder:r,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]})]})},ue=({value:e,onChange:t,min:r,max:n})=>{const[l,o]=a(String(e?.value??"")),[s,i]=a(String(e?.secondValue??"")),[c,d]=a(e?.operator||"equals"),u=(e,r=!1)=>{r?i(e):o(e);const n=parseFloat(e),a=parseFloat(s);"between"===c?isNaN(n)||isNaN(a)?t(null):t({type:"number",value:Math.min(n,a),secondValue:Math.max(n,a),operator:"between"}):isNaN(n)?t(null):t({type:"number",value:n,operator:c})};return N.jsxs("div",{className:"space-y-3",children:[N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Filter Type"}),N.jsxs("select",{value:c,onChange:e=>(e=>{const r=e;if(d(r),"between"===r){const e=parseFloat(l),r=parseFloat(s);isNaN(e)||isNaN(r)||t({type:"number",value:Math.min(e,r),secondValue:Math.max(e,r),operator:"between"})}else{const e=parseFloat(l);isNaN(e)||t({type:"number",value:e,operator:r})}})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[N.jsx("option",{value:"equals",children:"Equals"}),N.jsx("option",{value:"gt",children:"Greater than"}),N.jsx("option",{value:"gte",children:"Greater than or equal"}),N.jsx("option",{value:"lt",children:"Less than"}),N.jsx("option",{value:"lte",children:"Less than or equal"}),N.jsx("option",{value:"between",children:"Between"})]})]}),N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"between"===c?"From Value":"Number Value"}),N.jsx("input",{type:"number",value:l,onChange:e=>u(e.target.value),min:r,max:n,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),"between"===c&&N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"To Value"}),N.jsx("input",{type:"number",value:s,onChange:e=>u(e.target.value,!0),min:r,max:n,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]})]})},ge=({name:e,label:t,value:r,onChange:n,className:a=""})=>N.jsxs("div",{className:`space-y-1 ${a}`,children:[t&&N.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:t}),N.jsx("input",{type:"date",name:e,value:r||"",onChange:e=>n(e.target.value||null),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),me=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,he=e=>{const[t,r,n]=e.split("-").map(Number);return t&&r&&n?new Date(t,r-1,n):new Date(NaN)},xe=e=>`${String(e.getDate()).padStart(2,"0")}-${String(e.getMonth()+1).padStart(2,"0")}-${e.getFullYear()}`,fe=({value:e,onChange:t,min:r,max:o})=>{const s=e=>{if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;try{const t=he(String(e));return isNaN(t.getTime())?null:t}catch(t){const r=new Date(e);return isNaN(r.getTime())?null:r}},i=e=>e?me(e):"",[c,d]=a(s(e?.value)),[u,g]=a("between"===e?.operator?s(e?.secondValue??e?.value):null),[m,h]=a(e?.operator||"between");l(()=>{h(e?.operator||"between"),d(s(e?.value)),g("between"===e?.operator?s(e?.secondValue??e?.value):null)},[e?.value,e?.secondValue,e?.operator]),l(()=>{"between"===m&&!u&&c&&g(c)},[m,c,u]);const x=(e,t,r)=>e?t&&e<t||r&&e>r?null:e:null,f=(e,r=!1)=>{const n=r?c:e,a=r?e:u,l="between"===m&&u?u:y,o=r?x(e,c??p??void 0,y):x(e,p,l);if(r?g(o):d(o),"between"===m)if(n&&a){const e=n>=a?n:a;t({type:"date",value:i(n<=a?n:a),secondValue:i(e),operator:"between"})}else t(null);else t(o?{type:"date",value:i(o),operator:m}:null)},p=n(()=>r?new Date(r):void 0,[r]),y=n(()=>o?new Date(o):void 0,[o]);return N.jsxs("div",{className:"space-y-3",children:[N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Filter Type"}),N.jsxs("select",{value:m,onChange:e=>(e=>{const r=e;h(r),"between"===r?c&&u&&t({type:"date",value:c<=u?c:u,secondValue:c>=u?c:u,operator:"between"}):c&&t({type:"date",value:c,operator:r})})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[N.jsx("option",{value:"equals",children:"On Date"}),N.jsx("option",{value:"gt",children:"After"}),N.jsx("option",{value:"gte",children:"On or After"}),N.jsx("option",{value:"lt",children:"Before"}),N.jsx("option",{value:"lte",children:"On or Before"}),N.jsx("option",{value:"between",children:"Between Dates"})]})]}),N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"between"===m?"From Date":"Date"}),N.jsx(ge,{name:"date_filter_start",value:c?me(c):null,onChange:e=>f(e?he(e):null,!1),className:"w-full"})]}),"between"===m&&N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"To Date"}),N.jsx(ge,{name:"date_filter_end",value:u?me(u):null,onChange:e=>f(e?he(e):null,!0),className:"w-full"})]})]})},pe=({value:e,onChange:t,options:r,data:o,columnKey:s})=>{const[i,c]=a(""),[d,u]=a(new Set(Array.isArray(e?.value)?e.value:[]));l(()=>{u(new Set(Array.isArray(e?.value)?e.value:[]))},[e]);const g=n(()=>{let e=[];const t=e=>null==e||""===e||"string"==typeof e&&""===e.trim();if(r&&r.length>0)e=r;else{const r=o.map(e=>{const r=e[s];return t(r)?null:r});e=[...new Set(r)].map(e=>({label:null===e?"Blank":String(e),value:e}))}const n=e.map(e=>{const r=t(e.value);return{...e,label:r?"Blank":e.label,value:r?null:e.value,isBlank:r}});return Array.from(new Map(n.map(e=>[e.isBlank?"__blank__":e.value,e])).values()).sort((e,t)=>e.isBlank&&!t.isBlank?1:!e.isBlank&&t.isBlank?-1:String(e.label).localeCompare(String(t.label)))},[r,o,s]),m=n(()=>{if(!i)return g;const e=i.toLowerCase();return g.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)||"blank"===e&&t.isBlank)},[g,i]);return N.jsxs("div",{className:"space-y-3",children:[N.jsxs("div",{className:"relative",children:[N.jsx(re,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4 dark:text-gray-500"}),N.jsx("input",{type:"text",value:i,onChange:e=>c(e.target.value),placeholder:"Search options...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),N.jsxs("div",{className:"flex justify-between items-center text-sm",children:[N.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[d.size," of ",g.length," selected"]}),N.jsxs("div",{className:"flex gap-2",children:[N.jsx("button",{onClick:()=>{const e=new Set(m.map(e=>e.value));u(e),t({type:"multiselect",value:Array.from(e),operator:"equals"})},className:"text-blue-600 hover:text-blue-800 transition-colors dark:text-blue-400",children:"Select All"}),N.jsx("button",{onClick:()=>{u(new Set),t(null)},className:"text-gray-600 hover:text-gray-800 transition-colors dark:text-gray-400",children:"Clear All"})]})]}),N.jsx("div",{className:"max-h-48 overflow-y-auto border border-gray-200 rounded-md dark:border-gray-700",children:0===m.length?N.jsx("div",{className:"p-3 text-sm text-gray-500 text-center dark:text-gray-400",children:"No options found"}):m.map((e,r)=>{const n=d.has(e.value);return N.jsxs("div",{className:`flex items-center gap-3 p-2 cursor-pointer hover:bg-gray-50 transition-colors ${n?"bg-blue-50 dark:bg-blue-900/30":""} dark:hover:bg-gray-800`,onClick:()=>(e=>{const r=new Set(d);r.has(e)?r.delete(e):r.add(e),u(r),t(r.size>0?{type:"multiselect",value:Array.from(r),operator:"equals"}:null)})(e.value),children:[N.jsx("div",{className:"w-4 h-4 border-2 rounded flex items-center justify-center "+(n?"bg-blue-600 border-blue-600 text-white":"border-gray-300 dark:border-gray-600"),children:n&&N.jsx(P,{className:"w-3 h-3"})}),N.jsx("span",{className:`text-sm ${n?"text-blue-900 dark:text-blue-100 font-medium":"text-gray-700 dark:text-gray-300"} ${e.isBlank?"italic text-gray-500 dark:text-gray-500":""}`,children:e.label})]},r)})})]})},ye=({value:e,onChange:t})=>{const[r,n]=a(void 0!==e?.value?String(e.value):"");return N.jsx("div",{className:"space-y-3",children:N.jsxs("div",{children:[N.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Boolean Value"}),N.jsxs("select",{value:r,onChange:e=>{return n(r=e.target.value),void t(""===r?null:{type:"boolean",value:"true"===r,operator:"equals"});var r},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[N.jsx("option",{value:"",children:"All values"}),N.jsx("option",{value:"true",children:"True"}),N.jsx("option",{value:"false",children:"False"})]})]})})},be=({column:e,data:t,value:r,onChange:a})=>{const l=n(()=>{if("object"==typeof e.filterable)return e.filterable;const r=t.slice(0,100).map(t=>t[e.key]).filter(e=>null!=e);if(0===r.length)return{type:"text"};const n=r[0];if("boolean"==typeof n)return{type:"boolean"};if("number"==typeof n)return{type:"number"};if(n instanceof Date||"string"==typeof n&&!isNaN(Date.parse(n)))return{type:"date"};const a=[...new Set(r)];return a.length<=20?{type:"multiselect",options:a.map(e=>({label:String(e),value:e}))}:{type:"text"}},[e.filterable,e.key,t]);switch(l.type){case"text":return N.jsx(de,{value:r,onChange:a,placeholder:l.placeholder});case"number":return N.jsx(ue,{value:r,onChange:a,min:l.min,max:l.max});case"date":return N.jsx(fe,{value:r,onChange:a,min:l.min,max:l.max});case"multiselect":return N.jsx(pe,{value:r,onChange:a,options:l.options||[],data:t,columnKey:e.key});case"boolean":return N.jsx(ye,{value:r,onChange:a});default:return null}},ve=({pinnedColumns:e,unpinnedColumns:t,hvPadLeft:r=0,hvPadRight:o=0,headerHeight:s,sortConfig:i,columnFilters:c,selectable:d,selectedRows:u,totalRows:g,data:m,onSort:h,onColumnFilter:x,onSelectAll:f,onColumnResize:p,pinnedKeySet:y=new Set,onColumnPin:b,groupable:v=!1,groupedByColumn:w,onGroupBy:k,groupedByColumns:j=[],onGroupToggle:S,onAutosizeColumn:R,onAutosizeAllColumns:M,onResetColumns:D,columnOrder:E,onColumnOrderChange:L,paginationMode:A="client",minResizeWidth:F=80})=>{const I=n(()=>[...e,...t],[e,t]),[O,P]=a(null),[_,K]=a(null),[V,B]=a(null),[W,Y]=a(0),[Q,ee]=a(0),[te,re]=a("menu"),[ne,ae]=a(null),[le,oe]=a(!1);l(()=>{oe("ontouchstart"in window||navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches)},[]);const[se,ie]=a(null),[ce,de]=a(null),ue=u.size===g&&g>0,ge=u.size>0&&u.size<g,me=(e,t)=>{if(t.stopPropagation(),O===e)P(null);else{P(e),re("menu"),ae(c[e]||null);const r=t.currentTarget.getBoundingClientRect(),n=t.currentTarget.closest("[data-grid-container]"),a=n?n.getBoundingClientRect():new DOMRect(0,0,window.innerWidth,window.innerHeight),l=10,o=Math.max(a.left+l,Math.min(r.left,a.right-320-l));K({top:r.bottom+4,left:o,containerRect:a})}},he=e=>{x(e,ne||null),P(null)},xe=e=>null!=c[e],fe=(r,n)=>{n.preventDefault(),B(r),Y(n.clientX);const a=[...e,...t].find(e=>e.key===r);ee(a?.width||100)},pe=e=>{if(!V||!p)return;const t=Math.max(F,Q+(e.clientX-W));p(V,t)},ye=()=>{B(null),Y(0),ee(0)},[ve,we]=a(null),[ke,je]=a(null),Ne=(e,t)=>{we(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},Ce=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();je({key:e,position:t.clientX<r.left+r.width/2?"before":"after"})},Se=e=>{const t=ve;if(!t||t===e)return;if(y.has(t)!==y.has(e))return we(null),void je(null);const r=ke?.key!==e||"before"===ke?.position,n=E.filter(e=>e!==t);let a=n.indexOf(e);if(-1===a)return L(n),we(null),void je(null);r||(a+=1),n.splice(a,0,t),L(n),we(null),je(null)},Re=()=>{we(null),je(null)},Me=(e,t)=>{ie(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},De=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();de({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})},Ee=e=>{const t=se;if(!t||t===e)return;if(y.has(t)!==y.has(e))return ie(null),void de(null);const r=ce?.key!==e||"before"===ce?.position,n=E.filter(e=>e!==t);let a=n.indexOf(e);if(-1===a)return L(n),ie(null),void de(null);r||(a+=1),n.splice(a,0,t),L(n),ie(null),de(null)},Le=()=>{ie(null),de(null)};return l(()=>{if(V)return document.addEventListener("mousemove",pe),document.addEventListener("mouseup",ye),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",ye),document.body.style.cursor="",document.body.style.userSelect=""}},[V,W,Q,p]),l(()=>{const e=e=>{O&&!e.target.closest("[data-column-menu]")&&P(null)};if(O)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[O]),N.jsx(N.Fragment,{children:N.jsx("div",{className:"bg-blue-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",style:{height:s},role:"row","aria-label":"Column headers",children:N.jsxs("div",{className:"flex h-full",children:[d&&N.jsx("div",{className:"px-3 border-r border-gray-200 dark:border-gray-700 flex items-center justify-center bg-blue-50 dark:bg-gray-800 sticky left-0 z-3 h-full",style:{width:C,height:s},role:"columnheader","aria-label":"Select all rows",children:N.jsx("input",{type:"checkbox",checked:ue,ref:e=>{e&&(e.indeterminate=ge)},onChange:f,onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),f())},className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 h-4 w-4 transition-all duration-150 dark:text-blue-400","aria-label":ue?"Deselect all rows":ge?`${u.size} rows selected. Click to select all`:"Select all rows",title:ue?`Deselect all ${g} rows`:ge?`${u.size} of ${g} rows selected`:`Select all ${g} rows`})}),e.map((t,r)=>{const n=y.has(t.key),a=e.filter(e=>y.has(e.key)).map(e=>e.key),l=a.indexOf(t.key),o=n?a.slice(0,l).reduce((t,r)=>{const n=e.find(e=>e.key===r);return t+(n?.width||100)},d?C:0):0,c="center"===t.headerAlign?"justify-center":"right"===t.headerAlign?"justify-end":"justify-start",u=!1!==t.sortable;return N.jsxs("div",{className:`flex-none border-r border-gray-200 dark:border-gray-700 last:border-r-0 relative ${n?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-700 sticky z-2":""} `,style:{width:t.width||100,left:n?`${o}px`:"auto",height:s},"data-column-key":t.key,draggable:!0,onDragStart:e=>Ne(t.key,e),onDragOver:e=>Ce(t.key,e),onDrop:()=>Se(t.key),onDragEnd:Re,children:[ke?.key===t.key&&N.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===ke?.position?0:void 0,right:"after"===ke?.position?0:void 0}}),N.jsx("div",{className:"px-3 h-full",children:N.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[N.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${c} ${u?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>u&&h(t.key),children:[N.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[xe(t.key)&&N.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),N.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",children:t.header})]}),u&&i.key===t.key&&N.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:N.jsx("asc"===i.direction?z:$,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(t.filterable||b||v)&&N.jsxs("div",{className:"relative "+(O===t.key||le?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[N.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:e=>me(t.key,e),"data-menu-trigger":!0,children:N.jsx(H,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),O===t.key&&_&&N.jsxs("div",{className:"fixed bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg z-1000 w-[320px] overflow-auto",style:{top:`${_.top}px`,left:`${_.left}px`,maxHeight:`${Math.max(160,_.containerRect.bottom-12-_.top)}px`},"data-column-menu":!0,children:[N.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("menu"),children:N.jsx(H,{className:"w-4 h-4"})}),t.filterable&&N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("filter"),children:N.jsx(G,{className:"w-4 h-4"})}),N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("reorder"),children:N.jsx(T,{className:"w-4 h-4"})})]}),"menu"===te&&N.jsxs("div",{className:"py-1",children:[b&&(w===t.key?N.jsxs("div",{className:"w-full px-3 py-2 text-left text-sm flex items-center gap-2 text-blue-600 dark:text-blue-400",children:[N.jsx(q,{className:"w-4 h-4"}),"Pinned by grouping"]}):N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200",onClick:e=>{e.stopPropagation(),P(null),b?.(t.key,!y.has(t.key))},children:y.has(t.key)?N.jsxs(N.Fragment,{children:[N.jsx(X,{className:"w-4 h-4"}),"Unpin Column"]}):N.jsxs(N.Fragment,{children:[N.jsx(q,{className:"w-4 h-4"}),"Pin Column"]})})),R&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{R?.(t.key),P(null)},children:"Autosize This Column"}),M&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{M?.(),P(null)},children:"Autosize All Columns"}),v&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200",onClick:e=>{e.stopPropagation(),P(null);const r=j?.includes(t.key)||w===t.key;S?S(t.key,!r):k?.(r?null:t.key)},children:w===t.key||j?.includes(t.key)?N.jsxs(N.Fragment,{children:[N.jsx(Z,{className:"w-4 h-4"}),"Ungroup"]}):N.jsxs(N.Fragment,{children:[N.jsx(J,{className:"w-4 h-4"}),"Group by ",t.header]})}),D&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{D?.(),P(null)},children:"Reset Columns"})]}),"filter"===te&&N.jsxs("div",{className:"p-3 w-full",children:[xe(t.key)&&N.jsxs("button",{className:"mb-2 text-xs text-red-600 hover:underline flex items-center gap-1 dark:text-red-400",onClick:()=>{ae(null),x(t.key,null),P(null)},children:[N.jsx(U,{className:"w-3 h-3"})," Clear Filter"]}),N.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:N.jsx(be,{column:t,data:m,value:ne,onChange:e=>{ae(e),"server"!==A&&x(t.key,e)}})}),"server"===A?N.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[N.jsx("button",{className:"px-3 py-1.5 text-sm bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-700",onClick:()=>P(null),children:"Cancel"}),N.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>he(t.key),children:"Apply"})]}):N.jsx("div",{className:"flex justify-end mt-3",children:N.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>P(null),children:"Close"})})]}),"reorder"===te&&N.jsxs("div",{className:"px-3 py-2",children:[N.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1 dark:text-gray-400",children:"Reorder Columns"}),N.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md dark:border-gray-700",children:[...E.map(e=>I.find(t=>t.key===e)).filter(Boolean),...I.filter(e=>!E.includes(e.key))].map(e=>{const t=y.has(e.key);return N.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b border-gray-100 last:border-b-0 relative ${se===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""} dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-gray-700`,draggable:!0,onDragStart:t=>Me(e.key,t),onDragOver:t=>De(e.key,t),onDrop:()=>Ee(e.key),onDragEnd:Le,children:[ce?.key===e.key&&N.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===ce?.position?0:void 0,bottom:"after"===ce?.position?0:void 0}}),N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsx("span",{className:"text-gray-400 select-none dark:text-gray-500",children:"⋮⋮"}),N.jsxs("span",{className:"text-gray-800 truncate max-w-45 dark:text-gray-200",children:[e.header,t&&N.jsx("span",{className:"ml-1 text-[10px] text-blue-600 dark:text-blue-400",children:"(pinned)"})]})]})]},e.key)})}),N.jsx("div",{className:"text-[10px] text-gray-400 mt-1 dark:text-gray-500",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<e.length-1&&p&&N.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:e=>fe(t.key,e),onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),R?.(t.key)},title:"Drag to resize • Double‑click to autosize",children:N.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},t.key+r)}),r>0&&N.jsx("div",{style:{width:r,height:s},className:"flex-none"}),t.map((e,r)=>{const n="center"===e.headerAlign?"justify-center":"right"===e.headerAlign?"justify-end":"justify-start",a=!1!==e.sortable;return N.jsxs("div",{className:"flex-none border-r border-gray-200 dark:border-gray-700 last:border-r-0 relative",style:{width:e.width||100,height:s},"data-column-key":e.key,draggable:!0,onDragStart:t=>Ne(e.key,t),onDragOver:t=>Ce(e.key,t),onDrop:()=>Se(e.key),onDragEnd:Re,children:[ke?.key===e.key&&N.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===ke?.position?0:void 0,right:"after"===ke?.position?0:void 0}}),N.jsx("div",{className:"px-3 h-full",children:N.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[N.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${n} ${a?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>a&&h(e.key),children:[N.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[xe(e.key)&&N.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),N.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",title:e.headerTooltip||e.header||"",children:e.header})]}),a&&i.key===e.key&&N.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:N.jsx("asc"===i.direction?z:$,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(e.filterable||b||v)&&N.jsxs("div",{className:"relative "+(O===e.key||le?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[N.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:t=>me(e.key,t),"data-menu-trigger":!0,children:N.jsx(H,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),O===e.key&&_&&N.jsxs("div",{className:"fixed bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg z-10 w-[320px] overflow-auto",style:{top:`${_.top}px`,left:`${_.left}px`,maxHeight:`${Math.max(160,_.containerRect.bottom-12-_.top)}px`},"data-column-menu":!0,children:[N.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("menu"),children:N.jsx(H,{className:"w-4 h-4"})}),e.filterable&&N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("filter"),children:N.jsx(G,{className:"w-4 h-4"})}),N.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===te?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>re("reorder"),children:N.jsx(T,{className:"w-4 h-4"})})]}),"menu"===te&&N.jsxs("div",{className:"py-1",children:[b&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200",onClick:t=>{t.stopPropagation(),P(null);const r=!y.has(e.key);b?.(e.key,r)},children:y.has(e.key)?N.jsxs(N.Fragment,{children:[N.jsx(X,{className:"w-4 h-4"}),"Unpin Column"]}):N.jsxs(N.Fragment,{children:[N.jsx(q,{className:"w-4 h-4"}),"Pin Column"]})}),R&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{R?.(e.key),P(null)},children:"Autosize This Column"}),M&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{M?.(),P(null)},children:"Autosize All Columns"}),v&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200 ",onClick:t=>{t.stopPropagation(),P(null);const r=j?.includes(e.key)||w===e.key;S?S(e.key,!r):k?.(r?null:e.key)},children:w===e.key||j?.includes(e.key)?N.jsxs(N.Fragment,{children:[N.jsx(Z,{className:"w-4 h-4"}),"Ungroup"]}):N.jsxs(N.Fragment,{children:[N.jsx(J,{className:"w-4 h-4"}),"Group by ",e.header]})}),D&&N.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{D?.(),P(null)},children:"Reset Columns"})]}),"filter"===te&&N.jsxs("div",{className:"p-3 w-full",children:[N.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:N.jsx(be,{column:e,data:m,value:ne,onChange:t=>{ae(t),"server"!==A&&x(e.key,t)}})}),N.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[xe(e.key)&&N.jsxs("button",{className:"px-3 py-1.5 text-sm bg-red-500 text-white rounded-md hover:bg-red-600 flex items-center gap-2 cursor-pointer",onClick:()=>{ae(null),x(e.key,null),P(null)},children:[N.jsx(U,{className:"w-3 h-3"})," Clear Filter"]}),N.jsx("button",{className:"px-3 py-1.5 text-sm bg-green-100 text-green-700 rounded-md hover:bg-green-200 cursor-pointer dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50",onClick:()=>P(null),children:"Apply"}),"server"===A&&N.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>he(e.key),children:"Apply"})]})]}),"reorder"===te&&N.jsxs("div",{className:"px-3 py-2",children:[N.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1 dark:text-gray-400",children:"Reorder Columns"}),N.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md dark:border-gray-700",children:[...E.map(e=>I.find(t=>t.key===e)).filter(Boolean),...I.filter(e=>!E.includes(e.key))].map(e=>{const t=y.has(e.key);return N.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b border-gray-100 last:border-b-0 relative ${se===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""} dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-gray-700`,draggable:!0,onDragStart:t=>Me(e.key,t),onDragOver:t=>De(e.key,t),onDrop:()=>Ee(e.key),onDragEnd:Le,children:[ce?.key===e.key&&N.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===ce?.position?0:void 0,bottom:"after"===ce?.position?0:void 0}}),N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsx("span",{className:"text-gray-400 select-none dark:text-gray-500",children:"⋮⋮"}),N.jsxs("span",{className:"text-gray-800 truncate max-w-45 dark:text-gray-200",children:[e.header,t&&N.jsx("span",{className:"ml-1 text-[10px] text-blue-600 dark:text-blue-400",children:"(pinned)"})]})]})]},e.key)})}),N.jsx("div",{className:"text-[10px] text-gray-400 mt-1 dark:text-gray-500",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<t.length-1&&p&&N.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:t=>fe(e.key,t),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),R?.(e.key)},title:"Drag to resize • Double‑click to autosize",children:N.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},e.key+r)}),o>0&&N.jsx("div",{style:{width:o,height:s},className:"flex-none"})]})})})};ve.displayName="GridHeader";const we=r(ve);N.jsx(ee,{className:"w-4 h-4"}),N.jsx(_,{className:"w-4 h-4"}),N.jsx(V,{className:"w-4 h-4"});const ke=({row:e,position:t,isVisible:r,onClose:a,menuItems:s})=>{const i=o(null);l(()=>{if(!r)return;const e=e=>{i.current&&!i.current.contains(e.target)&&a()},t=e=>{"Escape"===e.key&&a()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r,a]);const c=n(()=>{if(!r||!s?.length)return t;const e=40*s.filter(e=>!e.separator).length+10*s.filter(e=>e.separator).length,n=window.innerWidth,a=window.innerHeight;let l=t.x,o=t.y;return l+100>n&&(l=n-100-10),l-100<0&&(l=110),o+e>a&&(o=o-e-10),{x:l,y:o}},[t,r,s]);return r&&s?.length?N.jsxs(N.Fragment,{children:[N.jsx("div",{className:"fixed inset-0 z-40",onClick:a}),N.jsx("div",{ref:i,role:"menu","aria-label":"Row actions",className:"fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 min-w-[180px]",style:{left:`${c.x}px`,top:`${c.y}px`,transform:"translate(-50%, 0)"},children:s.map(t=>t.separator?N.jsx("div",{role:"separator",className:"border-t border-gray-100 dark:border-gray-700 my-1"},t.id):N.jsxs("button",{role:"menuitem",onClick:()=>(t=>{t.disabled||t.separator||(t.onClick(e),a())})(t),disabled:t.disabled,className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-left transition-colors "+(t.disabled?"text-gray-400 dark:text-gray-600 cursor-not-allowed":"delete"===t.id?"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20":"text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700"),children:[t.icon&&N.jsx("span",{className:"shrink-0",children:t.icon}),N.jsx("span",{className:"flex-1",children:t.label})]},t.id))})]}):null},je=({column:e,row:t,initialValue:r,onCommit:n,onCancel:i})=>{const[c,d]=a(null==r?"":r),u=o(!1),g=o(!1),m=o(null),h=o(null),x=o(null);l(()=>{const e=h.current??m.current??x.current;e&&(e.focus(),"select"in e&&e.select())},[]);const f=s(()=>{if(u.current||g.current)return;g.current=!0;const t="number"===e.editorType&&""!==c?Number(c):c;n(t)},[c,e.editorType,n]),p=s(()=>{u.current=!0,i()},[i]),y=s(t=>{"Enter"===t.key&&"textarea"!==e.editorType?(t.preventDefault(),t.stopPropagation(),f()):"Escape"===t.key?(t.preventDefault(),t.stopPropagation(),p()):"Tab"===t.key&&f()},[f,p,e.editorType]),b=s(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key?(e.preventDefault(),f()):"Escape"===e.key?(e.preventDefault(),p()):"Tab"===e.key&&f()},[f,p]),v=s(()=>{f()},[f]),w="w-full h-full bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 text-sm outline-none border border-blue-500 dark:border-blue-400 rounded-sm px-2 focus:ring-2 focus:ring-blue-400/30 transition-shadow";return N.jsx("div",e.editor?{className:"absolute inset-0 z-10 flex items-center",children:e.editor(c,t,n,i)}:"textarea"===e.editorType?{className:"absolute inset-0 z-10 flex items-start p-0.5",children:N.jsx("textarea",{ref:h,value:c,rows:3,className:`${w} resize-none py-1`,onChange:e=>d(e.target.value),onKeyDown:b,onBlur:v})}:"select"===e.editorType?{className:"absolute inset-0 z-10 flex items-center p-0.5",children:N.jsxs("select",{ref:x,value:c,className:`${w} cursor-pointer`,onChange:e=>{d(e.target.value)},onKeyDown:y,onBlur:v,children:[N.jsx("option",{value:"",disabled:!0,hidden:!0,children:"Select..."}),e.editorOptions?.map(e=>N.jsx("option",{value:e.value,children:e.label},String(e.value)))]})}:{className:"absolute inset-0 z-10 flex items-center p-0.5",children:N.jsx("input",{ref:m,type:e.editorType??"text",value:c,className:w,onChange:e=>d(e.target.value),onKeyDown:y,onBlur:v})})},Ne=({data:e,columns:t,selectedRows:r,virtualized:l,virtualizedRange:o,rowHeight:i,selectable:c,isRowSelectable:d,onRowSelect:u,pinnedColumns:g=new Set,hvPadLeft:m=0,hvPadRight:h=0,rowStyle:x,globalFilter:f,onContextMenu:p,onRowDoubleClick:y,onRowClick:b,onCellClick:v,isCellFocused:w,isCellSelected:k,onCellContextMenu:j,onCellMouseDown:S,onCellMouseEnter:R,contextMenuItems:M,getRowId:D,isEditing:E,onStartEdit:L,onCommitEdit:A,onCancelEdit:F,editingInitialValue:I})=>{const z=n(()=>e.length*i,[e.length,i]),{leftOffsetByPinnedKey:$}=n(()=>{if(0===g.size)return{leftOffsetByPinnedKey:new Map};const e=t.filter(e=>g.has(e.key)).map(e=>e.key),r=new Map;for(const e of t)r.set(e.key,e.width||100);const n=new Map;let a=c?C:0;for(const t of e)n.set(t,a),a+=r.get(t)||100;return{leftOffsetByPinnedKey:n}},[t,g,c]),T=n(()=>t.reduce((e,t)=>e+(g.has(t.key)?1:0),0),[t,g]),[O,P]=a(null),_=s((e,t)=>{e.preventDefault(),p?.({row:t,event:e}),M?.length&&P({row:t,x:e.clientX,y:e.clientY})},[p,M]),K=s(()=>P(null),[]);return N.jsxs(N.Fragment,{children:[N.jsx("div",{style:{height:l?`${z}px`:"auto",position:"relative"},children:N.jsx("div",{style:{transform:l?`translate3d(0, ${o.offsetY}px, 0)`:"none",position:l?"absolute":"static",top:0,left:0,right:0},children:e.map((e,n)=>{const a=l?o.startIndex+n:n,s=x?.(e),p=((e,t)=>D?D(e):void 0!==e.id?e.id:("undefined"!=typeof window&&window.KD_DEV_LOG&&0===t&&console.warn("[KDGrid] No row IDs found. Either:\n 1. Add 'id' property to each row object, or\n 2. Provide 'getRowId' prop to extract a unique identifier.\n Using row index as fallback ID, but this may cause issues with pagination/filtering."),t??0))(e,a),M=a%2==0?"bg-white dark:bg-gray-900":"bg-gray-50 dark:bg-gray-800",z=r.has(p)?"bg-blue-50 dark:bg-blue-900/20":"";return N.jsxs("div",{className:`flex border-b border-gray-100 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-900 dark:text-gray-100 ${z||(s?"":M)}`,style:{height:`${i}px`,...s},onContextMenu:t=>_(t,e),onDoubleClick:t=>((e,t)=>{y?.({row:t,event:e})})(t,e),onClick:t=>((e,t)=>{b?.({row:t,event:e})})(t,e),children:[c&&N.jsx("div",{className:"flex items-center justify-center sticky left-0 bg-inherit z-2 border-r border-gray-200 dark:border-gray-700",style:{width:C},children:N.jsx("input",{type:"checkbox",checked:r.has(p),disabled:!!d&&!d(e),onChange:e=>u(p,e.target.checked),onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),u(p,!r.has(p)))},className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 h-4 w-4 transition-all duration-150 dark:text-blue-400","aria-label":`Select row ${p}`,tabIndex:0})}),t.map((t,r)=>{const n=g.has(t.key),a=n&&$.get(t.key)||0,l=e[t.key];let o,s;if(t.cellRenderer?(o=t.cellRenderer(l,e),"string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l||(s=String(l))):t.formatter?(o=t.formatter(l),s=String(o)):(o="bigint"==typeof l?l.toString():l??"",s=o?String(o):void 0),f&&f.trim()&&!t.cellRenderer&&o){const e=String(o);((e,t)=>{if(!t||null==e)return!1;const r=t.toLowerCase().trim();return!!r&&String(e).toLowerCase().includes(r)})(e,f)&&(o=((e,t)=>{if(!t||!e)return e;const r=t.toLowerCase().trim(),n=e.toLowerCase();if(!r||!n.includes(r))return e;const a=[];let l=0,o=0,s=0;for(;-1!==(o=n.indexOf(r,l));)o>l&&a.push(e.slice(l,o)),a.push(N.jsx("mark",{className:"bg-yellow-200 dark:bg-yellow-600/40 text-current font-medium px-0.5 py-0 rounded-sm",style:{margin:0},children:e.slice(o,o+r.length)},"highlight-"+s++)),l=o+r.length;return l<e.length&&a.push(e.slice(l)),N.jsx(N.Fragment,{children:a})})(e,f))}s&&0===s.trim().length&&(s=void 0);const i="center"===t.align?"text-center":"right"===t.align?"text-right":"text-left",c="center"===t.align?"justify-center":"right"===t.align?"justify-end":"justify-start",d=t.noPadding?"p-0":"p-3",u="function"==typeof t.className?t.className(l,e):t.className||"",h="function"==typeof t.cellStyle?t.cellStyle(l,e):t.cellStyle||void 0,x="function"==typeof t.tooltip?t.tooltip(l,e):t.tooltip,y=N.jsxs("div",{title:x??("string"==typeof s?s:void 0),className:`border-r border-gray-200 dark:border-gray-700 last:border-r-0 ${d} text-sm flex items-center ${k?.(p,t.key)?"bg-blue-100/60 dark:bg-blue-900/30":""} ${n?w?.(p,t.key)||E?.(p,t.key)?"sticky z-10 bg-inherit":"sticky z-1 bg-inherit":""} ${w?.(p,t.key)||E?.(p,t.key)?"relative z-10 box-border group/cell":"relative box-border group/cell"} ${i} ${c} ${u}`,style:{width:`${t.width||100}px`,left:n?`${a}px`:"auto",...h},onClick:r=>((e,t,r,n)=>{v?.({row:t,column:r,value:n,event:e})})(r,e,t,e[t.key]),onContextMenu:r=>{e._isGroupHeader||e._isGroupFooter||j&&(r.preventDefault(),r.stopPropagation(),j({row:e,column:t,value:e[t.key],displayValue:s??"",event:r}))},onMouseDown:r=>S?.({row:e,column:t,event:r}),onMouseEnter:r=>R?.({row:e,column:t,event:r}),onDoubleClick:r=>((e,t,r)=>{L?.(t,r)})(0,e,t),children:[w?.(p,t.key)&&N.jsx("div",{className:"pointer-events-none absolute inset-0 border border-blue-400 z-10"}),E?.(p,t.key)?N.jsx(je,{column:t,row:e,initialValue:I,onCommit:A,onCancel:F}):N.jsx(N.Fragment,{children:!1===t.wrapCellContent?N.jsx(N.Fragment,{children:o}):N.jsx("div",{className:"truncate w-full",children:o})})]},`${t.key}-${r}`);return m>0&&r===T?N.jsxs(N.Fragment,{children:[N.jsx("div",{style:{width:m},className:"flex-none"}),y]}):y}),h>0&&N.jsx("div",{style:{width:h},className:"flex-none"})]},`${p}-${a}`)})})}),O&&N.jsx(ke,{row:O.row,position:{x:O.x,y:O.y},isVisible:!0,onClose:K,menuItems:M})]})},Ce=(e,t)=>{if(e.isEditing!==t.isEditing)return!1;if(e.onCommitEdit!==t.onCommitEdit)return!1;if(e.editingInitialValue!==t.editingInitialValue)return!1;if(e.rowHeight!==t.rowHeight)return!1;if(e.selectable!==t.selectable)return!1;if(e.virtualized!==t.virtualized)return!1;if(e.globalFilter!==t.globalFilter)return!1;if(e.virtualizedRange.startIndex!==t.virtualizedRange.startIndex)return!1;if(e.virtualizedRange.endIndex!==t.virtualizedRange.endIndex)return!1;if(e.virtualizedRange.offsetY!==t.virtualizedRange.offsetY)return!1;if(e.isCellSelected!==t.isCellSelected)return!1;if(e.isCellFocused!==t.isCellFocused)return!1;if(e.onCellMouseDown!==t.onCellMouseDown)return!1;if(e.onCellMouseEnter!==t.onCellMouseEnter)return!1;if(e.getRowId!==t.getRowId)return!1;if(e.selectedRows.size!==t.selectedRows.size)return!1;if(e.pinnedColumns?.size!==t.pinnedColumns?.size)return!1;if(e.rowStyle!==t.rowStyle)return!1;if(e.columns.map(e=>e.key).join("|")!==t.columns.map(e=>e.key).join("|"))return!1;if(e.data.length!==t.data.length)return!1;if(e.data===t.data)return!0;const r=(e,t,r)=>r?r(e):void 0!==e.id?e.id:t;for(let n=0;n<t.data.length;n++)if(r(e.data[n],n,e.getRowId)!==r(t.data[n],n,t.getRowId))return!1;return!0};Ne.displayName="GridRows";const Se=r(Ne,Ce),Re=({columns:e,groupedKeys:t,onRemove:r,onReorder:n,onDropColumnKey:l,onToggleExpandAll:o,isAnyExpanded:s=!1})=>{const[i,c]=a(null),[d,u]=a(null),[g,m]=a(!0),h=t=>e.find(e=>e.key===t)?.header||t,x=e=>t=>{c(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-group-key",e)},f=e=>t=>{t.preventDefault();const r=t.currentTarget.getBoundingClientRect(),n=t.clientX<r.left+r.width/2;u(e),m(n)};return N.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-gray-50 border-b border-gray-200 text-sm dark:bg-gray-800 dark:border-gray-700",onDrop:e=>{e.preventDefault();const r=e.dataTransfer.getData("text/plain");r&&(t.includes(r)||l(r))},onDragOver:e=>{e.preventDefault()},onDragEnd:()=>{c(null),u(null)},children:[N.jsx("span",{className:"text-gray-600 whitespace-nowrap dark:text-gray-400",children:"Group by:"}),t.length>0&&N.jsx("button",{type:"button",className:"ml-1 px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100 dark:border-gray-600 dark:hover:bg-gray-700",title:s?"Collapse all groups":"Expand all groups",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},children:s?"Collapse All":"Expand All"}),0===t.length&&N.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Drag a column here"}),N.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.map(e=>{return N.jsxs("div",{className:"inline-flex items-center gap-2 bg-blue-100 text-blue-800 px-2 py-1 rounded-md border border-blue-200 cursor-move relative dark:bg-blue-900/40 dark:text-blue-300 dark:border-blue-800",draggable:!0,onDragStart:x(e),onDragOver:f(e),onDrop:(a=e,()=>{if(!i||i===a)return c(null),void u(null);const e=t.filter(e=>e!==i),r=e.indexOf(a);-1!==r&&(e.splice(g?r:r+1,0,i),n(e),c(null),u(null))}),title:h(e),children:[N.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:h(e)}),N.jsx("button",{className:"text-blue-700 hover:text-blue-900 dark:text-blue-400",onClick:()=>r(e),"aria-label":`Remove grouping ${h(e)}`,children:"×"}),d===e&&N.jsx("span",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 dark:bg-blue-400 animate-pulse",style:{left:g?0:void 0,right:g?void 0:0},"aria-hidden":"true"})]},e);var a})})]})},Me=r(({row:e,isExpanded:t,onToggle:r,viewportWidth:n,selectable:a,rowHeight:l=40,getHeaderLabel:o,getValueLabel:s,renderGroupActions:i})=>{const c=()=>{e._groupKey&&r(e._groupKey)};return N.jsxs("div",{className:"flex items-center bg-blue-50 dark:bg-blue-900/20 border-b border-gray-200 dark:border-gray-800 hover:bg-blue-100/70 cursor-pointer sticky left-0 z-20 overflow-hidden",style:{minWidth:`${n+(a?C:0)}px`,height:`${l}px`},onClick:c,role:"button",tabIndex:0,"aria-expanded":t,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),c())},children:[a&&N.jsx("div",{className:"w-12 flex items-center justify-center"}),N.jsxs("div",{className:"flex items-center px-4 py-2 flex-1",children:[N.jsx("div",{className:"flex items-center mr-3",style:{paddingLeft:(e._groupLevel?16*e._groupLevel:0)+"px"},children:N.jsx(t?A:L,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:[e._groupColumnKey?`${o?o(e._groupColumnKey):e._groupColumnKey}: `:"",s&&e._groupColumnKey?s(e._groupColumnKey,e._groupValue):e._groupValue??(e._groupKey||"Unknown")]}),N.jsxs("span",{className:"text-sm text-gray-600 bg-gray-200/70 px-2 py-1 rounded-full dark:text-gray-400",children:[e._groupCount," ",1===e._groupCount?"item":"items"]})]}),i&&N.jsx("div",{className:"flex items-center px-4",onClick:e=>e.stopPropagation(),children:i({groupKey:e._groupKey||"",columnKey:e._groupColumnKey||"",groupValue:e._groupValue,rows:e._groupRows||[],count:e._groupCount||0,level:e._groupLevel||0})})]})]})}),De=({hasFilters:e=!1,hasData:t=!0,message:r,renderer:n})=>{if(n)return N.jsx(N.Fragment,{children:n()});const{title:a,description:l,icon:o}=r?{title:r,description:"",icon:ne}:t?e?{title:"No Results Found",description:"No data matches your current search criteria. Try adjusting your filters.",icon:re}:{title:"No Data to Display",description:"There are no items to show at the moment.",icon:ne}:{title:"No Data Available",description:"There is no data to display in this table.",icon:ne};return N.jsxs("div",{className:"flex flex-col items-center justify-center pt-16 pb-10 px-4 text-center",children:[N.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center mb-4",children:N.jsx(o,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),N.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:a}),N.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-md",children:l})]})},Ee=({paginationConfig:e,currentPage:t,isServerLoading:r,selectedRowsCount:n,totalDataLength:a,filteredDataLength:l,paginationMode:o="client",onPageChange:s,onPageSizeChange:i})=>{const{start:c,end:d,total:u}=(()=>{const r=e.enabled||"server"===o?e.totalRows||a:l||a;return{start:e.enabled?Math.min((t-1)*e.pageSize+1,r):1,end:e.enabled?Math.min(t*e.pageSize,r):r,total:r}})(),g="client"===o&&l&&l!==a;return N.jsx("div",{className:"px-3 sm:px-6 py-2 border-t border-gray-200 dark:border-gray-700 bg-linear-to-r from-white via-gray-50 to-white dark:from-gray-900 dark:via-gray-800 dark:to-gray-900",children:N.jsxs("div",{className:"flex flex-col xl:flex-row gap-4 xl:gap-6 xl:justify-between xl:items-center",children:[N.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4 items-start sm:items-center",children:[N.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[!e.enabled&&N.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold bg-linear-to-r from-blue-500 to-blue-600 text-white shadow-lg ring-2 ring-blue-500/20",children:[N.jsx(ne,{className:"w-3 h-3"}),N.jsxs("span",{className:"font-bold",children:[u.toLocaleString()," ",1===u?"Record":"Records"]}),g&&N.jsxs("span",{className:"text-blue-100 font-normal",children:["(of ",a.toLocaleString(),")"]})]}),n>0&&N.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold bg-blue-500 text-white ring-2 ring-blue-500/20",children:[N.jsx(oe,{className:"w-3 h-3"}),N.jsxs("span",{children:[n.toLocaleString()," selected"]})]}),g&&N.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-linear-to-r from-warning/10 to-warning/5 text-warning border border-white dark:from-warning/10 dark:to-warning/5 dark:text-warning dark:border-warning/20",children:[N.jsx(ee,{className:"w-3 h-3 dark:text-gray-300"}),N.jsx("span",{className:"dark:text-gray-300",children:"Filtered"})]}),e.enabled&&N.jsx("div",{className:"hidden sm:block text-sm text-gray-600 dark:text-gray-400 font-medium",children:N.jsxs("span",{className:"inline-flex items-center gap-1",children:[N.jsx("span",{children:"Showing"}),N.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:c.toLocaleString()}),N.jsx("span",{children:"-"}),N.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:d.toLocaleString()}),N.jsxs("span",{children:["of ",u.toLocaleString()]})]})})]}),e.enabled&&e.showPageSizeSelector&&N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 whitespace-nowrap",children:"Rows per page:"}),N.jsx("select",{value:e.pageSize,onChange:e=>i(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 rounded-xl px-3 py-1 text-sm font-medium focus:ring-2 focus:ring-primary focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed shadow-sm transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500",disabled:r,children:e.pageSizeOptions?.map(e=>N.jsx("option",{value:e,children:e},e))})]})]}),e.enabled&&N.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4",children:[r&&N.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-900/20 rounded-full border border-blue-200 dark:border-blue-800",children:[N.jsx(ie,{className:"w-4 h-4 animate-spin text-primary"}),N.jsx("span",{className:"text-sm font-medium text-primary",children:"Loading..."})]}),N.jsx("div",{className:"sm:hidden text-sm text-gray-600 dark:text-gray-400 font-medium",children:N.jsxs("div",{className:"flex flex-col gap-1",children:[N.jsxs("span",{className:"inline-flex items-center gap-1",children:[N.jsx("span",{children:"Page"}),N.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:t.toLocaleString()}),N.jsx("span",{children:"of"}),N.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:e.totalPages.toLocaleString()})]}),N.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-500",children:[c.toLocaleString()," - ",d.toLocaleString()," of"," ",u.toLocaleString()]})]})}),N.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[N.jsx("button",{onClick:()=>s(1,e.pageSize),disabled:1===t||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"First page","aria-label":"Go to first page",children:N.jsx(F,{className:"w-3.5 h-3.5"})}),N.jsx("button",{onClick:()=>s(t-1,e.pageSize),disabled:1===t||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"Previous page","aria-label":"Go to previous page",children:N.jsx(E,{className:"w-3.5 h-3.5"})}),N.jsx("div",{className:"sm:hidden",children:N.jsx("select",{value:t,onChange:t=>s(Number(t.target.value),e.pageSize),className:"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 rounded-xl px-3 py-2 text-sm font-medium focus:ring-2 focus:ring-primary focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed shadow-sm min-w-[80px]",disabled:r,"aria-label":"Select page",children:Array.from({length:e.totalPages},(e,t)=>t+1).map(e=>N.jsx("option",{value:e,children:e},e))})}),N.jsx("div",{className:"hidden sm:flex items-center gap-1 mx-2",children:(()=>{const n=[],a=e.totalPages,l=t,o="undefined"!=typeof window&&window.innerWidth>=768?7:5;if(a<=o)for(let e=1;e<=a;e++)n.push(e);else{const e=Math.floor(o/2)-1;if(l<=e+1){for(let e=1;e<=o-2;e++)n.push(e);n.push("ellipsis1"),n.push(a)}else if(l>=a-e){n.push(1),n.push("ellipsis1");for(let e=a-(o-3);e<=a;e++)n.push(e)}else{n.push(1),n.push("ellipsis1");for(let t=l-e;t<=l+e;t++)n.push(t);n.push("ellipsis2"),n.push(a)}}return n.map(t=>{if("string"==typeof t)return N.jsx("div",{className:"flex items-center justify-center w-8 h-8 text-gray-400 dark:text-gray-500 select-none","aria-hidden":"true",children:N.jsx("span",{className:"text-lg leading-none",children:"⋯"})},t);const n=t===l;return N.jsx("button",{onClick:()=>s(t,e.pageSize),disabled:r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full text-sm font-semibold transition-all duration-200 focus:ring-2 focus:ring-primary/20 focus:outline-none cursor-pointer "+(n?"bg-linear-to-r from-primary to-primary text-white shadow-lg ring-2 ring-primary/20 transform scale-105 z-10 relative bg-blue-500":"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md disabled:opacity-40 disabled:cursor-not-allowed"),"aria-label":`Go to page ${t}`,"aria-current":n?"page":void 0,children:t},t)})})()}),N.jsx("button",{onClick:()=>s(t+1,e.pageSize),disabled:t===e.totalPages||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"Next page","aria-label":"Go to next page",children:N.jsx(L,{className:"w-3.5 h-3.5"})}),N.jsx("button",{onClick:()=>s(e.totalPages,e.pageSize),disabled:t===e.totalPages||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"Last page","aria-label":"Go to last page",children:N.jsx(I,{className:"w-3.5 h-3.5"})})]})]})]})})};Ee.displayName="PaginationControls";const Le=r(Ee),Ae=({options:e,value:t,placeholder:r="Select an option...",onChange:n,searchable:s=!0,className:i=""})=>{const[c,d]=a(!1),[u,g]=a(""),[m,h]=a(-1),x=o(null),f=o(null),p=o(null),y=e.find(e=>e.value===t),b=s?e.filter(e=>e.label?.toLowerCase()?.includes(u?.toLowerCase())):e;l(()=>{const e=e=>{x.current&&!x.current.contains(e.target)&&(d(!1),g(""),h(-1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),l(()=>{const e=e=>{if(c)switch(e.key){case"ArrowDown":e.preventDefault(),h(e=>e<b.length-1?e+1:0);break;case"ArrowUp":e.preventDefault(),h(e=>e>0?e-1:b.length-1);break;case"Enter":e.preventDefault(),m>=0&&b[m]&&v(b[m].value);break;case"Escape":d(!1),g(""),h(-1)}};if(c)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[c,m,b]),l(()=>{if(m>=0&&p.current){const e=p.current.children[m];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}},[m]);const v=e=>{n(e),d(!1),g(""),h(-1)};return N.jsxs("div",{className:`relative ${i}`,ref:x,children:[N.jsx("div",{className:`relative w-full cursor-pointer border border-gray-300 rounded-lg bg-white transition-all duration-200 ${c?"ring-2 ring-blue-500 border-blue-500":"hover:border-gray-400 focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500"} dark:border-gray-600 dark:bg-gray-800`,onClick:()=>{d(!c),s&&!c&&setTimeout(()=>f.current?.focus(),0)},children:N.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5",children:[s&&c?N.jsx("input",{ref:f,type:"text",className:"flex-1 outline-none text-sm bg-transparent text-gray-900 dark:text-gray-100",placeholder:`Search ${r?.toLowerCase()}...`,value:u,onChange:e=>{g(e.target.value),h(-1),c||d(!0)},onClick:e=>e.stopPropagation()}):N.jsx("span",{className:"flex-1 text-sm truncate "+(y?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"),children:y?y.label:r}),N.jsx(A,{className:`w-4 h-4 text-gray-400 transition-transform duration-200 ${c?"rotate-180":""} dark:text-gray-400`})]})}),c&&N.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-99999 max-h-80 overflow-hidden dark:bg-gray-800 dark:border-gray-700",children:b.length>0?N.jsx("ul",{ref:p,className:"py-1 overflow-y-auto max-h-80",children:b.map((e,t)=>N.jsxs("li",{className:"px-3 py-2 text-sm cursor-pointer flex items-center justify-between transition-colors "+(t===m?"bg-blue-50 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),onClick:()=>v(e.value),onMouseEnter:()=>h(t),children:[N.jsx("span",{className:"truncate",children:e.label}),y?.value===e.value&&N.jsx(P,{className:"w-4 h-4 text-blue-600 shrink-0 ml-2 dark:text-blue-400"})]},e.value))}):N.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center dark:text-gray-400",children:"No options found"})})]})},Fe=({columns:e,columnFilters:t,onColumnFilter:r})=>{const n=e.filter(e=>e.filterable),[o,s]=a(n.length>0?n[0].key:""),[i,c]=a(""),d=n.map(e=>({label:e.header,value:e.key})),u=n.find(e=>e.key===o);return l(()=>{c("")},[o]),N.jsxs("div",{className:"space-y-4",children:[N.jsxs("div",{children:[N.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:"Select Column to Filter"}),N.jsx(Ae,{options:d,value:o,placeholder:"Choose a column...",onChange:e=>{s(e)},searchable:!0})]}),o&&(()=>{if(!u)return null;const e=u.filterable?.type||"text",n=t[o];if("multiselect"===e&&u.filterable?.options){const e=i.toLowerCase(),t=e?u.filterable.options.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)):u.filterable.options;return N.jsxs("div",{className:"mt-3",children:[N.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),N.jsxs("div",{className:"relative mb-2",children:[N.jsx(re,{className:"w-4 h-4 text-gray-400 absolute left-2 top-1/2 -translate-y-1/2 dark:text-gray-500"}),N.jsx("input",{type:"text",value:i,onChange:e=>c(e.target.value),placeholder:"Search options...",className:"w-full pl-8 pr-2 py-1.5 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"}),i&&N.jsx("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",title:"Clear search",children:N.jsx(O,{className:"w-3 h-3"})})]}),N.jsxs("div",{className:"max-h-32 overflow-y-auto border border-gray-300 rounded-md p-2 bg-white dark:border-gray-600 dark:bg-gray-800",children:[0===t.length&&N.jsx("div",{className:"text-xs text-gray-500 px-1 py-1 dark:text-gray-400",children:"No matches"}),t.map(e=>{const t=n?.value||[],a=Array.isArray(t)&&t.includes(e.value);return N.jsxs("label",{className:"flex items-center gap-2 py-1 hover:bg-gray-50 cursor-pointer dark:hover:bg-gray-700 rounded px-1",children:[N.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:text-blue-400",checked:a,onChange:t=>{const a=n?.value||[];let l;l=t.target.checked?[...a,e.value]:a.filter(t=>t!==e.value),r?.(o,l.length>0?{type:"multiselect",value:l,operator:"in"}:null)}}),N.jsx("span",{className:"text-sm dark:text-gray-300",children:e.label})]},e.value)})]})]})}if("select"===e&&u.filterable?.options){const e=[{label:`All ${u.header}`,value:""},...u.filterable.options.map(e=>({label:e.label,value:String(e.value)}))];return N.jsxs("div",{className:"mt-3",children:[N.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),N.jsx(Ae,{options:e,value:n?.value||"",placeholder:`Select ${u.header.toLowerCase()}...`,onChange:e=>{r?.(o,e?{type:"select",value:e,operator:"between"}:null)},searchable:!0})]})}if("date"===e){const e=e=>{if(!e)return null;if(e instanceof Date&&!isNaN(e.getTime()))return e;const t=he(String(e));if(!isNaN(t.getTime()))return t;const r=new Date(e);return isNaN(r.getTime())?null:r},t=e(n?.value),a=e(n?.secondValue),l=n?.operator||"between";return N.jsxs("div",{className:"mt-3",children:[N.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),N.jsx("div",{className:"mb-3",children:N.jsx(Ae,{options:[{label:"Between Dates",value:"between"},{label:"On Date",value:"equals"}],value:l,placeholder:"Select date filter...",onChange:e=>{r?.(o,{type:"date",value:n?.value||"",operator:e,secondValue:n?.secondValue||""})},searchable:!1},`date-operator-${o}-${l}`)}),N.jsxs("div",{className:"flex items-end gap-2",children:[N.jsx("div",{className:"flex-1 min-w-37.5",children:N.jsx(ge,{name:"column_filter_start",label:"between"===l?"Start Date":"Date",value:t?me(t):null,onChange:e=>{if(e){const t=me(he(e));r?.(o,{type:"date",value:t,operator:l,secondValue:n?.secondValue||null})}else r?.(o,null)},className:"w-full"})}),"between"===l&&N.jsx("div",{className:"flex-1 min-w-37.5",children:N.jsx(ge,{name:"column_filter_end",label:"End Date",value:a?me(a):null,onChange:e=>{if(e&&n){const t=me(he(e));r?.(o,{...n,secondValue:t})}},className:"w-full"})})]})]})}return N.jsxs("div",{className:"mt-3",children:[N.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),N.jsxs(N.Fragment,{children:[N.jsx("input",{type:"text",placeholder:u.filterable?.placeholder||`Filter ${u.header.toLowerCase()}...`,className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",value:n?.value||"",onChange:e=>{r?.(o,e.target.value?{type:"text",value:e.target.value,operator:"contains"}:null)}}),n&&N.jsx("div",{className:"mt-2",children:N.jsx(Ae,{options:[{label:"Contains",value:"contains"},{label:"Equals",value:"equals"},{label:"Starts with",value:"startsWith"},{label:"Ends with",value:"endsWith"}],value:n?.operator||"contains",placeholder:"Select operator...",onChange:e=>{n&&r?.(o,{...n,operator:e})},searchable:!1})})]})]})})(),Object.keys(t).length>0&&N.jsxs("div",{className:"mt-4",children:[N.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:"Active Filters"}),N.jsx("div",{className:"space-y-2",children:Object.entries(t).map(([e,t])=>{const a=n.find(t=>t.key===e);return a?N.jsxs("div",{className:"flex items-center justify-between bg-blue-50 border border-blue-200 rounded-md px-3 py-2 cursor-pointer hover:bg-blue-100 dark:bg-blue-900/20 dark:border-blue-800 dark:hover:bg-blue-900/40",role:"button",title:`Edit filter for ${a.header}`,onClick:()=>(e=>{s(e)})(e),children:[N.jsxs("div",{className:"flex-1",children:[N.jsxs("span",{className:"text-sm font-medium text-blue-900 dark:text-blue-100",children:[a.header,":"]}),N.jsx("span",{className:"text-sm text-blue-700 ml-1 dark:text-blue-300",children:(()=>{if(Array.isArray(t.value))return`${t.value.length} selected`;if("date"===t.type){const e=e=>{try{if(!e)return"";if(e instanceof Date&&!isNaN(e.getTime()))return xe(e);if("string"==typeof e){const t=he(e);if(!isNaN(t.getTime()))return xe(t);const r=new Date(e);if(!isNaN(r.getTime()))return xe(r)}return String(e)}catch{return String(e??"")}},r={equals:"On",gt:"After",gte:"On or After",lt:"Before",lte:"On or Before",between:"Between"}[t.operator]||"On";return"between"===t.operator&&t.secondValue?`${r} ${e(t.value)} - ${e(t.secondValue)}`:`${r} ${e(t.value)}`}return t.value})()})]}),N.jsx("button",{onClick:t=>{t.stopPropagation(),r?.(e,null)},className:"text-blue-400 hover:text-red-500 transition-colors",title:"Clear filter",children:N.jsx(O,{className:"w-4 h-4"})})]},e):null})})]})]})};function Ie(){return"undefined"!=typeof window}function ze(e){return Oe(e)?(e.nodeName||"").toLowerCase():"#document"}function $e(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Te(e){var t;return null==(t=(Oe(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Oe(e){return!!Ie()&&(e instanceof Node||e instanceof $e(e).Node)}function Pe(e){return!!Ie()&&(e instanceof Element||e instanceof $e(e).Element)}function _e(e){return!!Ie()&&(e instanceof HTMLElement||e instanceof $e(e).HTMLElement)}function Ke(e){return!(!Ie()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof $e(e).ShadowRoot)}const Ve=new Set(["inline","contents"]);function Be(e){const{overflow:t,overflowX:r,overflowY:n,display:a}=tt(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!Ve.has(a)}const We=new Set(["table","td","th"]);function He(e){return We.has(ze(e))}const Ge=[":popover-open",":modal"];function Ue(e){return Ge.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const Ye=["transform","translate","scale","rotate","perspective"],qe=["transform","translate","scale","rotate","perspective","filter"],Xe=["paint","layout","strict","content"];function Je(e){const t=Ze(),r=Pe(e)?tt(e):e;return Ye.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||qe.some(e=>(r.willChange||"").includes(e))||Xe.some(e=>(r.contain||"").includes(e))}function Ze(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Qe=new Set(["html","body","#document"]);function et(e){return Qe.has(ze(e))}function tt(e){return $e(e).getComputedStyle(e)}function rt(e){return Pe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nt(e){if("html"===ze(e))return e;const t=e.assignedSlot||e.parentNode||Ke(e)&&e.host||Te(e);return Ke(t)?t.host:t}function at(e){const t=nt(e);return et(t)?e.ownerDocument?e.ownerDocument.body:e.body:_e(t)&&Be(t)?t:at(t)}function lt(e,t,r){var n;void 0===t&&(t=[]),void 0===r&&(r=!0);const a=at(e),l=a===(null==(n=e.ownerDocument)?void 0:n.body),o=$e(a);if(l){const e=ot(o);return t.concat(o,o.visualViewport||[],Be(a)?a:[],e&&r?lt(e):[])}return t.concat(a,lt(a,[],r))}function ot(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const st=Math.min,it=Math.max,ct=Math.round,dt=Math.floor,ut=e=>({x:e,y:e}),gt={left:"right",right:"left",bottom:"top",top:"bottom"},mt={start:"end",end:"start"};function ht(e,t,r){return it(e,st(t,r))}function xt(e,t){return"function"==typeof e?e(t):e}function ft(e){return e.split("-")[0]}function pt(e){return e.split("-")[1]}function yt(e){return"x"===e?"y":"x"}function bt(e){return"y"===e?"height":"width"}const vt=new Set(["top","bottom"]);function wt(e){return vt.has(ft(e))?"y":"x"}function kt(e){return yt(wt(e))}function jt(e){return e.replace(/start|end/g,e=>mt[e])}const Nt=["left","right"],Ct=["right","left"],St=["top","bottom"],Rt=["bottom","top"];function Mt(e){return e.replace(/left|right|bottom|top/g,e=>gt[e])}function Dt(e){const{x:t,y:r,width:n,height:a}=e;return{width:n,height:a,top:r,left:t,right:t+n,bottom:r+a,x:t,y:r}}var Et="undefined"!=typeof document?i:function(){};const Lt={...e}.useInsertionEffect||(e=>e());function At(e,t,r){let{reference:n,floating:a}=e;const l=wt(t),o=kt(t),s=bt(o),i=ft(t),c="y"===l,d=n.x+n.width/2-a.width/2,u=n.y+n.height/2-a.height/2,g=n[s]/2-a[s]/2;let m;switch(i){case"top":m={x:d,y:n.y-a.height};break;case"bottom":m={x:d,y:n.y+n.height};break;case"right":m={x:n.x+n.width,y:u};break;case"left":m={x:n.x-a.width,y:u};break;default:m={x:n.x,y:n.y}}switch(pt(t)){case"start":m[o]-=g*(r&&c?-1:1);break;case"end":m[o]+=g*(r&&c?-1:1)}return m}async function Ft(e,t){var r;void 0===t&&(t={});const{x:n,y:a,platform:l,rects:o,elements:s,strategy:i}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:g=!1,padding:m=0}=xt(t,e),h=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(m),x=s[g?"floating"===u?"reference":"floating":u],f=Dt(await l.getClippingRect({element:null==(r=await(null==l.isElement?void 0:l.isElement(x)))||r?x:x.contextElement||await(null==l.getDocumentElement?void 0:l.getDocumentElement(s.floating)),boundary:c,rootBoundary:d,strategy:i})),p="floating"===u?{x:n,y:a,width:o.floating.width,height:o.floating.height}:o.reference,y=await(null==l.getOffsetParent?void 0:l.getOffsetParent(s.floating)),b=await(null==l.isElement?void 0:l.isElement(y))&&await(null==l.getScale?void 0:l.getScale(y))||{x:1,y:1},v=Dt(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:p,offsetParent:y,strategy:i}):p);return{top:(f.top-v.top+h.top)/b.y,bottom:(v.bottom-f.bottom+h.bottom)/b.y,left:(f.left-v.left+h.left)/b.x,right:(v.right-f.right+h.right)/b.x}}const It=new Set(["left","top"]);function zt(e){const t=tt(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const a=_e(e),l=a?e.offsetWidth:r,o=a?e.offsetHeight:n,s=ct(r)!==l||ct(n)!==o;return s&&(r=l,n=o),{width:r,height:n,$:s}}function $t(e){return Pe(e)?e:e.contextElement}function Tt(e){const t=$t(e);if(!_e(t))return ut(1);const r=t.getBoundingClientRect(),{width:n,height:a,$:l}=zt(t);let o=(l?ct(r.width):r.width)/n,s=(l?ct(r.height):r.height)/a;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}const Ot=ut(0);function Pt(e){const t=$e(e);return Ze()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Ot}function _t(e,t,r,n){void 0===t&&(t=!1),void 0===r&&(r=!1);const a=e.getBoundingClientRect(),l=$t(e);let o=ut(1);t&&(n?Pe(n)&&(o=Tt(n)):o=Tt(e));const s=function(e,t,r){return void 0===t&&(t=!1),!(!r||t&&r!==$e(e))&&t}(l,r,n)?Pt(l):ut(0);let i=(a.left+s.x)/o.x,c=(a.top+s.y)/o.y,d=a.width/o.x,u=a.height/o.y;if(l){const e=$e(l),t=n&&Pe(n)?$e(n):n;let r=e,a=ot(r);for(;a&&n&&t!==r;){const e=Tt(a),t=a.getBoundingClientRect(),n=tt(a),l=t.left+(a.clientLeft+parseFloat(n.paddingLeft))*e.x,o=t.top+(a.clientTop+parseFloat(n.paddingTop))*e.y;i*=e.x,c*=e.y,d*=e.x,u*=e.y,i+=l,c+=o,r=$e(a),a=ot(r)}}return Dt({width:d,height:u,x:i,y:c})}function Kt(e,t){const r=rt(e).scrollLeft;return t?t.left+r:_t(Te(e)).left+r}function Vt(e,t){const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-Kt(e,r),y:r.top+t.scrollTop}}const Bt=new Set(["absolute","fixed"]);function Wt(e,t,r){let n;if("viewport"===t)n=function(e,t){const r=$e(e),n=Te(e),a=r.visualViewport;let l=n.clientWidth,o=n.clientHeight,s=0,i=0;if(a){l=a.width,o=a.height;const e=Ze();(!e||e&&"fixed"===t)&&(s=a.offsetLeft,i=a.offsetTop)}const c=Kt(n);if(c<=0){const e=n.ownerDocument,t=e.body,r=getComputedStyle(t),a="CSS1Compat"===e.compatMode&&parseFloat(r.marginLeft)+parseFloat(r.marginRight)||0,o=Math.abs(n.clientWidth-t.clientWidth-a);o<=25&&(l-=o)}else c<=25&&(l+=c);return{width:l,height:o,x:s,y:i}}(e,r);else if("document"===t)n=function(e){const t=Te(e),r=rt(e),n=e.ownerDocument.body,a=it(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),l=it(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let o=-r.scrollLeft+Kt(e);const s=-r.scrollTop;return"rtl"===tt(n).direction&&(o+=it(t.clientWidth,n.clientWidth)-a),{width:a,height:l,x:o,y:s}}(Te(e));else if(Pe(t))n=function(e,t){const r=_t(e,!0,"fixed"===t),n=r.top+e.clientTop,a=r.left+e.clientLeft,l=_e(e)?Tt(e):ut(1);return{width:e.clientWidth*l.x,height:e.clientHeight*l.y,x:a*l.x,y:n*l.y}}(t,r);else{const r=Pt(e);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Dt(n)}function Ht(e,t){const r=nt(e);return!(r===t||!Pe(r)||et(r))&&("fixed"===tt(r).position||Ht(r,t))}function Gt(e,t,r){const n=_e(t),a=Te(t),l="fixed"===r,o=_t(e,!0,l,t);let s={scrollLeft:0,scrollTop:0};const i=ut(0);function c(){i.x=Kt(a)}if(n||!n&&!l)if(("body"!==ze(t)||Be(a))&&(s=rt(t)),n){const e=_t(t,!0,l,t);i.x=e.x+t.clientLeft,i.y=e.y+t.clientTop}else a&&c();l&&!n&&a&&c();const d=!a||n||l?ut(0):Vt(a,s);return{x:o.left+s.scrollLeft-i.x-d.x,y:o.top+s.scrollTop-i.y-d.y,width:o.width,height:o.height}}function Ut(e){return"static"===tt(e).position}function Yt(e,t){if(!_e(e)||"fixed"===tt(e).position)return null;if(t)return t(e);let r=e.offsetParent;return Te(e)===r&&(r=r.ownerDocument.body),r}function qt(e,t){const r=$e(e);if(Ue(e))return r;if(!_e(e)){let t=nt(e);for(;t&&!et(t);){if(Pe(t)&&!Ut(t))return t;t=nt(t)}return r}let n=Yt(e,t);for(;n&&He(n)&&Ut(n);)n=Yt(n,t);return n&&et(n)&&Ut(n)&&!Je(n)?r:n||function(e){let t=nt(e);for(;_e(t)&&!et(t);){if(Je(t))return t;if(Ue(t))return null;t=nt(t)}return null}(e)||r}const Xt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:r,offsetParent:n,strategy:a}=e;const l="fixed"===a,o=Te(n),s=!!t&&Ue(t.floating);if(n===o||s&&l)return r;let i={scrollLeft:0,scrollTop:0},c=ut(1);const d=ut(0),u=_e(n);if((u||!u&&!l)&&(("body"!==ze(n)||Be(o))&&(i=rt(n)),_e(n))){const e=_t(n);c=Tt(n),d.x=e.x+n.clientLeft,d.y=e.y+n.clientTop}const g=!o||u||l?ut(0):Vt(o,i);return{width:r.width*c.x,height:r.height*c.y,x:r.x*c.x-i.scrollLeft*c.x+d.x+g.x,y:r.y*c.y-i.scrollTop*c.y+d.y+g.y}},getDocumentElement:Te,getClippingRect:function(e){let{element:t,boundary:r,rootBoundary:n,strategy:a}=e;const l=[..."clippingAncestors"===r?Ue(t)?[]:function(e,t){const r=t.get(e);if(r)return r;let n=lt(e,[],!1).filter(e=>Pe(e)&&"body"!==ze(e)),a=null;const l="fixed"===tt(e).position;let o=l?nt(e):e;for(;Pe(o)&&!et(o);){const t=tt(o),r=Je(o);r||"fixed"!==t.position||(a=null),(l?!r&&!a:!r&&"static"===t.position&&a&&Bt.has(a.position)||Be(o)&&!r&&Ht(e,o))?n=n.filter(e=>e!==o):a=t,o=nt(o)}return t.set(e,n),n}(t,this._c):[].concat(r),n],o=l.reduce((e,r)=>{const n=Wt(t,r,a);return e.top=it(n.top,e.top),e.right=st(n.right,e.right),e.bottom=st(n.bottom,e.bottom),e.left=it(n.left,e.left),e},Wt(t,l[0],a));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:qt,getElementRects:async function(e){const t=this.getOffsetParent||qt,r=this.getDimensions,n=await r(e.floating);return{reference:Gt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:r}=zt(e);return{width:t,height:r}},getScale:Tt,isElement:Pe,isRTL:function(e){return"rtl"===tt(e).direction}};function Jt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zt(e,t,r,n){void 0===n&&(n={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:i=!1}=n,c=$t(e),d=a||l?[...c?lt(c):[],...lt(t)]:[];d.forEach(e=>{a&&e.addEventListener("scroll",r,{passive:!0}),l&&e.addEventListener("resize",r)});const u=c&&s?function(e,t){let r,n=null;const a=Te(e);function l(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return function o(s,i){void 0===s&&(s=!1),void 0===i&&(i=1),l();const c=e.getBoundingClientRect(),{left:d,top:u,width:g,height:m}=c;if(s||t(),!g||!m)return;const h={rootMargin:-dt(u)+"px "+-dt(a.clientWidth-(d+g))+"px "+-dt(a.clientHeight-(u+m))+"px "+-dt(d)+"px",threshold:it(0,st(1,i))||1};let x=!0;function f(t){const n=t[0].intersectionRatio;if(n!==i){if(!x)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==n||Jt(c,e.getBoundingClientRect())||o(),x=!1}try{n=new IntersectionObserver(f,{...h,root:a.ownerDocument})}catch(e){n=new IntersectionObserver(f,h)}n.observe(e)}(!0),l}(c,r):null;let g,m=-1,h=null;o&&(h=new ResizeObserver(e=>{let[n]=e;n&&n.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var e;null==(e=h)||e.observe(t)})),r()}),c&&!i&&h.observe(c),h.observe(t));let x=i?_t(e):null;return i&&function t(){const n=_t(e);x&&!Jt(x,n)&&r(),x=n,g=requestAnimationFrame(t)}(),r(),()=>{var e;d.forEach(e=>{a&&e.removeEventListener("scroll",r),l&&e.removeEventListener("resize",r)}),null==u||u(),null==(e=h)||e.disconnect(),h=null,i&&cancelAnimationFrame(g)}}const Qt=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:a,y:l,placement:o,middlewareData:s}=t,i=await async function(e,t){const{placement:r,platform:n,elements:a}=e,l=await(null==n.isRTL?void 0:n.isRTL(a.floating)),o=ft(r),s=pt(r),i="y"===wt(r),c=It.has(o)?-1:1,d=l&&i?-1:1,u=xt(t,e);let{mainAxis:g,crossAxis:m,alignmentAxis:h}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&"number"==typeof h&&(m="end"===s?-1*h:h),i?{x:m*d,y:g*c}:{x:g*c,y:m*d}}(t,e);return o===(null==(r=s.offset)?void 0:r.placement)&&null!=(n=s.arrow)&&n.alignmentOffset?{}:{x:a+i.x,y:l+i.y,data:{...i,placement:o}}}}},er=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:a,platform:l}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:i={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...c}=xt(e,t),d={x:r,y:n},u=await l.detectOverflow(t,c),g=wt(ft(a)),m=yt(g);let h=d[m],x=d[g];o&&(h=ht(h+u["y"===m?"top":"left"],h,h-u["y"===m?"bottom":"right"])),s&&(x=ht(x+u["y"===g?"top":"left"],x,x-u["y"===g?"bottom":"right"]));const f=i.fn({...t,[m]:h,[g]:x});return{...f,data:{x:f.x-r,y:f.y-n,enabled:{[m]:o,[g]:s}}}}}},tr=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:a,middlewareData:l,rects:o,initialPlacement:s,platform:i,elements:c}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:g,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:x=!0,...f}=xt(e,t);if(null!=(r=l.arrow)&&r.alignmentOffset)return{};const p=ft(a),y=wt(s),b=ft(s)===s,v=await(null==i.isRTL?void 0:i.isRTL(c.floating)),w=g||(b||!x?[Mt(s)]:function(e){const t=Mt(e);return[jt(e),t,jt(t)]}(s)),k="none"!==h;!g&&k&&w.push(...function(e,t,r,n){const a=pt(e);let l=function(e,t,r){switch(e){case"top":case"bottom":return r?t?Ct:Nt:t?Nt:Ct;case"left":case"right":return t?St:Rt;default:return[]}}(ft(e),"start"===r,n);return a&&(l=l.map(e=>e+"-"+a),t&&(l=l.concat(l.map(jt)))),l}(s,x,h,v));const j=[s,...w],N=await i.detectOverflow(t,f),C=[];let S=(null==(n=l.flip)?void 0:n.overflows)||[];if(d&&C.push(N[p]),u){const e=function(e,t,r){void 0===r&&(r=!1);const n=pt(e),a=kt(e),l=bt(a);let o="x"===a?n===(r?"end":"start")?"right":"left":"start"===n?"bottom":"top";return t.reference[l]>t.floating[l]&&(o=Mt(o)),[o,Mt(o)]}(a,o,v);C.push(N[e[0]],N[e[1]])}if(S=[...S,{placement:a,overflows:C}],!C.every(e=>e<=0)){var R,M;const e=((null==(R=l.flip)?void 0:R.index)||0)+1,t=j[e];if(t&&("alignment"!==u||y===wt(t)||S.every(e=>wt(e.placement)!==y||e.overflows[0]>0)))return{data:{index:e,overflows:S},reset:{placement:t}};let r=null==(M=S.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:M.placement;if(!r)switch(m){case"bestFit":{var D;const e=null==(D=S.filter(e=>{if(k){const t=wt(e.placement);return t===y||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:D[0];e&&(r=e);break}case"initialPlacement":r=s}if(a!==r)return{reset:{placement:r}}}return{}}}},rr=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:a,rects:l,platform:o,elements:s}=t,{apply:i=()=>{},...c}=xt(e,t),d=await o.detectOverflow(t,c),u=ft(a),g=pt(a),m="y"===wt(a),{width:h,height:x}=l.floating;let f,p;"top"===u||"bottom"===u?(f=u,p=g===(await(null==o.isRTL?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(p=u,f="end"===g?"top":"bottom");const y=x-d.top-d.bottom,b=h-d.left-d.right;let v=st(x-d[f],y),w=st(h-d[p],b);if(null!=(r=t.middlewareData.shift)&&r.enabled.x&&(w=b),null!=(n=t.middlewareData.shift)&&n.enabled.y&&(v=y),!t.middlewareData.shift&&!g){const e=it(d.left,0),t=it(d.right,0),r=it(d.top,0),n=it(d.bottom,0);m?w=h-2*(0!==e||0!==t?e+t:it(d.left,d.right)):v=x-2*(0!==r||0!==n?r+n:it(d.top,d.bottom))}await i({...t,availableWidth:w,availableHeight:v});const k=await o.getDimensions(s.floating);return h!==k.width||x!==k.height?{reset:{rects:!0}}:{}}}},nr=(e,t,r)=>{const n=new Map,a={platform:Xt,...r},l={...a.platform,_c:n};return(async(e,t,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:l=[],platform:o}=r,s=l.filter(Boolean),i=await(null==o.isRTL?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:u}=At(c,n,i),g=n,m={},h=0;for(let r=0;r<s.length;r++){var x;const{name:l,fn:f}=s[r],{x:p,y:y,data:b,reset:v}=await f({x:d,y:u,initialPlacement:n,placement:g,strategy:a,middlewareData:m,rects:c,platform:{...o,detectOverflow:null!=(x=o.detectOverflow)?x:Ft},elements:{reference:e,floating:t}});d=null!=p?p:d,u=null!=y?y:u,m={...m,[l]:{...m[l],...b}},v&&h<=50&&(h++,"object"==typeof v&&(v.placement&&(g=v.placement),v.rects&&(c=!0===v.rects?await o.getElementRects({reference:e,floating:t,strategy:a}):v.rects),({x:d,y:u}=At(c,g,i))),r=-1)}return{x:d,y:u,placement:g,strategy:a,middlewareData:m}})(e,t,{...a,platform:l})};var ar="undefined"!=typeof document?i:function(){};function lr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let r,n,a;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;0!==n--;)if(!lr(e[n],t[n]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(t).length)return!1;for(n=r;0!==n--;)if(!{}.hasOwnProperty.call(t,a[n]))return!1;for(n=r;0!==n--;){const r=a[n];if(!("_owner"===r&&e.$$typeof||lr(e[r],t[r])))return!1}return!0}return e!=e&&t!=t}function or(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function sr(e,t){const r=or(e);return Math.round(t*r)/r}function ir(t){const r=e.useRef(t);return ar(()=>{r.current=t}),r}const cr=(e,t)=>({...Qt(e),options:[e,t]}),dr=(e,t)=>({...er(e),options:[e,t]}),ur=(e,t)=>({...rr(e),options:[e,t]}),gr={...e};let mr=!1,hr=0;const xr=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+hr++,fr=gr.useId||function(){const[t,r]=e.useState(()=>mr?xr():void 0);return Et(()=>{null==t&&r(xr())},[]),e.useEffect(()=>{mr=!0},[]),t};let pr;"production"!==process.env.NODE_ENV&&(pr=new Set);const yr=e.createContext(null),br=e.createContext(null);function vr(t){void 0===t&&(t={});const{nodeId:r}=t,n=function(t){const{open:r=!1,onOpenChange:n,elements:a}=t,l=fr(),o=e.useRef({}),[s]=e.useState(()=>function(){const e=new Map;return{emit(t,r){var n;null==(n=e.get(t))||n.forEach(e=>e(r))},on(t,r){e.has(t)||e.set(t,new Set),e.get(t).add(r)},off(t,r){var n;null==(n=e.get(t))||n.delete(r)}}}()),i=null!=((null==(c=e.useContext(yr))?void 0:c.id)||null);var c;if("production"!==process.env.NODE_ENV){const e=a.reference;e&&!Pe(e)&&function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];const a="Floating UI: "+r.join(" ");var l;null!=(e=pr)&&e.has(a)||(null==(l=pr)||l.add(a),console.error(a))}("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[d,u]=e.useState(a.reference),g=function(t){const r=e.useRef(()=>{if("production"!==process.env.NODE_ENV)throw new Error("Cannot call an event handler while rendering.")});return Lt(()=>{r.current=t}),e.useCallback(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return null==r.current?void 0:r.current(...t)},[])}((e,t,r)=>{o.current.openEvent=e?t:void 0,s.emit("openchange",{open:e,event:t,reason:r,nested:i}),null==n||n(e,t,r)}),m=e.useMemo(()=>({setPositionReference:u}),[]),h=e.useMemo(()=>({reference:d||a.reference||null,floating:a.floating||null,domReference:a.reference}),[d,a.reference,a.floating]);return e.useMemo(()=>({dataRef:o,open:r,onOpenChange:g,elements:h,events:s,floatingId:l,refs:m}),[r,g,h,s,l,m])}({...t,elements:{reference:null,floating:null,...t.elements}}),a=t.rootContext||n,l=a.elements,[o,s]=e.useState(null),[i,c]=e.useState(null),d=(null==l?void 0:l.domReference)||o,u=e.useRef(null),g=e.useContext(br);Et(()=>{d&&(u.current=d)},[d]);const h=function(t){void 0===t&&(t={});const{placement:r="bottom",strategy:n="absolute",middleware:a=[],platform:l,elements:{reference:o,floating:s}={},transform:i=!0,whileElementsMounted:c,open:d}=t,[u,g]=e.useState({x:0,y:0,strategy:n,placement:r,middlewareData:{},isPositioned:!1}),[h,x]=e.useState(a);lr(h,a)||x(a);const[f,p]=e.useState(null),[y,b]=e.useState(null),v=e.useCallback(e=>{e!==N.current&&(N.current=e,p(e))},[]),w=e.useCallback(e=>{e!==C.current&&(C.current=e,b(e))},[]),k=o||f,j=s||y,N=e.useRef(null),C=e.useRef(null),S=e.useRef(u),R=null!=c,M=ir(c),D=ir(l),E=ir(d),L=e.useCallback(()=>{if(!N.current||!C.current)return;const e={placement:r,strategy:n,middleware:h};D.current&&(e.platform=D.current),nr(N.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==E.current};A.current&&!lr(S.current,t)&&(S.current=t,m.flushSync(()=>{g(t)}))})},[h,r,n,D,E]);ar(()=>{!1===d&&S.current.isPositioned&&(S.current.isPositioned=!1,g(e=>({...e,isPositioned:!1})))},[d]);const A=e.useRef(!1);ar(()=>(A.current=!0,()=>{A.current=!1}),[]),ar(()=>{if(k&&(N.current=k),j&&(C.current=j),k&&j){if(M.current)return M.current(k,j,L);L()}},[k,j,L,M,R]);const F=e.useMemo(()=>({reference:N,floating:C,setReference:v,setFloating:w}),[v,w]),I=e.useMemo(()=>({reference:k,floating:j}),[k,j]),z=e.useMemo(()=>{const e={position:n,left:0,top:0};if(!I.floating)return e;const t=sr(I.floating,u.x),r=sr(I.floating,u.y);return i?{...e,transform:"translate("+t+"px, "+r+"px)",...or(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,i,I.floating,u.x,u.y]);return e.useMemo(()=>({...u,update:L,refs:F,elements:I,floatingStyles:z}),[u,L,F,I,z])}({...t,elements:{...l,...i&&{reference:i}}}),x=e.useCallback(e=>{const t=Pe(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;c(t),h.refs.setReference(t)},[h.refs]),f=e.useCallback(e=>{(Pe(e)||null===e)&&(u.current=e,s(e)),(Pe(h.refs.reference.current)||null===h.refs.reference.current||null!==e&&!Pe(e))&&h.refs.setReference(e)},[h.refs]),p=e.useMemo(()=>({...h.refs,setReference:f,setPositionReference:x,domReference:u}),[h.refs,f,x]),y=e.useMemo(()=>({...h.elements,domReference:d}),[h.elements,d]),b=e.useMemo(()=>({...h,...a,refs:p,elements:y,nodeId:r}),[h,p,y,r,a]);return Et(()=>{a.dataRef.current.floatingContext=b;const e=null==g?void 0:g.nodesRef.current.find(e=>e.id===r);e&&(e.context=b)}),e.useMemo(()=>({...h,context:b,refs:p,elements:y}),[h,p,y,b])}var wr=({open:e,anchorEl:t,onClose:r,placement:n="bottom-start",offset:a=8,sameWidth:o=!1,maxHeight:s,zIndex:i=1e3,className:c,children:d,shouldIgnoreClose:u})=>{const{refs:g,floatingStyles:m,update:x}=vr({placement:n,whileElementsMounted:Zt,middleware:[cr(a),(f={padding:8},{...tr(f),options:[f,void 0]}),dr({padding:8}),ur({apply({rects:e,elements:t,availableHeight:r,availableWidth:n}){const a=t.floating;a&&(o&&(a.style.width=`${e.reference.width}px`),a.style.maxHeight=null!=s?"number"==typeof s?`${s}px`:String(s):`${r}px`,null!=n&&(a.style.maxWidth=`${n}px`))}})]});var f;return l(()=>{t&&g.setReference(t),e&&x&&x()},[t,e,g,x]),l(()=>{if(!e)return;const n=e=>{const n=e.target;if(u&&u(n))return;const a=g.floating.current;a&&(t&&t.contains(n)||a&&a.contains(n)||r())},a=e=>{"Escape"===e.key&&r()};return document.addEventListener("mousedown",n),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",a)}},[e,r,g.floating,t]),e&&t?h(N.jsx("div",{ref:g.setFloating,"data-popover-root":"true",style:{...m,zIndex:i,position:m.position,overflowX:"hidden"},className:c,children:d}),document.body):null};const kr=({globalFilter:e,filteredDataLength:t,totalDataLength:r,selectedRowsCount:s=0,selectedRows:i=new Set,showExport:c=!0,showColumnToggle:d=!0,showBulkActions:u=!0,columns:g=[],columnVisibility:m={},columnFilters:h={},bulkActions:x=[],exportOptions:f,onGlobalFilterChange:p,onClearFilters:y,onColumnVisibilityChange:b,onColumnFilter:v,onResetColumns:w,columnOrder:k=[],onColumnOrderChange:j,pinnedColumns:C,onScrollToColumn:S,density:R="md",onDensityChange:M,showDensityControl:D=!1,customLeftContent:E,customRightContent:L})=>{const[A,F]=a(!1),[I,z]=a(!1),[$,T]=a(!1),[P,H]=a(!1),[U,q]=a(""),[X,J]=a(null),[Z,oe]=a(null),ie=o(null),ce=o(null),de=o(null),ue=o(null),ge=o(null),me=o(null),he=o(null),xe=o(null),fe=o(null);l(()=>{const e=e=>{(e=>{let t=e;for(;t;){if(t.getAttribute&&"true"===t.getAttribute("data-popover-root")||t.dataset&&"true"===t.dataset.popoverRoot)return!0;t=t.parentNode}return!1})(e.target)||(ce.current&&!ce.current.contains(e.target)&&F(!1),de.current&&!de.current.contains(e.target)&&T(!1),ue.current&&!ue.current.contains(e.target)&&H(!1),!ge.current||ge.current.contains(e.target)||(e=>{let t=e;for(;t;){if(t.classList){const e=Array.from(t.classList).join(" ");if(/MuiPickers|MuiDatePicker|MuiPickersPopper/.test(e))return!0}if(t.getAttribute&&"dialog"===t.getAttribute("role")){const e=t.className?.toString()||"";if(/MuiPickers|MuiDatePicker/.test(e))return!0}t=t.parentNode}return!1})(e.target)||z(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const pe=f?.formats||["xlsx"],ye=(e?.length??0)>0||Object.keys(h||{}).length>0,be=s>0,ve=g.filter(e=>!1!==m[e.key]).length,we=[...k.map(e=>g.find(t=>t.key===e)).filter(Boolean),...g.filter(e=>!k.includes(e.key))].filter(e=>e.header?.toLowerCase()?.includes(U?.toLowerCase())),ke=e=>{switch(e){case"csv":return N.jsx(le,{size:18});case"json":return N.jsx(ne,{size:18});case"xlsx":return N.jsx(ae,{size:18});default:return N.jsx(W,{size:18})}},je=e=>{switch(e){case"delete":return N.jsx(V,{size:18});case"archive":return N.jsx(B,{size:18});case"copy":return N.jsx(_,{size:18});case"edit":return N.jsx(K,{size:18});case"export":return N.jsx(W,{size:18});default:return N.jsx(Q,{size:18})}},Ne=e=>{switch(e){case"csv":return"CSV";case"json":return"JSON";case"xlsx":return"Excel";default:return e}},Ce=(e,t=!1)=>{f?.onExport?.(e,t),F(!1)},Se=()=>{J(null),oe(null)},Re=n(()=>g.some(e=>e.filterable),[g]);return N.jsxs("div",{className:"bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",role:"toolbar","aria-label":"Data grid toolbar",children:[N.jsxs("div",{id:"search-results-status",className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true",children:[ye?`Showing ${t} of ${r} rows`:`${t} total rows`,be&&`, ${s} row${1!==s?"s":""} selected`]}),N.jsx("div",{className:"px-3 py-2",children:N.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-4",children:[N.jsxs("div",{className:"order-1 flex items-center flex-wrap gap-2 sm:gap-3",children:[N.jsxs("div",{className:"relative",ref:ge,children:[Re&&N.jsxs("button",{ref:e=>{me.current=e},onClick:()=>z(!I),className:"flex cursor-pointer items-center gap-2 px-3 py-1.5 border rounded-lg transition-colors "+(I?"bg-blue-50 dark:bg-blue-900/40 border-blue-200 dark:border-blue-600 text-blue-700 dark:text-blue-300":"border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800"),title:"Toggle column filters (Ctrl+K)","aria-label":"Toggle column filters","aria-haspopup":"menu","aria-expanded":I,"aria-controls":"filters-menu","aria-keyshortcuts":"Control+K",children:[N.jsx(G,{className:"w-4 h-4"}),N.jsx("span",{className:"hidden sm:inline text-sm",children:"Filters"}),Object.keys(h).length>0&&N.jsxs("button",{type:"button",onClick:e=>{e.stopPropagation(),y?.()},className:"bg-red-500 cursor-pointer hover:bg-red-600 text-white text-xs px-1.5 py-0.5 rounded-full min-w-5 h-5 flex items-center justify-center transition-all group relative",title:"Clear all filters",children:[N.jsx("span",{className:"group-hover:hidden",children:Object.keys(h).length}),N.jsx(O,{className:"w-3 h-3 hidden group-hover:block absolute"})]})]}),N.jsxs(wr,{open:I,anchorEl:me.current,onClose:()=>z(!1),placement:"bottom-start",offset:8,zIndex:1e3,maxHeight:520,className:"w-88 sm:w-88 max-w-[90vw] bg-white border border-gray-200 rounded-lg shadow-xl overflow-y-auto min-h-100 dark:bg-gray-800 dark:border-gray-700",shouldIgnoreClose:e=>{let t=e;for(;t;){if(t.classList){const e=Array.from(t.classList).join(" ");if(/MuiPickers|MuiDatePicker|MuiPickersPopper/.test(e))return!0}if(t.getAttribute&&"dialog"===t.getAttribute("role")){const e=t.className?.toString()||"";if(/MuiPickers|MuiDatePicker/.test(e))return!0}t=t.parentNode}return!1},children:[N.jsxs("div",{className:"flex items-center justify-between px-2",children:[N.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[N.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Column Filters"}),N.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:"Filter data by column values"})]}),N.jsx("button",{onClick:y,className:"px-3 py-1.5 text-sm text-gray-600 dark:text-gray-400 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:"Clear All"})]}),N.jsx("div",{className:"p-3 space-y-3",children:N.jsx(Fe,{columns:g,columnFilters:h,onColumnFilter:v})}),N.jsx("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700",children:N.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:Object.keys(h).length>0&&N.jsxs("span",{children:[Object.keys(h).length," filter",1!==Object.keys(h).length?"s":""," ","applied"]})})})]})]}),E]}),N.jsxs("div",{className:"order-2 flex items-center gap-2 sm:gap-3 flex-wrap sm:flex-nowrap",children:[L,u&&be&&x.length>0&&N.jsxs("div",{className:"relative",ref:de,children:[N.jsxs("button",{ref:e=>{xe.current=e},onClick:()=>T(!$),className:"flex items-center gap-2 px-3 py-2.5 bg-orange-600 text-white rounded-lg hover:bg-orange-700 transition-colors",title:"Bulk actions",children:[N.jsx(Q,{className:"w-4 h-4"}),N.jsxs("span",{className:"hidden sm:inline text-sm font-medium",children:["Actions (",s,")"]})]}),N.jsxs(wr,{open:$,anchorEl:xe.current,onClose:()=>T(!1),placement:"bottom-end",offset:8,zIndex:1e3,className:"w-56 bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[N.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[N.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Bulk Actions"}),N.jsxs("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:[s," row",1!==s?"s":""," selected"]})]}),N.jsx("div",{className:"p-2",children:x.map(e=>N.jsxs("button",{onClick:()=>(e=>{e.disabled||(e.onClick(i),T(!1))})(e),disabled:e.disabled,className:"w-full flex items-center gap-3 px-3 py-2 text-sm rounded-md transition-colors "+(e.disabled?"text-gray-400 dark:text-gray-500 cursor-not-allowed":e.destructive?"text-red-700 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800"),children:[e.icon??je(e.id),e.label]},e.id))})]})]}),d&&g.length>0&&N.jsxs("div",{className:"relative",ref:ue,children:[N.jsxs("button",{ref:e=>{fe.current=e},onClick:()=>H(!P),className:"flex items-center gap-2 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",title:"Column visibility","aria-label":`Column visibility. ${ve} of ${g.length} columns visible`,"aria-haspopup":"menu","aria-expanded":P,"aria-controls":"column-visibility-menu",children:[N.jsx(Y,{className:"w-4 h-4 dark:text-gray-300"}),N.jsx("span",{className:"hidden sm:inline text-sm font-medium dark:text-gray-300",children:"Columns"}),N.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["(",ve,"/",g.length,")"]})]}),N.jsxs(wr,{open:P,anchorEl:fe.current,onClose:()=>H(!1),placement:"bottom-end",offset:8,zIndex:1e3,className:"w-[90vw] sm:w-72 max-w-[90vw] bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[N.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[N.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Show/Hide Columns"}),N.jsxs("div",{className:"relative mt-2",children:[N.jsx(re,{className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4 dark:text-gray-500"}),N.jsx("input",{type:"text",placeholder:"Search columns...",className:"w-full pl-8 pr-2 py-1.5 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm dark:border-gray-600 dark:text-gray-300",value:U,onChange:e=>q(e.target.value)})]})]}),N.jsx("div",{className:"max-h-60 overflow-y-auto p-2",children:we.map(e=>{const t=!1!==m[e.key];return N.jsxs("label",{className:`flex items-center gap-3 p-2 hover:bg-gray-50 rounded-md cursor-grab relative ${X===e.key?"opacity-60":""} dark:hover:bg-gray-800`,draggable:!0,onDragStart:t=>((e,t)=>{J(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)})(e.key,t),onDragOver:t=>((e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();oe({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})})(e.key,t),onDrop:()=>(e=>{const t=X;if(!t||t===e)return;if(C&&C.has(t)!==C.has(e))return J(null),void oe(null);const r=Z?.key!==e||"before"===Z.position,n=(k&&k.length?k:g.map(e=>e.key)).filter(e=>e!==t);let a=n.indexOf(e);if(-1===a)return j?.(n),J(null),void oe(null);r||(a+=1),n.splice(a,0,t),j?.(n),J(null),oe(null)})(e.key),onDragEnd:Se,children:[Z?.key===e.key&&N.jsx("span",{className:"absolute left-2 right-2 h-0.5 bg-blue-600",style:{top:"before"===Z.position?0:void 0,bottom:"after"===Z.position?0:void 0}}),N.jsx("input",{type:"checkbox",checked:t,onChange:()=>(e=>{const t=!1!==m[e];b?.(e,!t)})(e.key),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:text-blue-400"}),t?N.jsx(ee,{className:"w-4 h-4 text-green-600"}):N.jsx(te,{className:"w-4 h-4 text-gray-400 dark:text-gray-500"}),N.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.header}),N.jsx("button",{type:"button",onClick:r=>{r.preventDefault(),r.stopPropagation(),t?S?.(e.key):(b?.(e.key,!0),requestAnimationFrame(()=>S?.(e.key)))},className:"ml-auto p-1 text-gray-400 hover:text-blue-600 dark:text-gray-500",title:"Scroll to this column","aria-label":`Scroll to column ${e.header}`,children:N.jsx(se,{className:"w-4 h-4"})})]},e.key)})}),N.jsxs("div",{className:"p-2 border-t border-gray-100 dark:border-gray-700",children:[N.jsxs("div",{className:"flex items-center justify-between",children:[N.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 cursor-pointer hover:bg-gray-50 px-3 py-1.5 rounded transition-colors min-h-9 dark:text-gray-400 dark:hover:text-gray-100 dark:hover:bg-gray-800",children:[N.jsx("input",{type:"checkbox",checked:we.every(e=>!1!==m[e.key]),onChange:e=>{we.forEach(t=>{b?.(t.key,e.target.checked)})},className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:text-blue-400"}),N.jsx("span",{children:"Select All"})]}),N.jsx("button",{className:"text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-50 px-3 py-1.5 rounded transition-colors min-h-9 dark:text-gray-400 dark:hover:text-gray-100 dark:hover:bg-gray-800",onClick:()=>{g.forEach(e=>{b?.(e.key,!1!==e.visible)}),j?.(g.map(e=>e.key)),w?.(),H(!1)},children:"Reset Columns"})]}),U&&N.jsx("button",{className:"text-xs text-blue-600 hover:underline mt-2 dark:text-blue-400",onClick:()=>q(""),children:"Clear Search"})]})]})]}),D&&N.jsx("div",{className:"flex items-center",children:N.jsx("div",{className:"flex items-center gap-1 border border-gray-300 rounded-lg p-1 dark:border-gray-600",title:"Row density",children:["sm","md","lg"].map(e=>N.jsx("button",{className:"px-2 py-1 text-xs rounded-md "+(R===e?"bg-blue-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"),onClick:()=>M?.(e),children:e.toUpperCase()},e))})}),N.jsx("div",{className:"flex items-center gap-2 order-3 w-full sm:order-0 sm:w-auto flex-1 min-w-0",children:N.jsxs("div",{className:"relative",children:[N.jsx(re,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4 dark:text-gray-500","aria-hidden":"true"}),N.jsx("input",{ref:ie,type:"text",placeholder:"Search...",className:"w-full sm:w-64 pl-10 pr-10 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:text-gray-200 transition-colors",value:e,onChange:p,"aria-label":"Search all columns","aria-keyshortcuts":"Control+F","aria-describedby":"search-results-status"}),e&&N.jsx("button",{onClick:()=>p({target:{value:""}}),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors dark:text-gray-500 dark:hover:text-gray-300",title:"Clear search",children:N.jsx(O,{className:"w-4 h-4"})})]})}),c&&f?.enabled&&N.jsxs("div",{className:"relative",ref:ce,children:[N.jsx("button",{ref:e=>{he.current=e},onClick:()=>F(!A),className:"p-2.5 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300 transition-colors","aria-label":"Export data"+(be?` (${s} rows selected)`:` (${t} rows)`),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":"export-menu","aria-keyshortcuts":"Control+E",title:"Export data (Ctrl+E)",children:N.jsx(W,{className:"w-4 h-4"})}),N.jsxs(wr,{open:A,anchorEl:he.current,onClose:()=>F(!1),placement:"bottom-end",offset:8,zIndex:1e3,className:"w-[90vw] sm:w-64 max-w-[90vw] bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[N.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[N.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Export Data"}),N.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:"Choose format and data scope"})]}),N.jsxs("div",{className:"p-2",children:[N.jsxs("div",{className:"mb-3",children:[N.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2 dark:text-gray-300",children:"Export All Data"}),N.jsx("div",{className:"space-y-1",children:pe.map(e=>N.jsxs("button",{onClick:()=>Ce(e,!1),className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md transition-colors cursor-pointer",children:[ke(e),N.jsxs("span",{children:["Export as ",Ne(e)]}),N.jsxs("span",{className:"ml-auto text-xs text-gray-500 dark:text-gray-400",children:[t.toLocaleString()," rows"]})]},`all-${e}`))})]}),be&&N.jsxs("div",{children:[N.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2 dark:text-gray-300",children:"Export Selected"}),N.jsx("div",{className:"space-y-1",children:pe.map(e=>N.jsxs("button",{onClick:()=>Ce(e,!0),className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-blue-700 hover:bg-blue-50 rounded-md transition-colors dark:text-blue-400 dark:hover:bg-blue-900/20",children:[ke(e),N.jsxs("span",{children:["Export as ",Ne(e)]}),N.jsxs("span",{className:"ml-auto text-xs text-blue-500",children:[s," rows"]})]},`selected-${e}`))})]})]})]})]})]})]})})]})};kr.displayName="SearchToolbar";const jr=r(kr),Nr=({data:e,columns:t})=>{const[r,l]=a(""),[i,u]=a({}),[g,m]=c(),[,h]=c(),x=s(e=>{m(()=>l(e))},[]),f=d(r),p=s((e,t,r,n)=>{const a=e[t];switch(r.type){case"text":{const e=String(a||"").toLowerCase(),t=String(r.value||"").toLowerCase();switch(r.operator){case"contains":default:return e.includes(t);case"equals":return e===t;case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t)}}case"number":{const e=parseFloat(a),t=parseFloat(String(r.value));if(isNaN(e)||isNaN(t))return!1;switch(r.operator){case"equals":default:return e===t;case"gt":return e>t;case"gte":return e>=t;case"lt":return e<t;case"lte":return e<=t;case"between":{const n=parseFloat(String(r.secondValue??""));return!isNaN(n)&&e>=t&&e<=n}}}case"date":{const e=n?.filterTs,t=n?.secondTs;if(void 0===e||isNaN(e))return!1;const l=new Date(a);if(isNaN(l.getTime()))return!1;const o=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime();switch(r.operator){case"equals":default:return o===e;case"gt":return o>e;case"gte":return o>=e;case"lt":return o<e;case"lte":return o<=e;case"between":return void 0!==t&&!isNaN(t)&&o>=e&&o<=t}}case"boolean":return Boolean(a)===Boolean(r.value);case"multiselect":{const e=e=>null==e||""===e||"string"==typeof e&&""===e.trim()?null:e;return(Array.isArray(r.value)?r.value:[r.value]).map(e).includes(e(a))}default:return!0}},[]),y=o(new WeakMap),b=o(0),v=s(()=>{b.current>5e3&&(y.current=new WeakMap,b.current=0)},[]),w=n(()=>{v();const r=Object.keys(i).length>0,n=!!f;if(!r&&!n)return e;const a=f.toLowerCase(),l=y.current;let o=e;if(r)for(const[e,t]of Object.entries(i)){if(!t)continue;let r;if("date"===t.type){const e=t.value instanceof Date?t.value:new Date(String(t.value??"")),n=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let a;if(t.secondValue){const e=t.secondValue instanceof Date?t.secondValue:new Date(String(t.secondValue??""));a=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}r={filterTs:n,secondTs:a}}if(o=o.filter(n=>p(n,e,t,r)),0===o.length)break}if(n&&o.length>0){const e=t.filter(e=>!1!==e.visible);o=o.filter(t=>{let r=l.get(t);return null==r&&(r=e.map(e=>{const r=t[e.key];if(null==r)return"";if("string"==typeof r)return r.toLowerCase();if("number"==typeof r||"boolean"==typeof r)return String(r).toLowerCase();const n=String(r);return n.length>100?n.slice(0,100):n}).join("|"),b.current<5e3&&(l.set(t,r),b.current++)),r.includes(a)})}return o},[e,i,f,t,p,v]),k=s((e,t)=>{h(()=>{u(r=>{const n={...r};return t?n[e]=t:delete n[e],n})})},[]),j=s(e=>{k(e,null)},[k]),N=s(()=>{m(()=>l("")),h(()=>u({})),y.current=new WeakMap,b.current=0},[]),C=s(()=>{let e=0;return f&&e++,e+Object.keys(i).length},[f,i]);return{globalFilter:r,setGlobalFilter:x,columnFilters:i,filteredData:w,setColumnFilter:k,clearColumnFilter:j,clearAllFilters:N,getActiveFilterCount:C,isFilterPending:g}};function Cr(){const e=self,t=(e,t)=>{if(!e||0===e.length)return e;if(!t?.key)return e;const{key:r,direction:n}=t,a="asc"===n?1:-1;return[...e].sort((e,t)=>{const n=e?.[r],l=t?.[r];return null==n&&null==l?0:null==n?-1*a:null==l?1*a:"number"==typeof n&&"number"==typeof l?(n-l)*a:String(n).localeCompare(String(l))*a})};e.onmessage=r=>{const n=r.data;if(n&&"process"===n.type)try{const{rows:r,sort:a}=n.payload;e.postMessage({type:"result",payload:{rows:t(r,a??null)}})}catch{e.postMessage({type:"result",payload:{rows:n.payload?.rows??[]}})}}}function Sr(e){const t=e?.enabled??!0,r=o(null),n=o(null),a=o(t);l(()=>{a.current=t,!t&&r.current&&(r.current.terminate(),r.current=null,n.current&&(n.current.reject(new DOMException("Worker disabled","AbortError")),n.current=null))},[t]);const i=o(()=>null);return i.current=()=>{if(!a.current)return null;if(r.current)return r.current;const e=`(${Cr.toString()})()`,t=new Blob([e],{type:"application/javascript"}),l=URL.createObjectURL(t),o=new Worker(l);return URL.revokeObjectURL(l),o.onmessage=e=>{"result"===e.data?.type&&(n.current?.resolve(e.data.payload.rows),n.current=null)},r.current=o,o},l(()=>()=>{r.current?.terminate(),r.current=null,n.current&&(n.current.reject(new DOMException("Unmounted","AbortError")),n.current=null)},[]),{process:s((e,t)=>{if(!a.current)return Promise.resolve(e);const r=i.current();return r?new Promise((a,l)=>{n.current&&n.current.reject(new DOMException("Superseded by newer sort","AbortError")),n.current={resolve:a,reject:l},r.postMessage({type:"process",payload:{rows:e,sort:t}})}):Promise.resolve(e)},[])}}const Rr="Unknown",Mr=e=>e.join("|"),Dr=(e,t,r,n,a)=>{const l=t[r],o=new Map;for(const t of e){const e=String(t[l]??Rr),r=o.get(e);r?r.push(t):o.set(e,[t])}for(const[e,s]of o.entries()){const o=[...n,`${l}=${e}`];a.add(Mr(o)),r<t.length-1&&Dr(s,t,r+1,o,a)}},Er=(e,t)=>{const r={};for(const n of t){if(!n.aggregate)continue;const t=e.map(e=>e[n.key]);let a=null;if("function"==typeof n.aggregate)try{a=n.aggregate(t)}catch(e){a=null}else{const e=e=>!!(/^\d{4}-\d{2}-\d{2}$/.test(e)||/^\d{2}-\d{2}-\d{4}$/.test(e)||/^\d{4}\/\d{2}\/\d{2}$/.test(e)||/^\d{2}\/\d{2}\/\d{4}$/.test(e)||(e.includes("-")||e.includes("/"))&&Number.isFinite(Date.parse(e))),r=t.map(t=>{if("number"==typeof t)return t;if(null==t)return NaN;const r=String(t);if(e(r))return NaN;const n=parseFloat(r.replace(/,/g,""));return Number.isFinite(n)?n:NaN}).filter(e=>Number.isFinite(e)),l=()=>t.map(e=>{if(e instanceof Date)return e.getTime();if("string"==typeof e||"number"==typeof e){const t=Date.parse(String(e));return Number.isFinite(t)?t:NaN}return NaN}).filter(e=>Number.isFinite(e));if("sum"===n.aggregate||"avg"===n.aggregate)r.length&&(a="sum"===n.aggregate?r.reduce((e,t)=>e+t,0):r.reduce((e,t)=>e+t,0)/r.length);else if("min"===n.aggregate||"max"===n.aggregate)if(r.length)a="min"===n.aggregate?Math.min(...r):Math.max(...r);else{const e=l();if(e.length){const t="min"===n.aggregate?Math.min(...e):Math.max(...e);a=new Date(t)}}}null!=a&&(r[n.key]=a)}return r},Lr=({data:e,pagination:t})=>{const[r,o]=a(1),[i,c]=a(t?.pageSize||50),[d,u]=a(!1);l(()=>{const e=t?.pageSize;e&&e!==i&&(c(e),o(1))},[t?.pageSize]);const g=s(()=>{o(1)},[]),m=n(()=>{const n=!1!==t?.enabled,a="server"===(t?.mode||"client")?t?.serverConfig?.totalRows||0:e.length,l=Math.ceil(a/i);return{enabled:n,pageSize:i,currentPage:r,totalPages:l,totalRows:a,showPageSizeSelector:!1!==t?.showPageSizeSelector,pageSizeOptions:t?.pageSizeOptions||[25,50,100,200,500]}},[t,i,r,e.length]),h=n(()=>{if(!m.enabled||"server"===t?.mode)return e;const n=(r-1)*i;return e.slice(n,n+i)},[e,r,i,m.enabled,t?.mode]),x=s(async e=>{if("server"===t?.mode&&t?.serverConfig?.onPageChange){u(!0);try{await t.serverConfig.onPageChange(e,i)}finally{u(!1)}}o(e)},[t,i]),f=s(async e=>{if("server"===t?.mode&&t?.serverConfig?.onPageSizeChange){u(!0);try{await t.serverConfig.onPageSizeChange(e)}finally{u(!1)}}c(e),o(1)},[t]);return{currentPage:r,resetPage:g,paginationConfig:m,paginatedData:h,isServerLoading:d,handlePageChange:x,handlePageSizeChange:f}},Ar=(e,t)=>{if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0},Fr=({data:e,selectedRowIds:t,onRowSelect:r,getRowId:o})=>{const i=s((e,t)=>o?o(e):void 0!==e.id?e.id:t??0,[o]),[c,d]=a(()=>new Set(t?Array.from(t):[]));l(()=>{t&&d(e=>{const r=new Set(Array.from(t));return Ar(e,r)?e:r})},[t]);const u=n(()=>{const t=new Map;return e.forEach((e,r)=>t.set(i(e,r),e)),t},[e,i]);l(()=>{if(0===c.size)return;let e=!1;for(const t of c)if(!u.has(t)){e=!0;break}e&&d(e=>{const t=new Set;return e.forEach(e=>{u.has(e)&&t.add(e)}),Ar(e,t)?e:t})},[u]);const g=s((e,t)=>{if(d(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n}),r){const t=u.get(e);t&&r(t)}},[u,r]),m=s(t=>{d(t?new Set(e.map((e,t)=>i(e,t))):new Set)},[e,i]);return{selectedRows:c,handleRowSelect:g,handleSelectAll:m}},Ir=({data:e,virtualized:t=!0,rowHeight:r=40,overscan:i=10,height:c})=>{const d=o(null),[u,g]=a(0),m=o(null),h=o(0),[x,f]=a(c);l(()=>{const e=d.current;if(!e)return;const t=new ResizeObserver(([e])=>{const t=e.contentRect.height;t>0&&f(t)});t.observe(e);const r=e.clientHeight;return r>0&&f(r),()=>t.disconnect()},[]),l(()=>{c>0&&f(c)},[c]);const p=n(()=>{if(!t)return{startIndex:0,endIndex:e.length-1,offsetY:0};const n=Math.max(1,Math.ceil(x/r)),a=Math.max(i,Math.min(n,20)),l=Math.max(0,Math.floor(u/r)-a),o=Math.ceil(x/r);return{startIndex:l,endIndex:Math.min(e.length-1,l+o+2*a),offsetY:l*r}},[u,x,e.length,r,i,t]),y=n(()=>t?e.slice(p.startIndex,p.endIndex+1):e,[e,p,t]),b=e.length*r,v=s(e=>{h.current=e.target.scrollTop,null==m.current&&(m.current=requestAnimationFrame(()=>{m.current=null,g(h.current)}))},[]);return l(()=>()=>{null!=m.current&&cancelAnimationFrame(m.current)},[]),{scrollRef:d,virtualizedRange:p,visibleData:y,totalHeight:b,handleScroll:v}};let zr=null;const $r=new Uint32Array([439041101,1584364171,2626518639,1514880045]);function Tr(e,t){let r=e[0],n=e[1],a=3337565984;for(let e=0;e<32;e++)n=n-((r<<4)+t[2]^r+a^(r>>>5)+t[3])>>>0,r=r-((n<<4)+t[0]^n+a^(n>>>5)+t[1])>>>0,a=a-2654435769>>>0;e[0]=r,e[1]=n}let Or;function Pr(e){Or=e}const _r=()=>!0,Kr=u(function({data:e,columns:t,getRowId:r,height:i,density:c="md",headerDensity:d,headerHeight:u,minResizeWidth:m,onDensityChange:h,showDensityControl:x=!1,onRowSelect:f,onSelectedRowsChange:p,selectable:y=!1,isRowSelectable:b,showToolbar:v=!0,showExport:w=!1,filterable:k=!0,groupable:j=!1,virtualized:R=!0,rowHeight:D,overscan:E=6,rowStyle:L,onContextMenu:A,onRowDoubleClick:F,onRowClick:I,onCellClick:z,onCellContextMenu:$,cellFocusEnabled:T=!1,onCellFocusChange:O,onCellEdit:P,onCellEditStart:_,cellSelectionEnabled:K=!1,canSelectCell:V=_r,onCellSelectionChange:B,pagination:W={enabled:!1,mode:"client",pageSize:50},virtualizationThreshold:H=300,loading:G=!1,onFilterChange:U,onSort:Y,onColumnConfigChange:q,initialColumnConfig:X,toolbarLeft:J,toolbarRight:Z,groupBarVisibility:Q="auto",groupFooterVariant:ee="chips",onCopyCells:te,selectedRowIds:re,performanceConfig:ne={},exportOptions:ae,renderGroupActions:le,contextMenuItems:oe,infiniteScroll:se,licenseKey:ie,noDataMessage:de,noDataRenderer:ue,savedFilters:ge,onSaveFilter:me,onLoadFilter:he,onDeleteFilter:xe},fe){l(()=>{if("undefined"!=typeof window&&window.KD_DEV_LOG){const e=[];void 0!==ge&&e.push("savedFilters"),void 0!==me&&e.push("onSaveFilter"),void 0!==he&&e.push("onLoadFilter"),void 0!==xe&&e.push("onDeleteFilter"),e.length>0&&console.warn(`[KDGrid] The following props are deprecated and have no effect: ${e.join(", ")}. They will be removed in a future major version. Use onFilterChange + your own state to manage saved filters.`)}},[]);const pe=o(null),[ye,be]=a(0);l(()=>{const e=pe.current;if(!e)return;const t=()=>be(e.clientWidth||0);t();const r=new ResizeObserver(()=>t());return r.observe(e),()=>r.disconnect()},[]);const[ve,ke]=a(c);l(()=>{ke(c)},[c]);const je=n(()=>({sm:28,md:40,lg:56}),[]),Ne=n(()=>null!=D?D:je[ve],[D,ve,je]),Ce=n(()=>null!=u?u:je[d??"md"],[u,d,je]),{globalFilter:Ee,columnFilters:Ae,filteredData:Fe,setGlobalFilter:Ie,setColumnFilter:ze,clearAllFilters:$e}=Nr({data:e,columns:t}),[Te,Oe]=a({key:null,direction:null}),Pe=o(null),_e=o(null),Ke=s(e=>{let t=e,r="asc";Te.key!==e?(t=e,r="asc"):"asc"===Te.direction?r="desc":"desc"===Te.direction?(t=null,r=null):r="asc",Oe({key:t,direction:r}),Y&&Y(t??"",r)},[Y,Te.key,Te.direction]),{process:Ve}=Sr({enabled:!0}),[Be,We]=a(Fe),He=ne?.sortWorkerThreshold??5e3;l(()=>{let e=!1;if(!Te.key)return void We(Fe);const t=Fe;if(t.length<He){const e="asc"===Te.direction?1:-1,r=[...t].sort((t,r)=>{const n=t?.[Te.key],a=r?.[Te.key];return null==n&&null==a?0:null==n?-1*e:null==a?1*e:"number"==typeof n&&"number"==typeof a?(n-a)*e:String(n).localeCompare(String(a))*e});return void We(r)}return Ve(t,{key:Te.key,direction:Te.direction}).then(t=>{e||We(t)}),()=>{e=!0}},[Fe,Te,Ve,He]);const Ge=n(()=>se?.enabled?{enabled:!1}:W,[se?.enabled,W?.enabled,W?.mode,W?.pageSize,W?.showPageSizeSelector,W?.pageSizeOptions,W?.serverConfig?.enabled,W?.serverConfig?.totalRows,W?.serverConfig?.loading,W?.serverConfig?.onPageChange,W?.serverConfig?.onPageSizeChange]),{paginationConfig:Ue,paginatedData:Ye,isServerLoading:qe,handlePageChange:Xe,handlePageSizeChange:Je,resetPage:Ze,currentPage:Qe}=Lr({data:Be,pagination:Ge}),et=s(e=>{Ie(e.target.value)},[Ie]),tt=W?.enabled?"server"===W.mode?e:Ye:Be,{groupConfig:rt,displayData:nt,handleGroupBy:at,addGroupKey:lt,removeGroupKey:ot,setGroupKeys:st,toggleGroupExpansion:it,isGrouped:ct,expandAllGroups:dt,collapseAllGroups:ut}=(({data:e,columns:t})=>{const[r,o]=a({columnKeys:[],expanded:new Set}),s=n(()=>{const n=r.columnKeys;if(!n.length)return e;const a=[],l=(e,o,s)=>{const i=n[o],c=new Map;for(const t of e){const e=String(t[i]??Rr),r=c.get(e);r?r.push(t):c.set(e,[t])}const d=Array.from(c.entries()).sort(([e],[t])=>e.localeCompare(t));for(const[e,c]of d){const d=[...s,`${i}=${e}`],u=Mr(d);if(a.push({id:`group-${u}`,_isGroupHeader:!0,_groupKey:u,_groupCount:c.length,_groupLevel:o,_groupColumnKey:i,_groupValue:e,_groupRows:c}),!r.expanded.has(u))continue;if(o<n.length-1)l(c,o+1,d);else for(const e of c)a.push(e);const g=Er(c,t);a.push({id:`group-footer-${u}`,_isGroupFooter:!0,_groupKey:u,_groupLevel:o,_groupAgg:g})}};return l(e,0,[]),a},[e,t,r.columnKeys,r.expanded]);return l(()=>{if(!r.columnKeys.length)return;const t=new Set;Dr(e,r.columnKeys,0,[],t);let n=!1;if(t.size!==r.expanded.size)n=!0;else for(const e of t)if(!r.expanded.has(e)){n=!0;break}n&&o(e=>({...e,expanded:t}))},[r.columnKeys,e]),{groupConfig:r,displayData:s,handleGroupBy:e=>{o({columnKeys:e?[e]:[],expanded:new Set})},addGroupKey:e=>{o(t=>t.columnKeys.includes(e)?t:{...t,columnKeys:[...t.columnKeys,e]})},removeGroupKey:e=>{o(t=>{const r=t.columnKeys.filter(t=>t!==e),n=new Set;for(const r of t.expanded)r.includes(`${e}=`)||n.add(r);return{columnKeys:r,expanded:n}})},setGroupKeys:e=>{o({columnKeys:[...e],expanded:new Set})},toggleGroupExpansion:e=>{o(t=>{const r=new Set(t.expanded);return r.has(e)?r.delete(e):r.add(e),{...t,expanded:r}})},expandAllGroups:()=>{const t=r.columnKeys;if(!t.length)return;const n=new Set;Dr(e,t,0,[],n),o(e=>({...e,expanded:n}))},collapseAllGroups:()=>{o(e=>({...e,expanded:new Set}))},isGrouped:r.columnKeys.length>0}})({data:tt,columns:t}),{columnWidths:gt,columnOrder:mt,pinnedColumns:ht,columnVisibility:xt,handleColumnResize:ft,handleColumnPin:pt,handleColumnVisibilityChange:yt,setColumnOrder:bt,autosizeColumn:vt,autosizeAllColumns:wt,resetColumns:kt}=(({columns:e,data:t,initialColumnConfig:r,onColumnConfigChange:n,setSortConfig:i,setGroupKeys:c,setDensity:d,setGlobalFilter:u,setColumnFilter:g,sortConfig:m,groupConfig:h,globalFilter:x,columnFilters:f,density:p})=>{const[y,b]=a(()=>{const t={};return e.forEach(e=>{t[e.key]=e.width||100}),t}),v=o(e.reduce((e,t)=>(e[t.key]=t.width||100,e),{})),w=o(e.map(e=>e.key)),[k,j]=a(()=>w.current.slice()),[N,C]=a(new Set),[S,R]=a(()=>{const t={};return e.forEach(e=>{t[e.key]=!0}),t}),M=s((e,t)=>{b(r=>({...r,[e]:t}))},[]),D=s((e,t)=>{C(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n})},[]),E=s((e,t)=>{R(r=>({...r,[e]:t}))},[]),L=s(e=>{if(null==e)return 0;const t="string"==typeof e?e:String(e);if(!t)return 0;try{if("undefined"!=typeof document){if(!zr){const e=document.createElement("canvas");zr=e.getContext("2d"),zr&&(zr.font="13px Inter, ui-sans-serif, system-ui, sans-serif")}if(zr)return Math.ceil(zr.measureText(t).width)}}catch{}return 8*t.length},[]),A=s(r=>{const n=e.find(e=>e.key===r);if(!n)return;const a=L(n.header),l=t.slice(0,500);let o=0;for(const e of l)o=Math.max(o,L(e[r]));const s=Math.max(60,Math.min(500,Math.max(a,o)+32));b(e=>({...e,[r]:s}))},[e,t,L]),F=s(()=>{e.forEach(e=>A(e.key))},[e,A]),I=s(()=>{b({...v.current}),C(new Set),R(e=>{const t={};return Object.keys(e).forEach(e=>t[e]=!0),t}),j(w.current.slice())},[]);return l(()=>{if(!r)return;const t=new Set(e.map(e=>e.key));if(r.columnWidths){const e=Object.fromEntries(Object.entries(r.columnWidths).filter(([e])=>t.has(e)));b(t=>({...t,...e}))}if(r.columnVisibility){const e=Object.fromEntries(Object.entries(r.columnVisibility).filter(([e])=>t.has(e)));R(t=>({...t,...e}))}if(r.pinnedColumns){const e=r.pinnedColumns.filter(e=>t.has(e));C(new Set(e))}if(r.sortConfig){const e="asc"===r.sortConfig.direction||"desc"===r.sortConfig.direction?r.sortConfig.direction:null;i({key:e?r.sortConfig.key:null,direction:e})}if(r.filters){u(r.filters.globalFilter||"");const e=Object.entries(r.filters.columnFilters||{}).filter(([e])=>t.has(e));for(const[t,r]of e)g(t,r)}if(r.columnOrder&&r.columnOrder.length){const n=r.columnOrder.filter(e=>t.has(e)),a=e.map(e=>e.key).filter(e=>!n.includes(e));j([...n,...a])}r.groupConfig?.columnKeys&&r.groupConfig.columnKeys.length&&c(r.groupConfig.columnKeys),r.density&&d(r.density)},[]),l(()=>{if(!n)return;const e=setTimeout(()=>{n({columnWidths:y,columnVisibility:S,pinnedColumns:Array.from(N),sortConfig:m,groupConfig:{columnKeys:h.columnKeys},filters:{globalFilter:x,columnFilters:f},columnOrder:k,density:p})},200);return()=>clearTimeout(e)},[n,y,S,N,m,h,x,f,k,p]),{columnWidths:y,columnOrder:k,pinnedColumns:N,columnVisibility:S,handleColumnResize:M,handleColumnPin:D,handleColumnVisibilityChange:E,setColumnOrder:j,autosizeColumn:A,autosizeAllColumns:F,resetColumns:I,setColumnWidths:b,setPinnedColumns:C,setColumnVisibility:R}})({columns:t,data:e,initialColumnConfig:X,onColumnConfigChange:q,setSortConfig:Oe,setGroupKeys:st,setDensity:ke,setGlobalFilter:Ie,setColumnFilter:ze,sortConfig:Te,groupConfig:rt,globalFilter:Ee,columnFilters:Ae,density:ve}),jt=o([]),Nt=o([]),Ct=o(36),St=o(!1),Rt=o(null);g(fe,()=>({setGroupKeys:st,addGroupKey:lt,removeGroupKey:ot,expandAllGroups:dt,collapseAllGroups:ut,toggleGroupExpansion:it,getGroupConfig:()=>rt,setColumnFilter:(e,t)=>{ze(e,t)},clearColumnFilter:e=>{ze(e,null)},clearAllFilters:()=>{$e()},setGlobalFilter:e=>{Ie(e)},scrollToRow:e=>{const t=Rt.current;if(!t)return;const n=jt.current.findIndex(t=>(r?r(t):void 0!==t.id?t.id:void 0)===e);if(-1===n)return;const a=Ct.current,l=n*a,o=l+a;l<t.scrollTop?t.scrollTo({top:l,behavior:"smooth"}):o>t.scrollTop+t.clientHeight&&t.scrollTo({top:o-t.clientHeight,behavior:"smooth"})},scrollToColumn:e=>{const t=Rt.current;if(!t)return;const r=Nt.current,n=r.findIndex(t=>t.key===e);if(-1===n)return;let a=St.current?C:0;for(let e=0;e<n;e++)a+=r[e]?.width||100;const l=a+(r[n]?.width||100);a<t.scrollLeft?t.scrollTo({left:a,behavior:"smooth"}):l>t.scrollLeft+t.clientWidth&&t.scrollTo({left:l-t.clientWidth,behavior:"smooth"})}}),[rt,st,lt,ot,dt,ut,it,ze,$e,Ie,r]);const Mt=n(()=>new Set(ht),[ht]),Dt=ct?nt:tt,{selectedRows:Et,handleRowSelect:Lt,handleSelectAll:At}=Fr({data:Dt,onRowSelect:f,selectedRowIds:re,getRowId:r}),Ft=o(p);l(()=>{Ft.current=p},[p]),l(()=>{Ft.current&&Ft.current(Et)},[Et]);const{exportData:It}=(({data:e,columns:t,selectedRows:r,filename:n="data",columnVisibility:a})=>{const l=s(()=>a?t.filter(e=>!1!==a[e.key]):t,[t,a]),o=s((e,t,r)=>{const n=new Blob([e],{type:r}),a=URL.createObjectURL(n),l=document.createElement("a");l.href=a,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)},[]),i=s((e,t)=>{const r=l(),n=r.map(e=>e.header).join(","),a=e.map(e=>r.map(t=>{const r=String(e[t.key]??"");return r.includes(",")||r.includes('"')?`"${r.replace(/"/g,'""')}"`:r}).join(","));o([n,...a].join("\n"),`${t}.csv`,"text/csv")},[l,o]),c=s((e,t)=>{const r=l(),n=e.map(e=>{const t={};for(const n of r)t[n.header]=e[n.key];return t});o(JSON.stringify(n,null,2),`${t}.json`,"application/json")},[l,o]),d=s(async(e,t)=>{const r=l(),[{default:n},{saveAs:a}]=await Promise.all([import("exceljs"),import("file-saver")]),o=new n.Workbook,s=o.addWorksheet("Data"),i=e.slice(0,50),c=e=>{if(null==e)return"";if("number"==typeof e||"boolean"==typeof e||e instanceof Date)return e;const t=String(e);if(/[a-zA-Z]/.test(t))return t;if(/^-?[\d,]+\.?\d*$/.test(t.trim())){const e=Number(t.replace(/,/g,""));if(Number.isFinite(e))return e}return t};s.columns=r.map(e=>{const t=e.header||e.key;let r=t?.length||10;for(const t of i){const n=null==t[e.key]?"":String(t[e.key]);n.length>r&&(r=n.length)}return{header:t,key:e.key,width:Math.max(8,Math.min(50,Math.ceil(1.1*r)))}});for(const t of e){const e={};for(const n of r)e[n.key]=c(t[n.key]);s.addRow(e)}s.getRow(1).font={bold:!0},s.autoFilter={from:{row:1,column:1},to:{row:Math.max(1,s.rowCount),column:r.length}};const d=await o.xlsx.writeBuffer();a(new Blob([d],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),`${t}.xlsx`)},[l]);return{exportData:s((t,a=!1)=>{const l=a&&r&&r.size>0?e.filter(e=>r.has(e.id)):e,o=a&&r&&r.size>0?`${n}_selected_${r.size}_rows`:n;switch(t){case"csv":i(l,o);break;case"json":c(l,o);break;case"xlsx":d(l,o);break;default:console.warn(`[KDGrid] Unsupported export format: ${t}`)}},[e,r,n,i,c,d]),canExportSelected:!!(r&&r.size>0),selectedCount:r?.size??0}})({data:tt,columns:t,selectedRows:Et,filename:ae&&ae.filename||"grid-data",columnVisibility:xt}),zt=s((e,t)=>{const r=Array.from(Et||[]);"server"===ae?.exportMode&&"function"==typeof ae?.onServerExport?ae.onServerExport(e,t,r):It(e,t)},[ae?.exportMode,ae?.onServerExport,It,Et]),$t=s(()=>{$e()},[$e]),Tt=s(e=>{ke(e),h&&h(e)},[h]),Ot=n(()=>!!R&&Dt.length>H,[R,Dt.length,H]),Pt=n(()=>({enableHorizontalVirtualization:!0,horizontalVirtualizationThreshold:50,sortWorkerThreshold:5e3,maxFilterCacheSize:5e3,enableAggressiveMemoization:!0,...ne}),[ne]),{scrollRef:_t,virtualizedRange:Kt,visibleData:Vt,handleScroll:Bt}=Ir({data:Dt,virtualized:Ot,rowHeight:Ne,overscan:E,height:i||400}),{sentinelRef:Wt}=function({enabled:e,onLoadMore:t,threshold:r=200,rootRef:n}){const a=o(null),s=o(t);return l(()=>{s.current=t},[t]),l(()=>{if(!e)return;const t=a.current;if(!t)return;const l=new IntersectionObserver(e=>{e[0].isIntersecting&&s.current()},{root:n?.current||null,rootMargin:`0px 0px ${r}px 0px`,threshold:0});return l.observe(t),()=>l.disconnect()},[e,r,n]),{sentinelRef:a}}({enabled:se?.enabled??!1,hasMore:se?.hasMore??!1,isLoading:se?.isLoading??!1,onLoadMore:()=>{!se?.isLoading&&se?.hasMore&&se.onLoadMore()},threshold:se?.threshold??250,rootRef:_t}),Ht=(({scrollRef:e,footerScrollRef:t,hasFooterAggregate:r})=>{const[n,i]=a(0),c=o(0),d=o(null),u=s(e=>{c.current=e,null==d.current&&(d.current=requestAnimationFrame(()=>{d.current=null,i(c.current)}))},[]),[g,m]=a(0);l(()=>{const t=e.current;if(!t)return;const r=()=>m(t.clientWidth||0);r();const n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()},[e]),l(()=>{const r=e.current;if(!r)return;let n=!1;const a=()=>{if(n)return;n=!0;const e=t.current;e&&e.scrollLeft!==r.scrollLeft&&(e.scrollLeft=r.scrollLeft),u(r.scrollLeft),requestAnimationFrame(()=>{n=!1})};return r.addEventListener("scroll",a,{passive:!0}),t.current&&(t.current.scrollLeft=r.scrollLeft),()=>{r.removeEventListener("scroll",a)}},[e,r,u]);const h=s(t=>{const r=e.current;if(!r)return;const n=Math.abs(t.deltaX)>=Math.abs(t.deltaY)?t.deltaX:t.deltaY;0!==n&&(t.preventDefault(),r.scrollBy({left:n,top:0,behavior:"auto"}))},[e]);return{hScrollLeft:n,viewportWidth:g,scheduleHScrollUpdate:u,forwardWheelToBody:h}})({scrollRef:_t,footerScrollRef:_e,hasFooterAggregate:!1}),{hScrollLeft:Gt,viewportWidth:Ut,forwardWheelToBody:Yt}=Ht,{showLoader:qt,finishingLoader:Xt,loaderTop:Jt}=(({loading:e,isServerLoading:t,resolvedHeaderHeight:r,scrollRef:n,containerRef:o})=>{const s=e||t,[i,c]=a(s),[d,u]=a(!1),[g,m]=a(0);return l(()=>{if(s)return c(!0),void u(!1);if(i){u(!0);const e=setTimeout(()=>{c(!1),u(!1)},200);return()=>clearTimeout(e)}},[s]),l(()=>{const e=()=>{const e=n.current;e&&m((e.offsetTop||0)+(r||0)-1)};e();const t=new ResizeObserver(e);return o.current&&t.observe(o.current),n.current&&t.observe(n.current),()=>t.disconnect()},[r]),{showLoader:i,finishingLoader:d,loaderTop:g}})({loading:G,isServerLoading:qe,resolvedHeaderHeight:Ce,scrollRef:_t,containerRef:pe});l(()=>{if(!U)return;if(!W?.enabled||"server"!==W.mode)return;const e=t.filter(e=>!!e.filterable).map(e=>e.key);U({globalFilter:Ee,columnFilters:Ae,filterableKeys:e})},[Ee,Ae,U,t,W?.enabled,W?.mode]);const Zt=n(()=>{if(0===t.length)return[];const e=new Map(mt.map((e,t)=>[e,t])),r=t.filter(e=>!1!==xt[e.key]).sort((t,r)=>(e.get(t.key)||0)-(e.get(r.key)||0)).map(e=>{const t=gt[e.key]??e.width,r=Number.isFinite(Number(t))?Number(t):100,n=!1!==e.sortable;return{...e,width:r,sortable:n}}),n=Math.max(0,ye-(y?C:0)),a=r.reduce((e,t)=>e+t.width,0),l=new Map;if(n>a){const e=r.filter(e=>e.flex);if(e.length>0){const t=n-a,r=e.reduce((e,t)=>e+Math.max(0,!0===t.flex?1:"number"==typeof t.flex?t.flex:1),0);if(r>0)for(const n of e)l.set(n.key,Math.max(n.minWidth??0,Math.min(n.maxWidth??Number.POSITIVE_INFINITY,n.width+t*(!0===n.flex?1:"number"==typeof n.flex?n.flex:1)/r)))}}const o=e=>l.has(e.key)?{...e,width:l.get(e.key)}:e,s=[],i=[];for(const e of r)Mt.has(e.key)?s.push(o(e)):i.push(o(e));if(rt.columnKeys&&rt.columnKeys.length>0){const e=new Map(rt.columnKeys.map((e,t)=>[e,t]));i.sort((t,r)=>(e.get(t.key)??Number.POSITIVE_INFINITY)-(e.get(r.key)??Number.POSITIVE_INFINITY))}return[...s,...i]},[t,gt,Mt,xt,mt,rt.columnKeys,ye,y]),Qt=n(()=>Pt.enableHorizontalVirtualization&&Zt.length>Pt.horizontalVirtualizationThreshold,[Zt.length,Pt.enableHorizontalVirtualization,Pt.horizontalVirtualizationThreshold]),er=n(()=>Zt.filter(e=>Mt.has(e.key)),[Zt,Mt]),tr=n(()=>Zt.filter(e=>!Mt.has(e.key)),[Zt,Mt]),rr=n(()=>{const e=tr.map(e=>e.width||100),t=new Array(e.length+1).fill(0);for(let r=0;r<e.length;r++)t[r+1]=t[r]+e[r];return{widths:e,prefix:t,totalWidth:t[e.length]||0}},[tr]),nr=n(()=>{if(!Qt)return Zt;const e=y?C:0,t=er.reduce((e,t)=>e+(t.width||100),0),r=Math.max(0,Gt-200),n=Gt+Ut+200,a=e+t,l=Math.max(0,r-a),o=Math.max(0,Math.min(rr.totalWidth,n-a)),s=(e=>{if(!rr.widths.length)return 0;let t=0,r=rr.widths.length-1,n=0;for(;t<=r;){const a=t+r>>1;rr.prefix[a+1]>=e?(n=a,r=a-1):t=a+1}return Math.max(0,Math.min(n,rr.widths.length-1))})(l),i=(e=>{if(!rr.widths.length)return-1;let t=0,r=rr.widths.length-1,n=rr.widths.length-1;for(;t<=r;){const a=t+r>>1;rr.prefix[a]<=e?(n=a,t=a+1):r=a-1}return Math.max(0,Math.min(n,rr.widths.length-1))})(o),c=i>=s&&i>=0?tr.slice(s,i+1):[];return[...er,...c]},[Qt,Zt,Gt,Ut,y,er,tr,rr]),ar=n(()=>{const e=new Map;return tr.forEach((t,r)=>e.set(t.key,r)),e},[tr]),{hvPadLeftMemo:lr,hvPadRightMemo:or}=n(()=>{if(!Qt)return{hvPadLeftMemo:0,hvPadRightMemo:0};const e=nr.filter(e=>!Mt.has(e.key));if(!e.length)return{hvPadLeftMemo:0,hvPadRightMemo:0};const t=ar.get(e[0].key),r=ar.get(e[e.length-1].key);return null==t||null==r?{hvPadLeftMemo:0,hvPadRightMemo:0}:{hvPadLeftMemo:rr.prefix[t],hvPadRightMemo:rr.totalWidth-rr.prefix[r+1]}},[Qt,nr,Mt,ar,rr]),sr=n(()=>Zt.some(e=>e.footerAggregate),[Zt]),ir=n(()=>{const e=new Map;return Zt.forEach((t,r)=>e.set(t.key,r)),e},[Zt]),cr=n(()=>{const e=new Map;return Zt.forEach(t=>e.set(t.key,t)),e},[Zt]),dr=n(()=>Dt.filter(e=>!e._isGroupHeader&&!e._isGroupFooter),[Dt]),ur=n(()=>{const e=new Map;return dr.forEach((t,n)=>{const a=r?r(t):void 0!==t.id?t.id:n;e.set(a,n)}),e},[dr,r]),gr=n(()=>{const e=new Map;return dr.forEach((t,n)=>{const a=r?r(t):void 0!==t.id?t.id:n;e.set(a,t)}),e},[dr,r]),mr=n(()=>Zt.map(e=>e.key),[Zt]),hr=s(e=>r?r(e):void 0!==e.id?e.id:dr.indexOf(e),[r,dr]),{focusedCell:xr,dragOverlay:fr,isCellSelected:pr,isCellFocused:yr,handleCellMouseDown:br,handleCellMouseEnter:vr}=(({cellFocusEnabled:e,cellSelectionEnabled:t,canSelectCell:r,flatRows:i,columnsWithWidths:c,rowIndexById:d,colIndexByKey:u,rowById:g,colByKey:m,scrollRef:h,headerScrollRef:x,resolvedRowHeight:f,selectable:p,onCellFocusChange:y,onCellSelectionChange:b,onCopyCells:v,columnKeys:w,getRowId:k})=>{const j=s((e,t)=>k?k(e):void 0!==e.id?e.id:t??0,[k]),[N,C]=a(null),[S,R]=a(null),[M,D]=a(null),[E,L]=a(null),A=o(!1),F=o(null),I=o(null),z=o(b),$=o(v),T=o(null);l(()=>{z.current=b},[b]),l(()=>{$.current=v},[v]);const O=n(()=>(e,n)=>{if(!t)return!1;if(!S||!M)return!1;const a=d.get(e),l=u.get(n);if(null==a||null==l)return!1;const o=g.get(e),s=m.get(n);if(o&&s&&!r(o,s))return!1;const i=Math.min(S.rowIndex,M.rowIndex),c=Math.max(S.rowIndex,M.rowIndex),h=Math.min(S.colIndex,M.colIndex),x=Math.max(S.colIndex,M.colIndex);return a>=i&&a<=c&&l>=h&&l<=x},[t,S,M,d,u,g,m,r]),P=n(()=>(e,t)=>N?.rowId===e&&N?.columnKey===t,[N]),_=s(({row:n,column:a,event:l})=>{const o=j(n),s=d.get(o),i=u.get(a.key);e&&null!=s&&null!=i&&(document.body.hasAttribute("data-modal-open")||(C({rowId:o,columnKey:a.key}),y&&y({row:n,column:a,value:n[a.key],rowIndex:s,colIndex:i}))),t&&r(n,a)&&0===l.button&&(A.current=!0,F.current={x:l.clientX,y:l.clientY},null!=s&&null!=i&&(C({rowId:o,columnKey:a.key}),R({rowIndex:s,colIndex:i}),D({rowIndex:s,colIndex:i}),L({x:l.clientX,y:l.clientY,rows:1,cols:1})))},[e,y,t,r,d,u,j]),K=s(({row:e,column:n,event:a})=>{if(!t)return;if(!A.current||!S)return;if(!r(e,n))return;const l=j(e),o=d.get(l),s=u.get(n.key);if(null==o||null==s)return;D({rowIndex:o,colIndex:s}),F.current={x:a.clientX,y:a.clientY};const i=Math.min(S.rowIndex,o),c=Math.max(S.rowIndex,o),g=Math.min(S.colIndex,s),m=Math.max(S.colIndex,s);L({x:a.clientX,y:a.clientY,rows:c-i+1,cols:m-g+1})},[t,r,S,d,u,j]);l(()=>{const e=()=>{A.current=!1,L(null),I.current&&(cancelAnimationFrame(I.current),I.current=null)};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),l(()=>{const e=e=>{A.current&&(F.current={x:e.clientX,y:e.clientY})};return window.addEventListener("mousemove",e),()=>window.removeEventListener("mousemove",e)},[]);const V=s(()=>{if(null!=I.current)return;const e=()=>{if(I.current=null,!A.current)return;const t=h.current,r=F.current;if(t&&r){const e=t.getBoundingClientRect(),n=24,a=24;let l=0,o=0;r.x<e.left+n?l=-(e.left+n-r.x):r.x>e.right-n&&(l=r.x-(e.right-n)),r.y<e.top+n?o=-(e.top+n-r.y):r.y>e.bottom-n&&(o=r.y-(e.bottom-n));const s=e=>Math.max(-a,Math.min(a,e));l=s(l),o=s(o),0===l&&0===o||t.scrollBy({left:l,top:o,behavior:"auto"})}I.current=requestAnimationFrame(e)};I.current=requestAnimationFrame(e)},[]);return l(()=>{A.current&&V()},[V,S]),l(()=>{const e=e=>{if("Escape"===e.key)return R(null),D(null),C(null),void L(null);const r=e.shiftKey,n=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key);if(!r||!n||!t)return;e.preventDefault();let a=M;if(!a){if(!N)return;{const e=d.get(N.rowId),t=u.get(N.columnKey);if(null==e||null==t)return;R({rowIndex:e,colIndex:t}),a={rowIndex:e,colIndex:t}}}const l=i.length-1,o=c.length-1;let s=a.rowIndex,g=a.colIndex;"ArrowUp"===e.key&&(s=Math.max(0,s-1)),"ArrowDown"===e.key&&(s=Math.min(l,s+1)),"ArrowLeft"===e.key&&(g=Math.max(0,g-1)),"ArrowRight"===e.key&&(g=Math.min(o,g+1)),D({rowIndex:s,colIndex:g});const m=h.current;if(m){const e=m.getBoundingClientRect();L({x:e.right-16,y:e.bottom-16,rows:Math.abs((S?.rowIndex??s)-s)+1,cols:Math.abs((S?.colIndex??g)-g)+1})}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,N,S,M,d,u,i.length,c.length]),l(()=>{if(!e)return;const t=h.current,r=x.current,n=e=>{if(!N)return;if(document.body.hasAttribute("data-modal-open"))return;const{key:n}=e;if("ArrowLeft"!==n&&"ArrowRight"!==n&&"ArrowUp"!==n&&"ArrowDown"!==n)return;e.preventDefault();const a=d.get(N.rowId),l=u.get(N.columnKey);if(null==a||null==l)return;let o=a,s=l;"ArrowLeft"===n&&(s=Math.max(0,l-1)),"ArrowRight"===n&&(s=Math.min(c.length-1,l+1)),"ArrowUp"===n&&(o=Math.max(0,a-1)),"ArrowDown"===n&&(o=Math.min(i.length-1,a+1));const g=i[o],m=c[s];if(!g||!m)return;const h=j(g,o);C({rowId:h,columnKey:m.key}),y&&y({row:g,column:m,value:g[m.key],rowIndex:o,colIndex:s}),((e,n)=>{if(!t)return;const a=t.clientHeight,l=e*f,o=l+f;l<t.scrollTop?t.scrollTop=l:o>t.scrollTop+a&&(t.scrollTop=o-a);const s=c[n]?.width||100;let i=p?36:0;for(let e=0;e<n;e++)i+=c[e]?.width||100;const d=i+s,u=t.clientWidth;i<t.scrollLeft?t.scrollLeft=i:d>t.scrollLeft+u&&(t.scrollLeft=d-u),r&&(r.scrollLeft=t.scrollLeft)})(o,s)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,N,i,c,f,p,d,u,y]),l(()=>{if(!t||!S||!M){const e={bounds:null,cells:[]},t="none";return void(t!==T.current&&(T.current=t,z.current?.(e)))}const e=Math.min(S.rowIndex,M.rowIndex),n=Math.max(S.rowIndex,M.rowIndex),a=Math.min(S.colIndex,M.colIndex),l=Math.max(S.colIndex,M.colIndex),o=[];for(let t=e;t<=n;t++){const e=i[t];if(e)for(let n=a;n<=l;n++){const a=c[n];a&&r(e,a)&&o.push({row:e,column:a,value:e[a.key],rowIndex:t,colIndex:n})}}const s={bounds:{rowStart:e,rowEnd:n,colStart:a,colEnd:l},cells:o},d=`${e}-${n}-${a}-${l}|len:${o.length}`;d!==T.current&&(T.current=d,z.current?.(s))},[t,S,M,i,w,r]),l(()=>{if(!t&&!e)return;const n=async t=>{if(!t.metaKey&&!t.ctrlKey||"c"!==t.key.toLowerCase())return;const n=!!t.shiftKey,a=!(!S||!M),l=!(!e||!N);if(!a&&!l)return;if(!a&&l){const e=window.getSelection();if(e&&e.toString().length>0)return;const t=document.activeElement;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return}t.preventDefault();const o=(()=>{const e=[];if(a&&S&&M){const t=Math.min(S.rowIndex,M.rowIndex),n=Math.max(S.rowIndex,M.rowIndex),a=Math.min(S.colIndex,M.colIndex),l=Math.max(S.colIndex,M.colIndex);for(let o=t;o<=n;o++){const t=i[o];if(t)for(let n=a;n<=l;n++){const a=c[n];a&&r(t,a)&&e.push({row:t,column:a,value:t[a.key],rowIndex:o,colIndex:n})}}}else if(l&&N){const t=d.get(N.rowId),r=u.get(N.columnKey);if(null!=t&&null!=r){const n=i[t],a=c[r];n&&a&&e.push({row:n,column:a,value:n[a.key],rowIndex:t,colIndex:r})}}return e})();if(!o.length)return;const s=e=>{const t=null==e?"":String(e);return t.includes('"')||t.includes("\t")||t.includes("\n")||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t};let g="";if(a&&S&&M){const e=Math.min(S.rowIndex,M.rowIndex),t=Math.max(S.rowIndex,M.rowIndex),a=Math.min(S.colIndex,M.colIndex),l=Math.max(S.colIndex,M.colIndex);if(n){const e=[];for(let t=a;t<=l;t++){const r=c[t];r&&e.push(s(r.header??r.key))}g+=e.join("\t")+"\n"}for(let n=e;n<=t;n++){const e=i[n];if(!e)continue;const o=[];for(let t=a;t<=l;t++){const n=c[t];n&&(r(e,n)?o.push(s(e[n.key])):o.push(""))}g+=o.join("\t"),n<t&&(g+="\n")}}else g=s(o[0].value);try{await navigator.clipboard.writeText(g)}catch{console.warn("Failed to write to clipboard")}if("function"==typeof $.current){const e=a&&S&&M?{rowStart:Math.min(S.rowIndex,M.rowIndex),rowEnd:Math.max(S.rowIndex,M.rowIndex),colStart:Math.min(S.colIndex,M.colIndex),colEnd:Math.max(S.colIndex,M.colIndex)}:null;try{$.current({text:g,bounds:e,cells:o,isRectangular:!!e,isFocusedCell:!e})}catch{}}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t,e,S,M,N,i,c,r,d,u]),{focusedCell:N,selectionAnchor:S,selectionEnd:M,dragOverlay:E,isCellSelected:O,isCellFocused:P,handleCellMouseDown:_,handleCellMouseEnter:K}})({cellFocusEnabled:T,cellSelectionEnabled:K,canSelectCell:V,flatRows:dr,columnsWithWidths:Zt,rowIndexById:ur,colIndexByKey:ir,rowById:gr,colByKey:cr,scrollRef:_t,headerScrollRef:Pe,resolvedRowHeight:Ne,selectable:y,onCellFocusChange:O,onCellSelectionChange:B,onCopyCells:te,columnKeys:mr,getRowId:hr}),{editingCell:wr,startEdit:kr,commitEdit:Cr,cancelEdit:Ar,isEditing:Pr}=(({getRowId:e,onCellEdit:t,onCellEditStart:r,focusedCell:n,getRowById:o,getColumnByKey:i})=>{const[c,d]=a(null),u=s((t,n)=>{if(!((e,t)=>!!e.editable&&("function"==typeof e.editable?e.editable(t):!!e.editable))(n,t))return;const a=t[n.key];if(r&&!1===r({row:t,column:n,value:a}))return;const l=e(t);d({rowId:l,columnKey:n.key,initialValue:a,row:t,column:n})},[e,r]),g=s(e=>{if(!c)return;const{row:r,column:n,initialValue:a,rowId:l}=c;d(null),e!==a&&t?.({row:r,column:n,oldValue:a,newValue:e,rowId:l})},[c,t]),m=s(()=>{d(null)},[]);l(()=>{if(!n||!o||!i)return;const e=e=>{if("F2"!==e.key)return;if(c)return;const t=o(n.rowId),r=i(n.columnKey);t&&r&&(e.preventDefault(),u(t,r))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,c,o,i,u]);const h=s((e,t)=>c?.rowId===e&&c?.columnKey===t,[c]);return{editingCell:c,startEdit:u,commitEdit:g,cancelEdit:m,isEditing:h}})({getRowId:hr,onCellEdit:P,onCellEditStart:_,focusedCell:xr,getRowById:e=>gr.get(e),getColumnByKey:e=>cr.get(e)}),Kr=Zt.reduce((e,t)=>e+(t.width||100),0);jt.current=dr,Nt.current=Zt,Ct.current=Ne,St.current=y,_t.current&&Rt.current!==_t.current&&(Rt.current=_t.current),l(()=>{1!==Qe&&(W?.enabled&&"server"===W.mode?Xe(1):Ze())},[Ee,Ae]);const Vr=n(()=>function(e){const t=(e||Or||"").replace(/-/g,"").toLowerCase();if("kdinternaldevbypass"===t)return!0;if(32!==t.length)return!1;try{const e=new Uint32Array(4);for(let r=0;r<4;r++)e[r]=parseInt(t.slice(8*r,8*r+8),16);const r=new Uint32Array([e[0],e[1]]),n=new Uint32Array([e[2],e[3]]);Tr(r,$r),Tr(n,$r);const a=r[1];if(1262769713!==r[0])return!1;const l=Math.floor(a/1e4),o=Math.floor(a%1e4/100)-1,s=a%100;if(l<2024||o<0||o>11||s<1||s>31)return!1;const i=new Date(l,o,s,23,59,59);return!(new Date>i&&(console.error("[KDGrid] License expired on "+i.toDateString()),1))}catch{return!1}}(ie),[ie]);return N.jsxs("div",{ref:pe,className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden bg-white dark:bg-gray-900 h-full flex flex-col","data-grid-container":!0,children:[v&&k&&N.jsx(jr,{globalFilter:Ee,filteredDataLength:Fe.length,totalDataLength:Ue.totalRows,paginationMode:W?.mode,selectedRowsCount:Et.size,showExport:w,columns:t,columnFilters:Ae,columnVisibility:xt,onResetColumns:kt,exportOptions:{enabled:(ae?.enabled??!0)&&w,formats:ae?.formats??["xlsx"],filename:ae?.filename??"grid-data",onExport:zt},customLeftContent:J,customRightContent:Z,onGlobalFilterChange:et,onClearFilters:$t,onColumnFilter:ze,onColumnVisibilityChange:yt,columnOrder:mt,onColumnOrderChange:bt,pinnedColumns:ht,onScrollToColumn:e=>{const t=_t.current,r=Pe.current;if(!t)return;const n=ir.get(e);if(null==n)return;const a=Zt[n]?.width||100;let l=y?C:0;for(let e=0;e<n;e++)l+=Zt[e]?.width||100;const o=l+a,s=t.clientWidth;if(l<t.scrollLeft)t.scrollTo({left:l,behavior:"smooth"});else if(o>t.scrollLeft+s)t.scrollTo({left:o-s,behavior:"smooth"});else{const e=Math.max(0,l-Math.max(0,(s-a)/2));t.scrollTo({left:e,behavior:"smooth"})}r&&(r.scrollLeft=t.scrollLeft)},density:ve,onDensityChange:Tt,showDensityControl:x}),N.jsxs("div",{className:"flex flex-col relative flex-1 min-h-50",children:[j&&("visible"===Q||"auto"===Q&&rt.columnKeys.length>0)&&N.jsx(Re,{columns:t,groupedKeys:rt.columnKeys,onRemove:ot,onReorder:st,onDropColumnKey:lt,isAnyExpanded:rt.expanded.size>0,onToggleExpandAll:()=>{rt.expanded.size>0?ut():dt()}}),N.jsxs("div",{ref:_t,role:"grid","aria-rowcount":dr.length+1,"aria-colcount":Zt.length,"aria-label":"Data grid",className:"flex-1 overflow-auto relative [&::-webkit-scrollbar]:thin "+(K?"select-none":""),onScroll:Bt,children:[N.jsx("div",{className:"sticky top-0 z-3",children:N.jsx("div",{style:{minWidth:`${Kr+(y?C:0)}px`},children:(()=>{const t=er,r=nr.filter(e=>!Mt.has(e.key));return N.jsx(we,{pinnedColumns:t,unpinnedColumns:r,hvPadLeft:lr,hvPadRight:or,headerHeight:Ce,sortConfig:Te,columnFilters:Ae,selectable:y,selectedRows:Et,totalRows:Dt.length,data:e,onSort:Ke,onColumnFilter:ze,onSelectAll:()=>At(Et.size!==Dt.length),onColumnResize:ft,pinnedKeySet:Mt,onColumnPin:pt,groupable:j,groupedByColumn:rt.columnKeys[0]||null,groupedByColumns:rt.columnKeys,onGroupToggle:(e,t)=>t?lt(e):ot(e),onGroupBy:at,onAutosizeColumn:vt,onAutosizeAllColumns:wt,onResetColumns:kt,columnOrder:mt,onColumnOrderChange:bt,paginationMode:W?.enabled?W.mode:null,minResizeWidth:m})})()})}),N.jsx("div",{style:{minWidth:`${Kr+(y?C:0)}px`,height:Ot?Dt.length*Ne+"px":"auto"},children:Vr?G||0!==Dt.length?N.jsx("div",{style:{transform:`translateY(${Ot?Kt.offsetY:0}px)`,willChange:"transform",contain:"content"},children:(()=>{const e=[];let n=[];const a=()=>{if(!n.length)return;const t=`chunk-${hr(n[0])}-${n.length}-${Kt.offsetY}`,a=null!=wr&&n.some(e=>hr(e)===wr.rowId);e.push(N.jsx("div",{style:{opacity:G?.5:1},children:N.jsx(Se,{data:n,columns:nr,selectedRows:Et,virtualized:!1,virtualizedRange:{startIndex:0,endIndex:n.length-1,offsetY:0},rowHeight:Ne,selectable:y,isRowSelectable:b,onRowSelect:Lt,pinnedColumns:Mt,hvPadLeft:lr,hvPadRight:or,rowStyle:L,globalFilter:Ee,onContextMenu:A,onRowDoubleClick:F,onRowClick:I,onCellClick:z,onCellContextMenu:$,isCellFocused:yr,isCellSelected:pr,onCellMouseDown:br,onCellMouseEnter:vr,contextMenuItems:oe,getRowId:r,isEditing:Pr,onStartEdit:kr,onCommitEdit:Cr,onCancelEdit:Ar,editingInitialValue:a?wr?.initialValue:void 0})},t)),n=[]};for(const r of Vt)if(r._isGroupHeader)a(),e.push(N.jsx(Me,{row:r,isExpanded:rt.expanded.has(r._groupKey||""),onToggle:it,viewportWidth:ye,selectable:y,rowHeight:Ne,getHeaderLabel:e=>t.find(t=>t.key===e)?.header||e,getValueLabel:(e,r)=>{const n=t.find(t=>t.key===e);if(n?.formatter)try{return n.formatter(r)}catch(e){return String(r??"")}return String(r??"")},renderGroupActions:le},r.id));else if(r._isGroupFooter)if(a(),"chips"===ee){const t=Zt.filter(e=>!!e.aggregate&&r._groupAgg&&void 0!==r._groupAgg[e.key]).map(e=>{const t=r._groupAgg[e.key],n=e.aggregateFormatter||e.formatter,a=n?(()=>{try{return n(t)}catch{return String(t)}})():String(t);return N.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-900/40 text-blue-700 dark:text-blue-200 text-xs font-medium",title:`${e.header}`,children:[e.header,": ",a]},e.key)});e.push(N.jsx("div",{className:"sticky left-0 z-1",style:{minWidth:`${Kr+(y?C:0)}px`,height:`${Ne}px`},children:N.jsxs("div",{className:"flex items-center justify-between h-full border-t border-blue-200 dark:border-blue-800 bg-blue-50/60 dark:bg-blue-900/20 px-4",role:"contentinfo",children:[N.jsx("div",{className:"flex items-center gap-2 flex-wrap overflow-hidden",children:t.length?t:N.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"No aggregates"})}),N.jsx("span",{className:"text-[10px] uppercase tracking-wide text-blue-700 dark:text-blue-300",children:"Group Summary"})]})},r.id))}else e.push(N.jsx("div",{className:"sticky left-0 z-1 bg-blue-100 dark:bg-gray-900",style:{minWidth:`${Kr+(y?C:0)}px`,height:`${Ne}px`},children:N.jsxs("div",{className:"flex h-full border-t border-blue-200 dark:border-blue-800 bg-blue-50/60 dark:bg-blue-900/20",role:"contentinfo",children:[y&&N.jsx("div",{style:{width:C},className:"shrink-0"}),Zt.map(e=>{const t=e.width||100,n=r._groupAgg?r._groupAgg[e.key]:void 0,a=e.aggregateFormatter||e.formatter,l=void 0===n?"":a?(()=>{try{return a(n)}catch{return n}})():n;let o;if("number"==typeof l)o=Number.isInteger(l)?String(l):l.toFixed(2);else if(isNaN(l)||""===l||null===l)o=String(l??"");else{const e=Number(l);o=Number.isInteger(e)?String(e):e.toFixed(2)}return N.jsx("div",{className:"px-2 text-xs font-medium text-blue-800 dark:text-blue-200 flex items-center overflow-hidden",style:{width:t,minWidth:t,maxWidth:t},title:o?`${e.header}: ${o}`:void 0,children:N.jsx("span",{className:"truncate w-full",children:o})},`agg-cell-${r._groupKey}-${e.key}`)})]})},r.id));else n.push(r);return a(),e})()}):N.jsx(N.Fragment,{}):N.jsx(M,{})}),se?.enabled&&N.jsxs("div",{style:{minWidth:`${Kr+(y?C:0)}px`},children:[N.jsx("div",{ref:Wt,style:{height:1},"aria-hidden":!0}),se.isLoading&&N.jsx("div",{className:"flex items-center justify-center gap-3 py-4 text-sm text-gray-500 dark:text-gray-400","aria-live":"polite","aria-label":"Loading more rows",children:se.loadingRenderer?se.loadingRenderer():N.jsxs(N.Fragment,{children:[N.jsx(ce,{className:"animate-spin h-4 w-4 text-blue-500"}),N.jsx("span",{children:"Loading more rows…"})]})}),!se.isLoading&&!se.hasMore&&N.jsxs("div",{className:"flex items-center justify-center py-3 text-xs text-gray-400 dark:text-gray-600 gap-2",children:[N.jsx("span",{className:"inline-block w-12 h-px bg-gray-200 dark:bg-gray-700"}),"All rows loaded",N.jsx("span",{className:"inline-block w-12 h-px bg-gray-200 dark:bg-gray-700"})]})]})]}),qt&&N.jsx("div",{className:`pointer-events-none absolute left-0 right-0 h-1 bg-gray-200 overflow-hidden z-30 ${Xt?"opacity-0 transition-opacity duration-200":"opacity-100"} dark:bg-gray-700`,style:{top:Jt},children:N.jsx("div",{className:"h-full w-1/3 bg-blue-500 animate-[slide_1.2s_linear_infinite]"})}),!G&&0===Dt.length&&N.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 flex items-center justify-center",children:N.jsx("div",{className:"pointer-events-auto",children:N.jsx(De,{hasFilters:!!Ee||Object.keys(Ae).length>0,hasData:e.length>0,message:de,renderer:ue})})})]}),sr&&N.jsx("div",{ref:_e,className:"shrink-0 overflow-x-hidden overflow-y-visible [&::-webkit-scrollbar]:hidden",style:{scrollbarWidth:"none",msOverflowStyle:"none"},onWheel:Yt,children:N.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700",style:{minWidth:`${Kr+(y?C:0)}px`,height:`${Ne}px`},children:N.jsx(S,{columns:Zt,data:dr,selectable:y,rowHeight:Ne,pinnedColumns:Mt})})}),!se?.enabled&&N.jsx(Le,{paginationConfig:Ue,currentPage:Ue.currentPage,isServerLoading:qe,selectedRowsCount:Et.size,totalDataLength:e.length,filteredDataLength:"server"===W?.mode?void 0:Fe.length,paginationMode:W.mode,onPageChange:Xe,onPageSizeChange:Je}),fr&&N.jsx("div",{className:"fixed z-50 pointer-events-none select-none",style:{top:fr.y+12,left:fr.x+12},children:N.jsxs("div",{className:"px-2 py-1 rounded bg-gray-800 text-white text-xs shadow-lg opacity-90",children:[fr.rows," × ",fr.cols]})})]})});export{S as FooterAggregate,we as GridHeader,Se as GridRows,Kr as KDGrid,Le as PaginationControls,jr as SearchToolbar,Pr as setLicenseKey,Nr as useAdvancedFiltering,Lr as usePagination,Fr as useSelection,Ir as useVirtualization};
|