react-kd-grid 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/GridHeader.d.ts +5 -1
- package/dist/components/PaginationControls.d.ts +4 -1
- package/dist/components/SearchToolbar.d.ts +4 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/dateUtils.d.ts +16 -0
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=require("react-dom");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var n,a=r(e),o=r(t),s={exports:{}},l={};function i(){if(n)return l;n=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 o in n={},r)"key"!==o&&(n[o]=r[o]);else n=r;return{$$typeof:e,type:t,key:a,ref:void 0!==(r=n.ref)?r:null,props:n}}return l.Fragment=t,l.jsx=r,l.jsxs=r,l}var c,u,d={};function m(){return c||(c=1,"production"!==process.env.NODE_ENV&&function(){function t(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===S?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case g:return"Fragment";case x:return"Profiler";case p:return"StrictMode";case v:return"Suspense";case k:return"SuspenseList";case C:return"Activity"}if("object"==typeof e)switch("number"==typeof e.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case f:return"Portal";case b:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case w:var r=e.render;return(e=e.displayName)||(e=""!==(e=r.displayName||r.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case j:return null!==(r=e.displayName||null)?r:t(e.type)||"Memo";case N:r=e._payload,e=e._init;try{return t(e(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(e){if(e===g)return"<>";if("object"==typeof e&&null!==e&&e.$$typeof===N)return"<...>";try{var r=t(e);return r?"<"+r+">":"<...>"}catch(e){return"<...>"}}function o(){return Error("react-stack-top-frame")}function s(){var e=t(this.type);return T[e]||(T[e]=!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!==(e=this.props.ref)?e:null}function l(e,r,a,o,l,c){var d,m=r.children;if(void 0!==m)if(o)if(R(m)){for(o=0;o<m.length;o++)i(m[o]);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(D.call(r,"key")){m=t(e);var f=Object.keys(r).filter(function(e){return"key"!==e});o=0<f.length?"{key: someKey, "+f.join(": ..., ")+": ...}":"{key: someKey}",F[m+o]||(f=0<f.length?"{"+f.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} />',o,m,f,m),F[m+o]=!0)}if(m=null,void 0!==a&&(n(a),m=""+a),function(e){if(D.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 g in a={},r)"key"!==g&&(a[g]=r[g]);else a=r;return m&&function(e,t){function r(){u||(u=!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 e?e.displayName||e.name||"Unknown":e),function(e,t,r,n,a,o){var l=r.ref;return e={$$typeof:h,type:e,key:t,props:r,_owner:n},Object.defineProperty(e,"ref",null!==(void 0!==l?l:null)?{enumerable:!1,get:s}:{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:o}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(e,m,a,null===(d=M.A)?null:d.getOwner(),l,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===h}var u,m=e,h=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),b=Symbol.for("react.context"),w=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"),M=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,R=Array.isArray,E=console.createTask?console.createTask:function(){return null},T={},P=(m={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(m,o)(),L=E(a(o)),F={};d.Fragment=g,d.jsx=function(e,t,r){var n=1e4>M.recentlyCreatedOwnerStacks++;return l(e,t,r,!1,n?Error("react-stack-top-frame"):P,n?E(a(e)):L)},d.jsxs=function(e,t,r){var n=1e4>M.recentlyCreatedOwnerStacks++;return l(e,t,r,!0,n?Error("react-stack-top-frame"):P,n?E(a(e)):L)}}()),d}function h(){return u||(u=1,s.exports="production"===process.env.NODE_ENV?i():m()),s.exports}var f=h();const g=48,p=e.memo(({columns:t,data:r,selectable:n,rowHeight:a,pinnedColumns:o=new Set})=>{const s=e.useMemo(()=>{const e={},n=t.filter(e=>e.footer_aggregate);return 0===n.length||n.forEach(t=>{const n=r.map(e=>e[t.key]);let a=null;if("function"==typeof t.footer_aggregate)try{a=t.footer_aggregate(n)}catch(e){console.warn(`Error computing custom footer aggregate for column ${t.key}:`,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))),o=n.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)),s=()=>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(t.footer_aggregate){case"count":a=r.length;break;case"sum":o.length&&(a=o.reduce((e,t)=>e+t,0));break;case"avg":o.length&&(a=o.reduce((e,t)=>e+t,0)/o.length);break;case"min":if(o.length)a=Math.min(...o);else{const e=s();e.length&&(a=new Date(Math.min(...e)))}break;case"max":if(o.length)a=Math.max(...o);else{const e=s();e.length&&(a=new Date(Math.max(...e)))}break;default:a=null}}null!=a&&(e[t.key]=a)}),e},[t,r]);if(!t.some(e=>e.footer_aggregate))return null;const l=t.reduce((e,t)=>e+t.width,0),i=e.useMemo(()=>{const e=new Map,r=t.filter(e=>o.has(e.key)).map(e=>e.key);let a=n?g:0;for(const n of r)e.set(n,a),a+=t.find(e=>e.key===n)?.width||100;return e},[t,o,n]);return f.jsxs("div",{className:"flex h-full",style:{minWidth:`${l+(n?g:0)}px`,height:`${a}px`},children:[n&&f.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:f.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Total"})},"select-footer-cell"),t.map(e=>{const t=e.width,r=s[e.key],n=e.footer_aggregate&&void 0!==r;let l="";if(n){const t=e.footerAggregateFormatter||e.formatter;if(t)try{l=t(r)}catch{l=String(r)}else l="number"==typeof r?r%1==0?r.toString():r.toFixed(2):String(r?.toFixed)}const c=o.has(e.key),u=c&&i.get(e.key)||0;return f.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?`${u}px`:"auto",height:`${a}px`},title:n?`${e.header}: ${l}`:void 0,children:n&&f.jsx("span",{className:"truncate w-full",children:l})},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.footer_aggregate!==a.footer_aggregate)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,o=e.data.length-1,s=t.data.length-1,l=e.data.length>0?r(e.data[o],o,e.getRowId):void 0,i=t.data.length>0?r(t.data[s],s,t.getRowId):void 0;return n===a&&l===i&&e.pinnedColumns?.size===t.pinnedColumns?.size}),x=({size:e=16,children:t,...r})=>f.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}),y=e=>f.jsx(x,{...e,children:f.jsx("polyline",{points:"15 18 9 12 15 6"})}),b=e=>f.jsx(x,{...e,children:f.jsx("polyline",{points:"9 18 15 12 9 6"})}),w=e=>f.jsx(x,{...e,children:f.jsx("polyline",{points:"6 9 12 15 18 9"})}),v=e=>f.jsxs(x,{...e,children:[f.jsx("polyline",{points:"11 17 6 12 11 7"}),f.jsx("polyline",{points:"18 17 13 12 18 7"})]}),k=e=>f.jsxs(x,{...e,children:[f.jsx("polyline",{points:"13 17 18 12 13 7"}),f.jsx("polyline",{points:"6 17 11 12 6 7"})]}),j=e=>f.jsxs(x,{...e,children:[f.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),f.jsx("polyline",{points:"5 12 12 5 19 12"})]}),N=e=>f.jsxs(x,{...e,children:[f.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),f.jsx("polyline",{points:"19 12 12 19 5 12"})]}),C=e=>f.jsxs(x,{...e,children:[f.jsx("path",{d:"m21 16-4 4-4-4"}),f.jsx("path",{d:"M17 20V4"}),f.jsx("path",{d:"m3 8 4-4 4 4"}),f.jsx("path",{d:"M7 4v16"})]}),S=e=>f.jsxs(x,{...e,children:[f.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),f.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),M=e=>f.jsx(x,{...e,children:f.jsx("polyline",{points:"20 6 9 17 4 12"})}),D=e=>f.jsxs(x,{...e,children:[f.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),f.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),R=e=>f.jsxs(x,{...e,children:[f.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),f.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),E=e=>f.jsxs(x,{...e,children:[f.jsx("polyline",{points:"3 6 5 6 21 6"}),f.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),f.jsx("path",{d:"M10 11v6"}),f.jsx("path",{d:"M14 11v6"}),f.jsx("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),T=e=>f.jsxs(x,{...e,children:[f.jsx("polyline",{points:"21 8 21 21 3 21 3 8"}),f.jsx("rect",{x:"1",y:"3",width:"22",height:"5"}),f.jsx("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]}),P=e=>f.jsxs(x,{...e,children:[f.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),f.jsx("polyline",{points:"7 10 12 15 17 10"}),f.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),L=e=>f.jsxs(x,{...e,children:[f.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),f.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),f.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]}),F=e=>f.jsx(x,{...e,children:f.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),A=e=>f.jsxs(x,{...e,children:[f.jsx("path",{d:"M13.013 3H2l8 9.46V19l4 2v-6.54l.9-1.055"}),f.jsx("line",{x1:"22",y1:"3",x2:"11",y2:"14"})]}),I=e=>f.jsxs(x,{...e,children:[f.jsx("circle",{cx:"12",cy:"12",r:"3"}),f.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"})]}),O=e=>f.jsxs(x,{...e,children:[f.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),f.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"})]}),z=e=>f.jsxs(x,{...e,children:[f.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),f.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),f.jsx("path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h12"}),f.jsx("path",{d:"M15 9.34V6h1a2 2 0 0 0 0-4H7.89"})]}),$=e=>f.jsxs(x,{...e,children:[f.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),f.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),f.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),f.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),f.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1"})]}),H=e=>f.jsxs(x,{...e,children:[f.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),f.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),f.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),f.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),f.jsx("rect",{x:"7",y:"7",width:"4",height:"4",rx:"1"}),f.jsx("rect",{x:"13",y:"13",width:"4",height:"4",rx:"1"})]}),_=e=>f.jsxs(x,{...e,children:[f.jsx("circle",{cx:"12",cy:"12",r:"1"}),f.jsx("circle",{cx:"19",cy:"12",r:"1"}),f.jsx("circle",{cx:"5",cy:"12",r:"1"})]}),W=e=>f.jsxs(x,{...e,children:[f.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),f.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Y=e=>f.jsxs(x,{...e,children:[f.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"}),f.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"}),f.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),K=e=>f.jsxs(x,{...e,children:[f.jsx("circle",{cx:"11",cy:"11",r:"8"}),f.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),q=e=>f.jsxs(x,{...e,children:[f.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),f.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"}),f.jsx("path",{d:"M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3"})]}),B=e=>f.jsxs(x,{...e,children:[f.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),f.jsx("polyline",{points:"14 2 14 8 20 8"}),f.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),f.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),f.jsx("polyline",{points:"10 9 9 9 8 9"})]}),V=e=>f.jsxs(x,{...e,children:[f.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),f.jsx("path",{d:"M3 9h18"}),f.jsx("path",{d:"M3 15h18"}),f.jsx("path",{d:"M9 3v18"})]}),G=e=>f.jsxs(x,{...e,children:[f.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),f.jsx("circle",{cx:"9",cy:"7",r:"4"}),f.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),f.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),X=e=>f.jsxs(x,{...e,children:[f.jsx("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),f.jsx("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),f.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),f.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),f.jsx("circle",{cx:"12",cy:"12",r:"4"}),f.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"})]}),Q=e=>f.jsx(x,{...e,children:f.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),U=({value:t,onChange:r,placeholder:n="Enter text to filter..."})=>{const[a,o]=e.useState(t?.value||""),[s,l]=e.useState(t?.operator||"contains");return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Filter Type"}),f.jsxs("select",{value:s,onChange:e=>(e=>{const t=e;l(t),a.trim()&&r({type:"text",value:a,operator:t})})(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",children:[f.jsx("option",{value:"contains",children:"Contains"}),f.jsx("option",{value:"equals",children:"Equals"}),f.jsx("option",{value:"startsWith",children:"Starts with"}),f.jsx("option",{value:"endsWith",children:"Ends with"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Value"}),f.jsx("input",{type:"text",value:a,onChange:e=>{return o(t=e.target.value),void(t.trim()?r({type:"text",value:t,operator:s}):r(null));var t},placeholder: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"})]})]})},J=({value:t,onChange:r,min:n,max:a})=>{const[o,s]=e.useState(t?.value||""),[l,i]=e.useState(t?.secondValue||""),[c,u]=e.useState(t?.operator||"equals"),d=(e,t=!1)=>{t?i(e):s(e);const n=parseFloat(e),a=parseFloat(l);"between"===c?isNaN(n)||isNaN(a)?r(null):r({type:"number",value:Math.min(n,a),secondValue:Math.max(n,a),operator:"between"}):isNaN(n)?r(null):r({type:"number",value:n,operator:c})};return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Filter Type"}),f.jsxs("select",{value:c,onChange:e=>(e=>{const t=e;if(u(t),"between"===t){const e=parseFloat(o),t=parseFloat(l);isNaN(e)||isNaN(t)||r({type:"number",value:Math.min(e,t),secondValue:Math.max(e,t),operator:"between"})}else{const e=parseFloat(o);isNaN(e)||r({type:"number",value:e,operator:t})}})(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",children:[f.jsx("option",{value:"equals",children:"Equals"}),f.jsx("option",{value:"gt",children:"Greater than"}),f.jsx("option",{value:"gte",children:"Greater than or equal"}),f.jsx("option",{value:"lt",children:"Less than"}),f.jsx("option",{value:"lte",children:"Less than or equal"}),f.jsx("option",{value:"between",children:"Between"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"between"===c?"From Value":"Number Value"}),f.jsx("input",{type:"number",value:o,onChange:e=>d(e.target.value),min:n,max:a,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),"between"===c&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"To Value"}),f.jsx("input",{type:"number",value:l,onChange:e=>d(e.target.value,!0),min:n,max:a,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]})]})},Z=({name:e,label:t,value:r,onChange:n,className:a=""})=>f.jsxs("div",{className:`space-y-1 ${a}`,children:[t&&f.jsx("label",{className:"text-sm font-medium text-gray-700",children:t}),f.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"})]});function ee(e){const t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new e.constructor(+e):"number"==typeof e||"[object Number]"===t||"string"==typeof e||"[object String]"===t?new Date(e):new Date(NaN)}function te(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function re(e,t){const r=ee(e);return isNaN(t)?te(e,NaN):t?(r.setDate(r.getDate()+t),r):r}const ne=6048e5;let ae={};function oe(){return ae}function se(e,t){const r=oe(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=ee(e),o=a.getDay(),s=(o<n?7:0)+o-n;return a.setDate(a.getDate()-s),a.setHours(0,0,0,0),a}function le(e){return se(e,{weekStartsOn:1})}function ie(e){const t=ee(e),r=t.getFullYear(),n=te(e,0);n.setFullYear(r+1,0,4),n.setHours(0,0,0,0);const a=le(n),o=te(e,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);const s=le(o);return t.getTime()>=a.getTime()?r+1:t.getTime()>=s.getTime()?r:r-1}function ce(e){const t=ee(e);return t.setHours(0,0,0,0),t}function ue(e){const t=ee(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}const de={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function me(e){return(t={})=>{const r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const he={date:me({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:me({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:me({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},fe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function ge(e){return(t,r)=>{let n;if("formatting"===(r?.context?String(r.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,a=r?.width?String(r.width):t;n=e.formattingValues[a]||e.formattingValues[t]}else{const t=e.defaultWidth,a=r?.width?String(r.width):e.defaultWidth;n=e.values[a]||e.values[t]}return n[e.argumentCallback?e.argumentCallback(t):t]}}const pe={ordinalNumber:(e,t)=>{const r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},era:ge({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:ge({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:ge({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:ge({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:ge({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function xe(e){return(t,r={})=>{const n=r.width,a=t.match(n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth]);if(!a)return null;const o=a[0],s=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(s)?function(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return r}(s,e=>e.test(o)):function(e,t){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}(s,e=>e.test(o));let i;return i=e.valueCallback?e.valueCallback(l):l,i=r.valueCallback?r.valueCallback(i):i,{value:i,rest:t.slice(o.length)}}}const ye={ordinalNumber:(be={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const r=e.match(be.matchPattern);if(!r)return null;const n=r[0],a=e.match(be.parsePattern);if(!a)return null;let o=be.valueCallback?be.valueCallback(a[0]):a[0];return o=t.valueCallback?t.valueCallback(o):o,{value:o,rest:e.slice(n.length)}}),era:xe({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:xe({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:xe({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:xe({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:xe({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})};var be;const we={code:"en-US",formatDistance:(e,t,r)=>{let n;const a=de[e];return n="string"==typeof a?a:1===t?a.one:a.other.replace("{{count}}",t.toString()),r?.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n},formatLong:he,formatRelative:(e,t,r,n)=>fe[e],localize:pe,match:ye,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ve(e){const t=ee(e),r=+le(t)-+function(e){const t=ie(e),r=te(e,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),le(r)}(t);return Math.round(r/ne)+1}function ke(e,t){const r=ee(e),n=r.getFullYear(),a=oe(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=te(e,0);s.setFullYear(n+1,0,o),s.setHours(0,0,0,0);const l=se(s,t),i=te(e,0);i.setFullYear(n,0,o),i.setHours(0,0,0,0);const c=se(i,t);return r.getTime()>=l.getTime()?n+1:r.getTime()>=c.getTime()?n:n-1}function je(e,t){const r=ee(e),n=+se(r,t)-+function(e,t){const r=oe(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=ke(e,t),o=te(e,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),se(o,t)}(r,t);return Math.round(n/ne)+1}function Ne(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const Ce={y(e,t){const r=e.getFullYear(),n=r>0?r:1-r;return Ne("yy"===t?n%100:n,t.length)},M(e,t){const r=e.getMonth();return"M"===t?String(r+1):Ne(r+1,2)},d:(e,t)=>Ne(e.getDate(),t.length),a(e,t){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];default:return"am"===r?"a.m.":"p.m."}},h:(e,t)=>Ne(e.getHours()%12||12,t.length),H:(e,t)=>Ne(e.getHours(),t.length),m:(e,t)=>Ne(e.getMinutes(),t.length),s:(e,t)=>Ne(e.getSeconds(),t.length),S(e,t){const r=t.length,n=e.getMilliseconds();return Ne(Math.trunc(n*Math.pow(10,r-3)),t.length)}},Se={G:function(e,t,r){const n=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});default:return r.era(n,{width:"wide"})}},y:function(e,t,r){if("yo"===t){const t=e.getFullYear();return r.ordinalNumber(t>0?t:1-t,{unit:"year"})}return Ce.y(e,t)},Y:function(e,t,r,n){const a=ke(e,n),o=a>0?a:1-a;return"YY"===t?Ne(o%100,2):"Yo"===t?r.ordinalNumber(o,{unit:"year"}):Ne(o,t.length)},R:function(e,t){return Ne(ie(e),t.length)},u:function(e,t){return Ne(e.getFullYear(),t.length)},Q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return Ne(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return Ne(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,r){const n=e.getMonth();switch(t){case"M":case"MM":return Ce.M(e,t);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,r){const n=e.getMonth();switch(t){case"L":return String(n+1);case"LL":return Ne(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,r,n){const a=je(e,n);return"wo"===t?r.ordinalNumber(a,{unit:"week"}):Ne(a,t.length)},I:function(e,t,r){const n=ve(e);return"Io"===t?r.ordinalNumber(n,{unit:"week"}):Ne(n,t.length)},d:function(e,t,r){return"do"===t?r.ordinalNumber(e.getDate(),{unit:"date"}):Ce.d(e,t)},D:function(e,t,r){const n=function(e){const t=ee(e),r=function(e,t){const r=ce(e),n=ce(t),a=+r-ue(r),o=+n-ue(n);return Math.round((a-o)/864e5)}(t,function(e){const t=ee(e),r=te(e,0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}(t));return r+1}(e);return"Do"===t?r.ordinalNumber(n,{unit:"dayOfYear"}):Ne(n,t.length)},E:function(e,t,r){const n=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,r,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return Ne(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,r,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return Ne(o,t.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,r){const n=e.getDay(),a=0===n?7:n;switch(t){case"i":return String(a);case"ii":return Ne(a,t.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,r){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(n,{width:"narrow",context:"formatting"});default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(e,t,r){const n=e.getHours();let a;switch(a=12===n?"noon":0===n?"midnight":n/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,r){const n=e.getHours();let a;switch(a=n>=17?"evening":n>=12?"afternoon":n>=4?"morning":"night",t){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,r){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),r.ordinalNumber(t,{unit:"hour"})}return Ce.h(e,t)},H:function(e,t,r){return"Ho"===t?r.ordinalNumber(e.getHours(),{unit:"hour"}):Ce.H(e,t)},K:function(e,t,r){const n=e.getHours()%12;return"Ko"===t?r.ordinalNumber(n,{unit:"hour"}):Ne(n,t.length)},k:function(e,t,r){let n=e.getHours();return 0===n&&(n=24),"ko"===t?r.ordinalNumber(n,{unit:"hour"}):Ne(n,t.length)},m:function(e,t,r){return"mo"===t?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):Ce.m(e,t)},s:function(e,t,r){return"so"===t?r.ordinalNumber(e.getSeconds(),{unit:"second"}):Ce.s(e,t)},S:function(e,t){return Ce.S(e,t)},X:function(e,t,r){const n=e.getTimezoneOffset();if(0===n)return"Z";switch(t){case"X":return De(n);case"XXXX":case"XX":return Re(n);default:return Re(n,":")}},x:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"x":return De(n);case"xxxx":case"xx":return Re(n);default:return Re(n,":")}},O:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Me(n,":");default:return"GMT"+Re(n,":")}},z:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Me(n,":");default:return"GMT"+Re(n,":")}},t:function(e,t,r){return Ne(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,r){return Ne(e.getTime(),t.length)}};function Me(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),o=n%60;return 0===o?r+String(a):r+String(a)+t+Ne(o,2)}function De(e,t){return e%60==0?(e>0?"-":"+")+Ne(Math.abs(e)/60,2):Re(e,t)}function Re(e,t=""){const r=e>0?"-":"+",n=Math.abs(e);return r+Ne(Math.trunc(n/60),2)+t+Ne(n%60,2)}const Ee=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Te=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},Pe={p:Te,P:(e,t)=>{const r=e.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return Ee(e,t);let o;switch(n){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;default:o=t.dateTime({width:"full"})}return o.replace("{{date}}",Ee(n,t)).replace("{{time}}",Te(a,t))}},Le=/^D+$/,Fe=/^Y+$/,Ae=["D","DD","YY","YYYY"];function Ie(e){return Le.test(e)}function Oe(e){return Fe.test(e)}function ze(e,t,r){const n=function(e,t,r){const n="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,r);if(console.warn(n),Ae.includes(e))throw new RangeError(n)}const $e=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,He=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,_e=/^'([^]*?)'?$/,We=/''/g,Ye=/[a-zA-Z]/;function Ke(e,t,r){const n=oe(),a=r?.locale??n.locale??we,o=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,l=ee(e);if(!function(e){if(!((t=e)instanceof Date||"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)||"number"==typeof e))return!1;var t;const r=ee(e);return!isNaN(Number(r))}(l))throw new RangeError("Invalid time value");let i=t.match(He).map(e=>{const t=e[0];return"p"===t||"P"===t?(0,Pe[t])(e,a.formatLong):e}).join("").match($e).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:qe(e)};if(Se[t])return{isToken:!0,value:e};if(t.match(Ye))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});a.localize.preprocessor&&(i=a.localize.preprocessor(l,i));const c={firstWeekContainsDate:o,weekStartsOn:s,locale:a};return i.map(n=>{if(!n.isToken)return n.value;const o=n.value;return(!r?.useAdditionalWeekYearTokens&&Oe(o)||!r?.useAdditionalDayOfYearTokens&&Ie(o))&&ze(o,t,String(e)),(0,Se[o[0]])(l,o,a.localize,c)}).join("")}function qe(e){const t=e.match(_e);return t?t[1].replace(We,"'"):e}class Be{subPriority=0;validate(e,t){return!0}}class Ve extends Be{constructor(e,t,r,n,a){super(),this.value=e,this.validateValue=t,this.setValue=r,this.priority=n,a&&(this.subPriority=a)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,r){return this.setValue(e,t,this.value,r)}}class Ge extends Be{priority=10;subPriority=-1;set(e,t){return t.timestampIsSet?e:te(e,function(e,t){const r=t instanceof Date?te(t,0):new t(0);return r.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),r.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),r}(e,Date))}}class Xe{run(e,t,r,n){const a=this.parse(e,t,r,n);return a?{setter:new Ve(a.value,this.validate,this.set,this.priority,this.subPriority),rest:a.rest}:null}validate(e,t,r){return!0}}const Qe=/^(1[0-2]|0?\d)/,Ue=/^(3[0-1]|[0-2]?\d)/,Je=/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,Ze=/^(5[0-3]|[0-4]?\d)/,et=/^(2[0-3]|[0-1]?\d)/,tt=/^(2[0-4]|[0-1]?\d)/,rt=/^(1[0-1]|0?\d)/,nt=/^(1[0-2]|0?\d)/,at=/^[0-5]?\d/,ot=/^[0-5]?\d/,st=/^\d/,lt=/^\d{1,2}/,it=/^\d{1,3}/,ct=/^\d{1,4}/,ut=/^-?\d+/,dt=/^-?\d/,mt=/^-?\d{1,2}/,ht=/^-?\d{1,3}/,ft=/^-?\d{1,4}/,gt=/^([+-])(\d{2})(\d{2})?|Z/,pt=/^([+-])(\d{2})(\d{2})|Z/,xt=/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,yt=/^([+-])(\d{2}):(\d{2})|Z/,bt=/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/;function wt(e,t){return e?{value:t(e.value),rest:e.rest}:e}function vt(e,t){const r=t.match(e);return r?{value:parseInt(r[0],10),rest:t.slice(r[0].length)}:null}function kt(e,t){const r=t.match(e);return r?"Z"===r[0]?{value:0,rest:t.slice(1)}:{value:("+"===r[1]?1:-1)*(36e5*(r[2]?parseInt(r[2],10):0)+6e4*(r[3]?parseInt(r[3],10):0)+1e3*(r[5]?parseInt(r[5],10):0)),rest:t.slice(r[0].length)}:null}function jt(e){return vt(ut,e)}function Nt(e,t){switch(e){case 1:return vt(st,t);case 2:return vt(lt,t);case 3:return vt(it,t);case 4:return vt(ct,t);default:return vt(new RegExp("^\\d{1,"+e+"}"),t)}}function Ct(e,t){switch(e){case 1:return vt(dt,t);case 2:return vt(mt,t);case 3:return vt(ht,t);case 4:return vt(ft,t);default:return vt(new RegExp("^-?\\d{1,"+e+"}"),t)}}function St(e){switch(e){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;default:return 0}}function Mt(e,t){const r=t>0,n=r?t:1-t;let a;if(n<=50)a=e||100;else{const t=n+50;a=e+100*Math.trunc(t/100)-(e>=t%100?100:0)}return r?a:1-a}function Dt(e){return e%400==0||e%4==0&&e%100!=0}const Rt=[31,28,31,30,31,30,31,31,30,31,30,31],Et=[31,29,31,30,31,30,31,31,30,31,30,31];function Tt(e,t,r){const n=oe(),a=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,o=ee(e),s=o.getDay(),l=7-a;return re(o,t<0||t>6?t-(s+l)%7:((t%7+7)%7+l)%7-(s+l)%7)}const Pt={G:new class extends Xe{priority=140;parse(e,t,r){switch(t){case"G":case"GG":case"GGG":return r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"});case"GGGGG":return r.era(e,{width:"narrow"});default:return r.era(e,{width:"wide"})||r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"})}}set(e,t,r){return t.era=r,e.setFullYear(r,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["R","u","t","T"]},y:new class extends Xe{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,t,r){const n=e=>({year:e,isTwoDigitYear:"yy"===t});switch(t){case"y":return wt(Nt(4,e),n);case"yo":return wt(r.ordinalNumber(e,{unit:"year"}),n);default:return wt(Nt(t.length,e),n)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r){const n=e.getFullYear();if(r.isTwoDigitYear){const t=Mt(r.year,n);return e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}return e.setFullYear("era"in t&&1!==t.era?1-r.year:r.year,0,1),e.setHours(0,0,0,0),e}},Y:new class extends Xe{priority=130;parse(e,t,r){const n=e=>({year:e,isTwoDigitYear:"YY"===t});switch(t){case"Y":return wt(Nt(4,e),n);case"Yo":return wt(r.ordinalNumber(e,{unit:"year"}),n);default:return wt(Nt(t.length,e),n)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r,n){const a=ke(e,n);if(r.isTwoDigitYear){const t=Mt(r.year,a);return e.setFullYear(t,0,n.firstWeekContainsDate),e.setHours(0,0,0,0),se(e,n)}return e.setFullYear("era"in t&&1!==t.era?1-r.year:r.year,0,n.firstWeekContainsDate),e.setHours(0,0,0,0),se(e,n)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R:new class extends Xe{priority=130;parse(e,t){return Ct("R"===t?4:t.length,e)}set(e,t,r){const n=te(e,0);return n.setFullYear(r,0,4),n.setHours(0,0,0,0),le(n)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},u:new class extends Xe{priority=130;parse(e,t){return Ct("u"===t?4:t.length,e)}set(e,t,r){return e.setFullYear(r,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]},Q:new class extends Xe{priority=120;parse(e,t,r){switch(t){case"Q":case"QQ":return Nt(t.length,e);case"Qo":return r.ordinalNumber(e,{unit:"quarter"});case"QQQ":return r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return r.quarter(e,{width:"narrow",context:"formatting"});default:return r.quarter(e,{width:"wide",context:"formatting"})||r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=1&&t<=4}set(e,t,r){return e.setMonth(3*(r-1),1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},q:new class extends Xe{priority=120;parse(e,t,r){switch(t){case"q":case"qq":return Nt(t.length,e);case"qo":return r.ordinalNumber(e,{unit:"quarter"});case"qqq":return r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return r.quarter(e,{width:"narrow",context:"standalone"});default:return r.quarter(e,{width:"wide",context:"standalone"})||r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=1&&t<=4}set(e,t,r){return e.setMonth(3*(r-1),1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M:new class extends Xe{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,t,r){const n=e=>e-1;switch(t){case"M":return wt(vt(Qe,e),n);case"MM":return wt(Nt(2,e),n);case"Mo":return wt(r.ordinalNumber(e,{unit:"month"}),n);case"MMM":return r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return r.month(e,{width:"narrow",context:"formatting"});default:return r.month(e,{width:"wide",context:"formatting"})||r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.setMonth(r,1),e.setHours(0,0,0,0),e}},L:new class extends Xe{priority=110;parse(e,t,r){const n=e=>e-1;switch(t){case"L":return wt(vt(Qe,e),n);case"LL":return wt(Nt(2,e),n);case"Lo":return wt(r.ordinalNumber(e,{unit:"month"}),n);case"LLL":return r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return r.month(e,{width:"narrow",context:"standalone"});default:return r.month(e,{width:"wide",context:"standalone"})||r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.setMonth(r,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},w:new class extends Xe{priority=100;parse(e,t,r){switch(t){case"w":return vt(Ze,e);case"wo":return r.ordinalNumber(e,{unit:"week"});default:return Nt(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r,n){return se(function(e,t,r){const n=ee(e),a=je(n,r)-t;return n.setDate(n.getDate()-7*a),n}(e,r,n),n)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},I:new class extends Xe{priority=100;parse(e,t,r){switch(t){case"I":return vt(Ze,e);case"Io":return r.ordinalNumber(e,{unit:"week"});default:return Nt(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r){return le(function(e,t){const r=ee(e),n=ve(r)-t;return r.setDate(r.getDate()-7*n),r}(e,r))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},d:new class extends Xe{priority=90;subPriority=1;parse(e,t,r){switch(t){case"d":return vt(Ue,e);case"do":return r.ordinalNumber(e,{unit:"date"});default:return Nt(t.length,e)}}validate(e,t){const r=Dt(e.getFullYear()),n=e.getMonth();return r?t>=1&&t<=Et[n]:t>=1&&t<=Rt[n]}set(e,t,r){return e.setDate(r),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]},D:new class extends Xe{priority=90;subpriority=1;parse(e,t,r){switch(t){case"D":case"DD":return vt(Je,e);case"Do":return r.ordinalNumber(e,{unit:"date"});default:return Nt(t.length,e)}}validate(e,t){return Dt(e.getFullYear())?t>=1&&t<=366:t>=1&&t<=365}set(e,t,r){return e.setMonth(0,r),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},E:new class extends Xe{priority=90;parse(e,t,r){switch(t){case"E":case"EE":case"EEE":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return r.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,n){return(e=Tt(e,r,n)).setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]},e:new class extends Xe{priority=90;parse(e,t,r,n){const a=e=>{const t=7*Math.floor((e-1)/7);return(e+n.weekStartsOn+6)%7+t};switch(t){case"e":case"ee":return wt(Nt(t.length,e),a);case"eo":return wt(r.ordinalNumber(e,{unit:"day"}),a);case"eee":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"eeeee":return r.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,n){return(e=Tt(e,r,n)).setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},c:new class extends Xe{priority=90;parse(e,t,r,n){const a=e=>{const t=7*Math.floor((e-1)/7);return(e+n.weekStartsOn+6)%7+t};switch(t){case"c":case"cc":return wt(Nt(t.length,e),a);case"co":return wt(r.ordinalNumber(e,{unit:"day"}),a);case"ccc":return r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});case"ccccc":return r.day(e,{width:"narrow",context:"standalone"});case"cccccc":return r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});default:return r.day(e,{width:"wide",context:"standalone"})||r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,n){return(e=Tt(e,r,n)).setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},i:new class extends Xe{priority=90;parse(e,t,r){const n=e=>0===e?7:e;switch(t){case"i":case"ii":return Nt(t.length,e);case"io":return r.ordinalNumber(e,{unit:"day"});case"iii":return wt(r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n);case"iiiii":return wt(r.day(e,{width:"narrow",context:"formatting"}),n);case"iiiiii":return wt(r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n);default:return wt(r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n)}}validate(e,t){return t>=1&&t<=7}set(e,t,r){return(e=function(e,t){const r=ee(e),n=function(e){let t=ee(e).getDay();return 0===t&&(t=7),t}(r);return re(r,t-n)}(e,r)).setHours(0,0,0,0),e}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]},a:new class extends Xe{priority=80;parse(e,t,r){switch(t){case"a":case"aa":case"aaa":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return r.dayPeriod(e,{width:"narrow",context:"formatting"});default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(St(r),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]},b:new class extends Xe{priority=80;parse(e,t,r){switch(t){case"b":case"bb":case"bbb":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return r.dayPeriod(e,{width:"narrow",context:"formatting"});default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(St(r),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]},B:new class extends Xe{priority=80;parse(e,t,r){switch(t){case"B":case"BB":case"BBB":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return r.dayPeriod(e,{width:"narrow",context:"formatting"});default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(St(r),0,0,0),e}incompatibleTokens=["a","b","t","T"]},h:new class extends Xe{priority=70;parse(e,t,r){switch(t){case"h":return vt(nt,e);case"ho":return r.ordinalNumber(e,{unit:"hour"});default:return Nt(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,r){const n=e.getHours()>=12;return e.setHours(n&&r<12?r+12:n||12!==r?r:0,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]},H:new class extends Xe{priority=70;parse(e,t,r){switch(t){case"H":return vt(et,e);case"Ho":return r.ordinalNumber(e,{unit:"hour"});default:return Nt(t.length,e)}}validate(e,t){return t>=0&&t<=23}set(e,t,r){return e.setHours(r,0,0,0),e}incompatibleTokens=["a","b","h","K","k","t","T"]},K:new class extends Xe{priority=70;parse(e,t,r){switch(t){case"K":return vt(rt,e);case"Ko":return r.ordinalNumber(e,{unit:"hour"});default:return Nt(t.length,e)}}validate(e,t){return t>=0&&t<=11}set(e,t,r){const n=e.getHours()>=12;return e.setHours(n&&r<12?r+12:r,0,0,0),e}incompatibleTokens=["h","H","k","t","T"]},k:new class extends Xe{priority=70;parse(e,t,r){switch(t){case"k":return vt(tt,e);case"ko":return r.ordinalNumber(e,{unit:"hour"});default:return Nt(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,r){return e.setHours(r<=24?r%24:r,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]},m:new class extends Xe{priority=60;parse(e,t,r){switch(t){case"m":return vt(at,e);case"mo":return r.ordinalNumber(e,{unit:"minute"});default:return Nt(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setMinutes(r,0,0),e}incompatibleTokens=["t","T"]},s:new class extends Xe{priority=50;parse(e,t,r){switch(t){case"s":return vt(ot,e);case"so":return r.ordinalNumber(e,{unit:"second"});default:return Nt(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setSeconds(r,0),e}incompatibleTokens=["t","T"]},S:new class extends Xe{priority=30;parse(e,t){return wt(Nt(t.length,e),e=>Math.trunc(e*Math.pow(10,3-t.length)))}set(e,t,r){return e.setMilliseconds(r),e}incompatibleTokens=["t","T"]},X:new class extends Xe{priority=10;parse(e,t){switch(t){case"X":return kt(gt,e);case"XX":return kt(pt,e);case"XXXX":return kt(xt,e);case"XXXXX":return kt(bt,e);default:return kt(yt,e)}}set(e,t,r){return t.timestampIsSet?e:te(e,e.getTime()-ue(e)-r)}incompatibleTokens=["t","T","x"]},x:new class extends Xe{priority=10;parse(e,t){switch(t){case"x":return kt(gt,e);case"xx":return kt(pt,e);case"xxxx":return kt(xt,e);case"xxxxx":return kt(bt,e);default:return kt(yt,e)}}set(e,t,r){return t.timestampIsSet?e:te(e,e.getTime()-ue(e)-r)}incompatibleTokens=["t","T","X"]},t:new class extends Xe{priority=40;parse(e){return jt(e)}set(e,t,r){return[te(e,1e3*r),{timestampIsSet:!0}]}incompatibleTokens="*"},T:new class extends Xe{priority=20;parse(e){return jt(e)}set(e,t,r){return[te(e,r),{timestampIsSet:!0}]}incompatibleTokens="*"}},Lt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ft=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,At=/^'([^]*?)'?$/,It=/''/g,Ot=/\S/,zt=/[a-zA-Z]/;function $t(e,t,r,n){const a=Object.assign({},oe()),o=n?.locale??a.locale??we,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,l=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0;if(""===t)return""===e?ee(r):te(r,NaN);const i={firstWeekContainsDate:s,weekStartsOn:l,locale:o},c=[new Ge],u=t.match(Ft).map(e=>{const t=e[0];return t in Pe?(0,Pe[t])(e,o.formatLong):e}).join("").match(Lt),d=[];for(let a of u){!n?.useAdditionalWeekYearTokens&&Oe(a)&&ze(a,t,e),!n?.useAdditionalDayOfYearTokens&&Ie(a)&&ze(a,t,e);const s=a[0],l=Pt[s];if(l){const{incompatibleTokens:t}=l;if(Array.isArray(t)){const e=d.find(e=>t.includes(e.token)||e.token===s);if(e)throw new RangeError(`The format string mustn't contain \`${e.fullToken}\` and \`${a}\` at the same time`)}else if("*"===l.incompatibleTokens&&d.length>0)throw new RangeError(`The format string mustn't contain \`${a}\` and any other token at the same time`);d.push({token:s,fullToken:a});const n=l.run(e,a,o.match,i);if(!n)return te(r,NaN);c.push(n.setter),e=n.rest}else{if(s.match(zt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+s+"`");if("''"===a?a="'":"'"===s&&(a=Ht(a)),0!==e.indexOf(a))return te(r,NaN);e=e.slice(a.length)}}if(e.length>0&&Ot.test(e))return te(r,NaN);const m=c.map(e=>e.priority).sort((e,t)=>t-e).filter((e,t,r)=>r.indexOf(e)===t).map(e=>c.filter(t=>t.priority===e).sort((e,t)=>t.subPriority-e.subPriority)).map(e=>e[0]);let h=ee(r);if(isNaN(h.getTime()))return te(r,NaN);const f={};for(const e of m){if(!e.validate(h,i))return te(r,NaN);const t=e.set(h,f,i);Array.isArray(t)?(h=t[0],Object.assign(f,t[1])):h=t}return te(r,h)}function Ht(e){return e.match(At)[1].replace(It,"'")}const _t=({value:t,onChange:r,min:n,max:a})=>{const o=e=>{if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;try{const t=$t(String(e),"yyyy-MM-dd",new Date);return isNaN(t.getTime())?null:t}catch(t){const r=new Date(e);return isNaN(r.getTime())?null:r}},s=e=>e?Ke(e,"yyyy-MM-dd"):"",[l,i]=e.useState(o(t?.value)),[c,u]=e.useState("between"===t?.operator?o(t?.secondValue??t?.value):null),[d,m]=e.useState(t?.operator||"between");e.useEffect(()=>{m(t?.operator||"between"),i(o(t?.value)),u("between"===t?.operator?o(t?.secondValue??t?.value):null)},[t?.value,t?.secondValue,t?.operator]),e.useEffect(()=>{"between"===d&&!c&&l&&u(l)},[d,l,c]);const h=(e,t,r)=>e?t&&e<t||r&&e>r?null:e:null,g=(e,t=!1)=>{const n=t?l:e,a=t?e:c,o="between"===d&&c?c:x,m=t?h(e,l??p??void 0,x):h(e,p,o);if(t?u(m):i(m),"between"===d)if(n&&a){const e=n>=a?n:a;r({type:"date",value:s(n<=a?n:a),secondValue:s(e),operator:"between"})}else r(null);else r(m?{type:"date",value:s(m),operator:d}:null)},p=e.useMemo(()=>n?new Date(n):void 0,[n]),x=e.useMemo(()=>a?new Date(a):void 0,[a]);return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Filter Type"}),f.jsxs("select",{value:d,onChange:e=>(e=>{const t=e;m(t),"between"===t?l&&c&&r({type:"date",value:l<=c?l:c,secondValue:l>=c?l:c,operator:"between"}):l&&r({type:"date",value:l,operator:t})})(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",children:[f.jsx("option",{value:"equals",children:"On Date"}),f.jsx("option",{value:"gt",children:"After"}),f.jsx("option",{value:"gte",children:"On or After"}),f.jsx("option",{value:"lt",children:"Before"}),f.jsx("option",{value:"lte",children:"On or Before"}),f.jsx("option",{value:"between",children:"Between Dates"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"between"===d?"From Date":"Date"}),f.jsx(Z,{name:"date_filter_start",value:l?Ke(l,"yyyy-MM-dd"):null,onChange:e=>g(e?$t(e,"yyyy-MM-dd",new Date):null,!1),className:"w-full"})]}),"between"===d&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"To Date"}),f.jsx(Z,{name:"date_filter_end",value:c?Ke(c,"yyyy-MM-dd"):null,onChange:e=>g(e?$t(e,"yyyy-MM-dd",new Date):null,!0),className:"w-full"})]})]})},Wt=({value:t,onChange:r,options:n,data:a,columnKey:o})=>{const[s,l]=e.useState(""),[i,c]=e.useState(new Set(t?.value||[]));e.useEffect(()=>{c(new Set(t?.value||[]))},[t]);const u=e.useMemo(()=>{let e=[];const t=e=>null==e||""===e||"string"==typeof e&&""===e.trim();if(n&&n.length>0)e=n;else{const r=a.map(e=>{const r=e[o];return t(r)?null:r});e=[...new Set(r)].map(e=>({label:null===e?"Blank":String(e),value:e}))}const r=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(r.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)))},[n,a,o]),d=e.useMemo(()=>{if(!s)return u;const e=s.toLowerCase();return u.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)||"blank"===e&&t.isBlank)},[u,s]);return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"relative",children:[f.jsx(K,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),f.jsx("input",{type:"text",value:s,onChange:e=>l(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"})]}),f.jsxs("div",{className:"flex justify-between items-center text-sm",children:[f.jsxs("span",{className:"text-gray-600",children:[i.size," of ",u.length," selected"]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("button",{onClick:()=>{const e=new Set(d.map(e=>e.value));c(e),r({type:"multiselect",value:Array.from(e),operator:"equals"})},className:"text-blue-600 hover:text-blue-800 transition-colors",children:"Select All"}),f.jsx("button",{onClick:()=>{c(new Set),r(null)},className:"text-gray-600 hover:text-gray-800 transition-colors",children:"Clear All"})]})]}),f.jsx("div",{className:"max-h-48 overflow-y-auto border border-gray-200 rounded-md",children:0===d.length?f.jsx("div",{className:"p-3 text-sm text-gray-500 text-center",children:"No options found"}):d.map((e,t)=>{const n=i.has(e.value);return f.jsxs("div",{onClick:()=>(e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t),r(t.size>0?{type:"multiselect",value:Array.from(t),operator:"equals"}:null)})(e.value),className:"flex items-center gap-3 p-2 cursor-pointer hover:bg-gray-50 transition-colors "+(n?"bg-blue-50":""),children:[f.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"),children:n&&f.jsx(M,{className:"w-3 h-3"})}),f.jsx("span",{className:`text-sm ${n?"text-blue-900 font-medium":"text-gray-700"} ${e.isBlank?"italic text-gray-500":""}`,children:e.label})]},t)})})]})},Yt=({value:t,onChange:r})=>{const[n,a]=e.useState(void 0!==t?.value?String(t.value):"");return f.jsx("div",{className:"space-y-3",children:f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Boolean Value"}),f.jsxs("select",{value:n,onChange:e=>{return a(t=e.target.value),void r(""===t?null:{type:"boolean",value:"true"===t,operator:"equals"});var t},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[f.jsx("option",{value:"",children:"All values"}),f.jsx("option",{value:"true",children:"True"}),f.jsx("option",{value:"false",children:"False"})]})]})})},Kt=({column:t,data:r,value:n,onChange:a})=>{const o=e.useMemo(()=>{if("object"==typeof t.filterable)return t.filterable;const e=r.slice(0,100).map(e=>e[t.key]).filter(e=>null!=e);if(0===e.length)return{type:"text"};const n=e[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(e)];return a.length<=20?{type:"multiselect",options:a.map(e=>({label:String(e),value:e}))}:{type:"text"}},[t.filterable,t.key,r]);switch(o.type){case"text":return f.jsx(U,{value:n,onChange:a,placeholder:o.placeholder});case"number":return f.jsx(J,{value:n,onChange:a,min:o.min,max:o.max});case"date":return f.jsx(_t,{value:n,onChange:a,min:o.min,max:o.max});case"multiselect":return f.jsx(Wt,{value:n,onChange:a,options:o.options||[],data:r,columnKey:t.key});case"boolean":return f.jsx(Yt,{value:n,onChange:a});default:return null}},qt=({pinnedColumns:t,unpinnedColumns:r,hvPadLeft:n=0,hvPadRight:a=0,headerHeight:o,sortConfig:s,columnFilters:l,selectable:i,selectedRows:c,totalRows:u,data:d,onSort:m,onColumnFilter:h,onSelectAll:p,onColumnResize:x,pinnedKeySet:y=new Set,onColumnPin:b,groupable:w=!1,groupedByColumn:v,onGroupBy:k,groupedByColumns:S=[],onGroupToggle:M,onAutosizeColumn:D,onAutosizeAllColumns:R,onResetColumns:E,columnOrder:T,onColumnOrderChange:P,paginationMode:I="client"})=>{const _=[...t,...r],[W,Y]=e.useState(null),[K,q]=e.useState(null),[B,V]=e.useState(null),[G,X]=e.useState(0),[Q,U]=e.useState(0),[J,Z]=e.useState("menu"),[ee,te]=e.useState(null),[re,ne]=e.useState(!1);e.useEffect(()=>{ne("ontouchstart"in window||navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches)},[]);const[ae,oe]=e.useState(null),[se,le]=e.useState(null),ie=c.size===u&&u>0,ce=c.size>0&&c.size<u,ue=(e,t)=>{if(t.stopPropagation(),W===e)Y(null);else{Y(e),Z("menu"),te(l[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),o=10,s=Math.max(a.left+o,Math.min(r.left,a.right-320-o));q({top:r.bottom+4,left:s,containerRect:a})}},de=e=>{h(e,ee||null),Y(null)},me=e=>null!=l[e],he=(e,n)=>{n.preventDefault(),V(e),X(n.clientX);const a=[...t,...r].find(t=>t.key===e);U(a?.width||100)},fe=e=>{if(!B||!x)return;const t=Math.max(50,Q+(e.clientX-G));x(B,t)},ge=()=>{V(null),X(0),U(0)},[pe,xe]=e.useState(null),[ye,be]=e.useState(null),we=(e,t)=>{xe(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},ve=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();be({key:e,position:t.clientX<r.left+r.width/2?"before":"after"})},ke=e=>{const t=pe;if(!t||t===e)return;if(y.has(t)!==y.has(e))return xe(null),void be(null);const r=ye?.key!==e||"before"===ye?.position,n=T.filter(e=>e!==t);let a=n.indexOf(e);if(-1===a)return P(n),xe(null),void be(null);r||(a+=1),n.splice(a,0,t),P(n),xe(null),be(null)},je=()=>{xe(null),be(null)},Ne=(e,t)=>{oe(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();le({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})},Se=e=>{const t=ae;if(!t||t===e)return;if(y.has(t)!==y.has(e))return oe(null),void le(null);const r=se?.key!==e||"before"===se?.position,n=T.filter(e=>e!==t);let a=n.indexOf(e);if(-1===a)return P(n),oe(null),void le(null);r||(a+=1),n.splice(a,0,t),P(n),oe(null),le(null)},Me=()=>{oe(null),le(null)};return e.useEffect(()=>{if(B)return document.addEventListener("mousemove",fe),document.addEventListener("mouseup",ge),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",ge),document.body.style.cursor="",document.body.style.userSelect=""}},[B,G,Q,x]),e.useEffect(()=>{const e=e=>{W&&!e.target.closest("[data-column-menu]")&&Y(null)};if(W)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[W]),f.jsx(f.Fragment,{children:f.jsx("div",{className:"bg-blue-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",style:{height:o},role:"row","aria-label":"Column headers",children:f.jsxs("div",{className:"flex h-full",children:[i&&f.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:g,height:o},role:"columnheader","aria-label":"Select all rows",children:f.jsx("input",{type:"checkbox",checked:ie,ref:e=>{e&&(e.indeterminate=ce)},onChange:p,onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),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","aria-label":ie?"Deselect all rows":ce?`${c.size} rows selected. Click to select all`:"Select all rows",title:ie?`Deselect all ${u} rows`:ce?`${c.size} of ${u} rows selected`:`Select all ${u} rows`})}),t.map((e,r)=>{const n=y.has(e.key),a=t.filter(e=>y.has(e.key)).map(e=>e.key),l=a.indexOf(e.key),c=n?a.slice(0,l).reduce((e,r)=>{const n=t.find(e=>e.key===r);return e+(n?.width||100)},i?g:0):0,u="center"===e.headerAlign?"justify-center":"right"===e.headerAlign?"justify-end":"justify-start",p=!1!==e.sortable;return f.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:e.width||100,left:n?`${c}px`:"auto",height:o},"data-column-key":e.key,draggable:!0,onDragStart:t=>we(e.key,t),onDragOver:t=>ve(e.key,t),onDrop:()=>ke(e.key),onDragEnd:je,children:[ye?.key===e.key&&f.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===ye?.position?0:void 0,right:"after"===ye?.position?0:void 0}}),f.jsx("div",{className:"px-3 h-full",children:f.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[f.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${u} ${p?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>p&&m(e.key),children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[me(e.key)&&f.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),f.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",children:e.header})]}),p&&s.key===e.key&&f.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:f.jsx("asc"===s.direction?j:N,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(e.filterable||b||w)&&f.jsxs("div",{className:"relative "+(W===e.key||re?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[f.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:t=>ue(e.key,t),"data-menu-trigger":!0,children:f.jsx(L,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),W===e.key&&K&&f.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:`${K.top}px`,left:`${K.left}px`,maxHeight:`${Math.max(160,K.containerRect.bottom-12-K.top)}px`},"data-column-menu":!0,children:[f.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[f.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===J?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Z("menu"),children:f.jsx(L,{className:"w-4 h-4"})}),e.filterable&&f.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===J?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Z("filter"),children:f.jsx(F,{className:"w-4 h-4"})}),f.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===J?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Z("reorder"),children:f.jsx(C,{className:"w-4 h-4"})})]}),"menu"===J&&f.jsxs("div",{className:"py-1",children:[b&&(v===e.key?f.jsxs("div",{className:"w-full px-3 py-2 text-left text-sm flex items-center gap-2 text-blue-600",children:[f.jsx(O,{className:"w-4 h-4"}),"Pinned by grouping"]}):f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2",onClick:t=>{t.stopPropagation(),Y(null),b?.(e.key,!y.has(e.key))},children:y.has(e.key)?f.jsxs(f.Fragment,{children:[f.jsx(z,{className:"w-4 h-4"}),"Unpin Column"]}):f.jsxs(f.Fragment,{children:[f.jsx(O,{className:"w-4 h-4"}),"Pin Column"]})})),D&&f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{D?.(e.key),Y(null)},children:"Autosize This Column"}),R&&f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{R?.(),Y(null)},children:"Autosize All Columns"}),w&&f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2",onClick:t=>{t.stopPropagation(),Y(null);const r=S?.includes(e.key)||v===e.key;M?M(e.key,!r):k?.(r?null:e.key)},children:v===e.key||S?.includes(e.key)?f.jsxs(f.Fragment,{children:[f.jsx(H,{className:"w-4 h-4"}),"Ungroup"]}):f.jsxs(f.Fragment,{children:[f.jsx($,{className:"w-4 h-4"}),"Group by ",e.header]})}),E&&f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{E?.(),Y(null)},children:"Reset Columns"})]}),"filter"===J&&f.jsxs("div",{className:"p-3 w-full",children:[me(e.key)&&f.jsxs("button",{className:"mb-2 text-xs text-red-600 hover:underline flex items-center gap-1",onClick:()=>{te(null),h(e.key,null),Y(null)},children:[f.jsx(A,{className:"w-3 h-3"})," Clear Filter"]}),f.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:f.jsx(Kt,{column:e,data:d,value:ee,onChange:t=>{te(t),"server"!==I&&h(e.key,t)}})}),"server"===I?f.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[f.jsx("button",{className:"px-3 py-1.5 text-sm bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200",onClick:()=>Y(null),children:"Cancel"}),f.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>de(e.key),children:"Apply"})]}):f.jsx("div",{className:"flex justify-end mt-3",children:f.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>Y(null),children:"Close"})})]}),"reorder"===J&&f.jsxs("div",{className:"px-3 py-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:"Reorder Columns"}),f.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md",children:[...T.map(e=>_.find(t=>t.key===e)).filter(Boolean),..._.filter(e=>!T.includes(e.key))].map(e=>{const t=y.has(e.key);return f.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b last:border-b-0 relative ${ae===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""}`,draggable:!0,onDragStart:t=>Ne(e.key,t),onDragOver:t=>Ce(e.key,t),onDrop:()=>Se(e.key),onDragEnd:Me,children:[se?.key===e.key&&f.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===se?.position?0:void 0,bottom:"after"===se?.position?0:void 0}}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-gray-400 select-none",children:"⋮⋮"}),f.jsxs("span",{className:"text-gray-800 truncate max-w-45",children:[e.header,t&&f.jsx("span",{className:"ml-1 text-[10px] text-blue-600",children:"(pinned)"})]})]})]},e.key)})}),f.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<t.length-1&&x&&f.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:t=>he(e.key,t),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),D?.(e.key)},title:"Drag to resize • Double‑click to autosize",children:f.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},e.key+r)}),n>0&&f.jsx("div",{style:{width:n,height:o},className:"flex-none"}),r.map((e,t)=>{const n="center"===e.headerAlign?"justify-center":"right"===e.headerAlign?"justify-end":"justify-start",a=!1!==e.sortable;return f.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:o},"data-column-key":e.key,draggable:!0,onDragStart:t=>we(e.key,t),onDragOver:t=>ve(e.key,t),onDrop:()=>ke(e.key),onDragEnd:je,children:[ye?.key===e.key&&f.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===ye?.position?0:void 0,right:"after"===ye?.position?0:void 0}}),f.jsx("div",{className:"px-3 h-full",children:f.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[f.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${n} ${a?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>a&&m(e.key),children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[me(e.key)&&f.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),f.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",children:e.header})]}),a&&s.key===e.key&&f.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:f.jsx("asc"===s.direction?j:N,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(e.filterable||b||w)&&f.jsxs("div",{className:"relative "+(W===e.key||re?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[f.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:t=>ue(e.key,t),"data-menu-trigger":!0,children:f.jsx(L,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),W===e.key&&K&&f.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:`${K.top}px`,left:`${K.left}px`,maxHeight:`${Math.max(160,K.containerRect.bottom-12-K.top)}px`},"data-column-menu":!0,children:[f.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[f.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===J?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Z("menu"),children:f.jsx(L,{className:"w-4 h-4"})}),e.filterable&&f.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===J?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Z("filter"),children:f.jsx(F,{className:"w-4 h-4"})}),f.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===J?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Z("reorder"),children:f.jsx(C,{className:"w-4 h-4"})})]}),"menu"===J&&f.jsxs("div",{className:"py-1",children:[b&&f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2",onClick:t=>{t.stopPropagation(),Y(null);const r=!y.has(e.key);b?.(e.key,r)},children:y.has(e.key)?f.jsxs(f.Fragment,{children:[f.jsx(z,{className:"w-4 h-4"}),"Unpin Column"]}):f.jsxs(f.Fragment,{children:[f.jsx(O,{className:"w-4 h-4"}),"Pin Column"]})}),D&&f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{D?.(e.key),Y(null)},children:"Autosize This Column"}),R&&f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{R?.(),Y(null)},children:"Autosize All Columns"}),w&&f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2",onClick:t=>{t.stopPropagation(),Y(null);const r=S?.includes(e.key)||v===e.key;M?M(e.key,!r):k?.(r?null:e.key)},children:v===e.key||S?.includes(e.key)?f.jsxs(f.Fragment,{children:[f.jsx(H,{className:"w-4 h-4"}),"Ungroup"]}):f.jsxs(f.Fragment,{children:[f.jsx($,{className:"w-4 h-4"}),"Group by ",e.header]})}),E&&f.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{E?.(),Y(null)},children:"Reset Columns"})]}),"filter"===J&&f.jsxs("div",{className:"p-3 w-full",children:[f.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:f.jsx(Kt,{column:e,data:d,value:ee,onChange:t=>{te(t),"server"!==I&&h(e.key,t)}})}),f.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[me(e.key)&&f.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:()=>{te(null),h(e.key,null),Y(null)},children:[f.jsx(A,{className:"w-3 h-3"})," Clear Filter"]}),f.jsx("button",{className:"px-3 py-1.5 text-sm bg-green-100 text-green-700 rounded-md hover:bg-green-200 cursor-pointer",onClick:()=>Y(null),children:"Apply"}),"server"===I&&f.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>de(e.key),children:"Apply"})]})]}),"reorder"===J&&f.jsxs("div",{className:"px-3 py-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:"Reorder Columns"}),f.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md",children:[...T.map(e=>_.find(t=>t.key===e)).filter(Boolean),..._.filter(e=>!T.includes(e.key))].map(e=>{const t=y.has(e.key);return f.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b last:border-b-0 relative ${ae===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""}`,draggable:!0,onDragStart:t=>Ne(e.key,t),onDragOver:t=>Ce(e.key,t),onDrop:()=>Se(e.key),onDragEnd:Me,children:[se?.key===e.key&&f.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===se?.position?0:void 0,bottom:"after"===se?.position?0:void 0}}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-gray-400 select-none",children:"⋮⋮"}),f.jsxs("span",{className:"text-gray-800 truncate max-w-45",children:[e.header,t&&f.jsx("span",{className:"ml-1 text-[10px] text-blue-600",children:"(pinned)"})]})]})]},e.key)})}),f.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),t<r.length-1&&x&&f.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:t=>he(e.key,t),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),D?.(e.key)},title:"Drag to resize • Double‑click to autosize",children:f.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},e.key+t)}),a>0&&f.jsx("div",{style:{width:a,height:o},className:"flex-none"})]})})})},Bt=({data:t,columns:r,selectedRows:n,virtualized:a,virtualizedRange:o,rowHeight:s,selectable:l,isRowSelectable:i,onRowSelect:c,pinnedColumns:u=new Set,hvPadLeft:d=0,hvPadRight:m=0,rowStyle:h,globalFilter:p,onContextMenu:x,onRowDoubleClick:y,onRowClick:b,onCellClick:w,isCellFocused:v,isCellSelected:k,onCellContextMenu:j,onCellMouseDown:N,onCellMouseEnter:C,getRowId:S})=>{const M=e.useMemo(()=>t.length*s,[t.length,s]),{leftOffsetByPinnedKey:D}=e.useMemo(()=>{if(0===u.size)return{leftOffsetByPinnedKey:new Map};const e=r.filter(e=>u.has(e.key)).map(e=>e.key),t=new Map;for(const e of r)t.set(e.key,e.width||100);const n=new Map;let a=l?g:0;for(const r of e)n.set(r,a),a+=t.get(r)||100;return{leftOffsetByPinnedKey:n}},[r,u,l]),R=e.useMemo(()=>r.reduce((e,t)=>e+(u.has(t.key)?1:0),0),[r,u]);return f.jsx("div",{style:{height:a?`${M}px`:"auto",position:"relative"},children:f.jsx("div",{style:{transform:a?`translate3d(0, ${o.offsetY}px, 0)`:"none",position:a?"absolute":"static",top:0,left:0,right:0},children:t.map((e,t)=>{const M=a?o.startIndex+t:t,E=h?.(e),T=((e,t)=>S?S(e):void 0!==e.id?e.id:("development"===process.env.NODE_ENV&&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,M),P=M%2==0?"bg-white dark:bg-gray-900":"bg-gray-25 dark:bg-gray-800",L=n.has(T)?"bg-blue-50 dark:bg-blue-900/20":"";return f.jsxs("div",{className:`flex border-b border-gray-100 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 ${L||(E?"":P)}`,style:{height:`${s}px`,...E},onContextMenu:t=>((e,t)=>{e.preventDefault(),x?.(t,e)})(t,e),onDoubleClick:t=>((e,t)=>{y?.(t,e)})(t,e),onClick:t=>((e,t)=>{b?.(t,e)})(t,e),children:[l&&f.jsx("div",{className:"flex items-center justify-center sticky left-0 bg-white dark:bg-gray-900 z-2 border-r border-gray-200 dark:border-gray-700",style:{width:g},children:f.jsx("input",{type:"checkbox",checked:n.has(T),disabled:!!i&&!i(e),onChange:e=>c(T,e.target.checked),onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),c(T,!n.has(T)))},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","aria-label":`Select row ${T}`,tabIndex:0})}),r.map((t,r)=>{const n=u.has(t.key),a=n&&D.get(t.key)||0,o=e[t.key];let s,l;if(t.cellRenderer?(s=t.cellRenderer(o,e),"string"!=typeof o&&"number"!=typeof o&&"boolean"!=typeof o||(l=String(o))):t.formatter?(s=t.formatter(o),l=String(s)):(s=o??"",l=s?String(s):void 0),p&&p.trim()&&!t.cellRenderer&&s){const e=String(s);((e,t)=>{if(!t||null==e)return!1;const r=t.toLowerCase().trim();return!!r&&String(e).toLowerCase().includes(r)})(e,p)&&(s=((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 o=0,s=0,l=0;for(;-1!==(s=n.indexOf(r,o));)s>o&&a.push(e.slice(o,s)),a.push(f.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(s,s+r.length)},"highlight-"+l++)),o=s+r.length;return o<e.length&&a.push(e.slice(o)),f.jsx(f.Fragment,{children:a})})(e,p))}l&&0===l.trim().length&&(l=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",m=t.noPadding?"p-0":"p-3",h="function"==typeof t.className?t.className(o,e):t.className||"",g="function"==typeof t.cellStyle?t.cellStyle(o,e):t.cellStyle||void 0,x=f.jsxs("div",{className:`border-r border-gray-200 last:border-r-0 ${m} text-sm flex items-center ${k?.(T,t.key)?"bg-blue-100/60 dark:bg-blue-900/30":""} ${n?v?.(T,t.key)?"sticky z-2 bg-inherit":"sticky z-1 bg-inherit":""} ${v?.(T,t.key)?"relative":""} ${i} ${c} ${h}`,style:{width:`${t.width||100}px`,left:n?`${a}px`:"auto",...g},title:l,onClick:r=>((e,t,r,n)=>{w?.({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:l??"",event:r}))},onMouseDown:r=>N?.({row:e,column:t,event:r}),onMouseEnter:r=>C?.({row:e,column:t,event:r}),children:[v?.(T,t.key)&&f.jsx("div",{className:"pointer-events-none absolute inset-0 border border-blue-400"}),!1===t.wrapCellContent?f.jsx(f.Fragment,{children:s}):f.jsx("div",{className:"truncate w-full",children:s})]},`${t.key}-${r}`);return d>0&&r===R?f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{width:d},className:"flex-none"}),x]}):x}),m>0&&f.jsx("div",{style:{width:m},className:"flex-none"})]},`${T}-${M}`)})})})},Vt=(e,t)=>{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.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};Bt.displayName="GridRows";const Gt=e.memo(Bt,Vt),Xt=({columns:t,groupedKeys:r,onRemove:n,onReorder:a,onDropColumnKey:o,onToggleExpandAll:s,isAnyExpanded:l=!1})=>{const[i,c]=e.useState(null),[u,d]=e.useState(null),[m,h]=e.useState(!0),g=e=>t.find(t=>t.key===e)?.header||e,p=e=>t=>{c(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-group-key",e)},x=e=>t=>{t.preventDefault();const r=t.currentTarget.getBoundingClientRect(),n=t.clientX<r.left+r.width/2;d(e),h(n)};return f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-gray-50 border-b border-gray-200 text-sm",onDrop:e=>{e.preventDefault();const t=e.dataTransfer.getData("text/plain");t&&(r.includes(t)||o(t))},onDragOver:e=>{e.preventDefault()},onDragEnd:()=>{c(null),d(null)},children:[f.jsx("span",{className:"text-gray-600 whitespace-nowrap",children:"Group by:"}),r.length>0&&f.jsx("button",{type:"button",className:"ml-1 px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100",title:l?"Collapse all groups":"Expand all groups",onClick:e=>{e.preventDefault(),e.stopPropagation(),s?.()},children:l?"Collapse All":"Expand All"}),0===r.length&&f.jsx("span",{className:"text-gray-400",children:"Drag a column here"}),f.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:r.map(e=>{return f.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",draggable:!0,onDragStart:p(e),onDragOver:x(e),onDrop:(t=e,()=>{if(!i||i===t)return c(null),void d(null);const e=r.filter(e=>e!==i),n=e.indexOf(t);-1!==n&&(e.splice(m?n:n+1,0,i),a(e),c(null),d(null))}),title:g(e),children:[f.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:g(e)}),f.jsx("button",{className:"text-blue-700 hover:text-blue-900",onClick:()=>n(e),"aria-label":`Remove grouping ${g(e)}`,children:"×"}),u===e&&f.jsx("span",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 dark:bg-blue-400 animate-pulse",style:{left:m?0:void 0,right:m?void 0:0},"aria-hidden":"true"})]},e);var t})})]})},Qt=e.memo(({row:e,isExpanded:t,onToggle:r,viewportWidth:n,selectable:a,rowHeight:o=40,getHeaderLabel:s,getValueLabel:l,renderGroupActions:i})=>{const c=()=>{e._groupKey&&r(e._groupKey)};return f.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?g:0)}px`,height:`${o}px`},onClick:c,role:"button",tabIndex:0,"aria-expanded":t,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),c())},children:[a&&f.jsx("div",{className:"w-12 flex items-center justify-center"}),f.jsxs("div",{className:"flex items-center px-4 py-2 flex-1",children:[f.jsx("div",{className:"flex items-center mr-3",style:{paddingLeft:(e._groupLevel?16*e._groupLevel:0)+"px"},children:f.jsx(t?w:b,{className:"w-4 h-4 text-gray-600"})}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"font-medium text-gray-900",children:[e._groupColumnKey?`${s?s(e._groupColumnKey):e._groupColumnKey}: `:"",l&&e._groupColumnKey?l(e._groupColumnKey,e._groupValue):e._groupValue??(e._groupKey||"Unknown")]}),f.jsxs("span",{className:"text-sm text-gray-600 bg-gray-200/70 px-2 py-1 rounded-full",children:[e._groupCount," ",1===e._groupCount?"item":"items"]})]}),i&&f.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})})]})]})}),Ut=({hasFilters:e=!1,hasData:t=!0,message:r})=>{const{title:n,description:a,icon:o}=r?{title:r,description:"",icon:q}:t?e?{title:"No Results Found",description:"No data matches your current search criteria. Try adjusting your filters.",icon:K}:{title:"No Data to Display",description:"There are no items to show at the moment.",icon:q}:{title:"No Data Available",description:"There is no data to display in this table.",icon:q};return f.jsxs("div",{className:"flex flex-col items-center justify-center pt-16 pb-10 px-4 text-center",children:[f.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center mb-4",children:f.jsx(o,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),f.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:n}),f.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-md",children:a})]})},Jt=({paginationConfig:e,currentPage:t,isServerLoading:r,selectedRowsCount:n,totalDataLength:a,filteredDataLength:o,paginationMode:s="client",onPageChange:l,onPageSizeChange:i})=>{const{start:c,end:u,total:d}=(()=>{const r=e.enabled||"server"===s?e.totalRows||a:o||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}})(),m="client"===s&&o&&o!==a;return f.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:f.jsxs("div",{className:"flex flex-col xl:flex-row gap-4 xl:gap-6 xl:justify-between xl:items-center",children:[f.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4 items-start sm:items-center",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[!e.enabled&&f.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:[f.jsx(q,{className:"w-3 h-3"}),f.jsxs("span",{className:"font-bold",children:[d.toLocaleString()," ",1===d?"Record":"Records"]}),m&&f.jsxs("span",{className:"text-blue-100 font-normal",children:["(of ",a.toLocaleString(),")"]})]}),n>0&&f.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-primary to-primary text-white shadow-lg ring-2 ring-primary/20",children:[f.jsx(G,{className:"w-3 h-3"}),f.jsxs("span",{children:[n.toLocaleString()," selected"]})]}),m&&f.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-warning/20",children:[f.jsx(W,{className:"w-3 h-3"}),f.jsx("span",{children:"Filtered"})]}),e.enabled&&f.jsx("div",{className:"hidden sm:block text-sm text-gray-600 dark:text-gray-400 font-medium",children:f.jsxs("span",{className:"inline-flex items-center gap-1",children:[f.jsx("span",{children:"Showing"}),f.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()}),f.jsx("span",{children:"-"}),f.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:u.toLocaleString()}),f.jsxs("span",{children:["of ",d.toLocaleString()]})]})})]}),e.enabled&&e.showPageSizeSelector&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 whitespace-nowrap",children:"Rows per page:"}),f.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=>f.jsx("option",{value:e,children:e},e))})]})]}),e.enabled&&f.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4",children:[r&&f.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:[f.jsx(Q,{className:"w-4 h-4 animate-spin text-primary"}),f.jsx("span",{className:"text-sm font-medium text-primary",children:"Loading..."})]}),f.jsx("div",{className:"sm:hidden text-sm text-gray-600 dark:text-gray-400 font-medium",children:f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("span",{className:"inline-flex items-center gap-1",children:[f.jsx("span",{children:"Page"}),f.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()}),f.jsx("span",{children:"of"}),f.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()})]}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-500",children:[c.toLocaleString()," - ",u.toLocaleString()," of"," ",d.toLocaleString()]})]})}),f.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[f.jsx("button",{onClick:()=>l(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:f.jsx(v,{className:"w-3.5 h-3.5"})}),f.jsx("button",{onClick:()=>l(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:f.jsx(y,{className:"w-3.5 h-3.5"})}),f.jsx("div",{className:"sm:hidden",children:f.jsx("select",{value:t,onChange:t=>l(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=>f.jsx("option",{value:e,children:e},e))})}),f.jsx("div",{className:"hidden sm:flex items-center gap-1 mx-2",children:(()=>{const n=[],a=e.totalPages,o=t,s="undefined"!=typeof window&&window.innerWidth>=768?7:5;if(a<=s)for(let e=1;e<=a;e++)n.push(e);else{const e=Math.floor(s/2)-1;if(o<=e+1){for(let e=1;e<=s-2;e++)n.push(e);n.push("ellipsis1"),n.push(a)}else if(o>=a-e){n.push(1),n.push("ellipsis1");for(let e=a-(s-3);e<=a;e++)n.push(e)}else{n.push(1),n.push("ellipsis1");for(let t=o-e;t<=o+e;t++)n.push(t);n.push("ellipsis2"),n.push(a)}}return n.map(t=>{if("string"==typeof t)return f.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:f.jsx("span",{className:"text-lg leading-none",children:"⋯"})},t);const n=t===o;return f.jsx("button",{onClick:()=>l(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":"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)})})()}),f.jsx("button",{onClick:()=>l(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:f.jsx(b,{className:"w-3.5 h-3.5"})}),f.jsx("button",{onClick:()=>l(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:f.jsx(k,{className:"w-3.5 h-3.5"})})]})]})]})})},Zt=({options:t,value:r,placeholder:n="Select an option...",onChange:a,searchable:o=!0,className:s=""})=>{const[l,i]=e.useState(!1),[c,u]=e.useState(""),[d,m]=e.useState(-1),h=e.useRef(null),g=e.useRef(null),p=e.useRef(null),x=t.find(e=>e.value===r),y=o?t.filter(e=>e.label?.toLowerCase()?.includes(c?.toLowerCase())):t;e.useEffect(()=>{const e=e=>{h.current&&!h.current.contains(e.target)&&(i(!1),u(""),m(-1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),e.useEffect(()=>{const e=e=>{if(l)switch(e.key){case"ArrowDown":e.preventDefault(),m(e=>e<y.length-1?e+1:0);break;case"ArrowUp":e.preventDefault(),m(e=>e>0?e-1:y.length-1);break;case"Enter":e.preventDefault(),d>=0&&y[d]&&b(y[d].value);break;case"Escape":i(!1),u(""),m(-1)}};if(l)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l,d,y]),e.useEffect(()=>{if(d>=0&&p.current){const e=p.current.children[d];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}},[d]);const b=e=>{a(e),i(!1),u(""),m(-1)};return f.jsxs("div",{className:`relative ${s}`,ref:h,children:[f.jsx("div",{className:"relative w-full cursor-pointer border border-gray-300 rounded-lg bg-white transition-all duration-200 "+(l?"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"),onClick:()=>{i(!l),o&&!l&&setTimeout(()=>g.current?.focus(),0)},children:f.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5",children:[o&&l?f.jsx("input",{ref:g,type:"text",className:"flex-1 outline-none text-sm bg-transparent",placeholder:`Search ${n?.toLowerCase()}...`,value:c,onChange:e=>{u(e.target.value),m(-1),l||i(!0)},onClick:e=>e.stopPropagation()}):f.jsx("span",{className:"flex-1 text-sm truncate "+(x?"text-gray-900":"text-gray-500"),children:x?x.label:n}),f.jsx(w,{className:"w-4 h-4 text-gray-400 transition-transform duration-200 "+(l?"rotate-180":"")})]})}),l&&f.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",children:y.length>0?f.jsx("ul",{ref:p,className:"py-1 overflow-y-auto max-h-80",children:y.map((e,t)=>f.jsxs("li",{className:"px-3 py-2 text-sm cursor-pointer flex items-center justify-between transition-colors "+(t===d?"bg-blue-50 text-blue-700":"text-gray-700 hover:bg-gray-50"),onClick:()=>b(e.value),onMouseEnter:()=>m(t),children:[f.jsx("span",{className:"truncate",children:e.label}),x?.value===e.value&&f.jsx(M,{className:"w-4 h-4 text-blue-600 shrink-0 ml-2"})]},e.value))}):f.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:"No options found"})})]})},er=({columns:t,columnFilters:r,onColumnFilter:n})=>{const a=t.filter(e=>e.filterable),[o,s]=e.useState(a.length>0?a[0].key:""),[l,i]=e.useState(""),c=a.map(e=>({label:e.header,value:e.key})),u=a.find(e=>e.key===o);return e.useEffect(()=>{i("")},[o]),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Select Column to Filter"}),f.jsx(Zt,{options:c,value:o,placeholder:"Choose a column...",onChange:e=>{s(e)},searchable:!0})]}),o&&(()=>{if(!u)return null;const e=u.filterable?.type||"text",t=r[o];if("multiselect"===e&&u.filterable?.options){const e=l.toLowerCase(),r=e?u.filterable.options.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)):u.filterable.options;return f.jsxs("div",{className:"mt-3",children:[f.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:["Filter by ",u.header]}),f.jsxs("div",{className:"relative mb-2",children:[f.jsx(K,{className:"w-4 h-4 text-gray-400 absolute left-2 top-1/2 -translate-y-1/2"}),f.jsx("input",{type:"text",value:l,onChange:e=>i(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"}),l&&f.jsx("button",{type:"button",onClick:()=>i(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear search",children:f.jsx(S,{className:"w-3 h-3"})})]}),f.jsxs("div",{className:"max-h-32 overflow-y-auto border border-gray-300 rounded-md p-2 bg-white",children:[0===r.length&&f.jsx("div",{className:"text-xs text-gray-500 px-1 py-1",children:"No matches"}),r.map(e=>{const r=t?.value||[],a=Array.isArray(r)&&r.includes(e.value);return f.jsxs("label",{className:"flex items-center gap-2 py-1 hover:bg-gray-50 cursor-pointer",children:[f.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500",checked:a,onChange:r=>{const a=t?.value||[];let s;s=r.target.checked?[...a,e.value]:a.filter(t=>t!==e.value),n?.(o,s.length>0?{type:"multiselect",value:s,operator:"in"}:null)}}),f.jsx("span",{className:"text-sm",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 f.jsxs("div",{className:"mt-3",children:[f.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:["Filter by ",u.header]}),f.jsx(Zt,{options:e,value:t?.value||"",placeholder:`Select ${u.header.toLowerCase()}...`,onChange:e=>{n?.(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=$t(String(e),"yyyy-MM-dd",new Date);if(!isNaN(t.getTime()))return t;const r=new Date(e);return isNaN(r.getTime())?null:r},r=e(t?.value),a=e(t?.secondValue),s=t?.operator||"between";return f.jsxs("div",{className:"mt-3",children:[f.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:["Filter by ",u.header]}),f.jsx("div",{className:"mb-3",children:f.jsx(Zt,{options:[{label:"Between Dates",value:"between"},{label:"On Date",value:"equals"}],value:s,placeholder:"Select date filter...",onChange:e=>{n?.(o,{type:"date",value:t?.value||"",operator:e,secondValue:t?.secondValue||""})},searchable:!1},`date-operator-${o}-${s}`)}),f.jsxs("div",{className:"flex items-end gap-2",children:[f.jsx("div",{className:"flex-1 min-w-37.5",children:f.jsx(Z,{name:"column_filter_start",label:"between"===s?"Start Date":"Date",value:r?Ke(r,"yyyy-MM-dd"):null,onChange:e=>{if(e){const r=Ke($t(e,"yyyy-MM-dd",new Date),"yyyy-MM-dd");n?.(o,{type:"date",value:r,operator:s,secondValue:t?.secondValue||null})}else n?.(o,null)},className:"w-full"})}),"between"===s&&f.jsx("div",{className:"flex-1 min-w-37.5",children:f.jsx(Z,{name:"column_filter_end",label:"End Date",value:a?Ke(a,"yyyy-MM-dd"):null,onChange:e=>{if(e&&t){const r=Ke($t(e,"yyyy-MM-dd",new Date),"yyyy-MM-dd");n?.(o,{...t,secondValue:r})}},className:"w-full"})})]})]})}return f.jsxs("div",{className:"mt-3",children:[f.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:["Filter by ",u.header]}),f.jsxs(f.Fragment,{children:[f.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",value:t?.value||"",onChange:e=>{n?.(o,e.target.value?{type:"text",value:e.target.value,operator:"contains"}:null)}}),t&&f.jsx("div",{className:"mt-2",children:f.jsx(Zt,{options:[{label:"Contains",value:"contains"},{label:"Equals",value:"equals"},{label:"Starts with",value:"startsWith"},{label:"Ends with",value:"endsWith"}],value:t?.operator||"contains",placeholder:"Select operator...",onChange:e=>{t&&n?.(o,{...t,operator:e})},searchable:!1})})]})]})})(),Object.keys(r).length>0&&f.jsxs("div",{className:"mt-4",children:[f.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Active Filters"}),f.jsx("div",{className:"space-y-2",children:Object.entries(r).map(([e,t])=>{const r=a.find(t=>t.key===e);return r?f.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",role:"button",title:`Edit filter for ${r.header}`,onClick:()=>(e=>{s(e)})(e),children:[f.jsxs("div",{className:"flex-1",children:[f.jsxs("span",{className:"text-sm font-medium text-blue-900",children:[r.header,":"]}),f.jsx("span",{className:"text-sm text-blue-700 ml-1",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 Ke(e,"dd-MM-yyyy");if("string"==typeof e){const t=$t(e,"yyyy-MM-dd",new Date);if(!isNaN(t.getTime()))return Ke(t,"dd-MM-yyyy");const r=new Date(e);if(!isNaN(r.getTime()))return Ke(r,"dd-MM-yyyy")}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})()})]}),f.jsx("button",{onClick:t=>{t.stopPropagation(),n?.(e,null)},className:"text-blue-400 hover:text-red-500 transition-colors",title:"Clear filter",children:f.jsx(S,{className:"w-4 h-4"})})]},e):null})})]})]})};function tr(){return"undefined"!=typeof window}function rr(e){return or(e)?(e.nodeName||"").toLowerCase():"#document"}function nr(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function ar(e){var t;return null==(t=(or(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function or(e){return!!tr()&&(e instanceof Node||e instanceof nr(e).Node)}function sr(e){return!!tr()&&(e instanceof Element||e instanceof nr(e).Element)}function lr(e){return!!tr()&&(e instanceof HTMLElement||e instanceof nr(e).HTMLElement)}function ir(e){return!(!tr()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof nr(e).ShadowRoot)}const cr=new Set(["inline","contents"]);function ur(e){const{overflow:t,overflowX:r,overflowY:n,display:a}=kr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!cr.has(a)}const dr=new Set(["table","td","th"]);function mr(e){return dr.has(rr(e))}const hr=[":popover-open",":modal"];function fr(e){return hr.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const gr=["transform","translate","scale","rotate","perspective"],pr=["transform","translate","scale","rotate","perspective","filter"],xr=["paint","layout","strict","content"];function yr(e){const t=br(),r=sr(e)?kr(e):e;return gr.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||pr.some(e=>(r.willChange||"").includes(e))||xr.some(e=>(r.contain||"").includes(e))}function br(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const wr=new Set(["html","body","#document"]);function vr(e){return wr.has(rr(e))}function kr(e){return nr(e).getComputedStyle(e)}function jr(e){return sr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Nr(e){if("html"===rr(e))return e;const t=e.assignedSlot||e.parentNode||ir(e)&&e.host||ar(e);return ir(t)?t.host:t}function Cr(e){const t=Nr(e);return vr(t)?e.ownerDocument?e.ownerDocument.body:e.body:lr(t)&&ur(t)?t:Cr(t)}function Sr(e,t,r){var n;void 0===t&&(t=[]),void 0===r&&(r=!0);const a=Cr(e),o=a===(null==(n=e.ownerDocument)?void 0:n.body),s=nr(a);if(o){const e=Mr(s);return t.concat(s,s.visualViewport||[],ur(a)?a:[],e&&r?Sr(e):[])}return t.concat(a,Sr(a,[],r))}function Mr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const Dr=Math.min,Rr=Math.max,Er=Math.round,Tr=Math.floor,Pr=e=>({x:e,y:e}),Lr={left:"right",right:"left",bottom:"top",top:"bottom"},Fr={start:"end",end:"start"};function Ar(e,t,r){return Rr(e,Dr(t,r))}function Ir(e,t){return"function"==typeof e?e(t):e}function Or(e){return e.split("-")[0]}function zr(e){return e.split("-")[1]}function $r(e){return"x"===e?"y":"x"}function Hr(e){return"y"===e?"height":"width"}const _r=new Set(["top","bottom"]);function Wr(e){return _r.has(Or(e))?"y":"x"}function Yr(e){return $r(Wr(e))}function Kr(e){return e.replace(/start|end/g,e=>Fr[e])}const qr=["left","right"],Br=["right","left"],Vr=["top","bottom"],Gr=["bottom","top"];function Xr(e){return e.replace(/left|right|bottom|top/g,e=>Lr[e])}function Qr(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 Ur="undefined"!=typeof document?e.useLayoutEffect:function(){};const Jr={...a}.useInsertionEffect||(e=>e());function Zr(e,t,r){let{reference:n,floating:a}=e;const o=Wr(t),s=Yr(t),l=Hr(s),i=Or(t),c="y"===o,u=n.x+n.width/2-a.width/2,d=n.y+n.height/2-a.height/2,m=n[l]/2-a[l]/2;let h;switch(i){case"top":h={x:u,y:n.y-a.height};break;case"bottom":h={x:u,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:d};break;case"left":h={x:n.x-a.width,y:d};break;default:h={x:n.x,y:n.y}}switch(zr(t)){case"start":h[s]-=m*(r&&c?-1:1);break;case"end":h[s]+=m*(r&&c?-1:1)}return h}async function en(e,t){var r;void 0===t&&(t={});const{x:n,y:a,platform:o,rects:s,elements:l,strategy:i}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:m=!1,padding:h=0}=Ir(t,e),f=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}}(h),g=l[m?"floating"===d?"reference":"floating":d],p=Qr(await o.getClippingRect({element:null==(r=await(null==o.isElement?void 0:o.isElement(g)))||r?g:g.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:i})),x="floating"===d?{x:n,y:a,width:s.floating.width,height:s.floating.height}:s.reference,y=await(null==o.getOffsetParent?void 0:o.getOffsetParent(l.floating)),b=await(null==o.isElement?void 0:o.isElement(y))&&await(null==o.getScale?void 0:o.getScale(y))||{x:1,y:1},w=Qr(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:y,strategy:i}):x);return{top:(p.top-w.top+f.top)/b.y,bottom:(w.bottom-p.bottom+f.bottom)/b.y,left:(p.left-w.left+f.left)/b.x,right:(w.right-p.right+f.right)/b.x}}const tn=new Set(["left","top"]);function rn(e){const t=kr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const a=lr(e),o=a?e.offsetWidth:r,s=a?e.offsetHeight:n,l=Er(r)!==o||Er(n)!==s;return l&&(r=o,n=s),{width:r,height:n,$:l}}function nn(e){return sr(e)?e:e.contextElement}function an(e){const t=nn(e);if(!lr(t))return Pr(1);const r=t.getBoundingClientRect(),{width:n,height:a,$:o}=rn(t);let s=(o?Er(r.width):r.width)/n,l=(o?Er(r.height):r.height)/a;return s&&Number.isFinite(s)||(s=1),l&&Number.isFinite(l)||(l=1),{x:s,y:l}}const on=Pr(0);function sn(e){const t=nr(e);return br()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:on}function ln(e,t,r,n){void 0===t&&(t=!1),void 0===r&&(r=!1);const a=e.getBoundingClientRect(),o=nn(e);let s=Pr(1);t&&(n?sr(n)&&(s=an(n)):s=an(e));const l=function(e,t,r){return void 0===t&&(t=!1),!(!r||t&&r!==nr(e))&&t}(o,r,n)?sn(o):Pr(0);let i=(a.left+l.x)/s.x,c=(a.top+l.y)/s.y,u=a.width/s.x,d=a.height/s.y;if(o){const e=nr(o),t=n&&sr(n)?nr(n):n;let r=e,a=Mr(r);for(;a&&n&&t!==r;){const e=an(a),t=a.getBoundingClientRect(),n=kr(a),o=t.left+(a.clientLeft+parseFloat(n.paddingLeft))*e.x,s=t.top+(a.clientTop+parseFloat(n.paddingTop))*e.y;i*=e.x,c*=e.y,u*=e.x,d*=e.y,i+=o,c+=s,r=nr(a),a=Mr(r)}}return Qr({width:u,height:d,x:i,y:c})}function cn(e,t){const r=jr(e).scrollLeft;return t?t.left+r:ln(ar(e)).left+r}function un(e,t){const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-cn(e,r),y:r.top+t.scrollTop}}const dn=new Set(["absolute","fixed"]);function mn(e,t,r){let n;if("viewport"===t)n=function(e,t){const r=nr(e),n=ar(e),a=r.visualViewport;let o=n.clientWidth,s=n.clientHeight,l=0,i=0;if(a){o=a.width,s=a.height;const e=br();(!e||e&&"fixed"===t)&&(l=a.offsetLeft,i=a.offsetTop)}const c=cn(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,s=Math.abs(n.clientWidth-t.clientWidth-a);s<=25&&(o-=s)}else c<=25&&(o+=c);return{width:o,height:s,x:l,y:i}}(e,r);else if("document"===t)n=function(e){const t=ar(e),r=jr(e),n=e.ownerDocument.body,a=Rr(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),o=Rr(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-r.scrollLeft+cn(e);const l=-r.scrollTop;return"rtl"===kr(n).direction&&(s+=Rr(t.clientWidth,n.clientWidth)-a),{width:a,height:o,x:s,y:l}}(ar(e));else if(sr(t))n=function(e,t){const r=ln(e,!0,"fixed"===t),n=r.top+e.clientTop,a=r.left+e.clientLeft,o=lr(e)?an(e):Pr(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:a*o.x,y:n*o.y}}(t,r);else{const r=sn(e);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Qr(n)}function hn(e,t){const r=Nr(e);return!(r===t||!sr(r)||vr(r))&&("fixed"===kr(r).position||hn(r,t))}function fn(e,t,r){const n=lr(t),a=ar(t),o="fixed"===r,s=ln(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const i=Pr(0);function c(){i.x=cn(a)}if(n||!n&&!o)if(("body"!==rr(t)||ur(a))&&(l=jr(t)),n){const e=ln(t,!0,o,t);i.x=e.x+t.clientLeft,i.y=e.y+t.clientTop}else a&&c();o&&!n&&a&&c();const u=!a||n||o?Pr(0):un(a,l);return{x:s.left+l.scrollLeft-i.x-u.x,y:s.top+l.scrollTop-i.y-u.y,width:s.width,height:s.height}}function gn(e){return"static"===kr(e).position}function pn(e,t){if(!lr(e)||"fixed"===kr(e).position)return null;if(t)return t(e);let r=e.offsetParent;return ar(e)===r&&(r=r.ownerDocument.body),r}function xn(e,t){const r=nr(e);if(fr(e))return r;if(!lr(e)){let t=Nr(e);for(;t&&!vr(t);){if(sr(t)&&!gn(t))return t;t=Nr(t)}return r}let n=pn(e,t);for(;n&&mr(n)&&gn(n);)n=pn(n,t);return n&&vr(n)&&gn(n)&&!yr(n)?r:n||function(e){let t=Nr(e);for(;lr(t)&&!vr(t);){if(yr(t))return t;if(fr(t))return null;t=Nr(t)}return null}(e)||r}const yn={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:r,offsetParent:n,strategy:a}=e;const o="fixed"===a,s=ar(n),l=!!t&&fr(t.floating);if(n===s||l&&o)return r;let i={scrollLeft:0,scrollTop:0},c=Pr(1);const u=Pr(0),d=lr(n);if((d||!d&&!o)&&(("body"!==rr(n)||ur(s))&&(i=jr(n)),lr(n))){const e=ln(n);c=an(n),u.x=e.x+n.clientLeft,u.y=e.y+n.clientTop}const m=!s||d||o?Pr(0):un(s,i);return{width:r.width*c.x,height:r.height*c.y,x:r.x*c.x-i.scrollLeft*c.x+u.x+m.x,y:r.y*c.y-i.scrollTop*c.y+u.y+m.y}},getDocumentElement:ar,getClippingRect:function(e){let{element:t,boundary:r,rootBoundary:n,strategy:a}=e;const o=[..."clippingAncestors"===r?fr(t)?[]:function(e,t){const r=t.get(e);if(r)return r;let n=Sr(e,[],!1).filter(e=>sr(e)&&"body"!==rr(e)),a=null;const o="fixed"===kr(e).position;let s=o?Nr(e):e;for(;sr(s)&&!vr(s);){const t=kr(s),r=yr(s);r||"fixed"!==t.position||(a=null),(o?!r&&!a:!r&&"static"===t.position&&a&&dn.has(a.position)||ur(s)&&!r&&hn(e,s))?n=n.filter(e=>e!==s):a=t,s=Nr(s)}return t.set(e,n),n}(t,this._c):[].concat(r),n],s=o.reduce((e,r)=>{const n=mn(t,r,a);return e.top=Rr(n.top,e.top),e.right=Dr(n.right,e.right),e.bottom=Dr(n.bottom,e.bottom),e.left=Rr(n.left,e.left),e},mn(t,o[0],a));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},getOffsetParent:xn,getElementRects:async function(e){const t=this.getOffsetParent||xn,r=this.getDimensions,n=await r(e.floating);return{reference:fn(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}=rn(e);return{width:t,height:r}},getScale:an,isElement:sr,isRTL:function(e){return"rtl"===kr(e).direction}};function bn(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function wn(e,t,r,n){void 0===n&&(n={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:i=!1}=n,c=nn(e),u=a||o?[...c?Sr(c):[],...Sr(t)]:[];u.forEach(e=>{a&&e.addEventListener("scroll",r,{passive:!0}),o&&e.addEventListener("resize",r)});const d=c&&l?function(e,t){let r,n=null;const a=ar(e);function o(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return function s(l,i){void 0===l&&(l=!1),void 0===i&&(i=1),o();const c=e.getBoundingClientRect(),{left:u,top:d,width:m,height:h}=c;if(l||t(),!m||!h)return;const f={rootMargin:-Tr(d)+"px "+-Tr(a.clientWidth-(u+m))+"px "+-Tr(a.clientHeight-(d+h))+"px "+-Tr(u)+"px",threshold:Rr(0,Dr(1,i))||1};let g=!0;function p(t){const n=t[0].intersectionRatio;if(n!==i){if(!g)return s();n?s(!1,n):r=setTimeout(()=>{s(!1,1e-7)},1e3)}1!==n||bn(c,e.getBoundingClientRect())||s(),g=!1}try{n=new IntersectionObserver(p,{...f,root:a.ownerDocument})}catch(e){n=new IntersectionObserver(p,f)}n.observe(e)}(!0),o}(c,r):null;let m,h=-1,f=null;s&&(f=new ResizeObserver(e=>{let[n]=e;n&&n.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var e;null==(e=f)||e.observe(t)})),r()}),c&&!i&&f.observe(c),f.observe(t));let g=i?ln(e):null;return i&&function t(){const n=ln(e);g&&!bn(g,n)&&r(),g=n,m=requestAnimationFrame(t)}(),r(),()=>{var e;u.forEach(e=>{a&&e.removeEventListener("scroll",r),o&&e.removeEventListener("resize",r)}),null==d||d(),null==(e=f)||e.disconnect(),f=null,i&&cancelAnimationFrame(m)}}const vn=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:a,y:o,placement:s,middlewareData:l}=t,i=await async function(e,t){const{placement:r,platform:n,elements:a}=e,o=await(null==n.isRTL?void 0:n.isRTL(a.floating)),s=Or(r),l=zr(r),i="y"===Wr(r),c=tn.has(s)?-1:1,u=o&&i?-1:1,d=Ir(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:f}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&"number"==typeof f&&(h="end"===l?-1*f:f),i?{x:h*u,y:m*c}:{x:m*c,y:h*u}}(t,e);return s===(null==(r=l.offset)?void 0:r.placement)&&null!=(n=l.arrow)&&n.alignmentOffset?{}:{x:a+i.x,y:o+i.y,data:{...i,placement:s}}}}},kn=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:a,platform:o}=t,{mainAxis:s=!0,crossAxis:l=!1,limiter:i={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...c}=Ir(e,t),u={x:r,y:n},d=await o.detectOverflow(t,c),m=Wr(Or(a)),h=$r(m);let f=u[h],g=u[m];s&&(f=Ar(f+d["y"===h?"top":"left"],f,f-d["y"===h?"bottom":"right"])),l&&(g=Ar(g+d["y"===m?"top":"left"],g,g-d["y"===m?"bottom":"right"]));const p=i.fn({...t,[h]:f,[m]:g});return{...p,data:{x:p.x-r,y:p.y-n,enabled:{[h]:s,[m]:l}}}}}},jn=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:a,middlewareData:o,rects:s,initialPlacement:l,platform:i,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:g=!0,...p}=Ir(e,t);if(null!=(r=o.arrow)&&r.alignmentOffset)return{};const x=Or(a),y=Wr(l),b=Or(l)===l,w=await(null==i.isRTL?void 0:i.isRTL(c.floating)),v=m||(b||!g?[Xr(l)]:function(e){const t=Xr(e);return[Kr(e),t,Kr(t)]}(l)),k="none"!==f;!m&&k&&v.push(...function(e,t,r,n){const a=zr(e);let o=function(e,t,r){switch(e){case"top":case"bottom":return r?t?Br:qr:t?qr:Br;case"left":case"right":return t?Vr:Gr;default:return[]}}(Or(e),"start"===r,n);return a&&(o=o.map(e=>e+"-"+a),t&&(o=o.concat(o.map(Kr)))),o}(l,g,f,w));const j=[l,...v],N=await i.detectOverflow(t,p),C=[];let S=(null==(n=o.flip)?void 0:n.overflows)||[];if(u&&C.push(N[x]),d){const e=function(e,t,r){void 0===r&&(r=!1);const n=zr(e),a=Yr(e),o=Hr(a);let s="x"===a?n===(r?"end":"start")?"right":"left":"start"===n?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Xr(s)),[s,Xr(s)]}(a,s,w);C.push(N[e[0]],N[e[1]])}if(S=[...S,{placement:a,overflows:C}],!C.every(e=>e<=0)){var M,D;const e=((null==(M=o.flip)?void 0:M.index)||0)+1,t=j[e];if(t&&("alignment"!==d||y===Wr(t)||S.every(e=>Wr(e.placement)!==y||e.overflows[0]>0)))return{data:{index:e,overflows:S},reset:{placement:t}};let r=null==(D=S.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:D.placement;if(!r)switch(h){case"bestFit":{var R;const e=null==(R=S.filter(e=>{if(k){const t=Wr(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:R[0];e&&(r=e);break}case"initialPlacement":r=l}if(a!==r)return{reset:{placement:r}}}return{}}}},Nn=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:a,rects:o,platform:s,elements:l}=t,{apply:i=()=>{},...c}=Ir(e,t),u=await s.detectOverflow(t,c),d=Or(a),m=zr(a),h="y"===Wr(a),{width:f,height:g}=o.floating;let p,x;"top"===d||"bottom"===d?(p=d,x=m===(await(null==s.isRTL?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(x=d,p="end"===m?"top":"bottom");const y=g-u.top-u.bottom,b=f-u.left-u.right;let w=Dr(g-u[p],y),v=Dr(f-u[x],b);if(null!=(r=t.middlewareData.shift)&&r.enabled.x&&(v=b),null!=(n=t.middlewareData.shift)&&n.enabled.y&&(w=y),!t.middlewareData.shift&&!m){const e=Rr(u.left,0),t=Rr(u.right,0),r=Rr(u.top,0),n=Rr(u.bottom,0);h?v=f-2*(0!==e||0!==t?e+t:Rr(u.left,u.right)):w=g-2*(0!==r||0!==n?r+n:Rr(u.top,u.bottom))}await i({...t,availableWidth:v,availableHeight:w});const k=await s.getDimensions(l.floating);return f!==k.width||g!==k.height?{reset:{rects:!0}}:{}}}},Cn=(e,t,r)=>{const n=new Map,a={platform:yn,...r},o={...a.platform,_c:n};return(async(e,t,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:s}=r,l=o.filter(Boolean),i=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:d}=Zr(c,n,i),m=n,h={},f=0;for(let r=0;r<l.length;r++){var g;const{name:o,fn:p}=l[r],{x:x,y:y,data:b,reset:w}=await p({x:u,y:d,initialPlacement:n,placement:m,strategy:a,middlewareData:h,rects:c,platform:{...s,detectOverflow:null!=(g=s.detectOverflow)?g:en},elements:{reference:e,floating:t}});u=null!=x?x:u,d=null!=y?y:d,h={...h,[o]:{...h[o],...b}},w&&f<=50&&(f++,"object"==typeof w&&(w.placement&&(m=w.placement),w.rects&&(c=!0===w.rects?await s.getElementRects({reference:e,floating:t,strategy:a}):w.rects),({x:u,y:d}=Zr(c,m,i))),r=-1)}return{x:u,y:d,placement:m,strategy:a,middlewareData:h}})(e,t,{...a,platform:o})};var Sn="undefined"!=typeof document?e.useLayoutEffect:function(){};function Mn(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(!Mn(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||Mn(e[r],t[r])))return!1}return!0}return e!=e&&t!=t}function Dn(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Rn(e,t){const r=Dn(e);return Math.round(t*r)/r}function En(e){const t=a.useRef(e);return Sn(()=>{t.current=e}),t}const Tn=(e,t)=>({...vn(e),options:[e,t]}),Pn=(e,t)=>({...kn(e),options:[e,t]}),Ln=(e,t)=>({...Nn(e),options:[e,t]}),Fn={...a};let An=!1,In=0;const On=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+In++,zn=Fn.useId||function(){const[e,t]=a.useState(()=>An?On():void 0);return Ur(()=>{null==e&&t(On())},[]),a.useEffect(()=>{An=!0},[]),e};let $n;"production"!==process.env.NODE_ENV&&($n=new Set);const Hn=a.createContext(null),_n=a.createContext(null);function Wn(e){void 0===e&&(e={});const{nodeId:t}=e,r=function(e){const{open:t=!1,onOpenChange:r,elements:n}=e,o=zn(),s=a.useRef({}),[l]=a.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=a.useContext(Hn))?void 0:c.id)||null);var c;if("production"!==process.env.NODE_ENV){const e=n.reference;e&&!sr(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 o;null!=(e=$n)&&e.has(a)||(null==(o=$n)||o.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[u,d]=a.useState(n.reference),m=function(e){const t=a.useRef(()=>{if("production"!==process.env.NODE_ENV)throw new Error("Cannot call an event handler while rendering.")});return Jr(()=>{t.current=e}),a.useCallback(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return null==t.current?void 0:t.current(...r)},[])}((e,t,n)=>{s.current.openEvent=e?t:void 0,l.emit("openchange",{open:e,event:t,reason:n,nested:i}),null==r||r(e,t,n)}),h=a.useMemo(()=>({setPositionReference:d}),[]),f=a.useMemo(()=>({reference:u||n.reference||null,floating:n.floating||null,domReference:n.reference}),[u,n.reference,n.floating]);return a.useMemo(()=>({dataRef:s,open:t,onOpenChange:m,elements:f,events:l,floatingId:o,refs:h}),[t,m,f,l,o,h])}({...e,elements:{reference:null,floating:null,...e.elements}}),n=e.rootContext||r,s=n.elements,[l,i]=a.useState(null),[c,u]=a.useState(null),d=(null==s?void 0:s.domReference)||l,m=a.useRef(null),h=a.useContext(_n);Ur(()=>{d&&(m.current=d)},[d]);const f=function(e){void 0===e&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:s,elements:{reference:l,floating:i}={},transform:c=!0,whileElementsMounted:u,open:d}=e,[m,h]=a.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,g]=a.useState(n);Mn(f,n)||g(n);const[p,x]=a.useState(null),[y,b]=a.useState(null),w=a.useCallback(e=>{e!==N.current&&(N.current=e,x(e))},[]),v=a.useCallback(e=>{e!==C.current&&(C.current=e,b(e))},[]),k=l||p,j=i||y,N=a.useRef(null),C=a.useRef(null),S=a.useRef(m),M=null!=u,D=En(u),R=En(s),E=En(d),T=a.useCallback(()=>{if(!N.current||!C.current)return;const e={placement:t,strategy:r,middleware:f};R.current&&(e.platform=R.current),Cn(N.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==E.current};P.current&&!Mn(S.current,t)&&(S.current=t,o.flushSync(()=>{h(t)}))})},[f,t,r,R,E]);Sn(()=>{!1===d&&S.current.isPositioned&&(S.current.isPositioned=!1,h(e=>({...e,isPositioned:!1})))},[d]);const P=a.useRef(!1);Sn(()=>(P.current=!0,()=>{P.current=!1}),[]),Sn(()=>{if(k&&(N.current=k),j&&(C.current=j),k&&j){if(D.current)return D.current(k,j,T);T()}},[k,j,T,D,M]);const L=a.useMemo(()=>({reference:N,floating:C,setReference:w,setFloating:v}),[w,v]),F=a.useMemo(()=>({reference:k,floating:j}),[k,j]),A=a.useMemo(()=>{const e={position:r,left:0,top:0};if(!F.floating)return e;const t=Rn(F.floating,m.x),n=Rn(F.floating,m.y);return c?{...e,transform:"translate("+t+"px, "+n+"px)",...Dn(F.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:t,top:n}},[r,c,F.floating,m.x,m.y]);return a.useMemo(()=>({...m,update:T,refs:L,elements:F,floatingStyles:A}),[m,T,L,F,A])}({...e,elements:{...s,...c&&{reference:c}}}),g=a.useCallback(e=>{const t=sr(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),f.refs.setReference(t)},[f.refs]),p=a.useCallback(e=>{(sr(e)||null===e)&&(m.current=e,i(e)),(sr(f.refs.reference.current)||null===f.refs.reference.current||null!==e&&!sr(e))&&f.refs.setReference(e)},[f.refs]),x=a.useMemo(()=>({...f.refs,setReference:p,setPositionReference:g,domReference:m}),[f.refs,p,g]),y=a.useMemo(()=>({...f.elements,domReference:d}),[f.elements,d]),b=a.useMemo(()=>({...f,...n,refs:x,elements:y,nodeId:t}),[f,x,y,t,n]);return Ur(()=>{n.dataRef.current.floatingContext=b;const e=null==h?void 0:h.nodesRef.current.find(e=>e.id===t);e&&(e.context=b)}),a.useMemo(()=>({...f,context:b,refs:x,elements:y}),[f,x,y,b])}var Yn=({open:r,anchorEl:n,onClose:a,placement:o="bottom-start",offset:s=8,sameWidth:l=!1,maxHeight:i,zIndex:c=1e3,className:u,children:d,shouldIgnoreClose:m})=>{const{refs:h,floatingStyles:g,update:p}=Wn({placement:o,whileElementsMounted:wn,middleware:[Tn(s),(x={padding:8},{...jn(x),options:[x,void 0]}),Pn({padding:8}),Ln({apply({rects:e,elements:t,availableHeight:r,availableWidth:n}){const a=t.floating;a&&(l&&(a.style.width=`${e.reference.width}px`),a.style.maxHeight=null!=i?"number"==typeof i?`${i}px`:String(i):`${r}px`,null!=n&&(a.style.maxWidth=`${n}px`))}})]});var x;return e.useEffect(()=>{n&&h.setReference(n),r&&p&&p()},[n,r,h,p]),e.useEffect(()=>{if(!r)return;const e=e=>{const t=e.target;if(m&&m(t))return;const r=h.floating.current;r&&(n&&n.contains(t)||r&&r.contains(t)||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,h.floating,n]),r&&n?t.createPortal(f.jsx("div",{ref:h.setFloating,"data-popover-root":"true",style:{...g,zIndex:c,position:g.position,overflowX:"hidden"},className:u,children:d}),document.body):null};const Kn=({globalFilter:t,filteredDataLength:r,selectedRowsCount:n=0,selectedRows:a=new Set,showExport:o=!0,showColumnToggle:s=!0,showBulkActions:l=!0,columns:i=[],columnVisibility:c={},columnFilters:u={},bulkActions:d=[],exportOptions:m,onGlobalFilterChange:h,onClearFilters:g,onColumnVisibilityChange:p,onColumnFilter:x,onResetColumns:y,columnOrder:b=[],onColumnOrderChange:w,pinnedColumns:v,onScrollToColumn:k,density:j="md",onDensityChange:N,showDensityControl:C=!1,customLeftContent:M,customRightContent:L})=>{const[A,O]=e.useState(!1),[z,$]=e.useState(!1),[H,G]=e.useState(!1),[Q,U]=e.useState(!1),[J,Z]=e.useState(""),[ee,te]=e.useState(null),[re,ne]=e.useState(null),ae=e.useRef(null),oe=e.useRef(null),se=e.useRef(null),le=e.useRef(null),ie=e.useRef(null),ce=e.useRef(null),ue=e.useRef(null),de=e.useRef(null),me=e.useRef(null);e.useEffect(()=>{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)||(oe.current&&!oe.current.contains(e.target)&&O(!1),se.current&&!se.current.contains(e.target)&&G(!1),le.current&&!le.current.contains(e.target)&&U(!1),!ie.current||ie.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)||$(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const he=m?.formats||["xlsx"],fe=(t?.length??0)>0||Object.keys(u||{}).length>0,ge=n>0,pe=i.filter(e=>!1!==c[e.key]).length,xe=[...b.map(e=>i.find(t=>t.key===e)).filter(Boolean),...i.filter(e=>!b.includes(e.key))].filter(e=>e.header?.toLowerCase()?.includes(J?.toLowerCase())),ye=e=>{switch(e){case"csv":return f.jsx(V,{size:18});case"json":return f.jsx(q,{size:18});case"xlsx":return f.jsx(B,{size:18});default:return f.jsx(P,{size:18})}},be=e=>{switch(e){case"delete":return f.jsx(E,{size:18});case"archive":return f.jsx(T,{size:18});case"copy":return f.jsx(D,{size:18});case"edit":return f.jsx(R,{size:18});case"export":return f.jsx(P,{size:18});default:return f.jsx(_,{size:18})}},we=e=>{switch(e){case"csv":return"CSV";case"json":return"JSON";case"xlsx":return"Excel";default:return e}},ve=(e,t=!1)=>{m?.onExport?.(e,t),O(!1)},ke=()=>{te(null),ne(null)},je=e.useMemo(()=>i.some(e=>e.filterable),[i]);return f.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:[f.jsxs("div",{id:"search-results-status",className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true",children:[fe?`Showing ${r} of ${r} rows`:`${r} total rows`,ge&&`, ${n} row${1!==n?"s":""} selected`]}),f.jsx("div",{className:"px-3 py-2",children:f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-4",children:[f.jsxs("div",{className:"order-1 flex items-center flex-wrap gap-2 sm:gap-3",children:[f.jsxs("div",{className:"relative",ref:ie,children:[je&&f.jsxs("button",{ref:e=>{ce.current=e},onClick:()=>$(!z),className:"flex cursor-pointer items-center gap-2 px-3 py-2 border rounded-lg transition-colors "+(z?"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":z,"aria-controls":"filters-menu","aria-keyshortcuts":"Control+K",children:[f.jsx(F,{className:"w-4 h-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Filters"}),Object.keys(u).length>0&&f.jsxs("button",{type:"button",onClick:e=>{e.stopPropagation(),g?.()},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:[f.jsx("span",{className:"group-hover:hidden",children:Object.keys(u).length}),f.jsx(S,{className:"w-3 h-3 hidden group-hover:block absolute"})]})]}),f.jsxs(Yn,{open:z,anchorEl:ce.current,onClose:()=>$(!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",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:[f.jsxs("div",{className:"flex items-center justify-between px-2",children:[f.jsxs("div",{className:"p-3 border-b border-gray-100",children:[f.jsx("h3",{className:"font-medium text-gray-900",children:"Column Filters"}),f.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Filter data by column values"})]}),f.jsx("button",{onClick:g,className:"px-3 py-1.5 text-sm text-gray-600 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors",children:"Clear All"})]}),f.jsx("div",{className:"p-3 space-y-3",children:f.jsx(er,{columns:i,columnFilters:u,onColumnFilter:x})}),f.jsx("div",{className:"flex items-center justify-between p-3 border-t border-gray-200",children:f.jsx("div",{className:"text-sm text-gray-600",children:Object.keys(u).length>0&&f.jsxs("span",{children:[Object.keys(u).length," filter",1!==Object.keys(u).length?"s":""," ","applied"]})})})]})]}),M]}),f.jsxs("div",{className:"order-2 flex items-center gap-2 sm:gap-3 flex-wrap sm:flex-nowrap",children:[L,l&&ge&&d.length>0&&f.jsxs("div",{className:"relative",ref:se,children:[f.jsxs("button",{ref:e=>{de.current=e},onClick:()=>G(!H),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:[f.jsx(_,{className:"w-4 h-4"}),f.jsxs("span",{className:"hidden sm:inline text-sm font-medium",children:["Actions (",n,")"]})]}),f.jsxs(Yn,{open:H,anchorEl:de.current,onClose:()=>G(!1),placement:"bottom-end",offset:8,zIndex:1e3,className:"w-56 bg-white border border-gray-200 rounded-lg shadow-xl",children:[f.jsxs("div",{className:"p-3 border-b border-gray-100",children:[f.jsx("h3",{className:"font-medium text-gray-900",children:"Bulk Actions"}),f.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[n," row",1!==n?"s":""," selected"]})]}),f.jsx("div",{className:"p-2",children:d.map(e=>f.jsxs("button",{onClick:()=>(e=>{e.disabled||(e.onClick(a),G(!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 cursor-not-allowed":e.destructive?"text-red-700 hover:bg-red-50":"text-gray-700 hover:bg-gray-50"),children:[be(e.id),e.label]},e.id))})]})]}),s&&i.length>0&&f.jsxs("div",{className:"relative",ref:le,children:[f.jsxs("button",{ref:e=>{me.current=e},onClick:()=>U(!Q),className:"flex items-center gap-2 px-3 py-2.5 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. ${pe} of ${i.length} columns visible`,"aria-haspopup":"menu","aria-expanded":Q,"aria-controls":"column-visibility-menu",children:[f.jsx(I,{className:"w-4 h-4"}),f.jsx("span",{className:"hidden sm:inline text-sm font-medium",children:"Columns"}),f.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500",children:["(",pe,"/",i.length,")"]})]}),f.jsxs(Yn,{open:Q,anchorEl:me.current,onClose:()=>U(!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",children:[f.jsxs("div",{className:"p-3 border-b border-gray-100",children:[f.jsx("h3",{className:"font-medium text-gray-900",children:"Show/Hide Columns"}),f.jsxs("div",{className:"relative mt-2",children:[f.jsx(K,{className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4"}),f.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",value:J,onChange:e=>Z(e.target.value)})]})]}),f.jsx("div",{className:"max-h-60 overflow-y-auto p-2",children:xe.map(e=>{const t=!1!==c[e.key];return f.jsxs("label",{className:"flex items-center gap-3 p-2 hover:bg-gray-50 rounded-md cursor-grab relative "+(ee===e.key?"opacity-60":""),draggable:!0,onDragStart:t=>((e,t)=>{te(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();ne({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})})(e.key,t),onDrop:()=>(e=>{const t=ee;if(!t||t===e)return;if(v&&v.has(t)!==v.has(e))return te(null),void ne(null);const r=re?.key!==e||"before"===re.position,n=(b&&b.length?b:i.map(e=>e.key)).filter(e=>e!==t);let a=n.indexOf(e);if(-1===a)return w?.(n),te(null),void ne(null);r||(a+=1),n.splice(a,0,t),w?.(n),te(null),ne(null)})(e.key),onDragEnd:ke,children:[re?.key===e.key&&f.jsx("span",{className:"absolute left-2 right-2 h-0.5 bg-blue-600",style:{top:"before"===re.position?0:void 0,bottom:"after"===re.position?0:void 0}}),f.jsx("input",{type:"checkbox",checked:t,onChange:()=>(e=>{const t=!1!==c[e];p?.(e,!t)})(e.key),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),t?f.jsx(W,{className:"w-4 h-4 text-green-600"}):f.jsx(Y,{className:"w-4 h-4 text-gray-400"}),f.jsx("span",{className:"text-sm text-gray-700",children:e.header}),f.jsx("button",{type:"button",onClick:r=>{r.preventDefault(),r.stopPropagation(),t?k?.(e.key):(p?.(e.key,!0),requestAnimationFrame(()=>k?.(e.key)))},className:"ml-auto p-1 text-gray-400 hover:text-blue-600",title:"Scroll to this column","aria-label":`Scroll to column ${e.header}`,children:f.jsx(X,{className:"w-4 h-4"})})]},e.key)})}),f.jsxs("div",{className:"p-2 border-t border-gray-100",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.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",children:[f.jsx("input",{type:"checkbox",checked:xe.every(e=>!1!==c[e.key]),onChange:e=>{xe.forEach(t=>{p?.(t.key,e.target.checked)})},className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),f.jsx("span",{children:"Select All"})]}),f.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",onClick:()=>{i.forEach(e=>{p?.(e.key,!1!==e.visible)}),w?.(i.map(e=>e.key)),y?.(),U(!1)},children:"Reset Columns"})]}),J&&f.jsx("button",{className:"text-xs text-blue-600 hover:underline mt-2",onClick:()=>Z(""),children:"Clear Search"})]})]})]}),C&&f.jsx("div",{className:"flex items-center",children:f.jsx("div",{className:"flex items-center gap-1 border border-gray-300 rounded-lg p-1",title:"Row density",children:["sm","md","lg"].map(e=>f.jsx("button",{className:"px-2 py-1 text-xs rounded-md "+(j===e?"bg-blue-600 text-white":"text-gray-700 hover:bg-gray-100"),onClick:()=>N?.(e),children:e.toUpperCase()},e))})}),f.jsx("div",{className:"flex items-center gap-2 order-3 w-full sm:order-0 sm:w-auto flex-1 min-w-0",children:f.jsxs("div",{className:"relative",children:[f.jsx(K,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4","aria-hidden":"true"}),f.jsx("input",{ref:ae,type:"text",placeholder:"Search...",className:"w-full sm:w-64 pl-10 pr-10 py-2.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:t,onChange:h,"aria-label":"Search all columns","aria-keyshortcuts":"Control+F","aria-describedby":"search-results-status"}),t&&f.jsx("button",{onClick:()=>h({target:{value:""}}),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors",title:"Clear search",children:f.jsx(S,{className:"w-4 h-4"})})]})}),o&&m?.enabled&&f.jsxs("div",{className:"relative",ref:oe,children:[f.jsx("button",{ref:e=>{ue.current=e},onClick:()=>O(!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"+(ge?` (${n} rows selected)`:` (${r} rows)`),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":"export-menu","aria-keyshortcuts":"Control+E",title:"Export data (Ctrl+E)",children:f.jsx(P,{className:"w-4 h-4"})}),f.jsxs(Yn,{open:A,anchorEl:ue.current,onClose:()=>O(!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",children:[f.jsxs("div",{className:"p-3 border-b border-gray-100",children:[f.jsx("h3",{className:"font-medium text-gray-900",children:"Export Data"}),f.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Choose format and data scope"})]}),f.jsxs("div",{className:"p-2",children:[f.jsxs("div",{className:"mb-3",children:[f.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2",children:"Export All Data"}),f.jsx("div",{className:"space-y-1",children:he.map(e=>f.jsxs("button",{onClick:()=>ve(e,!1),className:" cursor-pointer w-full flex items-center gap-3 px-3 py-2 text-sm text-gray-700 hover:bg-gray-50 rounded-md transition-colors",children:[ye(e),f.jsxs("span",{children:["Export as ",we(e)]}),f.jsxs("span",{className:"ml-auto text-xs text-gray-500",children:[r.toLocaleString()," rows"]})]},`all-${e}`))})]}),ge&&f.jsxs("div",{children:[f.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2",children:"Export Selected"}),f.jsx("div",{className:"space-y-1",children:he.map(e=>f.jsxs("button",{onClick:()=>ve(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",children:[ye(e),f.jsxs("span",{children:["Export as ",we(e)]}),f.jsxs("span",{className:"ml-auto text-xs text-blue-500",children:[n," rows"]})]},`selected-${e}`))})]})]})]})]})]})]})})]})},qn=({data:t,columns:r})=>{const[n,a]=e.useState(""),[o,s]=e.useState({}),[l,i]=e.useTransition(),[c,u]=e.useTransition(),d=e.useCallback(e=>{i(()=>a(e))},[]),m=e.useDeferredValue(n),h=e.useDeferredValue(o),f=e.useCallback((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(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(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 o=new Date(a);if(isNaN(o.getTime()))return!1;const s=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime();switch(r.operator){case"equals":default:return s===e;case"gt":return s>e;case"gte":return s>=e;case"lt":return s<e;case"lte":return s<=e;case"between":return void 0!==t&&!isNaN(t)&&s>=e&&s<=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}},[]),g=e.useRef(new WeakMap),p=e.useRef(0),x=e.useCallback(()=>{p.current>5e3&&(g.current=new WeakMap,p.current=0)},[]),y=e.useMemo(()=>{x();const e=Object.keys(h).length>0,n=!!m;if(!e&&!n)return t;const a=m.toLowerCase(),o=g.current;let s=t;if(e)for(const[e,t]of Object.entries(h)){if(!t)continue;let r;if("date"===t.type){const e=new Date(t.value),n=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let a;if(t.secondValue){const e=new Date(t.secondValue);a=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}r={filterTs:n,secondTs:a}}if(s=s.filter(n=>f(n,e,t,r)),0===s.length)break}if(n&&s.length>0){const e=r.filter(e=>!1!==e.visible);s=s.filter(t=>{let r=o.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("|"),p.current<5e3&&(o.set(t,r),p.current++)),r.includes(a)})}return s},[t,h,m,r,f,x]),b=e.useCallback((e,t)=>{u(()=>{s(r=>{const n={...r};return t?n[e]=t:delete n[e],n})})},[]),w=e.useCallback(e=>{b(e,null)},[b]),v=e.useCallback(()=>{i(()=>a("")),u(()=>s({})),g.current=new WeakMap,p.current=0},[]),k=e.useCallback(()=>{let e=0;return m&&e++,e+=Object.keys(h).length,e},[m,h]);return{globalFilter:n,setGlobalFilter:d,columnFilters:h,filteredData:y,setColumnFilter:b,clearColumnFilter:w,clearAllFilters:v,getActiveFilterCount:k,isFilterPending:l||c}};function Bn(){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],o=t?.[r];return null==n&&null==o?0:null==n?-1*a:null==o?1*a:"number"==typeof n&&"number"==typeof o?(n-o)*a:String(n).localeCompare(String(o))*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 Vn(t){const r=t?.enabled??!0,n=e.useRef(null),a=e.useRef(null),o=e.useRef(r);e.useEffect(()=>{o.current=r,!r&&n.current&&(n.current.terminate(),n.current=null,a.current=null)},[r]);const s=e.useRef(()=>null);return s.current=()=>{if(!o.current)return null;if(n.current)return n.current;const e=`(${Bn.toString()})()`,t=new Blob([e],{type:"application/javascript"}),r=URL.createObjectURL(t),s=new Worker(r);return URL.revokeObjectURL(r),s.onmessage=e=>{"result"===e.data?.type&&(a.current?.(e.data.payload.rows),a.current=null)},n.current=s,s},e.useEffect(()=>()=>{n.current?.terminate(),n.current=null,a.current=null},[]),{process:e.useCallback((e,t)=>{if(!o.current)return Promise.resolve(e);const r=s.current();return r?new Promise(n=>{a.current=n,r.postMessage({type:"process",payload:{rows:e,sort:t}})}):Promise.resolve(e)},[])}}const Gn="Unknown",Xn=e=>e.join("|"),Qn=(e,t,r,n,a)=>{const o=t[r],s=new Map;for(const t of e){const e=String(t[o]??Gn),r=s.get(e);r?r.push(t):s.set(e,[t])}for(const[e,l]of s.entries()){const s=[...n,`${o}=${e}`];a.add(Xn(s)),r<t.length-1&&Qn(l,t,r+1,s,a)}},Un=({data:t,pagination:r})=>{const[n,a]=e.useState(1),[o,s]=e.useState(r?.pageSize||50),[l,i]=e.useState(!1);e.useEffect(()=>{const e=r?.pageSize;e&&e!==o&&(s(e),a(1))},[r?.pageSize]);const c=e.useCallback(()=>{a(1)},[]),u=e.useMemo(()=>{const e=!1!==r?.enabled,a="server"===(r?.mode||"client")?r?.serverConfig?.totalRows||0:t.length,s=Math.ceil(a/o);return{enabled:e,pageSize:o,currentPage:n,totalPages:s,totalRows:a,showPageSizeSelector:!1!==r?.showPageSizeSelector,pageSizeOptions:r?.pageSizeOptions||[25,50,100,200,500]}},[r,o,n,t.length]),d=e.useMemo(()=>{if(!u.enabled||"server"===r?.mode)return t;const e=(n-1)*o;return t.slice(e,e+o)},[t,n,o,u.enabled,r?.mode]),m=e.useCallback(async e=>{if("server"===r?.mode&&r?.serverConfig?.onPageChange){i(!0);try{await r.serverConfig.onPageChange(e,o)}finally{i(!1)}}a(e)},[r,o]),h=e.useCallback(async e=>{if("server"===r?.mode&&r?.serverConfig?.onPageSizeChange){i(!0);try{await r.serverConfig.onPageSizeChange(e)}finally{i(!1)}}s(e),a(1)},[r]);return{currentPage:n,resetPage:c,paginationConfig:u,paginatedData:d,isServerLoading:l,handlePageChange:m,handlePageSizeChange:h}},Jn=(e,t)=>{if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0},Zn=({data:t,selectedRowIds:r,onRowSelect:n,getRowId:a})=>{const o=e.useCallback((e,t)=>a?a(e):void 0!==e.id?e.id:("development"===process.env.NODE_ENV&&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),[a]),[s,l]=e.useState(()=>new Set(r?Array.from(r):[]));e.useEffect(()=>{r&&l(e=>{const t=new Set(Array.from(r));return Jn(e,t)?e:t})},[r]),e.useEffect(()=>{if(0===s.size)return;t.length>0&&o(t[0],0),t.length>1&&o(t[t.length-1],t.length-1);const e=new Set(t.map((e,t)=>o(e,t)));let r=!1;for(const t of s)if(!e.has(t)){r=!0;break}r&&l(t=>{const r=new Set;return t.forEach(t=>{e.has(t)&&r.add(t)}),Jn(t,r)?t:r})},[t,o]);const i=e.useCallback((e,r)=>{if(l(t=>{const n=new Set(t);return r?n.add(e):n.delete(e),n}),n){const r=t.find((t,r)=>o(t,r)===e);r&&n(r)}},[t,n,o]),c=e.useCallback(e=>{l(e?new Set(t.map((e,t)=>o(e,t))):new Set)},[t,o]);return{selectedRows:s,handleRowSelect:i,handleSelectAll:c}},ea=({data:t,virtualized:r=!0,rowHeight:n=40,overscan:a=10,height:o})=>{const s=e.useRef(null),[l,i]=e.useState(0),c=e.useRef(null),u=e.useRef(0),[d,m]=e.useState(o);e.useEffect(()=>{const e=s.current;if(!e)return;const t=new ResizeObserver(([e])=>{const t=e.contentRect.height;t>0&&m(t)});t.observe(e);const r=e.clientHeight;return r>0&&m(r),()=>t.disconnect()},[]),e.useEffect(()=>{o>0&&m(o)},[o]);const h=e.useMemo(()=>{if(!r)return{startIndex:0,endIndex:t.length-1,offsetY:0};const e=Math.max(1,Math.ceil(d/n)),o=Math.max(a,Math.max(8,Math.min(2*e,50))),s=Math.max(0,Math.floor(l/n)-o),i=Math.ceil(d/n);return{startIndex:s,endIndex:Math.min(t.length-1,s+i+2*o),offsetY:s*n}},[l,d,t.length,n,a,r]),f=e.useMemo(()=>r?t.slice(h.startIndex,h.endIndex+1):t,[t,h,r]),g=t.length*n,p=e.useCallback(e=>{u.current=e.target.scrollTop,null==c.current&&(c.current=requestAnimationFrame(()=>{c.current=null,i(u.current)}))},[]);return e.useEffect(()=>()=>{null!=c.current&&cancelAnimationFrame(c.current)},[]),{scrollRef:s,virtualizedRange:h,visibleData:f,totalHeight:g,handleScroll:p}},ta=()=>!0,ra=e.forwardRef(function({data:t,columns:r,getRowId:n,height:a,density:o="md",headerDensity:s,headerHeight:l,onDensityChange:i,showDensityControl:c=!1,onRowSelect:u,onSelectedRowsChange:d,selectable:m=!1,isRowSelectable:h,showToolbar:x=!0,showExport:y=!1,filterable:b=!0,groupable:w=!1,virtualized:v=!0,rowHeight:k,overscan:j=6,rowStyle:N,onContextMenu:C,onRowDoubleClick:S,onRowClick:M,onCellClick:D,onCellContextMenu:R,cellFocusEnabled:E=!1,onCellFocusChange:T,cellSelectionEnabled:P=!1,canSelectCell:L=ta,onCellSelectionChange:F,pagination:A={enabled:!1,mode:"client",pageSize:50},virtualizationThreshold:I=300,isLoading:O=!1,onFilterChange:z,onSort:$,onColumnConfigChange:H,initialColumnConfig:_,toolbarLeft:W,toolbarRight:Y,groupBarVisibility:K="auto",groupFooterVariant:q="chips",onCopyCells:B,selectedRowIds:V,performanceConfig:G={},exportOptions:X,renderGroupActions:Q},U){const J=e.useRef(null),[Z,ee]=e.useState(0);e.useEffect(()=>{const e=J.current;if(!e)return;const t=()=>ee(e.clientWidth||0);t();const r=new ResizeObserver(()=>t());return r.observe(e),()=>r.disconnect()},[]);const[te,re]=e.useState(null),[ne,ae]=e.useState(null),[oe,se]=e.useState(null),le=e.useRef(!1),ie=e.useRef(null),ce=e.useRef(null),[ue,de]=e.useState(null),[me,he]=e.useState(o);e.useEffect(()=>{he(o)},[o]);const fe=e.useMemo(()=>({sm:28,md:40,lg:56}),[]),ge=e.useMemo(()=>null!=k?k:fe[me],[k,me,fe]),pe=e.useMemo(()=>null!=l?l:fe[s??"md"],[l,s,fe]),{globalFilter:xe,columnFilters:ye,filteredData:be,setGlobalFilter:we,setColumnFilter:ve,clearAllFilters:ke}=qn({data:t,columns:r}),[je,Ne]=e.useState({key:null,direction:null}),[Ce,Se]=e.useState(()=>{const e={};return r.forEach(t=>{e[t.key]=t.width||100}),e}),Me=e.useRef(r.reduce((e,t)=>(e[t.key]=t.width||100,e),{})),De=e.useRef(r.map(e=>e.key)),[Re,Ee]=e.useState(()=>De.current.slice()),[Te,Pe]=e.useState(new Set),[Le,Fe]=e.useState(()=>{const e={};return r.forEach(t=>{e[t.key]=!0}),e}),Ae=e.useCallback(e=>{let t=e,r="asc";je.key!==e?(t=e,r="asc"):"asc"===je.direction?r="desc":"desc"===je.direction?(t=null,r=null):r="asc",Ne({key:t,direction:r}),$&&"server"===A?.mode&&t&&r&&$(t,r)},[$,A?.mode,je.key,je.direction]),Ie=e.useCallback((e,t)=>{Se(r=>({...r,[e]:t}))},[]),Oe=e.useCallback(e=>null==e?0:8*("string"==typeof e?e:String(e)).length,[]),ze=e.useCallback(e=>{const n=r.find(t=>t.key===e);if(!n)return;const a=Oe(n.header),o=t.slice(0,500);let s=0;for(const t of o)s=Math.max(s,Oe(t[e]));const l=Math.max(60,Math.min(500,Math.max(a,s)+32));Se(t=>({...t,[e]:l}))},[r,t,Oe]),$e=e.useCallback(()=>{r.forEach(e=>ze(e.key))},[r,ze]),He=e.useCallback(()=>{Se({...Me.current}),Pe(new Set),Fe(e=>{const t={};return Object.keys(e).forEach(e=>t[e]=!0),t}),Ee(De.current.slice())},[]),_e=e.useRef(null),We=e.useRef(null),Ye=e.useCallback((e,t)=>{Pe(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n})},[]),Ke=e.useCallback((e,t)=>{Fe(r=>({...r,[e]:t}))},[]),{process:qe}=Vn({enabled:!0}),[Be,Ve]=e.useState(be),Ge=G?.sortWorkerThreshold??5e3;e.useEffect(()=>{let e=!1;if(!je.key)return void Ve(be);const t=be;if(t.length<Ge){const e="asc"===je.direction?1:-1,r=[...t].sort((t,r)=>{const n=t?.[je.key],a=r?.[je.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 Ve(r)}return qe(t,{key:je.key,direction:je.direction}).then(t=>{e||Ve(t)}),()=>{e=!0}},[be,je,qe,Ge]);const{paginationConfig:Xe,paginatedData:Qe,isServerLoading:Ue,handlePageChange:Je,handlePageSizeChange:Ze,resetPage:et,currentPage:tt}=Un({data:Be,pagination:A}),rt=O||Ue,[nt,at]=e.useState(rt),[ot,st]=e.useState(!1),[lt,it]=e.useState(0);e.useEffect(()=>{if(rt)return at(!0),void st(!1);if(nt){st(!0);const e=setTimeout(()=>{at(!1),st(!1)},200);return()=>clearTimeout(e)}},[rt]);const ct=e.useCallback(e=>{we(e.target.value)},[we]),{groupConfig:ut,displayData:dt,handleGroupBy:mt,addGroupKey:ht,removeGroupKey:ft,setGroupKeys:gt,toggleGroupExpansion:pt,isGrouped:xt,expandAllGroups:yt,collapseAllGroups:bt}=(({data:t,columns:r})=>{const[n,a]=e.useState({columnKeys:[],expanded:new Set}),o=e.useMemo(()=>{const e=n.columnKeys;if(!e.length)return t;const a=[],o=e=>{const t={};for(const n of r){if(!n.aggregate)continue;const r=e.map(e=>e[n.key]);let a=null;if("function"==typeof n.aggregate)try{a=n.aggregate(r)}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))),t=r.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)),o=()=>r.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)a=t.length?"sum"===n.aggregate?t.reduce((e,t)=>e+t,0):t.reduce((e,t)=>e+t,0)/t.length:null;else if("min"===n.aggregate||"max"===n.aggregate)if(t.length)a="min"===n.aggregate?Math.min(...t):Math.max(...t);else{const e=o();if(e.length){const t="min"===n.aggregate?Math.min(...e):Math.max(...e);a=new Date(t)}else a=null}}null!=a&&(t[n.key]=a)}return t},s=(t,r,l)=>{const i=e[r],c=new Map;for(const e of t){const t=String(e[i]??Gn),r=c.get(t);r?r.push(e):c.set(t,[e])}const u=Array.from(c.entries()).sort(([e],[t])=>e.localeCompare(t));for(const[t,c]of u){const u=[...l,`${i}=${t}`],d=Xn(u);if(a.push({id:`group-${d}`,_isGroupHeader:!0,_groupKey:d,_groupCount:c.length,_groupLevel:r,_groupColumnKey:i,_groupValue:t,_groupRows:c}),!n.expanded.has(d))continue;if(r<e.length-1)s(c,r+1,u);else for(const e of c)a.push(e);const m=o(c);a.push({id:`group-footer-${d}`,_isGroupFooter:!0,_groupKey:d,_groupLevel:r,_groupAgg:m})}};return s(t,0,[]),a},[t,n.columnKeys,n.expanded]);return e.useEffect(()=>{if(!n.columnKeys.length)return;const e=new Set;Qn(t,n.columnKeys,0,[],e);let r=!1;if(e.size!==n.expanded.size)r=!0;else for(const t of e)if(!n.expanded.has(t)){r=!0;break}r&&a(t=>({...t,expanded:e}))},[n.columnKeys,t]),{groupConfig:n,displayData:o,handleGroupBy:e=>{a({columnKeys:e?[e]:[],expanded:new Set})},addGroupKey:e=>{a(t=>t.columnKeys.includes(e)?t:{...t,columnKeys:[...t.columnKeys,e]})},removeGroupKey:e=>{a(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=>{a({columnKeys:[...e],expanded:new Set})},toggleGroupExpansion:e=>{a(t=>{const r=new Set(t.expanded);return r.has(e)?r.delete(e):r.add(e),{...t,expanded:r}})},expandAllGroups:()=>{const e=n.columnKeys;if(!e.length)return;const r=new Set;Qn(t,e,0,[],r),a(e=>({...e,expanded:r}))},collapseAllGroups:()=>{a(e=>({...e,expanded:new Set}))},isGrouped:n.columnKeys.length>0}})({data:Be,columns:r});e.useImperativeHandle(U,()=>({setGroupKeys:gt,addGroupKey:ht,removeGroupKey:ft,expandAllGroups:yt,collapseAllGroups:bt,toggleGroupExpansion:pt,getGroupConfig:()=>ut,setColumnFilter:(e,t)=>{ve(e,t)},clearColumnFilter:e=>{ve(e,null)},clearAllFilters:()=>{ke()},setGlobalFilter:e=>{we(e)}}),[ut,ve,ke,we]);const wt=e.useMemo(()=>new Set(Te),[Te]),vt=A?.enabled?"server"===A.mode?t:Qe:Be,kt=xt?dt:vt,{selectedRows:jt,handleRowSelect:Nt,handleSelectAll:Ct}=Zn({data:kt,onRowSelect:u,selectedRowIds:V,getRowId:n}),St=e.useRef(d);e.useEffect(()=>{St.current=d},[d]),e.useEffect(()=>{St.current&&St.current(jt)},[jt]);const{exportData:Mt}=(({data:t,columns:r,selectedRows:n,filename:a="data",columnVisibility:o})=>{const s=e.useCallback(()=>o?r.filter(e=>!1!==o[e.key]):r,[r,o]),l=e.useCallback((e,t,r)=>{const n=new Blob([e],{type:r}),a=URL.createObjectURL(n),o=document.createElement("a");o.href=a,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},[]),i=e.useCallback((e,t)=>{const r=s(),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(","));l([n,...a].join("\n"),`${t}.csv`,"text/csv")},[s,l]),c=e.useCallback((e,t)=>{const r=s(),n=e.map(e=>{const t={};for(const n of r)t[n.header]=e[n.key];return t});l(JSON.stringify(n,null,2),`${t}.json`,"application/json")},[s,l]),u=e.useCallback(async(e,t)=>{const r=s(),[{default:n},{saveAs:a}]=await Promise.all([import("exceljs"),import("file-saver")]),o=new n.Workbook,l=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};l.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]);l.addRow(e)}l.getRow(1).font={bold:!0},l.autoFilter={from:{row:1,column:1},to:{row:Math.max(1,l.rowCount),column:r.length}};const u=await o.xlsx.writeBuffer();a(new Blob([u],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),`${t}.xlsx`)},[s]),d=e.useCallback((e,r=!1)=>{const o=r&&n&&n.size>0?t.filter(e=>n.has(e.id)):t,s=r&&n&&n.size>0?`${a}_selected_${n.size}_rows`:a;switch(e){case"csv":i(o,s);break;case"json":c(o,s);break;case"xlsx":u(o,s);break;default:console.warn(`[KDGrid] Unsupported export format: ${e}`)}},[t,n,a,i,c,u]);return{exportData:d,canExportSelected:!!(n&&n.size>0),selectedCount:n?.size??0}})({data:vt,columns:r,selectedRows:jt,filename:X&&X.filename||"grid-data",columnVisibility:Le}),Dt=e.useCallback((e,t)=>{const r=Array.from(jt||[]);"server"===X?.exportMode&&"function"==typeof X?.onServerExport?X.onServerExport(e,t,r):Mt(e,t)},[X?.exportMode,X?.onServerExport,Mt,jt]),Rt=e.useCallback(()=>{ke()},[ke]),Et=e.useCallback(e=>{he(e),i&&i(e)},[i]),Tt=e.useMemo(()=>!!v&&kt.length>I,[v,kt.length,I]),Pt=e.useMemo(()=>({enableHorizontalVirtualization:!0,horizontalVirtualizationThreshold:50,sortWorkerThreshold:5e3,maxFilterCacheSize:5e3,enableAggressiveMemoization:!0,...G}),[G]),{scrollRef:Lt,virtualizedRange:Ft,visibleData:At,handleScroll:It}=ea({data:kt,virtualized:Tt,rowHeight:ge,overscan:j,height:a||400});e.useEffect(()=>{const e=()=>{const e=Lt.current;e&&it((e.offsetTop||0)+(pe||0)-1)};e();const t=new ResizeObserver(e);return J.current&&t.observe(J.current),Lt.current&&t.observe(Lt.current),()=>t.disconnect()},[pe]);const[Ot,zt]=e.useState(0),$t=e.useRef(0),Ht=e.useRef(null),_t=e.useCallback(e=>{$t.current=e,null==Ht.current&&(Ht.current=requestAnimationFrame(()=>{Ht.current=null,zt($t.current)}))},[]),[Wt,Yt]=e.useState(0);e.useEffect(()=>{const e=Lt.current;if(!e)return;const t=()=>Yt(e.clientWidth||0);t();const r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[Lt]),e.useEffect(()=>{if(!z)return;if(!A?.enabled||"server"!==A.mode)return;const e=r.filter(e=>!!e.filterable).map(e=>e.key);z({globalFilter:xe,columnFilters:ye,filterableKeys:e})},[xe,ye]),e.useEffect(()=>{if(!_)return;const e=new Set(r.map(e=>e.key));if(_.columnWidths){const t=Object.fromEntries(Object.entries(_.columnWidths).filter(([t])=>e.has(t)));Se(e=>({...e,...t}))}if(_.columnVisibility){const t=Object.fromEntries(Object.entries(_.columnVisibility).filter(([t])=>e.has(t)));Fe(e=>({...e,...t}))}if(_.pinnedColumns){const t=_.pinnedColumns.filter(t=>e.has(t));Pe(new Set(t))}if(_.sortConfig){const e="asc"===_.sortConfig.direction||"desc"===_.sortConfig.direction?_.sortConfig.direction:null;Ne({key:e?_.sortConfig.key:null,direction:e})}if(_.filters){we(_.filters.globalFilter||"");const t=Object.entries(_.filters.columnFilters||{}).filter(([t])=>e.has(t));for(const[e,r]of t)ve(e,r)}if(_.columnOrder&&_.columnOrder.length){const t=_.columnOrder.filter(t=>e.has(t)),n=r.map(e=>e.key).filter(e=>!t.includes(e));Ee([...t,...n])}_.groupConfig?.columnKeys&&_.groupConfig.columnKeys.length?gt(_.groupConfig.columnKeys):_.groupConfig?.columnKey&&mt(_.groupConfig.columnKey),_.density&&he(_.density)},[]),e.useEffect(()=>{if(!H)return;const e=setTimeout(()=>{H({columnWidths:Ce,columnVisibility:Le,pinnedColumns:Array.from(Te),sortConfig:je,groupConfig:{columnKeys:ut.columnKeys},filters:{globalFilter:xe,columnFilters:ye},columnOrder:Re,density:me})},200);return()=>clearTimeout(e)},[H,Ce,Le,Te,je,ut,xe,ye,Re,me]);const Kt=e.useMemo(()=>{if(0===r.length)return[];const e=new Map(Re.map((e,t)=>[e,t])),t=r.filter(e=>!1!==Le[e.key]).sort((t,r)=>(e.get(t.key)||0)-(e.get(r.key)||0)).map(e=>{const t=Ce[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,Z-(m?g:0)),a=t.reduce((e,t)=>e+t.width,0);if(n>a){const e=t.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)n.width=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=[],s=[];for(const e of t)wt.has(e.key)?o.push(e):s.push(e);if(ut.columnKeys&&ut.columnKeys.length>0){const e=new Map(ut.columnKeys.map((e,t)=>[e,t]));s.sort((t,r)=>(e.get(t.key)??Number.POSITIVE_INFINITY)-(e.get(r.key)??Number.POSITIVE_INFINITY))}return[...o,...s]},[r,Ce,wt,Le,Re,ut.columnKeys,Z,m]),Bt=e.useMemo(()=>Pt.enableHorizontalVirtualization&&Kt.length>Pt.horizontalVirtualizationThreshold,[Kt.length,Pt.enableHorizontalVirtualization,Pt.horizontalVirtualizationThreshold]),Vt=e.useMemo(()=>Kt.filter(e=>wt.has(e.key)),[Kt,wt]),Zt=e.useMemo(()=>Kt.filter(e=>!wt.has(e.key)),[Kt,wt]),er=e.useMemo(()=>{const e=Zt.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}},[Zt]),tr=e.useMemo(()=>{if(!Bt)return Kt;const e=m?g:0,t=Vt.reduce((e,t)=>e+(t.width||100),0),r=Math.max(0,Ot-200),n=Ot+Wt+200,a=e+t,o=Math.max(0,r-a),s=Math.max(0,Math.min(er.totalWidth,n-a)),l=(e=>{if(!er.widths.length)return 0;let t=0,r=er.widths.length-1,n=0;for(;t<=r;){const a=t+r>>1;er.prefix[a+1]>=e?(n=a,r=a-1):t=a+1}return Math.max(0,Math.min(n,er.widths.length-1))})(o),i=(e=>{if(!er.widths.length)return-1;let t=0,r=er.widths.length-1,n=er.widths.length-1;for(;t<=r;){const a=t+r>>1;er.prefix[a]<=e?(n=a,t=a+1):r=a-1}return Math.max(0,Math.min(n,er.widths.length-1))})(s),c=i>=l&&i>=0?Zt.slice(l,i+1):[];return[...Vt,...c]},[Bt,Kt,Ot,Wt,m,Vt,Zt,er]),rr=e.useMemo(()=>{const e=new Map;return Zt.forEach((t,r)=>e.set(t.key,r)),e},[Zt]),{hvPadLeftMemo:nr,hvPadRightMemo:ar}=e.useMemo(()=>{if(!Bt)return{hvPadLeftMemo:0,hvPadRightMemo:0};const e=tr.filter(e=>!wt.has(e.key));if(!e.length)return{hvPadLeftMemo:0,hvPadRightMemo:0};const t=rr.get(e[0].key),r=rr.get(e[e.length-1].key);return null==t||null==r?{hvPadLeftMemo:0,hvPadRightMemo:0}:{hvPadLeftMemo:er.prefix[t],hvPadRightMemo:er.totalWidth-er.prefix[r+1]}},[Bt,tr,wt,rr,er]),or=e.useMemo(()=>Kt.some(e=>e.footer_aggregate),[Kt]);e.useEffect(()=>{const e=Lt.current;if(!e)return;let t=!1;const r=()=>{if(t)return;t=!0;const r=We.current;r&&r.scrollLeft!==e.scrollLeft&&(r.scrollLeft=e.scrollLeft),_t(e.scrollLeft),requestAnimationFrame(()=>{t=!1})};return e.addEventListener("scroll",r,{passive:!0}),We.current&&(We.current.scrollLeft=e.scrollLeft),()=>{e.removeEventListener("scroll",r)}},[Lt,or]);const sr=e.useMemo(()=>{const e=new Map;return Kt.forEach((t,r)=>e.set(t.key,r)),e},[Kt]),lr=e.useMemo(()=>{const e=new Map;return Kt.forEach(t=>e.set(t.key,t)),e},[Kt]),ir=e.useMemo(()=>kt.filter(e=>!e._isGroupHeader&&!e._isGroupFooter),[kt]),cr=e.useMemo(()=>{const e=new Map;return ir.forEach((t,r)=>e.set(t.id,r)),e},[ir]),ur=e.useMemo(()=>{const e=new Map;return ir.forEach(t=>e.set(t.id,t)),e},[ir]),dr=e.useRef(null),mr=e.useRef(F),hr=e.useRef(B);e.useEffect(()=>{hr.current=B},[B]),e.useEffect(()=>{mr.current=F},[F]);const fr=e.useMemo(()=>Kt.map(e=>e.key),[Kt]),gr=e.useMemo(()=>(e,t)=>{if(!P)return!1;if(!ne||!oe)return!1;const r=cr.get(e),n=sr.get(t);if(null==r||null==n)return!1;const a=ur.get(e),o=lr.get(t);if(a&&o&&!L(a,o))return!1;const s=Math.min(ne.rowIndex,oe.rowIndex),l=Math.max(ne.rowIndex,oe.rowIndex),i=Math.min(ne.colIndex,oe.colIndex),c=Math.max(ne.colIndex,oe.colIndex);return r>=s&&r<=l&&n>=i&&n<=c},[P,ne,oe,cr,sr,ur,lr,L]),pr=e.useMemo(()=>(e,t)=>te?.rowId===e&&te?.columnKey===t,[te]),xr=e.useCallback(e=>{const t=Lt.current;if(!t)return;const r=Math.abs(e.deltaX)>=Math.abs(e.deltaY)?e.deltaX:e.deltaY;0!==r&&(e.preventDefault(),t.scrollBy({left:r,top:0,behavior:"auto"}))},[]),yr=e.useCallback(({row:e,column:t,event:r})=>{const n=cr.get(e.id),a=sr.get(t.key);E&&null!=n&&null!=a&&(document.body.hasAttribute("data-modal-open")||(re({rowId:e.id,columnKey:t.key}),T&&T({row:e,column:t,value:e[t.key],rowIndex:n,colIndex:a}))),P&&L(e,t)&&0===r.button&&(le.current=!0,ie.current={x:r.clientX,y:r.clientY},null!=n&&null!=a&&(re({rowId:e.id,columnKey:t.key}),ae({rowIndex:n,colIndex:a}),se({rowIndex:n,colIndex:a}),de({x:r.clientX,y:r.clientY,rows:1,cols:1})))},[E,T,P,L,cr,sr]),br=e.useCallback(({row:e,column:t,event:r})=>{if(!P)return;if(!le.current||!ne)return;if(!L(e,t))return;const n=cr.get(e.id),a=sr.get(t.key);if(null==n||null==a)return;se({rowIndex:n,colIndex:a}),ie.current={x:r.clientX,y:r.clientY};const o=Math.min(ne.rowIndex,n),s=Math.max(ne.rowIndex,n),l=Math.min(ne.colIndex,a),i=Math.max(ne.colIndex,a);de({x:r.clientX,y:r.clientY,rows:s-o+1,cols:i-l+1})},[P,L,ne,cr,sr]);e.useEffect(()=>{const e=()=>{le.current=!1,de(null),ce.current&&(cancelAnimationFrame(ce.current),ce.current=null)};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),e.useEffect(()=>{const e=e=>{le.current&&(ie.current={x:e.clientX,y:e.clientY})};return window.addEventListener("mousemove",e),()=>window.removeEventListener("mousemove",e)},[]);const wr=e.useCallback(()=>{if(null!=ce.current)return;const e=()=>{if(ce.current=null,!le.current)return;const t=Lt.current,r=ie.current;if(t&&r){const e=t.getBoundingClientRect(),n=24,a=24;let o=0,s=0;r.x<e.left+n?o=-(e.left+n-r.x):r.x>e.right-n&&(o=r.x-(e.right-n)),r.y<e.top+n?s=-(e.top+n-r.y):r.y>e.bottom-n&&(s=r.y-(e.bottom-n));const l=e=>Math.max(-a,Math.min(a,e));o=l(o),s=l(s),0===o&&0===s||t.scrollBy({left:o,top:s,behavior:"auto"})}ce.current=requestAnimationFrame(e)};ce.current=requestAnimationFrame(e)},[]);e.useEffect(()=>{le.current&&wr()},[wr,ne]),e.useEffect(()=>{const e=e=>{if("Escape"===e.key)return ae(null),se(null),re(null),void de(null);const t=e.shiftKey,r=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key);if(!t||!r||!P)return;e.preventDefault();let n=oe;if(!n){if(!te)return;{const e=cr.get(te.rowId),t=sr.get(te.columnKey);if(null==e||null==t)return;ae({rowIndex:e,colIndex:t}),n={rowIndex:e,colIndex:t}}}const a=ir.length-1,o=Kt.length-1;let s=n.rowIndex,l=n.colIndex;"ArrowUp"===e.key&&(s=Math.max(0,s-1)),"ArrowDown"===e.key&&(s=Math.min(a,s+1)),"ArrowLeft"===e.key&&(l=Math.max(0,l-1)),"ArrowRight"===e.key&&(l=Math.min(o,l+1)),se({rowIndex:s,colIndex:l});const i=Lt.current;if(i){const e=i.getBoundingClientRect();de({x:e.right-16,y:e.bottom-16,rows:Math.abs((ne?.rowIndex??s)-s)+1,cols:Math.abs((ne?.colIndex??l)-l)+1})}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[P,te,ne,oe,cr,sr,ir.length,Kt.length]),e.useEffect(()=>{if(!E)return;const e=Lt.current,t=_e.current,r=r=>{if(!te)return;if(document.body.hasAttribute("data-modal-open"))return;const{key:n}=r;if("ArrowLeft"!==n&&"ArrowRight"!==n&&"ArrowUp"!==n&&"ArrowDown"!==n)return;r.preventDefault();const a=cr.get(te.rowId),o=sr.get(te.columnKey);if(null==a||null==o)return;let s=a,l=o;"ArrowLeft"===r.key&&(l=Math.max(0,o-1)),"ArrowRight"===r.key&&(l=Math.min(Kt.length-1,o+1)),"ArrowUp"===r.key&&(s=Math.max(0,a-1)),"ArrowDown"===r.key&&(s=Math.min(ir.length-1,a+1));const i=ir[s],c=Kt[l];i&&c&&(re({rowId:i.id,columnKey:c.key}),T&&T({row:i,column:c,value:i[c.key],rowIndex:s,colIndex:l}),((r,n)=>{if(!e)return;const a=e.clientHeight,o=r*ge,s=o+ge;o<e.scrollTop?e.scrollTop=o:s>e.scrollTop+a&&(e.scrollTop=s-a);const l=Kt[n]?.width||100;let i=m?g:0;for(let e=0;e<n;e++)i+=Kt[e]?.width||100;const c=i+l,u=e.clientWidth;i<e.scrollLeft?e.scrollLeft=i:c>e.scrollLeft+u&&(e.scrollLeft=c-u),t&&(t.scrollLeft=e.scrollLeft)})(s,l))};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[E,te,ir,Kt,ge,m,cr,sr,T]),e.useEffect(()=>{if(!P||!ne||!oe){const e={bounds:null,cells:[]},t="none";return void(t!==dr.current&&(dr.current=t,mr.current?.(e)))}const e=Math.min(ne.rowIndex,oe.rowIndex),t=Math.max(ne.rowIndex,oe.rowIndex),r=Math.min(ne.colIndex,oe.colIndex),n=Math.max(ne.colIndex,oe.colIndex),a=[];for(let o=e;o<=t;o++){const e=ir[o];if(e)for(let t=r;t<=n;t++){const r=Kt[t];r&&L(e,r)&&a.push({row:e,column:r,value:e[r.key],rowIndex:o,colIndex:t})}}const o={bounds:{rowStart:e,rowEnd:t,colStart:r,colEnd:n},cells:a},s=`${e}-${t}-${r}-${n}|len:${a.length}`;s!==dr.current&&(dr.current=s,mr.current?.(o))},[P,ne,oe,ir,fr,L]),e.useEffect(()=>{if(!P&&!E)return;const e=async e=>{if(!e.metaKey&&!e.ctrlKey||"c"!==e.key.toLowerCase())return;const t=!!e.shiftKey,r=!(!ne||!oe),n=!(!E||!te);if(!r&&!n)return;if(!r&&n){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}e.preventDefault();const a=(()=>{const e=[];if(r&&ne&&oe){const t=Math.min(ne.rowIndex,oe.rowIndex),r=Math.max(ne.rowIndex,oe.rowIndex),n=Math.min(ne.colIndex,oe.colIndex),a=Math.max(ne.colIndex,oe.colIndex);for(let o=t;o<=r;o++){const t=ir[o];if(t)for(let r=n;r<=a;r++){const n=Kt[r];n&&L(t,n)&&e.push({row:t,column:n,value:t[n.key],rowIndex:o,colIndex:r})}}}else if(n&&te){const t=cr.get(te.rowId),r=sr.get(te.columnKey);if(null!=t&&null!=r){const n=ir[t],a=Kt[r];n&&a&&e.push({row:n,column:a,value:n[a.key],rowIndex:t,colIndex:r})}}return e})();if(!a.length)return;const o=e=>{const t=null==e?"":String(e);return t.includes('"')||t.includes("\t")||t.includes("\n")||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t};let s="";if(r&&ne&&oe){const e=Math.min(ne.rowIndex,oe.rowIndex),r=Math.max(ne.rowIndex,oe.rowIndex),n=Math.min(ne.colIndex,oe.colIndex),a=Math.max(ne.colIndex,oe.colIndex);if(t){const e=[];for(let t=n;t<=a;t++){const r=Kt[t];r&&e.push(o(r.header??r.key))}s+=e.join("\t")+"\n"}for(let t=e;t<=r;t++){const e=ir[t];if(!e)continue;const l=[];for(let t=n;t<=a;t++){const r=Kt[t];r&&(L(e,r)?l.push(o(e[r.key])):l.push(""))}s+=l.join("\t"),t<r&&(s+="\n")}}else s=o(a[0].value);try{await navigator.clipboard.writeText(s)}catch{console.warn("Failed to write to clipboard")}if("function"==typeof hr.current){const e=r&&ne&&oe?{rowStart:Math.min(ne.rowIndex,oe.rowIndex),rowEnd:Math.max(ne.rowIndex,oe.rowIndex),colStart:Math.min(ne.colIndex,oe.colIndex),colEnd:Math.max(ne.colIndex,oe.colIndex)}:null;try{hr.current({text:s,bounds:e,cells:a,isRectangular:!!e,isFocusedCell:!e})}catch{}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[P,E,ne,oe,te,ir,Kt,L,cr,sr,U]);const vr=Kt.reduce((e,t)=>e+(t.width||100),0);return e.useEffect(()=>{1!==tt&&(A?.enabled&&"server"===A.mode?Je(1):et())},[xe,ye]),f.jsxs("div",{ref:J,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:[x&&b&&f.jsx(Kn,{globalFilter:xe,filteredDataLength:be.length,totalDataLength:Xe.totalRows,paginationMode:A?.mode,selectedRowsCount:jt.size,showExport:y,columns:r,columnFilters:ye,columnVisibility:Le,onResetColumns:He,exportOptions:{enabled:(X?.enabled??!0)&&y,formats:X?.formats??["xlsx"],filename:X?.filename??"grid-data",onExport:Dt},customLeftContent:W,customRightContent:Y,onGlobalFilterChange:ct,onClearFilters:Rt,onColumnFilter:ve,onColumnVisibilityChange:Ke,columnOrder:Re,onColumnOrderChange:Ee,pinnedColumns:Te,onScrollToColumn:e=>{const t=Lt.current,r=_e.current;if(!t)return;const n=sr.get(e);if(null==n)return;const a=Kt[n]?.width||100;let o=m?g:0;for(let e=0;e<n;e++)o+=Kt[e]?.width||100;const s=o+a,l=t.clientWidth;if(o<t.scrollLeft)t.scrollTo({left:o,behavior:"smooth"});else if(s>t.scrollLeft+l)t.scrollTo({left:s-l,behavior:"smooth"});else{const e=Math.max(0,o-Math.max(0,(l-a)/2));t.scrollTo({left:e,behavior:"smooth"})}r&&(r.scrollLeft=t.scrollLeft)},density:me,onDensityChange:Et,showDensityControl:c}),f.jsxs("div",{className:"flex flex-col relative flex-1 min-h-50",children:[w&&("visible"===K||"auto"===K&&ut.columnKeys.length>0)&&f.jsx(Xt,{columns:r,groupedKeys:ut.columnKeys,onRemove:ft,onReorder:gt,onDropColumnKey:ht,isAnyExpanded:ut.expanded.size>0,onToggleExpandAll:()=>{ut.expanded.size>0?bt():yt()}}),f.jsxs("div",{ref:Lt,className:"flex-1 overflow-auto relative [&::-webkit-scrollbar]:thin "+(P?"select-none":""),onScroll:It,children:[f.jsx("div",{className:"sticky top-0 z-3",children:f.jsx("div",{style:{minWidth:`${vr+(m?g:0)}px`},children:(()=>{const e=Vt,r=tr.filter(e=>!wt.has(e.key));return f.jsx(qt,{pinnedColumns:e,unpinnedColumns:r,hvPadLeft:nr,hvPadRight:ar,headerHeight:pe,sortConfig:je,columnFilters:ye,selectable:m,selectedRows:jt,totalRows:kt.length,data:t,onSort:Ae,onColumnFilter:ve,onSelectAll:()=>Ct(jt.size!==kt.length),onColumnResize:Ie,pinnedKeySet:wt,onColumnPin:Ye,groupable:w,groupedByColumn:ut.columnKeys[0]||null,groupedByColumns:ut.columnKeys,onGroupToggle:(e,t)=>t?ht(e):ft(e),onGroupBy:mt,onAutosizeColumn:ze,onAutosizeAllColumns:$e,onResetColumns:He,columnOrder:Re,onColumnOrderChange:Ee,paginationMode:A?.enabled?A.mode:null})})()})}),f.jsx("div",{style:{minWidth:`${vr+(m?g:0)}px`,height:Tt?kt.length*ge+"px":"auto"},children:O||0!==kt.length?f.jsx("div",{style:{transform:`translateY(${Tt?Ft.offsetY:0}px)`,willChange:"transform",contain:"content"},children:(()=>{const e=[];let t=[];const a=()=>{if(!t.length)return;const r=`chunk-${t[0]?.id}-${t.length}-${Ft.offsetY}`;e.push(f.jsx("div",{style:{opacity:O?.5:1},children:f.jsx(Gt,{data:t,columns:tr,selectedRows:jt,virtualized:!1,virtualizedRange:{startIndex:0,endIndex:t.length-1,offsetY:0},rowHeight:ge,selectable:m,isRowSelectable:h,onRowSelect:Nt,pinnedColumns:wt,hvPadLeft:nr,hvPadRight:ar,rowStyle:N,globalFilter:xe,onContextMenu:C,onRowDoubleClick:S,onRowClick:M,onCellClick:D,onCellContextMenu:R,isCellFocused:pr,isCellSelected:gr,onCellMouseDown:yr,onCellMouseEnter:br,getRowId:n})},r)),t=[]};for(const n of At)if(n._isGroupHeader)a(),e.push(f.jsx(Qt,{row:n,isExpanded:ut.expanded.has(n._groupKey||""),onToggle:pt,viewportWidth:Z,selectable:m,rowHeight:ge,getHeaderLabel:e=>r.find(t=>t.key===e)?.header||e,getValueLabel:(e,t)=>{const n=r.find(t=>t.key===e);if(n?.formatter)try{return n.formatter(t)}catch(e){return String(t??"")}return String(t??"")},renderGroupActions:Q},n.id));else if(n._isGroupFooter)if(a(),"chips"===q){const t=Kt.filter(e=>!!e.aggregate&&n._groupAgg&&void 0!==n._groupAgg[e.key]).map(e=>{const t=n._groupAgg[e.key],r=e.aggregateFormatter||e.formatter,a=r?(()=>{try{return r(t)}catch{return String(t)}})():String(t);return f.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(f.jsx("div",{className:"sticky left-0 z-1",style:{minWidth:`${vr+(m?g:0)}px`,height:`${ge}px`},children:f.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:[f.jsx("div",{className:"flex items-center gap-2 flex-wrap overflow-hidden",children:t.length?t:f.jsx("span",{className:"text-xs text-gray-500",children:"No aggregates"})}),f.jsx("span",{className:"text-[10px] uppercase tracking-wide text-blue-700 dark:text-blue-300",children:"Group Summary"})]})},n.id))}else e.push(f.jsx("div",{className:"sticky left-0 z-1 bg-blue-100 dark:bg-gray-900",style:{minWidth:`${vr+(m?g:0)}px`,height:`${ge}px`},children:f.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:[m&&f.jsx("div",{style:{width:g},className:"shrink-0"}),Kt.map(e=>{const t=e.width||100,r=n._groupAgg?n._groupAgg[e.key]:void 0,a=e.aggregateFormatter||e.formatter,o=void 0===r?"":a?(()=>{try{return a(r)}catch{return r}})():r;let s;if("number"==typeof o)s=Number.isInteger(o)?String(o):o.toFixed(2);else if(isNaN(o)||""===o||null===o)s=String(o??"");else{const e=Number(o);s=Number.isInteger(e)?String(e):e.toFixed(2)}return f.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:s?`${e.header}: ${s}`:void 0,children:f.jsx("span",{className:"truncate w-full",children:s})},`agg-cell-${n._groupKey}-${e.key}`)})]})},n.id));else t.push(n);return a(),e})()}):f.jsx(f.Fragment,{})})]}),nt&&f.jsx("div",{className:"pointer-events-none absolute left-0 right-0 h-1 bg-gray-200 overflow-hidden z-30 "+(ot?"opacity-0 transition-opacity duration-200":"opacity-100"),style:{top:lt},children:f.jsx("div",{className:"h-full w-1/3 bg-blue-500 animate-[slide_1.2s_linear_infinite]"})}),!O&&0===kt.length&&f.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 flex items-center justify-center",children:f.jsx("div",{className:"pointer-events-auto",children:f.jsx(Ut,{hasFilters:!!xe||Object.keys(ye).length>0,hasData:t.length>0})})})]}),or&&f.jsx("div",{ref:We,className:"shrink-0 overflow-x-hidden overflow-y-visible [&::-webkit-scrollbar]:hidden",style:{scrollbarWidth:"none",msOverflowStyle:"none"},onWheel:xr,children:f.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700",style:{minWidth:`${vr+(m?g:0)}px`,height:`${ge}px`},children:f.jsx(p,{columns:Kt,data:ir,selectable:m,rowHeight:ge,pinnedColumns:wt})})}),f.jsx(Jt,{paginationConfig:Xe,currentPage:Xe.currentPage,isServerLoading:Ue,selectedRowsCount:jt.size,totalDataLength:t.length,filteredDataLength:"server"===A?.mode?void 0:be.length,paginationMode:A.mode,onPageChange:Je,onPageSizeChange:Ze}),ue&&f.jsx("div",{className:"fixed z-50 pointer-events-none select-none",style:{top:ue.y+12,left:ue.x+12},children:f.jsxs("div",{className:"px-2 py-1 rounded bg-gray-800 text-white text-xs shadow-lg opacity-90",children:[ue.rows," × ",ue.cols]})})]})});exports.FooterAggregate=p,exports.GridHeader=qt,exports.GridRows=Gt,exports.KDGrid=ra,exports.PaginationControls=Jt,exports.SearchToolbar=Kn,exports.useAdvancedFiltering=qn,exports.usePagination=Un,exports.useSelection=Zn,exports.useVirtualization=ea;
|
|
1
|
+
"use strict";var e=require("react"),t=require("react-dom");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var n,l=r(e),o=r(t),s={exports:{}},a={};function i(){if(n)return a;n=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(t,r,n){var l=null;if(void 0!==n&&(l=""+n),void 0!==r.key&&(l=""+r.key),"key"in r)for(var o in n={},r)"key"!==o&&(n[o]=r[o]);else n=r;return{$$typeof:e,type:t,key:l,ref:void 0!==(r=n.ref)?r:null,props:n}}return a.Fragment=t,a.jsx=r,a.jsxs=r,a}var c,u,d={};function m(){return c||(c=1,"production"!==process.env.NODE_ENV&&function(){function t(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===S?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case h:return"Fragment";case p:return"Profiler";case x:return"StrictMode";case w:return"Suspense";case j:return"SuspenseList";case C:return"Activity"}if("object"==typeof e)switch("number"==typeof e.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case g:return"Portal";case b:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case v:var r=e.render;return(e=e.displayName)||(e=""!==(e=r.displayName||r.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case k:return null!==(r=e.displayName||null)?r:t(e.type)||"Memo";case N:r=e._payload,e=e._init;try{return t(e(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 l(e){if(e===h)return"<>";if("object"==typeof e&&null!==e&&e.$$typeof===N)return"<...>";try{var r=t(e);return r?"<"+r+">":"<...>"}catch(e){return"<...>"}}function o(){return Error("react-stack-top-frame")}function s(){var e=t(this.type);return A[e]||(A[e]=!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!==(e=this.props.ref)?e:null}function a(e,r,l,o,a,c){var d,m=r.children;if(void 0!==m)if(o)if(E(m)){for(o=0;o<m.length;o++)i(m[o]);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(R.call(r,"key")){m=t(e);var g=Object.keys(r).filter(function(e){return"key"!==e});o=0<g.length?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}",z[m+o]||(g=0<g.length?"{"+g.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} />',o,m,g,m),z[m+o]=!0)}if(m=null,void 0!==l&&(n(l),m=""+l),function(e){if(R.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 h in l={},r)"key"!==h&&(l[h]=r[h]);else l=r;return m&&function(e,t){function r(){u||(u=!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})}(l,"function"==typeof e?e.displayName||e.name||"Unknown":e),function(e,t,r,n,l,o){var a=r.ref;return e={$$typeof:f,type:e,key:t,props:r,_owner:n},Object.defineProperty(e,"ref",null!==(void 0!==a?a:null)?{enumerable:!1,get:s}:{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:l}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:o}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(e,m,l,null===(d=M.A)?null:d.getOwner(),a,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===f}var u,m=e,f=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),b=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),M=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=Object.prototype.hasOwnProperty,E=Array.isArray,D=console.createTask?console.createTask:function(){return null},A={},L=(m={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(m,o)(),F=D(l(o)),z={};d.Fragment=h,d.jsx=function(e,t,r){var n=1e4>M.recentlyCreatedOwnerStacks++;return a(e,t,r,!1,n?Error("react-stack-top-frame"):L,n?D(l(e)):F)},d.jsxs=function(e,t,r){var n=1e4>M.recentlyCreatedOwnerStacks++;return a(e,t,r,!0,n?Error("react-stack-top-frame"):L,n?D(l(e)):F)}}()),d}function f(){return u||(u=1,s.exports="production"===process.env.NODE_ENV?i():m()),s.exports}var g=f();const h=48,x=e.memo(({columns:t,data:r,selectable:n,rowHeight:l,pinnedColumns:o=new Set})=>{const s=e.useMemo(()=>{const e={},n=t.filter(e=>e.footer_aggregate);return 0===n.length||n.forEach(t=>{const n=r.map(e=>e[t.key]);let l=null;if("function"==typeof t.footer_aggregate)try{l=t.footer_aggregate(n)}catch(e){console.warn(`Error computing custom footer aggregate for column ${t.key}:`,e),l=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))),o=n.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)),s=()=>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(t.footer_aggregate){case"count":l=r.length;break;case"sum":o.length&&(l=o.reduce((e,t)=>e+t,0));break;case"avg":o.length&&(l=o.reduce((e,t)=>e+t,0)/o.length);break;case"min":if(o.length)l=Math.min(...o);else{const e=s();e.length&&(l=new Date(Math.min(...e)))}break;case"max":if(o.length)l=Math.max(...o);else{const e=s();e.length&&(l=new Date(Math.max(...e)))}break;default:l=null}}null!=l&&(e[t.key]=l)}),e},[t,r]);if(!t.some(e=>e.footer_aggregate))return null;const a=t.reduce((e,t)=>e+t.width,0),i=e.useMemo(()=>{const e=new Map,r=t.filter(e=>o.has(e.key)).map(e=>e.key);let l=n?h:0;for(const n of r)e.set(n,l),l+=t.find(e=>e.key===n)?.width||100;return e},[t,o,n]);return g.jsxs("div",{className:"flex h-full",style:{minWidth:`${a+(n?h:0)}px`,height:`${l}px`},children:[n&&g.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:`${l}px`},children:g.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Total"})},"select-footer-cell"),t.map(e=>{const t=e.width,r=s[e.key],n=e.footer_aggregate&&void 0!==r;let a="";if(n){const t=e.footerAggregateFormatter||e.formatter;if(t)try{a=t(r)}catch{a=String(r)}else a="number"==typeof r?r%1==0?r.toString():r.toFixed(2):String(r?.toFixed)}const c=o.has(e.key),u=c&&i.get(e.key)||0;return g.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?`${u}px`:"auto",height:`${l}px`},title:n?`${e.header}: ${a}`:void 0,children:n&&g.jsx("span",{className:"truncate w-full",children:a})},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],l=t.columns[r];if(n.key!==l.key||n.width!==l.width||n.footer_aggregate!==l.footer_aggregate)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,l=t.data.length>0?r(t.data[0],0,t.getRowId):void 0,o=e.data.length-1,s=t.data.length-1,a=e.data.length>0?r(e.data[o],o,e.getRowId):void 0,i=t.data.length>0?r(t.data[s],s,t.getRowId):void 0;return n===l&&a===i&&e.pinnedColumns?.size===t.pinnedColumns?.size}),p=({size:e=16,children:t,...r})=>g.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}),y=e=>g.jsx(p,{...e,children:g.jsx("polyline",{points:"15 18 9 12 15 6"})}),b=e=>g.jsx(p,{...e,children:g.jsx("polyline",{points:"9 18 15 12 9 6"})}),v=e=>g.jsx(p,{...e,children:g.jsx("polyline",{points:"6 9 12 15 18 9"})}),w=e=>g.jsxs(p,{...e,children:[g.jsx("polyline",{points:"11 17 6 12 11 7"}),g.jsx("polyline",{points:"18 17 13 12 18 7"})]}),j=e=>g.jsxs(p,{...e,children:[g.jsx("polyline",{points:"13 17 18 12 13 7"}),g.jsx("polyline",{points:"6 17 11 12 6 7"})]}),k=e=>g.jsxs(p,{...e,children:[g.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),g.jsx("polyline",{points:"5 12 12 5 19 12"})]}),N=e=>g.jsxs(p,{...e,children:[g.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g.jsx("polyline",{points:"19 12 12 19 5 12"})]}),C=e=>g.jsxs(p,{...e,children:[g.jsx("path",{d:"m21 16-4 4-4-4"}),g.jsx("path",{d:"M17 20V4"}),g.jsx("path",{d:"m3 8 4-4 4 4"}),g.jsx("path",{d:"M7 4v16"})]}),S=e=>g.jsxs(p,{...e,children:[g.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),g.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),M=e=>g.jsx(p,{...e,children:g.jsx("polyline",{points:"20 6 9 17 4 12"})}),R=e=>g.jsxs(p,{...e,children:[g.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),g.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),E=e=>g.jsxs(p,{...e,children:[g.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),g.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),D=e=>g.jsxs(p,{...e,children:[g.jsx("polyline",{points:"3 6 5 6 21 6"}),g.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),g.jsx("path",{d:"M10 11v6"}),g.jsx("path",{d:"M14 11v6"}),g.jsx("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),A=e=>g.jsxs(p,{...e,children:[g.jsx("polyline",{points:"21 8 21 21 3 21 3 8"}),g.jsx("rect",{x:"1",y:"3",width:"22",height:"5"}),g.jsx("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]}),L=e=>g.jsxs(p,{...e,children:[g.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),g.jsx("polyline",{points:"7 10 12 15 17 10"}),g.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),F=e=>g.jsxs(p,{...e,children:[g.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),g.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),g.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]}),z=e=>g.jsx(p,{...e,children:g.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),$=e=>g.jsxs(p,{...e,children:[g.jsx("path",{d:"M13.013 3H2l8 9.46V19l4 2v-6.54l.9-1.055"}),g.jsx("line",{x1:"22",y1:"3",x2:"11",y2:"14"})]}),I=e=>g.jsxs(p,{...e,children:[g.jsx("circle",{cx:"12",cy:"12",r:"3"}),g.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"})]}),T=e=>g.jsxs(p,{...e,children:[g.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),g.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"})]}),O=e=>g.jsxs(p,{...e,children:[g.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),g.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),g.jsx("path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h12"}),g.jsx("path",{d:"M15 9.34V6h1a2 2 0 0 0 0-4H7.89"})]}),P=e=>g.jsxs(p,{...e,children:[g.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),g.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),g.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),g.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),g.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1"})]}),_=e=>g.jsxs(p,{...e,children:[g.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),g.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),g.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),g.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),g.jsx("rect",{x:"7",y:"7",width:"4",height:"4",rx:"1"}),g.jsx("rect",{x:"13",y:"13",width:"4",height:"4",rx:"1"})]}),K=e=>g.jsxs(p,{...e,children:[g.jsx("circle",{cx:"12",cy:"12",r:"1"}),g.jsx("circle",{cx:"19",cy:"12",r:"1"}),g.jsx("circle",{cx:"5",cy:"12",r:"1"})]}),V=e=>g.jsxs(p,{...e,children:[g.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),g.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),B=e=>g.jsxs(p,{...e,children:[g.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"}),g.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"}),g.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),W=e=>g.jsxs(p,{...e,children:[g.jsx("circle",{cx:"11",cy:"11",r:"8"}),g.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),H=e=>g.jsxs(p,{...e,children:[g.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),g.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"}),g.jsx("path",{d:"M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3"})]}),G=e=>g.jsxs(p,{...e,children:[g.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),g.jsx("polyline",{points:"14 2 14 8 20 8"}),g.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),g.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),g.jsx("polyline",{points:"10 9 9 9 8 9"})]}),U=e=>g.jsxs(p,{...e,children:[g.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),g.jsx("path",{d:"M3 9h18"}),g.jsx("path",{d:"M3 15h18"}),g.jsx("path",{d:"M9 3v18"})]}),Y=e=>g.jsxs(p,{...e,children:[g.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),g.jsx("circle",{cx:"9",cy:"7",r:"4"}),g.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),g.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),q=e=>g.jsxs(p,{...e,children:[g.jsx("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),g.jsx("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),g.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),g.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),g.jsx("circle",{cx:"12",cy:"12",r:"4"}),g.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"})]}),X=e=>g.jsx(p,{...e,children:g.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),J=({value:t,onChange:r,placeholder:n="Enter text to filter..."})=>{const[l,o]=e.useState(t?.value||""),[s,a]=e.useState(t?.operator||"contains");return g.jsxs("div",{className:"space-y-3",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Filter Type"}),g.jsxs("select",{value:s,onChange:e=>(e=>{const t=e;a(t),l.trim()&&r({type:"text",value:l,operator:t})})(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",children:[g.jsx("option",{value:"contains",children:"Contains"}),g.jsx("option",{value:"equals",children:"Equals"}),g.jsx("option",{value:"startsWith",children:"Starts with"}),g.jsx("option",{value:"endsWith",children:"Ends with"})]})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Value"}),g.jsx("input",{type:"text",value:l,onChange:e=>{return o(t=e.target.value),void(t.trim()?r({type:"text",value:t,operator:s}):r(null));var t},placeholder: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"})]})]})},Z=({value:t,onChange:r,min:n,max:l})=>{const[o,s]=e.useState(t?.value||""),[a,i]=e.useState(t?.secondValue||""),[c,u]=e.useState(t?.operator||"equals"),d=(e,t=!1)=>{t?i(e):s(e);const n=parseFloat(e),l=parseFloat(a);"between"===c?isNaN(n)||isNaN(l)?r(null):r({type:"number",value:Math.min(n,l),secondValue:Math.max(n,l),operator:"between"}):isNaN(n)?r(null):r({type:"number",value:n,operator:c})};return g.jsxs("div",{className:"space-y-3",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Filter Type"}),g.jsxs("select",{value:c,onChange:e=>(e=>{const t=e;if(u(t),"between"===t){const e=parseFloat(o),t=parseFloat(a);isNaN(e)||isNaN(t)||r({type:"number",value:Math.min(e,t),secondValue:Math.max(e,t),operator:"between"})}else{const e=parseFloat(o);isNaN(e)||r({type:"number",value:e,operator:t})}})(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",children:[g.jsx("option",{value:"equals",children:"Equals"}),g.jsx("option",{value:"gt",children:"Greater than"}),g.jsx("option",{value:"gte",children:"Greater than or equal"}),g.jsx("option",{value:"lt",children:"Less than"}),g.jsx("option",{value:"lte",children:"Less than or equal"}),g.jsx("option",{value:"between",children:"Between"})]})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"between"===c?"From Value":"Number Value"}),g.jsx("input",{type:"number",value:o,onChange:e=>d(e.target.value),min:n,max:l,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),"between"===c&&g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"To Value"}),g.jsx("input",{type:"number",value:a,onChange:e=>d(e.target.value,!0),min:n,max:l,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]})]})},Q=({name:e,label:t,value:r,onChange:n,className:l=""})=>g.jsxs("div",{className:`space-y-1 ${l}`,children:[t&&g.jsx("label",{className:"text-sm font-medium text-gray-700",children:t}),g.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"})]}),ee=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,te=e=>{const[t,r,n]=e.split("-").map(Number);return t&&r&&n?new Date(t,r-1,n):new Date(NaN)},re=e=>`${String(e.getDate()).padStart(2,"0")}-${String(e.getMonth()+1).padStart(2,"0")}-${e.getFullYear()}`,ne=({value:t,onChange:r,min:n,max:l})=>{const o=e=>{if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;try{const t=te(String(e));return isNaN(t.getTime())?null:t}catch(t){const r=new Date(e);return isNaN(r.getTime())?null:r}},s=e=>e?ee(e):"",[a,i]=e.useState(o(t?.value)),[c,u]=e.useState("between"===t?.operator?o(t?.secondValue??t?.value):null),[d,m]=e.useState(t?.operator||"between");e.useEffect(()=>{m(t?.operator||"between"),i(o(t?.value)),u("between"===t?.operator?o(t?.secondValue??t?.value):null)},[t?.value,t?.secondValue,t?.operator]),e.useEffect(()=>{"between"===d&&!c&&a&&u(a)},[d,a,c]);const f=(e,t,r)=>e?t&&e<t||r&&e>r?null:e:null,h=(e,t=!1)=>{const n=t?a:e,l=t?e:c,o="between"===d&&c?c:p,m=t?f(e,a??x??void 0,p):f(e,x,o);if(t?u(m):i(m),"between"===d)if(n&&l){const e=n>=l?n:l;r({type:"date",value:s(n<=l?n:l),secondValue:s(e),operator:"between"})}else r(null);else r(m?{type:"date",value:s(m),operator:d}:null)},x=e.useMemo(()=>n?new Date(n):void 0,[n]),p=e.useMemo(()=>l?new Date(l):void 0,[l]);return g.jsxs("div",{className:"space-y-3",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Filter Type"}),g.jsxs("select",{value:d,onChange:e=>(e=>{const t=e;m(t),"between"===t?a&&c&&r({type:"date",value:a<=c?a:c,secondValue:a>=c?a:c,operator:"between"}):a&&r({type:"date",value:a,operator:t})})(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",children:[g.jsx("option",{value:"equals",children:"On Date"}),g.jsx("option",{value:"gt",children:"After"}),g.jsx("option",{value:"gte",children:"On or After"}),g.jsx("option",{value:"lt",children:"Before"}),g.jsx("option",{value:"lte",children:"On or Before"}),g.jsx("option",{value:"between",children:"Between Dates"})]})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"between"===d?"From Date":"Date"}),g.jsx(Q,{name:"date_filter_start",value:a?ee(a):null,onChange:e=>h(e?te(e):null,!1),className:"w-full"})]}),"between"===d&&g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"To Date"}),g.jsx(Q,{name:"date_filter_end",value:c?ee(c):null,onChange:e=>h(e?te(e):null,!0),className:"w-full"})]})]})},le=({value:t,onChange:r,options:n,data:l,columnKey:o})=>{const[s,a]=e.useState(""),[i,c]=e.useState(new Set(t?.value||[]));e.useEffect(()=>{c(new Set(t?.value||[]))},[t]);const u=e.useMemo(()=>{let e=[];const t=e=>null==e||""===e||"string"==typeof e&&""===e.trim();if(n&&n.length>0)e=n;else{const r=l.map(e=>{const r=e[o];return t(r)?null:r});e=[...new Set(r)].map(e=>({label:null===e?"Blank":String(e),value:e}))}const r=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(r.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)))},[n,l,o]),d=e.useMemo(()=>{if(!s)return u;const e=s.toLowerCase();return u.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)||"blank"===e&&t.isBlank)},[u,s]);return g.jsxs("div",{className:"space-y-3",children:[g.jsxs("div",{className:"relative",children:[g.jsx(W,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),g.jsx("input",{type:"text",value:s,onChange:e=>a(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"})]}),g.jsxs("div",{className:"flex justify-between items-center text-sm",children:[g.jsxs("span",{className:"text-gray-600",children:[i.size," of ",u.length," selected"]}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx("button",{onClick:()=>{const e=new Set(d.map(e=>e.value));c(e),r({type:"multiselect",value:Array.from(e),operator:"equals"})},className:"text-blue-600 hover:text-blue-800 transition-colors",children:"Select All"}),g.jsx("button",{onClick:()=>{c(new Set),r(null)},className:"text-gray-600 hover:text-gray-800 transition-colors",children:"Clear All"})]})]}),g.jsx("div",{className:"max-h-48 overflow-y-auto border border-gray-200 rounded-md",children:0===d.length?g.jsx("div",{className:"p-3 text-sm text-gray-500 text-center",children:"No options found"}):d.map((e,t)=>{const n=i.has(e.value);return g.jsxs("div",{onClick:()=>(e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t),r(t.size>0?{type:"multiselect",value:Array.from(t),operator:"equals"}:null)})(e.value),className:"flex items-center gap-3 p-2 cursor-pointer hover:bg-gray-50 transition-colors "+(n?"bg-blue-50":""),children:[g.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"),children:n&&g.jsx(M,{className:"w-3 h-3"})}),g.jsx("span",{className:`text-sm ${n?"text-blue-900 font-medium":"text-gray-700"} ${e.isBlank?"italic text-gray-500":""}`,children:e.label})]},t)})})]})},oe=({value:t,onChange:r})=>{const[n,l]=e.useState(void 0!==t?.value?String(t.value):"");return g.jsx("div",{className:"space-y-3",children:g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Boolean Value"}),g.jsxs("select",{value:n,onChange:e=>{return l(t=e.target.value),void r(""===t?null:{type:"boolean",value:"true"===t,operator:"equals"});var t},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[g.jsx("option",{value:"",children:"All values"}),g.jsx("option",{value:"true",children:"True"}),g.jsx("option",{value:"false",children:"False"})]})]})})},se=({column:t,data:r,value:n,onChange:l})=>{const o=e.useMemo(()=>{if("object"==typeof t.filterable)return t.filterable;const e=r.slice(0,100).map(e=>e[t.key]).filter(e=>null!=e);if(0===e.length)return{type:"text"};const n=e[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 l=[...new Set(e)];return l.length<=20?{type:"multiselect",options:l.map(e=>({label:String(e),value:e}))}:{type:"text"}},[t.filterable,t.key,r]);switch(o.type){case"text":return g.jsx(J,{value:n,onChange:l,placeholder:o.placeholder});case"number":return g.jsx(Z,{value:n,onChange:l,min:o.min,max:o.max});case"date":return g.jsx(ne,{value:n,onChange:l,min:o.min,max:o.max});case"multiselect":return g.jsx(le,{value:n,onChange:l,options:o.options||[],data:r,columnKey:t.key});case"boolean":return g.jsx(oe,{value:n,onChange:l});default:return null}},ae=({pinnedColumns:t,unpinnedColumns:r,hvPadLeft:n=0,hvPadRight:l=0,headerHeight:o,sortConfig:s,columnFilters:a,selectable:i,selectedRows:c,totalRows:u,data:d,onSort:m,onColumnFilter:f,onSelectAll:x,onColumnResize:p,pinnedKeySet:y=new Set,onColumnPin:b,groupable:v=!1,groupedByColumn:w,onGroupBy:j,groupedByColumns:S=[],onGroupToggle:M,onAutosizeColumn:R,onAutosizeAllColumns:E,onResetColumns:D,columnOrder:A,onColumnOrderChange:L,paginationMode:I="client"})=>{const K=e.useMemo(()=>[...t,...r],[t,r]),[V,B]=e.useState(null),[W,H]=e.useState(null),[G,U]=e.useState(null),[Y,q]=e.useState(0),[X,J]=e.useState(0),[Z,Q]=e.useState("menu"),[ee,te]=e.useState(null),[re,ne]=e.useState(!1);e.useEffect(()=>{ne("ontouchstart"in window||navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches)},[]);const[le,oe]=e.useState(null),[ae,ie]=e.useState(null),ce=c.size===u&&u>0,ue=c.size>0&&c.size<u,de=(e,t)=>{if(t.stopPropagation(),V===e)B(null);else{B(e),Q("menu"),te(a[e]||null);const r=t.currentTarget.getBoundingClientRect(),n=t.currentTarget.closest("[data-grid-container]"),l=n?n.getBoundingClientRect():new DOMRect(0,0,window.innerWidth,window.innerHeight),o=10,s=Math.max(l.left+o,Math.min(r.left,l.right-320-o));H({top:r.bottom+4,left:s,containerRect:l})}},me=e=>{f(e,ee||null),B(null)},fe=e=>null!=a[e],ge=(e,n)=>{n.preventDefault(),U(e),q(n.clientX);const l=[...t,...r].find(t=>t.key===e);J(l?.width||100)},he=e=>{if(!G||!p)return;const t=Math.max(50,X+(e.clientX-Y));p(G,t)},xe=()=>{U(null),q(0),J(0)},[pe,ye]=e.useState(null),[be,ve]=e.useState(null),we=(e,t)=>{ye(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},je=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();ve({key:e,position:t.clientX<r.left+r.width/2?"before":"after"})},ke=e=>{const t=pe;if(!t||t===e)return;if(y.has(t)!==y.has(e))return ye(null),void ve(null);const r=be?.key!==e||"before"===be?.position,n=A.filter(e=>e!==t);let l=n.indexOf(e);if(-1===l)return L(n),ye(null),void ve(null);r||(l+=1),n.splice(l,0,t),L(n),ye(null),ve(null)},Ne=()=>{ye(null),ve(null)},Ce=(e,t)=>{oe(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},Se=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();ie({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})},Me=e=>{const t=le;if(!t||t===e)return;if(y.has(t)!==y.has(e))return oe(null),void ie(null);const r=ae?.key!==e||"before"===ae?.position,n=A.filter(e=>e!==t);let l=n.indexOf(e);if(-1===l)return L(n),oe(null),void ie(null);r||(l+=1),n.splice(l,0,t),L(n),oe(null),ie(null)},Re=()=>{oe(null),ie(null)};return e.useEffect(()=>{if(G)return document.addEventListener("mousemove",he),document.addEventListener("mouseup",xe),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",xe),document.body.style.cursor="",document.body.style.userSelect=""}},[G,Y,X,p]),e.useEffect(()=>{const e=e=>{V&&!e.target.closest("[data-column-menu]")&&B(null)};if(V)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[V]),g.jsx(g.Fragment,{children:g.jsx("div",{className:"bg-blue-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",style:{height:o},role:"row","aria-label":"Column headers",children:g.jsxs("div",{className:"flex h-full",children:[i&&g.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:h,height:o},role:"columnheader","aria-label":"Select all rows",children:g.jsx("input",{type:"checkbox",checked:ce,ref:e=>{e&&(e.indeterminate=ue)},onChange:x,onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),x())},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","aria-label":ce?"Deselect all rows":ue?`${c.size} rows selected. Click to select all`:"Select all rows",title:ce?`Deselect all ${u} rows`:ue?`${c.size} of ${u} rows selected`:`Select all ${u} rows`})}),t.map((e,r)=>{const n=y.has(e.key),l=t.filter(e=>y.has(e.key)).map(e=>e.key),a=l.indexOf(e.key),c=n?l.slice(0,a).reduce((e,r)=>{const n=t.find(e=>e.key===r);return e+(n?.width||100)},i?h:0):0,u="center"===e.headerAlign?"justify-center":"right"===e.headerAlign?"justify-end":"justify-start",x=!1!==e.sortable;return g.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:e.width||100,left:n?`${c}px`:"auto",height:o},"data-column-key":e.key,draggable:!0,onDragStart:t=>we(e.key,t),onDragOver:t=>je(e.key,t),onDrop:()=>ke(e.key),onDragEnd:Ne,children:[be?.key===e.key&&g.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===be?.position?0:void 0,right:"after"===be?.position?0:void 0}}),g.jsx("div",{className:"px-3 h-full",children:g.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[g.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${u} ${x?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>x&&m(e.key),children:[g.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[fe(e.key)&&g.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),g.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",children:e.header})]}),x&&s.key===e.key&&g.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:g.jsx("asc"===s.direction?k:N,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(e.filterable||b||v)&&g.jsxs("div",{className:"relative "+(V===e.key||re?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[g.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:t=>de(e.key,t),"data-menu-trigger":!0,children:g.jsx(F,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),V===e.key&&W&&g.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:`${W.top}px`,left:`${W.left}px`,maxHeight:`${Math.max(160,W.containerRect.bottom-12-W.top)}px`},"data-column-menu":!0,children:[g.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[g.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===Z?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Q("menu"),children:g.jsx(F,{className:"w-4 h-4"})}),e.filterable&&g.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===Z?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Q("filter"),children:g.jsx(z,{className:"w-4 h-4"})}),g.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===Z?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Q("reorder"),children:g.jsx(C,{className:"w-4 h-4"})})]}),"menu"===Z&&g.jsxs("div",{className:"py-1",children:[b&&(w===e.key?g.jsxs("div",{className:"w-full px-3 py-2 text-left text-sm flex items-center gap-2 text-blue-600",children:[g.jsx(T,{className:"w-4 h-4"}),"Pinned by grouping"]}):g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2",onClick:t=>{t.stopPropagation(),B(null),b?.(e.key,!y.has(e.key))},children:y.has(e.key)?g.jsxs(g.Fragment,{children:[g.jsx(O,{className:"w-4 h-4"}),"Unpin Column"]}):g.jsxs(g.Fragment,{children:[g.jsx(T,{className:"w-4 h-4"}),"Pin Column"]})})),R&&g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{R?.(e.key),B(null)},children:"Autosize This Column"}),E&&g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{E?.(),B(null)},children:"Autosize All Columns"}),v&&g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2",onClick:t=>{t.stopPropagation(),B(null);const r=S?.includes(e.key)||w===e.key;M?M(e.key,!r):j?.(r?null:e.key)},children:w===e.key||S?.includes(e.key)?g.jsxs(g.Fragment,{children:[g.jsx(_,{className:"w-4 h-4"}),"Ungroup"]}):g.jsxs(g.Fragment,{children:[g.jsx(P,{className:"w-4 h-4"}),"Group by ",e.header]})}),D&&g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{D?.(),B(null)},children:"Reset Columns"})]}),"filter"===Z&&g.jsxs("div",{className:"p-3 w-full",children:[fe(e.key)&&g.jsxs("button",{className:"mb-2 text-xs text-red-600 hover:underline flex items-center gap-1",onClick:()=>{te(null),f(e.key,null),B(null)},children:[g.jsx($,{className:"w-3 h-3"})," Clear Filter"]}),g.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:g.jsx(se,{column:e,data:d,value:ee,onChange:t=>{te(t),"server"!==I&&f(e.key,t)}})}),"server"===I?g.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[g.jsx("button",{className:"px-3 py-1.5 text-sm bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200",onClick:()=>B(null),children:"Cancel"}),g.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>me(e.key),children:"Apply"})]}):g.jsx("div",{className:"flex justify-end mt-3",children:g.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>B(null),children:"Close"})})]}),"reorder"===Z&&g.jsxs("div",{className:"px-3 py-2",children:[g.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:"Reorder Columns"}),g.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md",children:[...A.map(e=>K.find(t=>t.key===e)).filter(Boolean),...K.filter(e=>!A.includes(e.key))].map(e=>{const t=y.has(e.key);return g.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b last:border-b-0 relative ${le===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""}`,draggable:!0,onDragStart:t=>Ce(e.key,t),onDragOver:t=>Se(e.key,t),onDrop:()=>Me(e.key),onDragEnd:Re,children:[ae?.key===e.key&&g.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===ae?.position?0:void 0,bottom:"after"===ae?.position?0:void 0}}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-gray-400 select-none",children:"⋮⋮"}),g.jsxs("span",{className:"text-gray-800 truncate max-w-45",children:[e.header,t&&g.jsx("span",{className:"ml-1 text-[10px] text-blue-600",children:"(pinned)"})]})]})]},e.key)})}),g.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<t.length-1&&p&&g.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:t=>ge(e.key,t),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),R?.(e.key)},title:"Drag to resize • Double‑click to autosize",children:g.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},e.key+r)}),n>0&&g.jsx("div",{style:{width:n,height:o},className:"flex-none"}),r.map((e,t)=>{const n="center"===e.headerAlign?"justify-center":"right"===e.headerAlign?"justify-end":"justify-start",l=!1!==e.sortable;return g.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:o},"data-column-key":e.key,draggable:!0,onDragStart:t=>we(e.key,t),onDragOver:t=>je(e.key,t),onDrop:()=>ke(e.key),onDragEnd:Ne,children:[be?.key===e.key&&g.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===be?.position?0:void 0,right:"after"===be?.position?0:void 0}}),g.jsx("div",{className:"px-3 h-full",children:g.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[g.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${n} ${l?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>l&&m(e.key),children:[g.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[fe(e.key)&&g.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),g.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",children:e.header})]}),l&&s.key===e.key&&g.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:g.jsx("asc"===s.direction?k:N,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(e.filterable||b||v)&&g.jsxs("div",{className:"relative "+(V===e.key||re?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[g.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:t=>de(e.key,t),"data-menu-trigger":!0,children:g.jsx(F,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),V===e.key&&W&&g.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:`${W.top}px`,left:`${W.left}px`,maxHeight:`${Math.max(160,W.containerRect.bottom-12-W.top)}px`},"data-column-menu":!0,children:[g.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[g.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===Z?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Q("menu"),children:g.jsx(F,{className:"w-4 h-4"})}),e.filterable&&g.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===Z?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Q("filter"),children:g.jsx(z,{className:"w-4 h-4"})}),g.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===Z?"border-b-2 border-blue-600 text-blue-600":"text-gray-600"),onClick:()=>Q("reorder"),children:g.jsx(C,{className:"w-4 h-4"})})]}),"menu"===Z&&g.jsxs("div",{className:"py-1",children:[b&&g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2",onClick:t=>{t.stopPropagation(),B(null);const r=!y.has(e.key);b?.(e.key,r)},children:y.has(e.key)?g.jsxs(g.Fragment,{children:[g.jsx(O,{className:"w-4 h-4"}),"Unpin Column"]}):g.jsxs(g.Fragment,{children:[g.jsx(T,{className:"w-4 h-4"}),"Pin Column"]})}),R&&g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{R?.(e.key),B(null)},children:"Autosize This Column"}),E&&g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{E?.(),B(null)},children:"Autosize All Columns"}),v&&g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2",onClick:t=>{t.stopPropagation(),B(null);const r=S?.includes(e.key)||w===e.key;M?M(e.key,!r):j?.(r?null:e.key)},children:w===e.key||S?.includes(e.key)?g.jsxs(g.Fragment,{children:[g.jsx(_,{className:"w-4 h-4"}),"Ungroup"]}):g.jsxs(g.Fragment,{children:[g.jsx(P,{className:"w-4 h-4"}),"Group by ",e.header]})}),D&&g.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50",onClick:()=>{D?.(),B(null)},children:"Reset Columns"})]}),"filter"===Z&&g.jsxs("div",{className:"p-3 w-full",children:[g.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:g.jsx(se,{column:e,data:d,value:ee,onChange:t=>{te(t),"server"!==I&&f(e.key,t)}})}),g.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[fe(e.key)&&g.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:()=>{te(null),f(e.key,null),B(null)},children:[g.jsx($,{className:"w-3 h-3"})," Clear Filter"]}),g.jsx("button",{className:"px-3 py-1.5 text-sm bg-green-100 text-green-700 rounded-md hover:bg-green-200 cursor-pointer",onClick:()=>B(null),children:"Apply"}),"server"===I&&g.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>me(e.key),children:"Apply"})]})]}),"reorder"===Z&&g.jsxs("div",{className:"px-3 py-2",children:[g.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:"Reorder Columns"}),g.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md",children:[...A.map(e=>K.find(t=>t.key===e)).filter(Boolean),...K.filter(e=>!A.includes(e.key))].map(e=>{const t=y.has(e.key);return g.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b last:border-b-0 relative ${le===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""}`,draggable:!0,onDragStart:t=>Ce(e.key,t),onDragOver:t=>Se(e.key,t),onDrop:()=>Me(e.key),onDragEnd:Re,children:[ae?.key===e.key&&g.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===ae?.position?0:void 0,bottom:"after"===ae?.position?0:void 0}}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-gray-400 select-none",children:"⋮⋮"}),g.jsxs("span",{className:"text-gray-800 truncate max-w-45",children:[e.header,t&&g.jsx("span",{className:"ml-1 text-[10px] text-blue-600",children:"(pinned)"})]})]})]},e.key)})}),g.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),t<r.length-1&&p&&g.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:t=>ge(e.key,t),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),R?.(e.key)},title:"Drag to resize • Double‑click to autosize",children:g.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},e.key+t)}),l>0&&g.jsx("div",{style:{width:l,height:o},className:"flex-none"})]})})})};ae.displayName="GridHeader";const ie=e.memo(ae),ce=({data:t,columns:r,selectedRows:n,virtualized:l,virtualizedRange:o,rowHeight:s,selectable:a,isRowSelectable:i,onRowSelect:c,pinnedColumns:u=new Set,hvPadLeft:d=0,hvPadRight:m=0,rowStyle:f,globalFilter:x,onContextMenu:p,onRowDoubleClick:y,onRowClick:b,onCellClick:v,isCellFocused:w,isCellSelected:j,onCellContextMenu:k,onCellMouseDown:N,onCellMouseEnter:C,getRowId:S})=>{const M=e.useMemo(()=>t.length*s,[t.length,s]),{leftOffsetByPinnedKey:R}=e.useMemo(()=>{if(0===u.size)return{leftOffsetByPinnedKey:new Map};const e=r.filter(e=>u.has(e.key)).map(e=>e.key),t=new Map;for(const e of r)t.set(e.key,e.width||100);const n=new Map;let l=a?h:0;for(const r of e)n.set(r,l),l+=t.get(r)||100;return{leftOffsetByPinnedKey:n}},[r,u,a]),E=e.useMemo(()=>r.reduce((e,t)=>e+(u.has(t.key)?1:0),0),[r,u]);return g.jsx("div",{style:{height:l?`${M}px`:"auto",position:"relative"},children:g.jsx("div",{style:{transform:l?`translate3d(0, ${o.offsetY}px, 0)`:"none",position:l?"absolute":"static",top:0,left:0,right:0},children:t.map((e,t)=>{const M=l?o.startIndex+t:t,D=f?.(e),A=((e,t)=>S?S(e):void 0!==e.id?e.id:("development"===process.env.NODE_ENV&&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,M),L=M%2==0?"bg-white dark:bg-gray-900":"bg-gray-25 dark:bg-gray-800",F=n.has(A)?"bg-blue-50 dark:bg-blue-900/20":"";return g.jsxs("div",{className:`flex border-b border-gray-100 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 ${F||(D?"":L)}`,style:{height:`${s}px`,...D},onContextMenu:t=>((e,t)=>{e.preventDefault(),p?.(t,e)})(t,e),onDoubleClick:t=>((e,t)=>{y?.(t,e)})(t,e),onClick:t=>((e,t)=>{b?.(t,e)})(t,e),children:[a&&g.jsx("div",{className:"flex items-center justify-center sticky left-0 bg-white dark:bg-gray-900 z-2 border-r border-gray-200 dark:border-gray-700",style:{width:h},children:g.jsx("input",{type:"checkbox",checked:n.has(A),disabled:!!i&&!i(e),onChange:e=>c(A,e.target.checked),onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),c(A,!n.has(A)))},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","aria-label":`Select row ${A}`,tabIndex:0})}),r.map((t,r)=>{const n=u.has(t.key),l=n&&R.get(t.key)||0,o=e[t.key];let s,a;if(t.cellRenderer?(s=t.cellRenderer(o,e),"string"!=typeof o&&"number"!=typeof o&&"boolean"!=typeof o||(a=String(o))):t.formatter?(s=t.formatter(o),a=String(s)):(s=o??"",a=s?String(s):void 0),x&&x.trim()&&!t.cellRenderer&&s){const e=String(s);((e,t)=>{if(!t||null==e)return!1;const r=t.toLowerCase().trim();return!!r&&String(e).toLowerCase().includes(r)})(e,x)&&(s=((e,t)=>{if(!t||!e)return e;const r=t.toLowerCase().trim(),n=e.toLowerCase();if(!r||!n.includes(r))return e;const l=[];let o=0,s=0,a=0;for(;-1!==(s=n.indexOf(r,o));)s>o&&l.push(e.slice(o,s)),l.push(g.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(s,s+r.length)},"highlight-"+a++)),o=s+r.length;return o<e.length&&l.push(e.slice(o)),g.jsx(g.Fragment,{children:l})})(e,x))}a&&0===a.trim().length&&(a=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",m=t.noPadding?"p-0":"p-3",f="function"==typeof t.className?t.className(o,e):t.className||"",h="function"==typeof t.cellStyle?t.cellStyle(o,e):t.cellStyle||void 0,p=g.jsxs("div",{className:`border-r border-gray-200 last:border-r-0 ${m} text-sm flex items-center ${j?.(A,t.key)?"bg-blue-100/60 dark:bg-blue-900/30":""} ${n?w?.(A,t.key)?"sticky z-2 bg-inherit":"sticky z-1 bg-inherit":""} ${w?.(A,t.key)?"relative":""} ${i} ${c} ${f}`,style:{width:`${t.width||100}px`,left:n?`${l}px`:"auto",...h},title:a,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||k&&(r.preventDefault(),r.stopPropagation(),k({row:e,column:t,value:e[t.key],displayValue:a??"",event:r}))},onMouseDown:r=>N?.({row:e,column:t,event:r}),onMouseEnter:r=>C?.({row:e,column:t,event:r}),children:[w?.(A,t.key)&&g.jsx("div",{className:"pointer-events-none absolute inset-0 border border-blue-400"}),!1===t.wrapCellContent?g.jsx(g.Fragment,{children:s}):g.jsx("div",{className:"truncate w-full",children:s})]},`${t.key}-${r}`);return d>0&&r===E?g.jsxs(g.Fragment,{children:[g.jsx("div",{style:{width:d},className:"flex-none"}),p]}):p}),m>0&&g.jsx("div",{style:{width:m},className:"flex-none"})]},`${A}-${M}`)})})})},ue=(e,t)=>{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.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};ce.displayName="GridRows";const de=e.memo(ce,ue),me=({columns:t,groupedKeys:r,onRemove:n,onReorder:l,onDropColumnKey:o,onToggleExpandAll:s,isAnyExpanded:a=!1})=>{const[i,c]=e.useState(null),[u,d]=e.useState(null),[m,f]=e.useState(!0),h=e=>t.find(t=>t.key===e)?.header||e,x=e=>t=>{c(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-group-key",e)},p=e=>t=>{t.preventDefault();const r=t.currentTarget.getBoundingClientRect(),n=t.clientX<r.left+r.width/2;d(e),f(n)};return g.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-gray-50 border-b border-gray-200 text-sm",onDrop:e=>{e.preventDefault();const t=e.dataTransfer.getData("text/plain");t&&(r.includes(t)||o(t))},onDragOver:e=>{e.preventDefault()},onDragEnd:()=>{c(null),d(null)},children:[g.jsx("span",{className:"text-gray-600 whitespace-nowrap",children:"Group by:"}),r.length>0&&g.jsx("button",{type:"button",className:"ml-1 px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100",title:a?"Collapse all groups":"Expand all groups",onClick:e=>{e.preventDefault(),e.stopPropagation(),s?.()},children:a?"Collapse All":"Expand All"}),0===r.length&&g.jsx("span",{className:"text-gray-400",children:"Drag a column here"}),g.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:r.map(e=>{return g.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",draggable:!0,onDragStart:x(e),onDragOver:p(e),onDrop:(t=e,()=>{if(!i||i===t)return c(null),void d(null);const e=r.filter(e=>e!==i),n=e.indexOf(t);-1!==n&&(e.splice(m?n:n+1,0,i),l(e),c(null),d(null))}),title:h(e),children:[g.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:h(e)}),g.jsx("button",{className:"text-blue-700 hover:text-blue-900",onClick:()=>n(e),"aria-label":`Remove grouping ${h(e)}`,children:"×"}),u===e&&g.jsx("span",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 dark:bg-blue-400 animate-pulse",style:{left:m?0:void 0,right:m?void 0:0},"aria-hidden":"true"})]},e);var t})})]})},fe=e.memo(({row:e,isExpanded:t,onToggle:r,viewportWidth:n,selectable:l,rowHeight:o=40,getHeaderLabel:s,getValueLabel:a,renderGroupActions:i})=>{const c=()=>{e._groupKey&&r(e._groupKey)};return g.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+(l?h:0)}px`,height:`${o}px`},onClick:c,role:"button",tabIndex:0,"aria-expanded":t,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),c())},children:[l&&g.jsx("div",{className:"w-12 flex items-center justify-center"}),g.jsxs("div",{className:"flex items-center px-4 py-2 flex-1",children:[g.jsx("div",{className:"flex items-center mr-3",style:{paddingLeft:(e._groupLevel?16*e._groupLevel:0)+"px"},children:g.jsx(t?v:b,{className:"w-4 h-4 text-gray-600"})}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs("span",{className:"font-medium text-gray-900",children:[e._groupColumnKey?`${s?s(e._groupColumnKey):e._groupColumnKey}: `:"",a&&e._groupColumnKey?a(e._groupColumnKey,e._groupValue):e._groupValue??(e._groupKey||"Unknown")]}),g.jsxs("span",{className:"text-sm text-gray-600 bg-gray-200/70 px-2 py-1 rounded-full",children:[e._groupCount," ",1===e._groupCount?"item":"items"]})]}),i&&g.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})})]})]})}),ge=({hasFilters:e=!1,hasData:t=!0,message:r})=>{const{title:n,description:l,icon:o}=r?{title:r,description:"",icon:H}:t?e?{title:"No Results Found",description:"No data matches your current search criteria. Try adjusting your filters.",icon:W}:{title:"No Data to Display",description:"There are no items to show at the moment.",icon:H}:{title:"No Data Available",description:"There is no data to display in this table.",icon:H};return g.jsxs("div",{className:"flex flex-col items-center justify-center pt-16 pb-10 px-4 text-center",children:[g.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center mb-4",children:g.jsx(o,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),g.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:n}),g.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-md",children:l})]})},he=({paginationConfig:e,currentPage:t,isServerLoading:r,selectedRowsCount:n,totalDataLength:l,filteredDataLength:o,paginationMode:s="client",onPageChange:a,onPageSizeChange:i})=>{const{start:c,end:u,total:d}=(()=>{const r=e.enabled||"server"===s?e.totalRows||l:o||l;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}})(),m="client"===s&&o&&o!==l;return g.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:g.jsxs("div",{className:"flex flex-col xl:flex-row gap-4 xl:gap-6 xl:justify-between xl:items-center",children:[g.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4 items-start sm:items-center",children:[g.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[!e.enabled&&g.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:[g.jsx(H,{className:"w-3 h-3"}),g.jsxs("span",{className:"font-bold",children:[d.toLocaleString()," ",1===d?"Record":"Records"]}),m&&g.jsxs("span",{className:"text-blue-100 font-normal",children:["(of ",l.toLocaleString(),")"]})]}),n>0&&g.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-primary to-primary text-white shadow-lg ring-2 ring-primary/20",children:[g.jsx(Y,{className:"w-3 h-3"}),g.jsxs("span",{children:[n.toLocaleString()," selected"]})]}),m&&g.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-warning/20",children:[g.jsx(V,{className:"w-3 h-3"}),g.jsx("span",{children:"Filtered"})]}),e.enabled&&g.jsx("div",{className:"hidden sm:block text-sm text-gray-600 dark:text-gray-400 font-medium",children:g.jsxs("span",{className:"inline-flex items-center gap-1",children:[g.jsx("span",{children:"Showing"}),g.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()}),g.jsx("span",{children:"-"}),g.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:u.toLocaleString()}),g.jsxs("span",{children:["of ",d.toLocaleString()]})]})})]}),e.enabled&&e.showPageSizeSelector&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 whitespace-nowrap",children:"Rows per page:"}),g.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=>g.jsx("option",{value:e,children:e},e))})]})]}),e.enabled&&g.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4",children:[r&&g.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:[g.jsx(X,{className:"w-4 h-4 animate-spin text-primary"}),g.jsx("span",{className:"text-sm font-medium text-primary",children:"Loading..."})]}),g.jsx("div",{className:"sm:hidden text-sm text-gray-600 dark:text-gray-400 font-medium",children:g.jsxs("div",{className:"flex flex-col gap-1",children:[g.jsxs("span",{className:"inline-flex items-center gap-1",children:[g.jsx("span",{children:"Page"}),g.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()}),g.jsx("span",{children:"of"}),g.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()})]}),g.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-500",children:[c.toLocaleString()," - ",u.toLocaleString()," of"," ",d.toLocaleString()]})]})}),g.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[g.jsx("button",{onClick:()=>a(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:g.jsx(w,{className:"w-3.5 h-3.5"})}),g.jsx("button",{onClick:()=>a(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:g.jsx(y,{className:"w-3.5 h-3.5"})}),g.jsx("div",{className:"sm:hidden",children:g.jsx("select",{value:t,onChange:t=>a(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=>g.jsx("option",{value:e,children:e},e))})}),g.jsx("div",{className:"hidden sm:flex items-center gap-1 mx-2",children:(()=>{const n=[],l=e.totalPages,o=t,s="undefined"!=typeof window&&window.innerWidth>=768?7:5;if(l<=s)for(let e=1;e<=l;e++)n.push(e);else{const e=Math.floor(s/2)-1;if(o<=e+1){for(let e=1;e<=s-2;e++)n.push(e);n.push("ellipsis1"),n.push(l)}else if(o>=l-e){n.push(1),n.push("ellipsis1");for(let e=l-(s-3);e<=l;e++)n.push(e)}else{n.push(1),n.push("ellipsis1");for(let t=o-e;t<=o+e;t++)n.push(t);n.push("ellipsis2"),n.push(l)}}return n.map(t=>{if("string"==typeof t)return g.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:g.jsx("span",{className:"text-lg leading-none",children:"⋯"})},t);const n=t===o;return g.jsx("button",{onClick:()=>a(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":"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)})})()}),g.jsx("button",{onClick:()=>a(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:g.jsx(b,{className:"w-3.5 h-3.5"})}),g.jsx("button",{onClick:()=>a(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:g.jsx(j,{className:"w-3.5 h-3.5"})})]})]})]})})};he.displayName="PaginationControls";const xe=e.memo(he),pe=({options:t,value:r,placeholder:n="Select an option...",onChange:l,searchable:o=!0,className:s=""})=>{const[a,i]=e.useState(!1),[c,u]=e.useState(""),[d,m]=e.useState(-1),f=e.useRef(null),h=e.useRef(null),x=e.useRef(null),p=t.find(e=>e.value===r),y=o?t.filter(e=>e.label?.toLowerCase()?.includes(c?.toLowerCase())):t;e.useEffect(()=>{const e=e=>{f.current&&!f.current.contains(e.target)&&(i(!1),u(""),m(-1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),e.useEffect(()=>{const e=e=>{if(a)switch(e.key){case"ArrowDown":e.preventDefault(),m(e=>e<y.length-1?e+1:0);break;case"ArrowUp":e.preventDefault(),m(e=>e>0?e-1:y.length-1);break;case"Enter":e.preventDefault(),d>=0&&y[d]&&b(y[d].value);break;case"Escape":i(!1),u(""),m(-1)}};if(a)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a,d,y]),e.useEffect(()=>{if(d>=0&&x.current){const e=x.current.children[d];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}},[d]);const b=e=>{l(e),i(!1),u(""),m(-1)};return g.jsxs("div",{className:`relative ${s}`,ref:f,children:[g.jsx("div",{className:"relative w-full cursor-pointer border border-gray-300 rounded-lg bg-white transition-all duration-200 "+(a?"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"),onClick:()=>{i(!a),o&&!a&&setTimeout(()=>h.current?.focus(),0)},children:g.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5",children:[o&&a?g.jsx("input",{ref:h,type:"text",className:"flex-1 outline-none text-sm bg-transparent",placeholder:`Search ${n?.toLowerCase()}...`,value:c,onChange:e=>{u(e.target.value),m(-1),a||i(!0)},onClick:e=>e.stopPropagation()}):g.jsx("span",{className:"flex-1 text-sm truncate "+(p?"text-gray-900":"text-gray-500"),children:p?p.label:n}),g.jsx(v,{className:"w-4 h-4 text-gray-400 transition-transform duration-200 "+(a?"rotate-180":"")})]})}),a&&g.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",children:y.length>0?g.jsx("ul",{ref:x,className:"py-1 overflow-y-auto max-h-80",children:y.map((e,t)=>g.jsxs("li",{className:"px-3 py-2 text-sm cursor-pointer flex items-center justify-between transition-colors "+(t===d?"bg-blue-50 text-blue-700":"text-gray-700 hover:bg-gray-50"),onClick:()=>b(e.value),onMouseEnter:()=>m(t),children:[g.jsx("span",{className:"truncate",children:e.label}),p?.value===e.value&&g.jsx(M,{className:"w-4 h-4 text-blue-600 shrink-0 ml-2"})]},e.value))}):g.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:"No options found"})})]})},ye=({columns:t,columnFilters:r,onColumnFilter:n})=>{const l=t.filter(e=>e.filterable),[o,s]=e.useState(l.length>0?l[0].key:""),[a,i]=e.useState(""),c=l.map(e=>({label:e.header,value:e.key})),u=l.find(e=>e.key===o);return e.useEffect(()=>{i("")},[o]),g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Select Column to Filter"}),g.jsx(pe,{options:c,value:o,placeholder:"Choose a column...",onChange:e=>{s(e)},searchable:!0})]}),o&&(()=>{if(!u)return null;const e=u.filterable?.type||"text",t=r[o];if("multiselect"===e&&u.filterable?.options){const e=a.toLowerCase(),r=e?u.filterable.options.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)):u.filterable.options;return g.jsxs("div",{className:"mt-3",children:[g.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:["Filter by ",u.header]}),g.jsxs("div",{className:"relative mb-2",children:[g.jsx(W,{className:"w-4 h-4 text-gray-400 absolute left-2 top-1/2 -translate-y-1/2"}),g.jsx("input",{type:"text",value:a,onChange:e=>i(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"}),a&&g.jsx("button",{type:"button",onClick:()=>i(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear search",children:g.jsx(S,{className:"w-3 h-3"})})]}),g.jsxs("div",{className:"max-h-32 overflow-y-auto border border-gray-300 rounded-md p-2 bg-white",children:[0===r.length&&g.jsx("div",{className:"text-xs text-gray-500 px-1 py-1",children:"No matches"}),r.map(e=>{const r=t?.value||[],l=Array.isArray(r)&&r.includes(e.value);return g.jsxs("label",{className:"flex items-center gap-2 py-1 hover:bg-gray-50 cursor-pointer",children:[g.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500",checked:l,onChange:r=>{const l=t?.value||[];let s;s=r.target.checked?[...l,e.value]:l.filter(t=>t!==e.value),n?.(o,s.length>0?{type:"multiselect",value:s,operator:"in"}:null)}}),g.jsx("span",{className:"text-sm",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 g.jsxs("div",{className:"mt-3",children:[g.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:["Filter by ",u.header]}),g.jsx(pe,{options:e,value:t?.value||"",placeholder:`Select ${u.header.toLowerCase()}...`,onChange:e=>{n?.(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=te(String(e));if(!isNaN(t.getTime()))return t;const r=new Date(e);return isNaN(r.getTime())?null:r},r=e(t?.value),l=e(t?.secondValue),s=t?.operator||"between";return g.jsxs("div",{className:"mt-3",children:[g.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:["Filter by ",u.header]}),g.jsx("div",{className:"mb-3",children:g.jsx(pe,{options:[{label:"Between Dates",value:"between"},{label:"On Date",value:"equals"}],value:s,placeholder:"Select date filter...",onChange:e=>{n?.(o,{type:"date",value:t?.value||"",operator:e,secondValue:t?.secondValue||""})},searchable:!1},`date-operator-${o}-${s}`)}),g.jsxs("div",{className:"flex items-end gap-2",children:[g.jsx("div",{className:"flex-1 min-w-37.5",children:g.jsx(Q,{name:"column_filter_start",label:"between"===s?"Start Date":"Date",value:r?ee(r):null,onChange:e=>{if(e){const r=ee(te(e));n?.(o,{type:"date",value:r,operator:s,secondValue:t?.secondValue||null})}else n?.(o,null)},className:"w-full"})}),"between"===s&&g.jsx("div",{className:"flex-1 min-w-37.5",children:g.jsx(Q,{name:"column_filter_end",label:"End Date",value:l?ee(l):null,onChange:e=>{if(e&&t){const r=ee(te(e));n?.(o,{...t,secondValue:r})}},className:"w-full"})})]})]})}return g.jsxs("div",{className:"mt-3",children:[g.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:["Filter by ",u.header]}),g.jsxs(g.Fragment,{children:[g.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",value:t?.value||"",onChange:e=>{n?.(o,e.target.value?{type:"text",value:e.target.value,operator:"contains"}:null)}}),t&&g.jsx("div",{className:"mt-2",children:g.jsx(pe,{options:[{label:"Contains",value:"contains"},{label:"Equals",value:"equals"},{label:"Starts with",value:"startsWith"},{label:"Ends with",value:"endsWith"}],value:t?.operator||"contains",placeholder:"Select operator...",onChange:e=>{t&&n?.(o,{...t,operator:e})},searchable:!1})})]})]})})(),Object.keys(r).length>0&&g.jsxs("div",{className:"mt-4",children:[g.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Active Filters"}),g.jsx("div",{className:"space-y-2",children:Object.entries(r).map(([e,t])=>{const r=l.find(t=>t.key===e);return r?g.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",role:"button",title:`Edit filter for ${r.header}`,onClick:()=>(e=>{s(e)})(e),children:[g.jsxs("div",{className:"flex-1",children:[g.jsxs("span",{className:"text-sm font-medium text-blue-900",children:[r.header,":"]}),g.jsx("span",{className:"text-sm text-blue-700 ml-1",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 re(e);if("string"==typeof e){const t=te(e);if(!isNaN(t.getTime()))return re(t);const r=new Date(e);if(!isNaN(r.getTime()))return re(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})()})]}),g.jsx("button",{onClick:t=>{t.stopPropagation(),n?.(e,null)},className:"text-blue-400 hover:text-red-500 transition-colors",title:"Clear filter",children:g.jsx(S,{className:"w-4 h-4"})})]},e):null})})]})]})};function be(){return"undefined"!=typeof window}function ve(e){return ke(e)?(e.nodeName||"").toLowerCase():"#document"}function we(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function je(e){var t;return null==(t=(ke(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function ke(e){return!!be()&&(e instanceof Node||e instanceof we(e).Node)}function Ne(e){return!!be()&&(e instanceof Element||e instanceof we(e).Element)}function Ce(e){return!!be()&&(e instanceof HTMLElement||e instanceof we(e).HTMLElement)}function Se(e){return!(!be()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof we(e).ShadowRoot)}const Me=new Set(["inline","contents"]);function Re(e){const{overflow:t,overflowX:r,overflowY:n,display:l}=_e(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!Me.has(l)}const Ee=new Set(["table","td","th"]);function De(e){return Ee.has(ve(e))}const Ae=[":popover-open",":modal"];function Le(e){return Ae.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const Fe=["transform","translate","scale","rotate","perspective"],ze=["transform","translate","scale","rotate","perspective","filter"],$e=["paint","layout","strict","content"];function Ie(e){const t=Te(),r=Ne(e)?_e(e):e;return Fe.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||ze.some(e=>(r.willChange||"").includes(e))||$e.some(e=>(r.contain||"").includes(e))}function Te(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Oe=new Set(["html","body","#document"]);function Pe(e){return Oe.has(ve(e))}function _e(e){return we(e).getComputedStyle(e)}function Ke(e){return Ne(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ve(e){if("html"===ve(e))return e;const t=e.assignedSlot||e.parentNode||Se(e)&&e.host||je(e);return Se(t)?t.host:t}function Be(e){const t=Ve(e);return Pe(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ce(t)&&Re(t)?t:Be(t)}function We(e,t,r){var n;void 0===t&&(t=[]),void 0===r&&(r=!0);const l=Be(e),o=l===(null==(n=e.ownerDocument)?void 0:n.body),s=we(l);if(o){const e=He(s);return t.concat(s,s.visualViewport||[],Re(l)?l:[],e&&r?We(e):[])}return t.concat(l,We(l,[],r))}function He(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const Ge=Math.min,Ue=Math.max,Ye=Math.round,qe=Math.floor,Xe=e=>({x:e,y:e}),Je={left:"right",right:"left",bottom:"top",top:"bottom"},Ze={start:"end",end:"start"};function Qe(e,t,r){return Ue(e,Ge(t,r))}function et(e,t){return"function"==typeof e?e(t):e}function tt(e){return e.split("-")[0]}function rt(e){return e.split("-")[1]}function nt(e){return"x"===e?"y":"x"}function lt(e){return"y"===e?"height":"width"}const ot=new Set(["top","bottom"]);function st(e){return ot.has(tt(e))?"y":"x"}function at(e){return nt(st(e))}function it(e){return e.replace(/start|end/g,e=>Ze[e])}const ct=["left","right"],ut=["right","left"],dt=["top","bottom"],mt=["bottom","top"];function ft(e){return e.replace(/left|right|bottom|top/g,e=>Je[e])}function gt(e){const{x:t,y:r,width:n,height:l}=e;return{width:n,height:l,top:r,left:t,right:t+n,bottom:r+l,x:t,y:r}}var ht="undefined"!=typeof document?e.useLayoutEffect:function(){};const xt={...l}.useInsertionEffect||(e=>e());function pt(e,t,r){let{reference:n,floating:l}=e;const o=st(t),s=at(t),a=lt(s),i=tt(t),c="y"===o,u=n.x+n.width/2-l.width/2,d=n.y+n.height/2-l.height/2,m=n[a]/2-l[a]/2;let f;switch(i){case"top":f={x:u,y:n.y-l.height};break;case"bottom":f={x:u,y:n.y+n.height};break;case"right":f={x:n.x+n.width,y:d};break;case"left":f={x:n.x-l.width,y:d};break;default:f={x:n.x,y:n.y}}switch(rt(t)){case"start":f[s]-=m*(r&&c?-1:1);break;case"end":f[s]+=m*(r&&c?-1:1)}return f}async function yt(e,t){var r;void 0===t&&(t={});const{x:n,y:l,platform:o,rects:s,elements:a,strategy:i}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:m=!1,padding:f=0}=et(t,e),g=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}}(f),h=a[m?"floating"===d?"reference":"floating":d],x=gt(await o.getClippingRect({element:null==(r=await(null==o.isElement?void 0:o.isElement(h)))||r?h:h.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:i})),p="floating"===d?{x:n,y:l,width:s.floating.width,height:s.floating.height}:s.reference,y=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),b=await(null==o.isElement?void 0:o.isElement(y))&&await(null==o.getScale?void 0:o.getScale(y))||{x:1,y:1},v=gt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:p,offsetParent:y,strategy:i}):p);return{top:(x.top-v.top+g.top)/b.y,bottom:(v.bottom-x.bottom+g.bottom)/b.y,left:(x.left-v.left+g.left)/b.x,right:(v.right-x.right+g.right)/b.x}}const bt=new Set(["left","top"]);function vt(e){const t=_e(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const l=Ce(e),o=l?e.offsetWidth:r,s=l?e.offsetHeight:n,a=Ye(r)!==o||Ye(n)!==s;return a&&(r=o,n=s),{width:r,height:n,$:a}}function wt(e){return Ne(e)?e:e.contextElement}function jt(e){const t=wt(e);if(!Ce(t))return Xe(1);const r=t.getBoundingClientRect(),{width:n,height:l,$:o}=vt(t);let s=(o?Ye(r.width):r.width)/n,a=(o?Ye(r.height):r.height)/l;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const kt=Xe(0);function Nt(e){const t=we(e);return Te()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:kt}function Ct(e,t,r,n){void 0===t&&(t=!1),void 0===r&&(r=!1);const l=e.getBoundingClientRect(),o=wt(e);let s=Xe(1);t&&(n?Ne(n)&&(s=jt(n)):s=jt(e));const a=function(e,t,r){return void 0===t&&(t=!1),!(!r||t&&r!==we(e))&&t}(o,r,n)?Nt(o):Xe(0);let i=(l.left+a.x)/s.x,c=(l.top+a.y)/s.y,u=l.width/s.x,d=l.height/s.y;if(o){const e=we(o),t=n&&Ne(n)?we(n):n;let r=e,l=He(r);for(;l&&n&&t!==r;){const e=jt(l),t=l.getBoundingClientRect(),n=_e(l),o=t.left+(l.clientLeft+parseFloat(n.paddingLeft))*e.x,s=t.top+(l.clientTop+parseFloat(n.paddingTop))*e.y;i*=e.x,c*=e.y,u*=e.x,d*=e.y,i+=o,c+=s,r=we(l),l=He(r)}}return gt({width:u,height:d,x:i,y:c})}function St(e,t){const r=Ke(e).scrollLeft;return t?t.left+r:Ct(je(e)).left+r}function Mt(e,t){const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-St(e,r),y:r.top+t.scrollTop}}const Rt=new Set(["absolute","fixed"]);function Et(e,t,r){let n;if("viewport"===t)n=function(e,t){const r=we(e),n=je(e),l=r.visualViewport;let o=n.clientWidth,s=n.clientHeight,a=0,i=0;if(l){o=l.width,s=l.height;const e=Te();(!e||e&&"fixed"===t)&&(a=l.offsetLeft,i=l.offsetTop)}const c=St(n);if(c<=0){const e=n.ownerDocument,t=e.body,r=getComputedStyle(t),l="CSS1Compat"===e.compatMode&&parseFloat(r.marginLeft)+parseFloat(r.marginRight)||0,s=Math.abs(n.clientWidth-t.clientWidth-l);s<=25&&(o-=s)}else c<=25&&(o+=c);return{width:o,height:s,x:a,y:i}}(e,r);else if("document"===t)n=function(e){const t=je(e),r=Ke(e),n=e.ownerDocument.body,l=Ue(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),o=Ue(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-r.scrollLeft+St(e);const a=-r.scrollTop;return"rtl"===_e(n).direction&&(s+=Ue(t.clientWidth,n.clientWidth)-l),{width:l,height:o,x:s,y:a}}(je(e));else if(Ne(t))n=function(e,t){const r=Ct(e,!0,"fixed"===t),n=r.top+e.clientTop,l=r.left+e.clientLeft,o=Ce(e)?jt(e):Xe(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:l*o.x,y:n*o.y}}(t,r);else{const r=Nt(e);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return gt(n)}function Dt(e,t){const r=Ve(e);return!(r===t||!Ne(r)||Pe(r))&&("fixed"===_e(r).position||Dt(r,t))}function At(e,t,r){const n=Ce(t),l=je(t),o="fixed"===r,s=Ct(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const i=Xe(0);function c(){i.x=St(l)}if(n||!n&&!o)if(("body"!==ve(t)||Re(l))&&(a=Ke(t)),n){const e=Ct(t,!0,o,t);i.x=e.x+t.clientLeft,i.y=e.y+t.clientTop}else l&&c();o&&!n&&l&&c();const u=!l||n||o?Xe(0):Mt(l,a);return{x:s.left+a.scrollLeft-i.x-u.x,y:s.top+a.scrollTop-i.y-u.y,width:s.width,height:s.height}}function Lt(e){return"static"===_e(e).position}function Ft(e,t){if(!Ce(e)||"fixed"===_e(e).position)return null;if(t)return t(e);let r=e.offsetParent;return je(e)===r&&(r=r.ownerDocument.body),r}function zt(e,t){const r=we(e);if(Le(e))return r;if(!Ce(e)){let t=Ve(e);for(;t&&!Pe(t);){if(Ne(t)&&!Lt(t))return t;t=Ve(t)}return r}let n=Ft(e,t);for(;n&&De(n)&&Lt(n);)n=Ft(n,t);return n&&Pe(n)&&Lt(n)&&!Ie(n)?r:n||function(e){let t=Ve(e);for(;Ce(t)&&!Pe(t);){if(Ie(t))return t;if(Le(t))return null;t=Ve(t)}return null}(e)||r}const $t={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:r,offsetParent:n,strategy:l}=e;const o="fixed"===l,s=je(n),a=!!t&&Le(t.floating);if(n===s||a&&o)return r;let i={scrollLeft:0,scrollTop:0},c=Xe(1);const u=Xe(0),d=Ce(n);if((d||!d&&!o)&&(("body"!==ve(n)||Re(s))&&(i=Ke(n)),Ce(n))){const e=Ct(n);c=jt(n),u.x=e.x+n.clientLeft,u.y=e.y+n.clientTop}const m=!s||d||o?Xe(0):Mt(s,i);return{width:r.width*c.x,height:r.height*c.y,x:r.x*c.x-i.scrollLeft*c.x+u.x+m.x,y:r.y*c.y-i.scrollTop*c.y+u.y+m.y}},getDocumentElement:je,getClippingRect:function(e){let{element:t,boundary:r,rootBoundary:n,strategy:l}=e;const o=[..."clippingAncestors"===r?Le(t)?[]:function(e,t){const r=t.get(e);if(r)return r;let n=We(e,[],!1).filter(e=>Ne(e)&&"body"!==ve(e)),l=null;const o="fixed"===_e(e).position;let s=o?Ve(e):e;for(;Ne(s)&&!Pe(s);){const t=_e(s),r=Ie(s);r||"fixed"!==t.position||(l=null),(o?!r&&!l:!r&&"static"===t.position&&l&&Rt.has(l.position)||Re(s)&&!r&&Dt(e,s))?n=n.filter(e=>e!==s):l=t,s=Ve(s)}return t.set(e,n),n}(t,this._c):[].concat(r),n],s=o.reduce((e,r)=>{const n=Et(t,r,l);return e.top=Ue(n.top,e.top),e.right=Ge(n.right,e.right),e.bottom=Ge(n.bottom,e.bottom),e.left=Ue(n.left,e.left),e},Et(t,o[0],l));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},getOffsetParent:zt,getElementRects:async function(e){const t=this.getOffsetParent||zt,r=this.getDimensions,n=await r(e.floating);return{reference:At(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}=vt(e);return{width:t,height:r}},getScale:jt,isElement:Ne,isRTL:function(e){return"rtl"===_e(e).direction}};function It(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Tt(e,t,r,n){void 0===n&&(n={});const{ancestorScroll:l=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:i=!1}=n,c=wt(e),u=l||o?[...c?We(c):[],...We(t)]:[];u.forEach(e=>{l&&e.addEventListener("scroll",r,{passive:!0}),o&&e.addEventListener("resize",r)});const d=c&&a?function(e,t){let r,n=null;const l=je(e);function o(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return function s(a,i){void 0===a&&(a=!1),void 0===i&&(i=1),o();const c=e.getBoundingClientRect(),{left:u,top:d,width:m,height:f}=c;if(a||t(),!m||!f)return;const g={rootMargin:-qe(d)+"px "+-qe(l.clientWidth-(u+m))+"px "+-qe(l.clientHeight-(d+f))+"px "+-qe(u)+"px",threshold:Ue(0,Ge(1,i))||1};let h=!0;function x(t){const n=t[0].intersectionRatio;if(n!==i){if(!h)return s();n?s(!1,n):r=setTimeout(()=>{s(!1,1e-7)},1e3)}1!==n||It(c,e.getBoundingClientRect())||s(),h=!1}try{n=new IntersectionObserver(x,{...g,root:l.ownerDocument})}catch(e){n=new IntersectionObserver(x,g)}n.observe(e)}(!0),o}(c,r):null;let m,f=-1,g=null;s&&(g=new ResizeObserver(e=>{let[n]=e;n&&n.target===c&&g&&(g.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;null==(e=g)||e.observe(t)})),r()}),c&&!i&&g.observe(c),g.observe(t));let h=i?Ct(e):null;return i&&function t(){const n=Ct(e);h&&!It(h,n)&&r(),h=n,m=requestAnimationFrame(t)}(),r(),()=>{var e;u.forEach(e=>{l&&e.removeEventListener("scroll",r),o&&e.removeEventListener("resize",r)}),null==d||d(),null==(e=g)||e.disconnect(),g=null,i&&cancelAnimationFrame(m)}}const Ot=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:l,y:o,placement:s,middlewareData:a}=t,i=await async function(e,t){const{placement:r,platform:n,elements:l}=e,o=await(null==n.isRTL?void 0:n.isRTL(l.floating)),s=tt(r),a=rt(r),i="y"===st(r),c=bt.has(s)?-1:1,u=o&&i?-1:1,d=et(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:g}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&"number"==typeof g&&(f="end"===a?-1*g:g),i?{x:f*u,y:m*c}:{x:m*c,y:f*u}}(t,e);return s===(null==(r=a.offset)?void 0:r.placement)&&null!=(n=a.arrow)&&n.alignmentOffset?{}:{x:l+i.x,y:o+i.y,data:{...i,placement:s}}}}},Pt=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:l,platform:o}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:i={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...c}=et(e,t),u={x:r,y:n},d=await o.detectOverflow(t,c),m=st(tt(l)),f=nt(m);let g=u[f],h=u[m];s&&(g=Qe(g+d["y"===f?"top":"left"],g,g-d["y"===f?"bottom":"right"])),a&&(h=Qe(h+d["y"===m?"top":"left"],h,h-d["y"===m?"bottom":"right"]));const x=i.fn({...t,[f]:g,[m]:h});return{...x,data:{x:x.x-r,y:x.y-n,enabled:{[f]:s,[m]:a}}}}}},_t=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:l,middlewareData:o,rects:s,initialPlacement:a,platform:i,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...x}=et(e,t);if(null!=(r=o.arrow)&&r.alignmentOffset)return{};const p=tt(l),y=st(a),b=tt(a)===a,v=await(null==i.isRTL?void 0:i.isRTL(c.floating)),w=m||(b||!h?[ft(a)]:function(e){const t=ft(e);return[it(e),t,it(t)]}(a)),j="none"!==g;!m&&j&&w.push(...function(e,t,r,n){const l=rt(e);let o=function(e,t,r){switch(e){case"top":case"bottom":return r?t?ut:ct:t?ct:ut;case"left":case"right":return t?dt:mt;default:return[]}}(tt(e),"start"===r,n);return l&&(o=o.map(e=>e+"-"+l),t&&(o=o.concat(o.map(it)))),o}(a,h,g,v));const k=[a,...w],N=await i.detectOverflow(t,x),C=[];let S=(null==(n=o.flip)?void 0:n.overflows)||[];if(u&&C.push(N[p]),d){const e=function(e,t,r){void 0===r&&(r=!1);const n=rt(e),l=at(e),o=lt(l);let s="x"===l?n===(r?"end":"start")?"right":"left":"start"===n?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=ft(s)),[s,ft(s)]}(l,s,v);C.push(N[e[0]],N[e[1]])}if(S=[...S,{placement:l,overflows:C}],!C.every(e=>e<=0)){var M,R;const e=((null==(M=o.flip)?void 0:M.index)||0)+1,t=k[e];if(t&&("alignment"!==d||y===st(t)||S.every(e=>st(e.placement)!==y||e.overflows[0]>0)))return{data:{index:e,overflows:S},reset:{placement:t}};let r=null==(R=S.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:R.placement;if(!r)switch(f){case"bestFit":{var E;const e=null==(E=S.filter(e=>{if(j){const t=st(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:E[0];e&&(r=e);break}case"initialPlacement":r=a}if(l!==r)return{reset:{placement:r}}}return{}}}},Kt=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:l,rects:o,platform:s,elements:a}=t,{apply:i=()=>{},...c}=et(e,t),u=await s.detectOverflow(t,c),d=tt(l),m=rt(l),f="y"===st(l),{width:g,height:h}=o.floating;let x,p;"top"===d||"bottom"===d?(x=d,p=m===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(p=d,x="end"===m?"top":"bottom");const y=h-u.top-u.bottom,b=g-u.left-u.right;let v=Ge(h-u[x],y),w=Ge(g-u[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&&!m){const e=Ue(u.left,0),t=Ue(u.right,0),r=Ue(u.top,0),n=Ue(u.bottom,0);f?w=g-2*(0!==e||0!==t?e+t:Ue(u.left,u.right)):v=h-2*(0!==r||0!==n?r+n:Ue(u.top,u.bottom))}await i({...t,availableWidth:w,availableHeight:v});const j=await s.getDimensions(a.floating);return g!==j.width||h!==j.height?{reset:{rects:!0}}:{}}}},Vt=(e,t,r)=>{const n=new Map,l={platform:$t,...r},o={...l.platform,_c:n};return(async(e,t,r)=>{const{placement:n="bottom",strategy:l="absolute",middleware:o=[],platform:s}=r,a=o.filter(Boolean),i=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:l}),{x:u,y:d}=pt(c,n,i),m=n,f={},g=0;for(let r=0;r<a.length;r++){var h;const{name:o,fn:x}=a[r],{x:p,y:y,data:b,reset:v}=await x({x:u,y:d,initialPlacement:n,placement:m,strategy:l,middlewareData:f,rects:c,platform:{...s,detectOverflow:null!=(h=s.detectOverflow)?h:yt},elements:{reference:e,floating:t}});u=null!=p?p:u,d=null!=y?y:d,f={...f,[o]:{...f[o],...b}},v&&g<=50&&(g++,"object"==typeof v&&(v.placement&&(m=v.placement),v.rects&&(c=!0===v.rects?await s.getElementRects({reference:e,floating:t,strategy:l}):v.rects),({x:u,y:d}=pt(c,m,i))),r=-1)}return{x:u,y:d,placement:m,strategy:l,middlewareData:f}})(e,t,{...l,platform:o})};var Bt="undefined"!=typeof document?e.useLayoutEffect:function(){};function Wt(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,l;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(!Wt(e[n],t[n]))return!1;return!0}if(l=Object.keys(e),r=l.length,r!==Object.keys(t).length)return!1;for(n=r;0!==n--;)if(!{}.hasOwnProperty.call(t,l[n]))return!1;for(n=r;0!==n--;){const r=l[n];if(!("_owner"===r&&e.$$typeof||Wt(e[r],t[r])))return!1}return!0}return e!=e&&t!=t}function Ht(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Gt(e,t){const r=Ht(e);return Math.round(t*r)/r}function Ut(e){const t=l.useRef(e);return Bt(()=>{t.current=e}),t}const Yt=(e,t)=>({...Ot(e),options:[e,t]}),qt=(e,t)=>({...Pt(e),options:[e,t]}),Xt=(e,t)=>({...Kt(e),options:[e,t]}),Jt={...l};let Zt=!1,Qt=0;const er=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Qt++,tr=Jt.useId||function(){const[e,t]=l.useState(()=>Zt?er():void 0);return ht(()=>{null==e&&t(er())},[]),l.useEffect(()=>{Zt=!0},[]),e};let rr;"production"!==process.env.NODE_ENV&&(rr=new Set);const nr=l.createContext(null),lr=l.createContext(null);function or(e){void 0===e&&(e={});const{nodeId:t}=e,r=function(e){const{open:t=!1,onOpenChange:r,elements:n}=e,o=tr(),s=l.useRef({}),[a]=l.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=l.useContext(nr))?void 0:c.id)||null);var c;if("production"!==process.env.NODE_ENV){const e=n.reference;e&&!Ne(e)&&function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];const l="Floating UI: "+r.join(" ");var o;null!=(e=rr)&&e.has(l)||(null==(o=rr)||o.add(l),console.error(l))}("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[u,d]=l.useState(n.reference),m=function(e){const t=l.useRef(()=>{if("production"!==process.env.NODE_ENV)throw new Error("Cannot call an event handler while rendering.")});return xt(()=>{t.current=e}),l.useCallback(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return null==t.current?void 0:t.current(...r)},[])}((e,t,n)=>{s.current.openEvent=e?t:void 0,a.emit("openchange",{open:e,event:t,reason:n,nested:i}),null==r||r(e,t,n)}),f=l.useMemo(()=>({setPositionReference:d}),[]),g=l.useMemo(()=>({reference:u||n.reference||null,floating:n.floating||null,domReference:n.reference}),[u,n.reference,n.floating]);return l.useMemo(()=>({dataRef:s,open:t,onOpenChange:m,elements:g,events:a,floatingId:o,refs:f}),[t,m,g,a,o,f])}({...e,elements:{reference:null,floating:null,...e.elements}}),n=e.rootContext||r,s=n.elements,[a,i]=l.useState(null),[c,u]=l.useState(null),d=(null==s?void 0:s.domReference)||a,m=l.useRef(null),f=l.useContext(lr);ht(()=>{d&&(m.current=d)},[d]);const g=function(e){void 0===e&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:s,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:u,open:d}=e,[m,f]=l.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[g,h]=l.useState(n);Wt(g,n)||h(n);const[x,p]=l.useState(null),[y,b]=l.useState(null),v=l.useCallback(e=>{e!==N.current&&(N.current=e,p(e))},[]),w=l.useCallback(e=>{e!==C.current&&(C.current=e,b(e))},[]),j=a||x,k=i||y,N=l.useRef(null),C=l.useRef(null),S=l.useRef(m),M=null!=u,R=Ut(u),E=Ut(s),D=Ut(d),A=l.useCallback(()=>{if(!N.current||!C.current)return;const e={placement:t,strategy:r,middleware:g};E.current&&(e.platform=E.current),Vt(N.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==D.current};L.current&&!Wt(S.current,t)&&(S.current=t,o.flushSync(()=>{f(t)}))})},[g,t,r,E,D]);Bt(()=>{!1===d&&S.current.isPositioned&&(S.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[d]);const L=l.useRef(!1);Bt(()=>(L.current=!0,()=>{L.current=!1}),[]),Bt(()=>{if(j&&(N.current=j),k&&(C.current=k),j&&k){if(R.current)return R.current(j,k,A);A()}},[j,k,A,R,M]);const F=l.useMemo(()=>({reference:N,floating:C,setReference:v,setFloating:w}),[v,w]),z=l.useMemo(()=>({reference:j,floating:k}),[j,k]),$=l.useMemo(()=>{const e={position:r,left:0,top:0};if(!z.floating)return e;const t=Gt(z.floating,m.x),n=Gt(z.floating,m.y);return c?{...e,transform:"translate("+t+"px, "+n+"px)",...Ht(z.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:t,top:n}},[r,c,z.floating,m.x,m.y]);return l.useMemo(()=>({...m,update:A,refs:F,elements:z,floatingStyles:$}),[m,A,F,z,$])}({...e,elements:{...s,...c&&{reference:c}}}),h=l.useCallback(e=>{const t=Ne(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),g.refs.setReference(t)},[g.refs]),x=l.useCallback(e=>{(Ne(e)||null===e)&&(m.current=e,i(e)),(Ne(g.refs.reference.current)||null===g.refs.reference.current||null!==e&&!Ne(e))&&g.refs.setReference(e)},[g.refs]),p=l.useMemo(()=>({...g.refs,setReference:x,setPositionReference:h,domReference:m}),[g.refs,x,h]),y=l.useMemo(()=>({...g.elements,domReference:d}),[g.elements,d]),b=l.useMemo(()=>({...g,...n,refs:p,elements:y,nodeId:t}),[g,p,y,t,n]);return ht(()=>{n.dataRef.current.floatingContext=b;const e=null==f?void 0:f.nodesRef.current.find(e=>e.id===t);e&&(e.context=b)}),l.useMemo(()=>({...g,context:b,refs:p,elements:y}),[g,p,y,b])}var sr=({open:r,anchorEl:n,onClose:l,placement:o="bottom-start",offset:s=8,sameWidth:a=!1,maxHeight:i,zIndex:c=1e3,className:u,children:d,shouldIgnoreClose:m})=>{const{refs:f,floatingStyles:h,update:x}=or({placement:o,whileElementsMounted:Tt,middleware:[Yt(s),(p={padding:8},{..._t(p),options:[p,void 0]}),qt({padding:8}),Xt({apply({rects:e,elements:t,availableHeight:r,availableWidth:n}){const l=t.floating;l&&(a&&(l.style.width=`${e.reference.width}px`),l.style.maxHeight=null!=i?"number"==typeof i?`${i}px`:String(i):`${r}px`,null!=n&&(l.style.maxWidth=`${n}px`))}})]});var p;return e.useEffect(()=>{n&&f.setReference(n),r&&x&&x()},[n,r,f,x]),e.useEffect(()=>{if(!r)return;const e=e=>{const t=e.target;if(m&&m(t))return;const r=f.floating.current;r&&(n&&n.contains(t)||r&&r.contains(t)||l())},t=e=>{"Escape"===e.key&&l()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r,l,f.floating,n]),r&&n?t.createPortal(g.jsx("div",{ref:f.setFloating,"data-popover-root":"true",style:{...h,zIndex:c,position:h.position,overflowX:"hidden"},className:u,children:d}),document.body):null};const ar=({globalFilter:t,filteredDataLength:r,selectedRowsCount:n=0,selectedRows:l=new Set,showExport:o=!0,showColumnToggle:s=!0,showBulkActions:a=!0,columns:i=[],columnVisibility:c={},columnFilters:u={},bulkActions:d=[],exportOptions:m,onGlobalFilterChange:f,onClearFilters:h,onColumnVisibilityChange:x,onColumnFilter:p,onResetColumns:y,columnOrder:b=[],onColumnOrderChange:v,pinnedColumns:w,onScrollToColumn:j,density:k="md",onDensityChange:N,showDensityControl:C=!1,customLeftContent:M,customRightContent:F})=>{const[$,T]=e.useState(!1),[O,P]=e.useState(!1),[_,Y]=e.useState(!1),[X,J]=e.useState(!1),[Z,Q]=e.useState(""),[ee,te]=e.useState(null),[re,ne]=e.useState(null),le=e.useRef(null),oe=e.useRef(null),se=e.useRef(null),ae=e.useRef(null),ie=e.useRef(null),ce=e.useRef(null),ue=e.useRef(null),de=e.useRef(null),me=e.useRef(null);e.useEffect(()=>{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)||(oe.current&&!oe.current.contains(e.target)&&T(!1),se.current&&!se.current.contains(e.target)&&Y(!1),ae.current&&!ae.current.contains(e.target)&&J(!1),!ie.current||ie.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)||P(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const fe=m?.formats||["xlsx"],ge=(t?.length??0)>0||Object.keys(u||{}).length>0,he=n>0,xe=i.filter(e=>!1!==c[e.key]).length,pe=[...b.map(e=>i.find(t=>t.key===e)).filter(Boolean),...i.filter(e=>!b.includes(e.key))].filter(e=>e.header?.toLowerCase()?.includes(Z?.toLowerCase())),be=e=>{switch(e){case"csv":return g.jsx(U,{size:18});case"json":return g.jsx(H,{size:18});case"xlsx":return g.jsx(G,{size:18});default:return g.jsx(L,{size:18})}},ve=e=>{switch(e){case"delete":return g.jsx(D,{size:18});case"archive":return g.jsx(A,{size:18});case"copy":return g.jsx(R,{size:18});case"edit":return g.jsx(E,{size:18});case"export":return g.jsx(L,{size:18});default:return g.jsx(K,{size:18})}},we=e=>{switch(e){case"csv":return"CSV";case"json":return"JSON";case"xlsx":return"Excel";default:return e}},je=(e,t=!1)=>{m?.onExport?.(e,t),T(!1)},ke=()=>{te(null),ne(null)},Ne=e.useMemo(()=>i.some(e=>e.filterable),[i]);return g.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:[g.jsxs("div",{id:"search-results-status",className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true",children:[ge?`Showing ${r} of ${r} rows`:`${r} total rows`,he&&`, ${n} row${1!==n?"s":""} selected`]}),g.jsx("div",{className:"px-3 py-2",children:g.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-4",children:[g.jsxs("div",{className:"order-1 flex items-center flex-wrap gap-2 sm:gap-3",children:[g.jsxs("div",{className:"relative",ref:ie,children:[Ne&&g.jsxs("button",{ref:e=>{ce.current=e},onClick:()=>P(!O),className:"flex cursor-pointer items-center gap-2 px-3 py-2 border rounded-lg transition-colors "+(O?"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":O,"aria-controls":"filters-menu","aria-keyshortcuts":"Control+K",children:[g.jsx(z,{className:"w-4 h-4"}),g.jsx("span",{className:"hidden sm:inline",children:"Filters"}),Object.keys(u).length>0&&g.jsxs("button",{type:"button",onClick:e=>{e.stopPropagation(),h?.()},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:[g.jsx("span",{className:"group-hover:hidden",children:Object.keys(u).length}),g.jsx(S,{className:"w-3 h-3 hidden group-hover:block absolute"})]})]}),g.jsxs(sr,{open:O,anchorEl:ce.current,onClose:()=>P(!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",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:[g.jsxs("div",{className:"flex items-center justify-between px-2",children:[g.jsxs("div",{className:"p-3 border-b border-gray-100",children:[g.jsx("h3",{className:"font-medium text-gray-900",children:"Column Filters"}),g.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Filter data by column values"})]}),g.jsx("button",{onClick:h,className:"px-3 py-1.5 text-sm text-gray-600 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors",children:"Clear All"})]}),g.jsx("div",{className:"p-3 space-y-3",children:g.jsx(ye,{columns:i,columnFilters:u,onColumnFilter:p})}),g.jsx("div",{className:"flex items-center justify-between p-3 border-t border-gray-200",children:g.jsx("div",{className:"text-sm text-gray-600",children:Object.keys(u).length>0&&g.jsxs("span",{children:[Object.keys(u).length," filter",1!==Object.keys(u).length?"s":""," ","applied"]})})})]})]}),M]}),g.jsxs("div",{className:"order-2 flex items-center gap-2 sm:gap-3 flex-wrap sm:flex-nowrap",children:[F,a&&he&&d.length>0&&g.jsxs("div",{className:"relative",ref:se,children:[g.jsxs("button",{ref:e=>{de.current=e},onClick:()=>Y(!_),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:[g.jsx(K,{className:"w-4 h-4"}),g.jsxs("span",{className:"hidden sm:inline text-sm font-medium",children:["Actions (",n,")"]})]}),g.jsxs(sr,{open:_,anchorEl:de.current,onClose:()=>Y(!1),placement:"bottom-end",offset:8,zIndex:1e3,className:"w-56 bg-white border border-gray-200 rounded-lg shadow-xl",children:[g.jsxs("div",{className:"p-3 border-b border-gray-100",children:[g.jsx("h3",{className:"font-medium text-gray-900",children:"Bulk Actions"}),g.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[n," row",1!==n?"s":""," selected"]})]}),g.jsx("div",{className:"p-2",children:d.map(e=>g.jsxs("button",{onClick:()=>(e=>{e.disabled||(e.onClick(l),Y(!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 cursor-not-allowed":e.destructive?"text-red-700 hover:bg-red-50":"text-gray-700 hover:bg-gray-50"),children:[ve(e.id),e.label]},e.id))})]})]}),s&&i.length>0&&g.jsxs("div",{className:"relative",ref:ae,children:[g.jsxs("button",{ref:e=>{me.current=e},onClick:()=>J(!X),className:"flex items-center gap-2 px-3 py-2.5 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. ${xe} of ${i.length} columns visible`,"aria-haspopup":"menu","aria-expanded":X,"aria-controls":"column-visibility-menu",children:[g.jsx(I,{className:"w-4 h-4"}),g.jsx("span",{className:"hidden sm:inline text-sm font-medium",children:"Columns"}),g.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500",children:["(",xe,"/",i.length,")"]})]}),g.jsxs(sr,{open:X,anchorEl:me.current,onClose:()=>J(!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",children:[g.jsxs("div",{className:"p-3 border-b border-gray-100",children:[g.jsx("h3",{className:"font-medium text-gray-900",children:"Show/Hide Columns"}),g.jsxs("div",{className:"relative mt-2",children:[g.jsx(W,{className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4"}),g.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",value:Z,onChange:e=>Q(e.target.value)})]})]}),g.jsx("div",{className:"max-h-60 overflow-y-auto p-2",children:pe.map(e=>{const t=!1!==c[e.key];return g.jsxs("label",{className:"flex items-center gap-3 p-2 hover:bg-gray-50 rounded-md cursor-grab relative "+(ee===e.key?"opacity-60":""),draggable:!0,onDragStart:t=>((e,t)=>{te(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();ne({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})})(e.key,t),onDrop:()=>(e=>{const t=ee;if(!t||t===e)return;if(w&&w.has(t)!==w.has(e))return te(null),void ne(null);const r=re?.key!==e||"before"===re.position,n=(b&&b.length?b:i.map(e=>e.key)).filter(e=>e!==t);let l=n.indexOf(e);if(-1===l)return v?.(n),te(null),void ne(null);r||(l+=1),n.splice(l,0,t),v?.(n),te(null),ne(null)})(e.key),onDragEnd:ke,children:[re?.key===e.key&&g.jsx("span",{className:"absolute left-2 right-2 h-0.5 bg-blue-600",style:{top:"before"===re.position?0:void 0,bottom:"after"===re.position?0:void 0}}),g.jsx("input",{type:"checkbox",checked:t,onChange:()=>(e=>{const t=!1!==c[e];x?.(e,!t)})(e.key),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),t?g.jsx(V,{className:"w-4 h-4 text-green-600"}):g.jsx(B,{className:"w-4 h-4 text-gray-400"}),g.jsx("span",{className:"text-sm text-gray-700",children:e.header}),g.jsx("button",{type:"button",onClick:r=>{r.preventDefault(),r.stopPropagation(),t?j?.(e.key):(x?.(e.key,!0),requestAnimationFrame(()=>j?.(e.key)))},className:"ml-auto p-1 text-gray-400 hover:text-blue-600",title:"Scroll to this column","aria-label":`Scroll to column ${e.header}`,children:g.jsx(q,{className:"w-4 h-4"})})]},e.key)})}),g.jsxs("div",{className:"p-2 border-t border-gray-100",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.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",children:[g.jsx("input",{type:"checkbox",checked:pe.every(e=>!1!==c[e.key]),onChange:e=>{pe.forEach(t=>{x?.(t.key,e.target.checked)})},className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),g.jsx("span",{children:"Select All"})]}),g.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",onClick:()=>{i.forEach(e=>{x?.(e.key,!1!==e.visible)}),v?.(i.map(e=>e.key)),y?.(),J(!1)},children:"Reset Columns"})]}),Z&&g.jsx("button",{className:"text-xs text-blue-600 hover:underline mt-2",onClick:()=>Q(""),children:"Clear Search"})]})]})]}),C&&g.jsx("div",{className:"flex items-center",children:g.jsx("div",{className:"flex items-center gap-1 border border-gray-300 rounded-lg p-1",title:"Row density",children:["sm","md","lg"].map(e=>g.jsx("button",{className:"px-2 py-1 text-xs rounded-md "+(k===e?"bg-blue-600 text-white":"text-gray-700 hover:bg-gray-100"),onClick:()=>N?.(e),children:e.toUpperCase()},e))})}),g.jsx("div",{className:"flex items-center gap-2 order-3 w-full sm:order-0 sm:w-auto flex-1 min-w-0",children:g.jsxs("div",{className:"relative",children:[g.jsx(W,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4","aria-hidden":"true"}),g.jsx("input",{ref:le,type:"text",placeholder:"Search...",className:"w-full sm:w-64 pl-10 pr-10 py-2.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:t,onChange:f,"aria-label":"Search all columns","aria-keyshortcuts":"Control+F","aria-describedby":"search-results-status"}),t&&g.jsx("button",{onClick:()=>f({target:{value:""}}),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors",title:"Clear search",children:g.jsx(S,{className:"w-4 h-4"})})]})}),o&&m?.enabled&&g.jsxs("div",{className:"relative",ref:oe,children:[g.jsx("button",{ref:e=>{ue.current=e},onClick:()=>T(!$),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"+(he?` (${n} rows selected)`:` (${r} rows)`),"aria-haspopup":"menu","aria-expanded":$,"aria-controls":"export-menu","aria-keyshortcuts":"Control+E",title:"Export data (Ctrl+E)",children:g.jsx(L,{className:"w-4 h-4"})}),g.jsxs(sr,{open:$,anchorEl:ue.current,onClose:()=>T(!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",children:[g.jsxs("div",{className:"p-3 border-b border-gray-100",children:[g.jsx("h3",{className:"font-medium text-gray-900",children:"Export Data"}),g.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Choose format and data scope"})]}),g.jsxs("div",{className:"p-2",children:[g.jsxs("div",{className:"mb-3",children:[g.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2",children:"Export All Data"}),g.jsx("div",{className:"space-y-1",children:fe.map(e=>g.jsxs("button",{onClick:()=>je(e,!1),className:" cursor-pointer w-full flex items-center gap-3 px-3 py-2 text-sm text-gray-700 hover:bg-gray-50 rounded-md transition-colors",children:[be(e),g.jsxs("span",{children:["Export as ",we(e)]}),g.jsxs("span",{className:"ml-auto text-xs text-gray-500",children:[r.toLocaleString()," rows"]})]},`all-${e}`))})]}),he&&g.jsxs("div",{children:[g.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2",children:"Export Selected"}),g.jsx("div",{className:"space-y-1",children:fe.map(e=>g.jsxs("button",{onClick:()=>je(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",children:[be(e),g.jsxs("span",{children:["Export as ",we(e)]}),g.jsxs("span",{className:"ml-auto text-xs text-blue-500",children:[n," rows"]})]},`selected-${e}`))})]})]})]})]})]})]})})]})};ar.displayName="SearchToolbar";const ir=e.memo(ar),cr=({data:t,columns:r})=>{const[n,l]=e.useState(""),[o,s]=e.useState({}),[a,i]=e.useTransition(),[,c]=e.useTransition(),u=e.useCallback(e=>{i(()=>l(e))},[]),d=e.useDeferredValue(n),m=e.useCallback((e,t,r,n)=>{const l=e[t];switch(r.type){case"text":{const e=String(l||"").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(l),t=parseFloat(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(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 o=new Date(l);if(isNaN(o.getTime()))return!1;const s=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime();switch(r.operator){case"equals":default:return s===e;case"gt":return s>e;case"gte":return s>=e;case"lt":return s<e;case"lte":return s<=e;case"between":return void 0!==t&&!isNaN(t)&&s>=e&&s<=t}}case"boolean":return Boolean(l)===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(l))}default:return!0}},[]),f=e.useRef(new WeakMap),g=e.useRef(0),h=e.useCallback(()=>{g.current>5e3&&(f.current=new WeakMap,g.current=0)},[]),x=e.useMemo(()=>{h();const e=Object.keys(o).length>0,n=!!d;if(!e&&!n)return t;const l=d.toLowerCase(),s=f.current;let a=t;if(e)for(const[e,t]of Object.entries(o)){if(!t)continue;let r;if("date"===t.type){const e=new Date(t.value),n=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let l;if(t.secondValue){const e=new Date(t.secondValue);l=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}r={filterTs:n,secondTs:l}}if(a=a.filter(n=>m(n,e,t,r)),0===a.length)break}if(n&&a.length>0){const e=r.filter(e=>!1!==e.visible);a=a.filter(t=>{let r=s.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("|"),g.current<5e3&&(s.set(t,r),g.current++)),r.includes(l)})}return a},[t,o,d,r,m,h]),p=e.useCallback((e,t)=>{c(()=>{s(r=>{const n={...r};return t?n[e]=t:delete n[e],n})})},[]),y=e.useCallback(e=>{p(e,null)},[p]),b=e.useCallback(()=>{i(()=>l("")),c(()=>s({})),f.current=new WeakMap,g.current=0},[]),v=e.useCallback(()=>{let e=0;return d&&e++,e+Object.keys(o).length},[d,o]);return{globalFilter:n,setGlobalFilter:u,columnFilters:o,filteredData:x,setColumnFilter:p,clearColumnFilter:y,clearAllFilters:b,getActiveFilterCount:v,isFilterPending:a}};function ur(){const e=self,t=(e,t)=>{if(!e||0===e.length)return e;if(!t?.key)return e;const{key:r,direction:n}=t,l="asc"===n?1:-1;return[...e].sort((e,t)=>{const n=e?.[r],o=t?.[r];return null==n&&null==o?0:null==n?-1*l:null==o?1*l:"number"==typeof n&&"number"==typeof o?(n-o)*l:String(n).localeCompare(String(o))*l})};e.onmessage=r=>{const n=r.data;if(n&&"process"===n.type)try{const{rows:r,sort:l}=n.payload;e.postMessage({type:"result",payload:{rows:t(r,l??null)}})}catch{e.postMessage({type:"result",payload:{rows:n.payload?.rows??[]}})}}}function dr(t){const r=t?.enabled??!0,n=e.useRef(null),l=e.useRef(null),o=e.useRef(r);e.useEffect(()=>{o.current=r,!r&&n.current&&(n.current.terminate(),n.current=null,l.current&&(l.current.reject(new DOMException("Worker disabled","AbortError")),l.current=null))},[r]);const s=e.useRef(()=>null);return s.current=()=>{if(!o.current)return null;if(n.current)return n.current;const e=`(${ur.toString()})()`,t=new Blob([e],{type:"application/javascript"}),r=URL.createObjectURL(t),s=new Worker(r);return URL.revokeObjectURL(r),s.onmessage=e=>{"result"===e.data?.type&&(l.current?.resolve(e.data.payload.rows),l.current=null)},n.current=s,s},e.useEffect(()=>()=>{n.current?.terminate(),n.current=null,l.current&&(l.current.reject(new DOMException("Unmounted","AbortError")),l.current=null)},[]),{process:e.useCallback((e,t)=>{if(!o.current)return Promise.resolve(e);const r=s.current();return r?new Promise((n,o)=>{l.current&&l.current.reject(new DOMException("Superseded by newer sort","AbortError")),l.current={resolve:n,reject:o},r.postMessage({type:"process",payload:{rows:e,sort:t}})}):Promise.resolve(e)},[])}}const mr="Unknown",fr=e=>e.join("|"),gr=(e,t,r,n,l)=>{const o=t[r],s=new Map;for(const t of e){const e=String(t[o]??mr),r=s.get(e);r?r.push(t):s.set(e,[t])}for(const[e,a]of s.entries()){const s=[...n,`${o}=${e}`];l.add(fr(s)),r<t.length-1&&gr(a,t,r+1,s,l)}},hr=(e,t)=>{const r={};for(const n of t){if(!n.aggregate)continue;const t=e.map(e=>e[n.key]);let l=null;if("function"==typeof n.aggregate)try{l=n.aggregate(t)}catch(e){l=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)),o=()=>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&&(l="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)l="min"===n.aggregate?Math.min(...r):Math.max(...r);else{const e=o();if(e.length){const t="min"===n.aggregate?Math.min(...e):Math.max(...e);l=new Date(t)}}}null!=l&&(r[n.key]=l)}return r},xr=({data:t,pagination:r})=>{const[n,l]=e.useState(1),[o,s]=e.useState(r?.pageSize||50),[a,i]=e.useState(!1);e.useEffect(()=>{const e=r?.pageSize;e&&e!==o&&(s(e),l(1))},[r?.pageSize]);const c=e.useCallback(()=>{l(1)},[]),u=e.useMemo(()=>{const e=!1!==r?.enabled,l="server"===(r?.mode||"client")?r?.serverConfig?.totalRows||0:t.length,s=Math.ceil(l/o);return{enabled:e,pageSize:o,currentPage:n,totalPages:s,totalRows:l,showPageSizeSelector:!1!==r?.showPageSizeSelector,pageSizeOptions:r?.pageSizeOptions||[25,50,100,200,500]}},[r,o,n,t.length]),d=e.useMemo(()=>{if(!u.enabled||"server"===r?.mode)return t;const e=(n-1)*o;return t.slice(e,e+o)},[t,n,o,u.enabled,r?.mode]),m=e.useCallback(async e=>{if("server"===r?.mode&&r?.serverConfig?.onPageChange){i(!0);try{await r.serverConfig.onPageChange(e,o)}finally{i(!1)}}l(e)},[r,o]),f=e.useCallback(async e=>{if("server"===r?.mode&&r?.serverConfig?.onPageSizeChange){i(!0);try{await r.serverConfig.onPageSizeChange(e)}finally{i(!1)}}s(e),l(1)},[r]);return{currentPage:n,resetPage:c,paginationConfig:u,paginatedData:d,isServerLoading:a,handlePageChange:m,handlePageSizeChange:f}},pr=(e,t)=>{if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0},yr=({data:t,selectedRowIds:r,onRowSelect:n,getRowId:l})=>{const o=e.useCallback((e,t)=>l?l(e):void 0!==e.id?e.id:("development"===process.env.NODE_ENV&&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),[l]),[s,a]=e.useState(()=>new Set(r?Array.from(r):[]));e.useEffect(()=>{r&&a(e=>{const t=new Set(Array.from(r));return pr(e,t)?e:t})},[r]);const i=e.useMemo(()=>{const e=new Map;return t.forEach((t,r)=>e.set(o(t,r),t)),e},[t,o]);e.useEffect(()=>{if(0===s.size)return;let e=!1;for(const t of s)if(!i.has(t)){e=!0;break}e&&a(e=>{const t=new Set;return e.forEach(e=>{i.has(e)&&t.add(e)}),pr(e,t)?e:t})},[i]);const c=e.useCallback((e,t)=>{if(a(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n}),n){const t=i.get(e);t&&n(t)}},[i,n]),u=e.useCallback(e=>{a(e?new Set(t.map((e,t)=>o(e,t))):new Set)},[t,o]);return{selectedRows:s,handleRowSelect:c,handleSelectAll:u}},br=({data:t,virtualized:r=!0,rowHeight:n=40,overscan:l=10,height:o})=>{const s=e.useRef(null),[a,i]=e.useState(0),c=e.useRef(null),u=e.useRef(0),[d,m]=e.useState(o);e.useEffect(()=>{const e=s.current;if(!e)return;const t=new ResizeObserver(([e])=>{const t=e.contentRect.height;t>0&&m(t)});t.observe(e);const r=e.clientHeight;return r>0&&m(r),()=>t.disconnect()},[]),e.useEffect(()=>{o>0&&m(o)},[o]);const f=e.useMemo(()=>{if(!r)return{startIndex:0,endIndex:t.length-1,offsetY:0};const e=Math.max(1,Math.ceil(d/n)),o=Math.max(l,Math.max(8,Math.min(2*e,50))),s=Math.max(0,Math.floor(a/n)-o),i=Math.ceil(d/n);return{startIndex:s,endIndex:Math.min(t.length-1,s+i+2*o),offsetY:s*n}},[a,d,t.length,n,l,r]),g=e.useMemo(()=>r?t.slice(f.startIndex,f.endIndex+1):t,[t,f,r]),h=t.length*n,x=e.useCallback(e=>{u.current=e.target.scrollTop,null==c.current&&(c.current=requestAnimationFrame(()=>{c.current=null,i(u.current)}))},[]);return e.useEffect(()=>()=>{null!=c.current&&cancelAnimationFrame(c.current)},[]),{scrollRef:s,virtualizedRange:f,visibleData:g,totalHeight:h,handleScroll:x}},vr=()=>!0,wr=e.forwardRef(function({data:t,columns:r,getRowId:n,height:l,density:o="md",headerDensity:s,headerHeight:a,onDensityChange:i,showDensityControl:c=!1,onRowSelect:u,onSelectedRowsChange:d,selectable:m=!1,isRowSelectable:f,showToolbar:p=!0,showExport:y=!1,filterable:b=!0,groupable:v=!1,virtualized:w=!0,rowHeight:j,overscan:k=6,rowStyle:N,onContextMenu:C,onRowDoubleClick:S,onRowClick:M,onCellClick:R,onCellContextMenu:E,cellFocusEnabled:D=!1,onCellFocusChange:A,cellSelectionEnabled:L=!1,canSelectCell:F=vr,onCellSelectionChange:z,pagination:$={enabled:!1,mode:"client",pageSize:50},virtualizationThreshold:I=300,isLoading:T=!1,onFilterChange:O,onSort:P,onColumnConfigChange:_,initialColumnConfig:K,toolbarLeft:V,toolbarRight:B,groupBarVisibility:W="auto",groupFooterVariant:H="chips",onCopyCells:G,selectedRowIds:U,performanceConfig:Y={},exportOptions:q,renderGroupActions:X},J){const Z=e.useRef(null),[Q,ee]=e.useState(0);e.useEffect(()=>{const e=Z.current;if(!e)return;const t=()=>ee(e.clientWidth||0);t();const r=new ResizeObserver(()=>t());return r.observe(e),()=>r.disconnect()},[]);const[te,re]=e.useState(null),[ne,le]=e.useState(null),[oe,se]=e.useState(null),ae=e.useRef(!1),ce=e.useRef(null),ue=e.useRef(null),[he,pe]=e.useState(null),[ye,be]=e.useState(o);e.useEffect(()=>{be(o)},[o]);const ve=e.useMemo(()=>({sm:28,md:40,lg:56}),[]),we=e.useMemo(()=>null!=j?j:ve[ye],[j,ye,ve]),je=e.useMemo(()=>null!=a?a:ve[s??"md"],[a,s,ve]),{globalFilter:ke,columnFilters:Ne,filteredData:Ce,setGlobalFilter:Se,setColumnFilter:Me,clearAllFilters:Re}=cr({data:t,columns:r}),[Ee,De]=e.useState({key:null,direction:null}),[Ae,Le]=e.useState(()=>{const e={};return r.forEach(t=>{e[t.key]=t.width||100}),e}),Fe=e.useRef(r.reduce((e,t)=>(e[t.key]=t.width||100,e),{})),ze=e.useRef(r.map(e=>e.key)),[$e,Ie]=e.useState(()=>ze.current.slice()),[Te,Oe]=e.useState(new Set),[Pe,_e]=e.useState(()=>{const e={};return r.forEach(t=>{e[t.key]=!0}),e}),Ke=e.useCallback(e=>{let t=e,r="asc";Ee.key!==e?(t=e,r="asc"):"asc"===Ee.direction?r="desc":"desc"===Ee.direction?(t=null,r=null):r="asc",De({key:t,direction:r}),P&&"server"===$?.mode&&t&&r&&P(t,r)},[P,$?.mode,Ee.key,Ee.direction]),Ve=e.useCallback((e,t)=>{Le(r=>({...r,[e]:t}))},[]),Be=e.useCallback(e=>null==e?0:8*("string"==typeof e?e:String(e)).length,[]),We=e.useCallback(e=>{const n=r.find(t=>t.key===e);if(!n)return;const l=Be(n.header),o=t.slice(0,500);let s=0;for(const t of o)s=Math.max(s,Be(t[e]));const a=Math.max(60,Math.min(500,Math.max(l,s)+32));Le(t=>({...t,[e]:a}))},[r,t,Be]),He=e.useCallback(()=>{r.forEach(e=>We(e.key))},[r,We]),Ge=e.useCallback(()=>{Le({...Fe.current}),Oe(new Set),_e(e=>{const t={};return Object.keys(e).forEach(e=>t[e]=!0),t}),Ie(ze.current.slice())},[]),Ue=e.useRef(null),Ye=e.useRef(null),qe=e.useCallback((e,t)=>{Oe(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n})},[]),Xe=e.useCallback((e,t)=>{_e(r=>({...r,[e]:t}))},[]),{process:Je}=dr({enabled:!0}),[Ze,Qe]=e.useState(Ce),et=Y?.sortWorkerThreshold??5e3;e.useEffect(()=>{let e=!1;if(!Ee.key)return void Qe(Ce);const t=Ce;if(t.length<et){const e="asc"===Ee.direction?1:-1,r=[...t].sort((t,r)=>{const n=t?.[Ee.key],l=r?.[Ee.key];return null==n&&null==l?0:null==n?-1*e:null==l?1*e:"number"==typeof n&&"number"==typeof l?(n-l)*e:String(n).localeCompare(String(l))*e});return void Qe(r)}return Je(t,{key:Ee.key,direction:Ee.direction}).then(t=>{e||Qe(t)}),()=>{e=!0}},[Ce,Ee,Je,et]);const{paginationConfig:tt,paginatedData:rt,isServerLoading:nt,handlePageChange:lt,handlePageSizeChange:ot,resetPage:st,currentPage:at}=xr({data:Ze,pagination:$}),it=T||nt,[ct,ut]=e.useState(it),[dt,mt]=e.useState(!1),[ft,gt]=e.useState(0);e.useEffect(()=>{if(it)return ut(!0),void mt(!1);if(ct){mt(!0);const e=setTimeout(()=>{ut(!1),mt(!1)},200);return()=>clearTimeout(e)}},[it]);const ht=e.useCallback(e=>{Se(e.target.value)},[Se]),{groupConfig:xt,displayData:pt,handleGroupBy:yt,addGroupKey:bt,removeGroupKey:vt,setGroupKeys:wt,toggleGroupExpansion:jt,isGrouped:kt,expandAllGroups:Nt,collapseAllGroups:Ct}=(({data:t,columns:r})=>{const[n,l]=e.useState({columnKeys:[],expanded:new Set}),o=e.useMemo(()=>{const e=n.columnKeys;if(!e.length)return t;const l=[],o=(t,s,a)=>{const i=e[s],c=new Map;for(const e of t){const t=String(e[i]??mr),r=c.get(t);r?r.push(e):c.set(t,[e])}const u=Array.from(c.entries()).sort(([e],[t])=>e.localeCompare(t));for(const[t,c]of u){const u=[...a,`${i}=${t}`],d=fr(u);if(l.push({id:`group-${d}`,_isGroupHeader:!0,_groupKey:d,_groupCount:c.length,_groupLevel:s,_groupColumnKey:i,_groupValue:t,_groupRows:c}),!n.expanded.has(d))continue;if(s<e.length-1)o(c,s+1,u);else for(const e of c)l.push(e);const m=hr(c,r);l.push({id:`group-footer-${d}`,_isGroupFooter:!0,_groupKey:d,_groupLevel:s,_groupAgg:m})}};return o(t,0,[]),l},[t,r,n.columnKeys,n.expanded]);return e.useEffect(()=>{if(!n.columnKeys.length)return;const e=new Set;gr(t,n.columnKeys,0,[],e);let r=!1;if(e.size!==n.expanded.size)r=!0;else for(const t of e)if(!n.expanded.has(t)){r=!0;break}r&&l(t=>({...t,expanded:e}))},[n.columnKeys,t]),{groupConfig:n,displayData:o,handleGroupBy:e=>{l({columnKeys:e?[e]:[],expanded:new Set})},addGroupKey:e=>{l(t=>t.columnKeys.includes(e)?t:{...t,columnKeys:[...t.columnKeys,e]})},removeGroupKey:e=>{l(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=>{l({columnKeys:[...e],expanded:new Set})},toggleGroupExpansion:e=>{l(t=>{const r=new Set(t.expanded);return r.has(e)?r.delete(e):r.add(e),{...t,expanded:r}})},expandAllGroups:()=>{const e=n.columnKeys;if(!e.length)return;const r=new Set;gr(t,e,0,[],r),l(e=>({...e,expanded:r}))},collapseAllGroups:()=>{l(e=>({...e,expanded:new Set}))},isGrouped:n.columnKeys.length>0}})({data:Ze,columns:r});e.useImperativeHandle(J,()=>({setGroupKeys:wt,addGroupKey:bt,removeGroupKey:vt,expandAllGroups:Nt,collapseAllGroups:Ct,toggleGroupExpansion:jt,getGroupConfig:()=>xt,setColumnFilter:(e,t)=>{Me(e,t)},clearColumnFilter:e=>{Me(e,null)},clearAllFilters:()=>{Re()},setGlobalFilter:e=>{Se(e)}}),[xt,Me,Re,Se]);const St=e.useMemo(()=>new Set(Te),[Te]),Mt=$?.enabled?"server"===$.mode?t:rt:Ze,Rt=kt?pt:Mt,{selectedRows:Et,handleRowSelect:Dt,handleSelectAll:At}=yr({data:Rt,onRowSelect:u,selectedRowIds:U,getRowId:n}),Lt=e.useRef(d);e.useEffect(()=>{Lt.current=d},[d]),e.useEffect(()=>{Lt.current&&Lt.current(Et)},[Et]);const{exportData:Ft}=(({data:t,columns:r,selectedRows:n,filename:l="data",columnVisibility:o})=>{const s=e.useCallback(()=>o?r.filter(e=>!1!==o[e.key]):r,[r,o]),a=e.useCallback((e,t,r)=>{const n=new Blob([e],{type:r}),l=URL.createObjectURL(n),o=document.createElement("a");o.href=l,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(l)},[]),i=e.useCallback((e,t)=>{const r=s(),n=r.map(e=>e.header).join(","),l=e.map(e=>r.map(t=>{const r=String(e[t.key]??"");return r.includes(",")||r.includes('"')?`"${r.replace(/"/g,'""')}"`:r}).join(","));a([n,...l].join("\n"),`${t}.csv`,"text/csv")},[s,a]),c=e.useCallback((e,t)=>{const r=s(),n=e.map(e=>{const t={};for(const n of r)t[n.header]=e[n.key];return t});a(JSON.stringify(n,null,2),`${t}.json`,"application/json")},[s,a]),u=e.useCallback(async(e,t)=>{const r=s(),[{default:n},{saveAs:l}]=await Promise.all([import("exceljs"),import("file-saver")]),o=new n.Workbook,a=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};a.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]);a.addRow(e)}a.getRow(1).font={bold:!0},a.autoFilter={from:{row:1,column:1},to:{row:Math.max(1,a.rowCount),column:r.length}};const u=await o.xlsx.writeBuffer();l(new Blob([u],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),`${t}.xlsx`)},[s]);return{exportData:e.useCallback((e,r=!1)=>{const o=r&&n&&n.size>0?t.filter(e=>n.has(e.id)):t,s=r&&n&&n.size>0?`${l}_selected_${n.size}_rows`:l;switch(e){case"csv":i(o,s);break;case"json":c(o,s);break;case"xlsx":u(o,s);break;default:console.warn(`[KDGrid] Unsupported export format: ${e}`)}},[t,n,l,i,c,u]),canExportSelected:!!(n&&n.size>0),selectedCount:n?.size??0}})({data:Mt,columns:r,selectedRows:Et,filename:q&&q.filename||"grid-data",columnVisibility:Pe}),zt=e.useCallback((e,t)=>{const r=Array.from(Et||[]);"server"===q?.exportMode&&"function"==typeof q?.onServerExport?q.onServerExport(e,t,r):Ft(e,t)},[q?.exportMode,q?.onServerExport,Ft,Et]),$t=e.useCallback(()=>{Re()},[Re]),It=e.useCallback(e=>{be(e),i&&i(e)},[i]),Tt=e.useMemo(()=>!!w&&Rt.length>I,[w,Rt.length,I]),Ot=e.useMemo(()=>({enableHorizontalVirtualization:!0,horizontalVirtualizationThreshold:50,sortWorkerThreshold:5e3,maxFilterCacheSize:5e3,enableAggressiveMemoization:!0,...Y}),[Y]),{scrollRef:Pt,virtualizedRange:_t,visibleData:Kt,handleScroll:Vt}=br({data:Rt,virtualized:Tt,rowHeight:we,overscan:k,height:l||400});e.useEffect(()=>{const e=()=>{const e=Pt.current;e&>((e.offsetTop||0)+(je||0)-1)};e();const t=new ResizeObserver(e);return Z.current&&t.observe(Z.current),Pt.current&&t.observe(Pt.current),()=>t.disconnect()},[je]);const[Bt,Wt]=e.useState(0),Ht=e.useRef(0),Gt=e.useRef(null),Ut=e.useCallback(e=>{Ht.current=e,null==Gt.current&&(Gt.current=requestAnimationFrame(()=>{Gt.current=null,Wt(Ht.current)}))},[]),[Yt,qt]=e.useState(0);e.useEffect(()=>{const e=Pt.current;if(!e)return;const t=()=>qt(e.clientWidth||0);t();const r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[Pt]),e.useEffect(()=>{if(!O)return;if(!$?.enabled||"server"!==$.mode)return;const e=r.filter(e=>!!e.filterable).map(e=>e.key);O({globalFilter:ke,columnFilters:Ne,filterableKeys:e})},[ke,Ne]),e.useEffect(()=>{if(!K)return;const e=new Set(r.map(e=>e.key));if(K.columnWidths){const t=Object.fromEntries(Object.entries(K.columnWidths).filter(([t])=>e.has(t)));Le(e=>({...e,...t}))}if(K.columnVisibility){const t=Object.fromEntries(Object.entries(K.columnVisibility).filter(([t])=>e.has(t)));_e(e=>({...e,...t}))}if(K.pinnedColumns){const t=K.pinnedColumns.filter(t=>e.has(t));Oe(new Set(t))}if(K.sortConfig){const e="asc"===K.sortConfig.direction||"desc"===K.sortConfig.direction?K.sortConfig.direction:null;De({key:e?K.sortConfig.key:null,direction:e})}if(K.filters){Se(K.filters.globalFilter||"");const t=Object.entries(K.filters.columnFilters||{}).filter(([t])=>e.has(t));for(const[e,r]of t)Me(e,r)}if(K.columnOrder&&K.columnOrder.length){const t=K.columnOrder.filter(t=>e.has(t)),n=r.map(e=>e.key).filter(e=>!t.includes(e));Ie([...t,...n])}K.groupConfig?.columnKeys&&K.groupConfig.columnKeys.length?wt(K.groupConfig.columnKeys):K.groupConfig?.columnKey&&yt(K.groupConfig.columnKey),K.density&&be(K.density)},[]),e.useEffect(()=>{if(!_)return;const e=setTimeout(()=>{_({columnWidths:Ae,columnVisibility:Pe,pinnedColumns:Array.from(Te),sortConfig:Ee,groupConfig:{columnKeys:xt.columnKeys},filters:{globalFilter:ke,columnFilters:Ne},columnOrder:$e,density:ye})},200);return()=>clearTimeout(e)},[_,Ae,Pe,Te,Ee,xt,ke,Ne,$e,ye]);const Xt=e.useMemo(()=>{if(0===r.length)return[];const e=new Map($e.map((e,t)=>[e,t])),t=r.filter(e=>!1!==Pe[e.key]).sort((t,r)=>(e.get(t.key)||0)-(e.get(r.key)||0)).map(e=>{const t=Ae[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,Q-(m?h:0)),l=t.reduce((e,t)=>e+t.width,0);if(n>l){const e=t.filter(e=>e.flex);if(e.length>0){const t=n-l,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)n.width=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=[],s=[];for(const e of t)St.has(e.key)?o.push(e):s.push(e);if(xt.columnKeys&&xt.columnKeys.length>0){const e=new Map(xt.columnKeys.map((e,t)=>[e,t]));s.sort((t,r)=>(e.get(t.key)??Number.POSITIVE_INFINITY)-(e.get(r.key)??Number.POSITIVE_INFINITY))}return[...o,...s]},[r,Ae,St,Pe,$e,xt.columnKeys,Q,m]),Jt=e.useMemo(()=>Ot.enableHorizontalVirtualization&&Xt.length>Ot.horizontalVirtualizationThreshold,[Xt.length,Ot.enableHorizontalVirtualization,Ot.horizontalVirtualizationThreshold]),Zt=e.useMemo(()=>Xt.filter(e=>St.has(e.key)),[Xt,St]),Qt=e.useMemo(()=>Xt.filter(e=>!St.has(e.key)),[Xt,St]),er=e.useMemo(()=>{const e=Qt.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}},[Qt]),tr=e.useMemo(()=>{if(!Jt)return Xt;const e=m?h:0,t=Zt.reduce((e,t)=>e+(t.width||100),0),r=Math.max(0,Bt-200),n=Bt+Yt+200,l=e+t,o=Math.max(0,r-l),s=Math.max(0,Math.min(er.totalWidth,n-l)),a=(e=>{if(!er.widths.length)return 0;let t=0,r=er.widths.length-1,n=0;for(;t<=r;){const l=t+r>>1;er.prefix[l+1]>=e?(n=l,r=l-1):t=l+1}return Math.max(0,Math.min(n,er.widths.length-1))})(o),i=(e=>{if(!er.widths.length)return-1;let t=0,r=er.widths.length-1,n=er.widths.length-1;for(;t<=r;){const l=t+r>>1;er.prefix[l]<=e?(n=l,t=l+1):r=l-1}return Math.max(0,Math.min(n,er.widths.length-1))})(s),c=i>=a&&i>=0?Qt.slice(a,i+1):[];return[...Zt,...c]},[Jt,Xt,Bt,Yt,m,Zt,Qt,er]),rr=e.useMemo(()=>{const e=new Map;return Qt.forEach((t,r)=>e.set(t.key,r)),e},[Qt]),{hvPadLeftMemo:nr,hvPadRightMemo:lr}=e.useMemo(()=>{if(!Jt)return{hvPadLeftMemo:0,hvPadRightMemo:0};const e=tr.filter(e=>!St.has(e.key));if(!e.length)return{hvPadLeftMemo:0,hvPadRightMemo:0};const t=rr.get(e[0].key),r=rr.get(e[e.length-1].key);return null==t||null==r?{hvPadLeftMemo:0,hvPadRightMemo:0}:{hvPadLeftMemo:er.prefix[t],hvPadRightMemo:er.totalWidth-er.prefix[r+1]}},[Jt,tr,St,rr,er]),or=e.useMemo(()=>Xt.some(e=>e.footer_aggregate),[Xt]);e.useEffect(()=>{const e=Pt.current;if(!e)return;let t=!1;const r=()=>{if(t)return;t=!0;const r=Ye.current;r&&r.scrollLeft!==e.scrollLeft&&(r.scrollLeft=e.scrollLeft),Ut(e.scrollLeft),requestAnimationFrame(()=>{t=!1})};return e.addEventListener("scroll",r,{passive:!0}),Ye.current&&(Ye.current.scrollLeft=e.scrollLeft),()=>{e.removeEventListener("scroll",r)}},[Pt,or]);const sr=e.useMemo(()=>{const e=new Map;return Xt.forEach((t,r)=>e.set(t.key,r)),e},[Xt]),ar=e.useMemo(()=>{const e=new Map;return Xt.forEach(t=>e.set(t.key,t)),e},[Xt]),ur=e.useMemo(()=>Rt.filter(e=>!e._isGroupHeader&&!e._isGroupFooter),[Rt]),pr=e.useMemo(()=>{const e=new Map;return ur.forEach((t,r)=>e.set(t.id,r)),e},[ur]),wr=e.useMemo(()=>{const e=new Map;return ur.forEach(t=>e.set(t.id,t)),e},[ur]),jr=e.useRef(null),kr=e.useRef(z),Nr=e.useRef(G);e.useEffect(()=>{Nr.current=G},[G]),e.useEffect(()=>{kr.current=z},[z]);const Cr=e.useMemo(()=>Xt.map(e=>e.key),[Xt]),Sr=e.useMemo(()=>(e,t)=>{if(!L)return!1;if(!ne||!oe)return!1;const r=pr.get(e),n=sr.get(t);if(null==r||null==n)return!1;const l=wr.get(e),o=ar.get(t);if(l&&o&&!F(l,o))return!1;const s=Math.min(ne.rowIndex,oe.rowIndex),a=Math.max(ne.rowIndex,oe.rowIndex),i=Math.min(ne.colIndex,oe.colIndex),c=Math.max(ne.colIndex,oe.colIndex);return r>=s&&r<=a&&n>=i&&n<=c},[L,ne,oe,pr,sr,wr,ar,F]),Mr=e.useMemo(()=>(e,t)=>te?.rowId===e&&te?.columnKey===t,[te]),Rr=e.useCallback(e=>{const t=Pt.current;if(!t)return;const r=Math.abs(e.deltaX)>=Math.abs(e.deltaY)?e.deltaX:e.deltaY;0!==r&&(e.preventDefault(),t.scrollBy({left:r,top:0,behavior:"auto"}))},[]),Er=e.useCallback(({row:e,column:t,event:r})=>{const n=pr.get(e.id),l=sr.get(t.key);D&&null!=n&&null!=l&&(document.body.hasAttribute("data-modal-open")||(re({rowId:e.id,columnKey:t.key}),A&&A({row:e,column:t,value:e[t.key],rowIndex:n,colIndex:l}))),L&&F(e,t)&&0===r.button&&(ae.current=!0,ce.current={x:r.clientX,y:r.clientY},null!=n&&null!=l&&(re({rowId:e.id,columnKey:t.key}),le({rowIndex:n,colIndex:l}),se({rowIndex:n,colIndex:l}),pe({x:r.clientX,y:r.clientY,rows:1,cols:1})))},[D,A,L,F,pr,sr]),Dr=e.useCallback(({row:e,column:t,event:r})=>{if(!L)return;if(!ae.current||!ne)return;if(!F(e,t))return;const n=pr.get(e.id),l=sr.get(t.key);if(null==n||null==l)return;se({rowIndex:n,colIndex:l}),ce.current={x:r.clientX,y:r.clientY};const o=Math.min(ne.rowIndex,n),s=Math.max(ne.rowIndex,n),a=Math.min(ne.colIndex,l),i=Math.max(ne.colIndex,l);pe({x:r.clientX,y:r.clientY,rows:s-o+1,cols:i-a+1})},[L,F,ne,pr,sr]);e.useEffect(()=>{const e=()=>{ae.current=!1,pe(null),ue.current&&(cancelAnimationFrame(ue.current),ue.current=null)};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),e.useEffect(()=>{const e=e=>{ae.current&&(ce.current={x:e.clientX,y:e.clientY})};return window.addEventListener("mousemove",e),()=>window.removeEventListener("mousemove",e)},[]);const Ar=e.useCallback(()=>{if(null!=ue.current)return;const e=()=>{if(ue.current=null,!ae.current)return;const t=Pt.current,r=ce.current;if(t&&r){const e=t.getBoundingClientRect(),n=24,l=24;let o=0,s=0;r.x<e.left+n?o=-(e.left+n-r.x):r.x>e.right-n&&(o=r.x-(e.right-n)),r.y<e.top+n?s=-(e.top+n-r.y):r.y>e.bottom-n&&(s=r.y-(e.bottom-n));const a=e=>Math.max(-l,Math.min(l,e));o=a(o),s=a(s),0===o&&0===s||t.scrollBy({left:o,top:s,behavior:"auto"})}ue.current=requestAnimationFrame(e)};ue.current=requestAnimationFrame(e)},[]);e.useEffect(()=>{ae.current&&Ar()},[Ar,ne]),e.useEffect(()=>{const e=e=>{if("Escape"===e.key)return le(null),se(null),re(null),void pe(null);const t=e.shiftKey,r=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key);if(!t||!r||!L)return;e.preventDefault();let n=oe;if(!n){if(!te)return;{const e=pr.get(te.rowId),t=sr.get(te.columnKey);if(null==e||null==t)return;le({rowIndex:e,colIndex:t}),n={rowIndex:e,colIndex:t}}}const l=ur.length-1,o=Xt.length-1;let s=n.rowIndex,a=n.colIndex;"ArrowUp"===e.key&&(s=Math.max(0,s-1)),"ArrowDown"===e.key&&(s=Math.min(l,s+1)),"ArrowLeft"===e.key&&(a=Math.max(0,a-1)),"ArrowRight"===e.key&&(a=Math.min(o,a+1)),se({rowIndex:s,colIndex:a});const i=Pt.current;if(i){const e=i.getBoundingClientRect();pe({x:e.right-16,y:e.bottom-16,rows:Math.abs((ne?.rowIndex??s)-s)+1,cols:Math.abs((ne?.colIndex??a)-a)+1})}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[L,te,ne,oe,pr,sr,ur.length,Xt.length]),e.useEffect(()=>{if(!D)return;const e=Pt.current,t=Ue.current,r=r=>{if(!te)return;if(document.body.hasAttribute("data-modal-open"))return;const{key:n}=r;if("ArrowLeft"!==n&&"ArrowRight"!==n&&"ArrowUp"!==n&&"ArrowDown"!==n)return;r.preventDefault();const l=pr.get(te.rowId),o=sr.get(te.columnKey);if(null==l||null==o)return;let s=l,a=o;"ArrowLeft"===r.key&&(a=Math.max(0,o-1)),"ArrowRight"===r.key&&(a=Math.min(Xt.length-1,o+1)),"ArrowUp"===r.key&&(s=Math.max(0,l-1)),"ArrowDown"===r.key&&(s=Math.min(ur.length-1,l+1));const i=ur[s],c=Xt[a];i&&c&&(re({rowId:i.id,columnKey:c.key}),A&&A({row:i,column:c,value:i[c.key],rowIndex:s,colIndex:a}),((r,n)=>{if(!e)return;const l=e.clientHeight,o=r*we,s=o+we;o<e.scrollTop?e.scrollTop=o:s>e.scrollTop+l&&(e.scrollTop=s-l);const a=Xt[n]?.width||100;let i=m?h:0;for(let e=0;e<n;e++)i+=Xt[e]?.width||100;const c=i+a,u=e.clientWidth;i<e.scrollLeft?e.scrollLeft=i:c>e.scrollLeft+u&&(e.scrollLeft=c-u),t&&(t.scrollLeft=e.scrollLeft)})(s,a))};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[D,te,ur,Xt,we,m,pr,sr,A]),e.useEffect(()=>{if(!L||!ne||!oe){const e={bounds:null,cells:[]},t="none";return void(t!==jr.current&&(jr.current=t,kr.current?.(e)))}const e=Math.min(ne.rowIndex,oe.rowIndex),t=Math.max(ne.rowIndex,oe.rowIndex),r=Math.min(ne.colIndex,oe.colIndex),n=Math.max(ne.colIndex,oe.colIndex),l=[];for(let o=e;o<=t;o++){const e=ur[o];if(e)for(let t=r;t<=n;t++){const r=Xt[t];r&&F(e,r)&&l.push({row:e,column:r,value:e[r.key],rowIndex:o,colIndex:t})}}const o={bounds:{rowStart:e,rowEnd:t,colStart:r,colEnd:n},cells:l},s=`${e}-${t}-${r}-${n}|len:${l.length}`;s!==jr.current&&(jr.current=s,kr.current?.(o))},[L,ne,oe,ur,Cr,F]),e.useEffect(()=>{if(!L&&!D)return;const e=async e=>{if(!e.metaKey&&!e.ctrlKey||"c"!==e.key.toLowerCase())return;const t=!!e.shiftKey,r=!(!ne||!oe),n=!(!D||!te);if(!r&&!n)return;if(!r&&n){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}e.preventDefault();const l=(()=>{const e=[];if(r&&ne&&oe){const t=Math.min(ne.rowIndex,oe.rowIndex),r=Math.max(ne.rowIndex,oe.rowIndex),n=Math.min(ne.colIndex,oe.colIndex),l=Math.max(ne.colIndex,oe.colIndex);for(let o=t;o<=r;o++){const t=ur[o];if(t)for(let r=n;r<=l;r++){const n=Xt[r];n&&F(t,n)&&e.push({row:t,column:n,value:t[n.key],rowIndex:o,colIndex:r})}}}else if(n&&te){const t=pr.get(te.rowId),r=sr.get(te.columnKey);if(null!=t&&null!=r){const n=ur[t],l=Xt[r];n&&l&&e.push({row:n,column:l,value:n[l.key],rowIndex:t,colIndex:r})}}return e})();if(!l.length)return;const o=e=>{const t=null==e?"":String(e);return t.includes('"')||t.includes("\t")||t.includes("\n")||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t};let s="";if(r&&ne&&oe){const e=Math.min(ne.rowIndex,oe.rowIndex),r=Math.max(ne.rowIndex,oe.rowIndex),n=Math.min(ne.colIndex,oe.colIndex),l=Math.max(ne.colIndex,oe.colIndex);if(t){const e=[];for(let t=n;t<=l;t++){const r=Xt[t];r&&e.push(o(r.header??r.key))}s+=e.join("\t")+"\n"}for(let t=e;t<=r;t++){const e=ur[t];if(!e)continue;const a=[];for(let t=n;t<=l;t++){const r=Xt[t];r&&(F(e,r)?a.push(o(e[r.key])):a.push(""))}s+=a.join("\t"),t<r&&(s+="\n")}}else s=o(l[0].value);try{await navigator.clipboard.writeText(s)}catch{console.warn("Failed to write to clipboard")}if("function"==typeof Nr.current){const e=r&&ne&&oe?{rowStart:Math.min(ne.rowIndex,oe.rowIndex),rowEnd:Math.max(ne.rowIndex,oe.rowIndex),colStart:Math.min(ne.colIndex,oe.colIndex),colEnd:Math.max(ne.colIndex,oe.colIndex)}:null;try{Nr.current({text:s,bounds:e,cells:l,isRectangular:!!e,isFocusedCell:!e})}catch{}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[L,D,ne,oe,te,ur,Xt,F,pr,sr,J]);const Lr=Xt.reduce((e,t)=>e+(t.width||100),0);return e.useEffect(()=>{1!==at&&($?.enabled&&"server"===$.mode?lt(1):st())},[ke,Ne]),g.jsxs("div",{ref:Z,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:[p&&b&&g.jsx(ir,{globalFilter:ke,filteredDataLength:Ce.length,totalDataLength:tt.totalRows,paginationMode:$?.mode,selectedRowsCount:Et.size,showExport:y,columns:r,columnFilters:Ne,columnVisibility:Pe,onResetColumns:Ge,exportOptions:{enabled:(q?.enabled??!0)&&y,formats:q?.formats??["xlsx"],filename:q?.filename??"grid-data",onExport:zt},customLeftContent:V,customRightContent:B,onGlobalFilterChange:ht,onClearFilters:$t,onColumnFilter:Me,onColumnVisibilityChange:Xe,columnOrder:$e,onColumnOrderChange:Ie,pinnedColumns:Te,onScrollToColumn:e=>{const t=Pt.current,r=Ue.current;if(!t)return;const n=sr.get(e);if(null==n)return;const l=Xt[n]?.width||100;let o=m?h:0;for(let e=0;e<n;e++)o+=Xt[e]?.width||100;const s=o+l,a=t.clientWidth;if(o<t.scrollLeft)t.scrollTo({left:o,behavior:"smooth"});else if(s>t.scrollLeft+a)t.scrollTo({left:s-a,behavior:"smooth"});else{const e=Math.max(0,o-Math.max(0,(a-l)/2));t.scrollTo({left:e,behavior:"smooth"})}r&&(r.scrollLeft=t.scrollLeft)},density:ye,onDensityChange:It,showDensityControl:c}),g.jsxs("div",{className:"flex flex-col relative flex-1 min-h-50",children:[v&&("visible"===W||"auto"===W&&xt.columnKeys.length>0)&&g.jsx(me,{columns:r,groupedKeys:xt.columnKeys,onRemove:vt,onReorder:wt,onDropColumnKey:bt,isAnyExpanded:xt.expanded.size>0,onToggleExpandAll:()=>{xt.expanded.size>0?Ct():Nt()}}),g.jsxs("div",{ref:Pt,className:"flex-1 overflow-auto relative [&::-webkit-scrollbar]:thin "+(L?"select-none":""),onScroll:Vt,children:[g.jsx("div",{className:"sticky top-0 z-3",children:g.jsx("div",{style:{minWidth:`${Lr+(m?h:0)}px`},children:(()=>{const e=Zt,r=tr.filter(e=>!St.has(e.key));return g.jsx(ie,{pinnedColumns:e,unpinnedColumns:r,hvPadLeft:nr,hvPadRight:lr,headerHeight:je,sortConfig:Ee,columnFilters:Ne,selectable:m,selectedRows:Et,totalRows:Rt.length,data:t,onSort:Ke,onColumnFilter:Me,onSelectAll:()=>At(Et.size!==Rt.length),onColumnResize:Ve,pinnedKeySet:St,onColumnPin:qe,groupable:v,groupedByColumn:xt.columnKeys[0]||null,groupedByColumns:xt.columnKeys,onGroupToggle:(e,t)=>t?bt(e):vt(e),onGroupBy:yt,onAutosizeColumn:We,onAutosizeAllColumns:He,onResetColumns:Ge,columnOrder:$e,onColumnOrderChange:Ie,paginationMode:$?.enabled?$.mode:null})})()})}),g.jsx("div",{style:{minWidth:`${Lr+(m?h:0)}px`,height:Tt?Rt.length*we+"px":"auto"},children:T||0!==Rt.length?g.jsx("div",{style:{transform:`translateY(${Tt?_t.offsetY:0}px)`,willChange:"transform",contain:"content"},children:(()=>{const e=[];let t=[];const l=()=>{if(!t.length)return;const r=`chunk-${t[0]?.id}-${t.length}-${_t.offsetY}`;e.push(g.jsx("div",{style:{opacity:T?.5:1},children:g.jsx(de,{data:t,columns:tr,selectedRows:Et,virtualized:!1,virtualizedRange:{startIndex:0,endIndex:t.length-1,offsetY:0},rowHeight:we,selectable:m,isRowSelectable:f,onRowSelect:Dt,pinnedColumns:St,hvPadLeft:nr,hvPadRight:lr,rowStyle:N,globalFilter:ke,onContextMenu:C,onRowDoubleClick:S,onRowClick:M,onCellClick:R,onCellContextMenu:E,isCellFocused:Mr,isCellSelected:Sr,onCellMouseDown:Er,onCellMouseEnter:Dr,getRowId:n})},r)),t=[]};for(const n of Kt)if(n._isGroupHeader)l(),e.push(g.jsx(fe,{row:n,isExpanded:xt.expanded.has(n._groupKey||""),onToggle:jt,viewportWidth:Q,selectable:m,rowHeight:we,getHeaderLabel:e=>r.find(t=>t.key===e)?.header||e,getValueLabel:(e,t)=>{const n=r.find(t=>t.key===e);if(n?.formatter)try{return n.formatter(t)}catch(e){return String(t??"")}return String(t??"")},renderGroupActions:X},n.id));else if(n._isGroupFooter)if(l(),"chips"===H){const t=Xt.filter(e=>!!e.aggregate&&n._groupAgg&&void 0!==n._groupAgg[e.key]).map(e=>{const t=n._groupAgg[e.key],r=e.aggregateFormatter||e.formatter,l=r?(()=>{try{return r(t)}catch{return String(t)}})():String(t);return g.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,": ",l]},e.key)});e.push(g.jsx("div",{className:"sticky left-0 z-1",style:{minWidth:`${Lr+(m?h:0)}px`,height:`${we}px`},children:g.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:[g.jsx("div",{className:"flex items-center gap-2 flex-wrap overflow-hidden",children:t.length?t:g.jsx("span",{className:"text-xs text-gray-500",children:"No aggregates"})}),g.jsx("span",{className:"text-[10px] uppercase tracking-wide text-blue-700 dark:text-blue-300",children:"Group Summary"})]})},n.id))}else e.push(g.jsx("div",{className:"sticky left-0 z-1 bg-blue-100 dark:bg-gray-900",style:{minWidth:`${Lr+(m?h:0)}px`,height:`${we}px`},children:g.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:[m&&g.jsx("div",{style:{width:h},className:"shrink-0"}),Xt.map(e=>{const t=e.width||100,r=n._groupAgg?n._groupAgg[e.key]:void 0,l=e.aggregateFormatter||e.formatter,o=void 0===r?"":l?(()=>{try{return l(r)}catch{return r}})():r;let s;if("number"==typeof o)s=Number.isInteger(o)?String(o):o.toFixed(2);else if(isNaN(o)||""===o||null===o)s=String(o??"");else{const e=Number(o);s=Number.isInteger(e)?String(e):e.toFixed(2)}return g.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:s?`${e.header}: ${s}`:void 0,children:g.jsx("span",{className:"truncate w-full",children:s})},`agg-cell-${n._groupKey}-${e.key}`)})]})},n.id));else t.push(n);return l(),e})()}):g.jsx(g.Fragment,{})})]}),ct&&g.jsx("div",{className:"pointer-events-none absolute left-0 right-0 h-1 bg-gray-200 overflow-hidden z-30 "+(dt?"opacity-0 transition-opacity duration-200":"opacity-100"),style:{top:ft},children:g.jsx("div",{className:"h-full w-1/3 bg-blue-500 animate-[slide_1.2s_linear_infinite]"})}),!T&&0===Rt.length&&g.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 flex items-center justify-center",children:g.jsx("div",{className:"pointer-events-auto",children:g.jsx(ge,{hasFilters:!!ke||Object.keys(Ne).length>0,hasData:t.length>0})})})]}),or&&g.jsx("div",{ref:Ye,className:"shrink-0 overflow-x-hidden overflow-y-visible [&::-webkit-scrollbar]:hidden",style:{scrollbarWidth:"none",msOverflowStyle:"none"},onWheel:Rr,children:g.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700",style:{minWidth:`${Lr+(m?h:0)}px`,height:`${we}px`},children:g.jsx(x,{columns:Xt,data:ur,selectable:m,rowHeight:we,pinnedColumns:St})})}),g.jsx(xe,{paginationConfig:tt,currentPage:tt.currentPage,isServerLoading:nt,selectedRowsCount:Et.size,totalDataLength:t.length,filteredDataLength:"server"===$?.mode?void 0:Ce.length,paginationMode:$.mode,onPageChange:lt,onPageSizeChange:ot}),he&&g.jsx("div",{className:"fixed z-50 pointer-events-none select-none",style:{top:he.y+12,left:he.x+12},children:g.jsxs("div",{className:"px-2 py-1 rounded bg-gray-800 text-white text-xs shadow-lg opacity-90",children:[he.rows," × ",he.cols]})})]})});exports.FooterAggregate=x,exports.GridHeader=ie,exports.GridRows=de,exports.KDGrid=wr,exports.PaginationControls=xe,exports.SearchToolbar=ir,exports.useAdvancedFiltering=cr,exports.usePagination=xr,exports.useSelection=yr,exports.useVirtualization=br;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|