react-gridix 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1513,6 +1513,50 @@ Other slots work the same way: `root`, `toolbar`, `search`, `table`, `thead`, `h
1513
1513
  #### Width
1514
1514
 
1515
1515
  The grid is `width: 100%` of its container by default (it never overflows it: `max-width: 100%; min-width: 0`). To make it narrower, give it a width through `className` (`max-w-3xl`) or `style` (`{ maxWidth: 900 }`).
1516
+ ## `overflow` column option
1517
+
1518
+ Controls what happens to text that doesn't fit the column, in both the header and the cells.
1519
+
1520
+ | Value | Behavior | Example (width 60) |
1521
+ |---|---|---|
1522
+ | `"wrap"` | Breaks the text onto new lines, even inside a word | `Alexa` / `nder` |
1523
+ | `"ellipsis"` | Cuts the text and shows `...` | `Alexa...` |
1524
+ | `"clip"` | Cuts the text, no dots | `Alexa` |
1525
+
1526
+ **Default** (when `overflow` is not set):
1527
+
1528
+ - Column has a `width`: `"wrap"`
1529
+ - Numeric `width` under 40: `"clip"`
1530
+ - No `width`: the grid's normal behavior
1531
+
1532
+ ### Example
1533
+
1534
+ ```tsx
1535
+ const columns: ColumnDef<Person>[] = [
1536
+ { field: "color", header: "", width: 6 }, // thin strip, "clip" by default
1537
+ { field: "id", header: "ID", width: 50 }, // "wrap" by default
1538
+ { field: "name", header: "Name", width: 120, overflow: "ellipsis" }, // "Alexander Ha..."
1539
+ { field: "notes", header: "Notes", width: 200, overflow: "wrap" }, // new lines
1540
+ { field: "code", header: "Code", width: 80, overflow: "clip" }, // cut off
1541
+ ];
1542
+ ```
1543
+
1544
+ ### Notes
1545
+
1546
+ - Widths under 40 also remove the column's side padding, so `width: 1` really is 1px.
1547
+ - `"wrap"` in a very narrow column puts one character per line and makes rows tall. Use `"ellipsis"` or `"clip"` there.
1548
+ - To show the full text on hover, add a tooltip in a `cellRenderer`:
1549
+
1550
+ ```tsx
1551
+ {
1552
+ field: "name",
1553
+ header: "Name",
1554
+ width: 120,
1555
+ overflow: "ellipsis",
1556
+ cellRenderer: ({ value }) => <span title={String(value)}>{String(value)}</span>,
1557
+ }
1558
+ ```
1559
+
1516
1560
 
1517
1561
  #### Plain CSS class reference
1518
1562
 
package/dist/index.d.ts CHANGED
@@ -139,9 +139,16 @@ export declare interface ColumnDef<T = Record<string, any>> {
139
139
  sequenceStart?: number;
140
140
  /** Only for `type: "sequence"`: start again at `sequenceStart` on every page. Default false (the count continues: 11, 12, ...). */
141
141
  sequenceRestartEachPage?: boolean;
142
+ /** Column width: a number (pixels) or any CSS length such as "20%" or "12rem". Columns without one share the remaining space. */
142
143
  width?: number | string;
144
+ /**
145
+ * What happens to text that does not fit the column (header and cells):
146
+ * "wrap" breaks it onto new lines (even in the middle of a word), "ellipsis" cuts it and shows "...",
147
+ * "clip" just cuts it. Default: "wrap" for a column that has a `width` ("clip" when the width is under 40), otherwise the grid's normal behaviour.
148
+ */
149
+ overflow?: "wrap" | "ellipsis" | "clip";
143
150
  minWidth?: number | string;
144
- /** Largest width in pixels when the user resizes the column. */
151
+ /** Largest width in pixels (also limits dragging the column wider). */
145
152
  maxWidth?: number;
146
153
  align?: "left" | "center" | "right";
147
154
  /** Click the header to sort by this column. Default false: sorting is opt-in, column by column. */
@@ -241,7 +248,7 @@ export declare interface ColumnDef<T = Record<string, any>> {
241
248
  headerCheckbox?: boolean;
242
249
  }
243
250
 
244
- export declare function DataGrid<T extends AnyRow = AnyRow>({ columns, rows, getRowId, editable, enterMovesDown, onCellEdit, onRowsChange, rowSelection, selectedRowIds, defaultSelectedRowIds, onSelectionChange, isRowSelectable, sort: sortProp, defaultSort, onSortChange, multiSort, searchable, searchPlaceholder, search: searchProp, onSearchChange, filters: filtersProp, onFiltersChange, pagination, paginationPosition, showToolbar: allowToolbar, showFooter, pageSize: initialPageSize, pageSizeOptions, page: pageProp, onPageChange, onPageSizeChange, serverSide, rowCount, onQueryChange, queryDebounce, filterDebounce, loading: loadingProp, loadingRows, skeletonRow, errorMessage, columnMenu, onColumnVisibilityChange, keyboardNavigation, virtualize, rowHeight, overscan, exportable, onExportError, apiRef, onRowClick, toolbar, emptyMessage, emptyComponent, sortIndicator, striped, stripeColors, checkboxVariant, animateRows, rowAnimation, rowAnimationDuration, rowAnimationStagger, rowAnimationClassName, rowExitAnimationClassName, theme, maxHeight, className, style, classNames, styles, rowClassName, rowStyle, }: DataGridProps<T>): JSX_2.Element;
251
+ export declare function DataGrid<T extends AnyRow = AnyRow>({ columns, rows, getRowId, editable, enterMovesDown, onCellEdit, onRowsChange, rowSelection, selectedRowIds, defaultSelectedRowIds, onSelectionChange, isRowSelectable, sort: sortProp, defaultSort, onSortChange, multiSort, searchable, searchPlaceholder, search: searchProp, onSearchChange, filters: filtersProp, onFiltersChange, pagination, paginationPosition, showToolbar: allowToolbar, showFooter, pageSize: initialPageSize, pageSizeOptions, page: pageProp, onPageChange, onPageSizeChange, serverSide, rowCount, onQueryChange, queryDebounce, filterDebounce, loading: loadingProp, loadingRows, skeletonRow, errorMessage, columnMenu, onColumnVisibilityChange, keyboardNavigation, virtualize, rowHeight, overscan, exportable, onExportError, apiRef, onRowClick, toolbar, emptyMessage, emptyComponent, sortIndicator, sortIndicatorRotate, striped, stripeColors, checkboxVariant, animateRows, rowAnimation, rowAnimationDuration, rowAnimationStagger, rowAnimationClassName, rowExitAnimationClassName, theme, maxHeight, stickyToolbar, stickyHeader, stickyOffset, scrollbar, className, style, classNames, styles, rowClassName, rowStyle, }: DataGridProps<T>): JSX_2.Element;
245
252
 
246
253
  /** Methods you can call from outside by passing a ref as `apiRef`. */
247
254
  export declare interface DataGridApi<T = Record<string, any>> {
@@ -414,6 +421,12 @@ export declare interface DataGridProps<T = Record<string, any>> {
414
421
  * `{ column, direction, priority }`. A column can override it with its own `sortIndicator`.
415
422
  */
416
423
  sortIndicator?: SortIndicatorSetting<T>;
424
+ /**
425
+ * Turn the default ▲ and your own indicator smoothly (half a turn) when the sort direction changes.
426
+ * Default true. Does not affect `sortIndicator="arrow"`, which already turns itself. Set false if your
427
+ * own component animates by itself, so it is not turned twice.
428
+ */
429
+ sortIndicatorRotate?: boolean;
417
430
  /** Alternate row shading. Default false. */
418
431
  striped?: boolean;
419
432
  /** Two colours for the alternating rows, for example `["#ffffff", "#f1f5f9"]`. Implies `striped`. */
@@ -458,6 +471,26 @@ export declare interface DataGridProps<T = Record<string, any>> {
458
471
  theme?: GridTheme | (string & {});
459
472
  /** Makes the body scroll with a sticky header, e.g. 400 or "60vh". */
460
473
  maxHeight?: number | string;
474
+ /**
475
+ * Keep the toolbar at the top of the browser window while the PAGE scrolls past a tall grid.
476
+ * Optional (default false). Not needed with `maxHeight` (the toolbar already stays put there).
477
+ */
478
+ stickyToolbar?: boolean;
479
+ /** Keep the column headers at the top of the browser window while the PAGE scrolls (under the toolbar when it is sticky too). Default false. */
480
+ stickyHeader?: boolean;
481
+ /**
482
+ * Space kept free above the sticky parts, for a fixed bar of your own, e.g. 64 or "4rem". Default 0.
483
+ * Page-scroll sticky mode lets the table grow to its full height, so a table wider than the page
484
+ * overflows instead of getting its own horizontal scroll bar; give columns widths that fit.
485
+ */
486
+ stickyOffset?: number | string;
487
+ /**
488
+ * The scroll bars inside the grid. "thin" (default) is a slim bar, "auto" the browser's normal one,
489
+ * "hidden" shows none (scrolling still works) and "custom" adds no scroll bar style at all so
490
+ * your own CSS (`::-webkit-scrollbar`, ...) on `classNames.scroll` applies. The colours of "thin"
491
+ * come from `--rg-scrollbar-thumb` and `--rg-scrollbar-track`.
492
+ */
493
+ scrollbar?: "thin" | "auto" | "hidden" | "custom";
461
494
  /** Tailwind or any CSS classes for the root element. */
462
495
  className?: string;
463
496
  /** Inline styles for the root element. */
@@ -1,5 +1,5 @@
1
- "use strict";var ts=Object.create;var Ir=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var rs=Object.getOwnPropertyNames;var os=Object.getPrototypeOf,ss=Object.prototype.hasOwnProperty;var is=(t,n,s,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let f of rs(n))!ss.call(t,f)&&f!==s&&Ir(t,f,{get:()=>n[f],enumerable:!(o=ns(n,f))||o.enumerable});return t};var ls=(t,n,s)=>(s=t!=null?ts(os(t)):{},is(n||!t||!t.__esModule?Ir(s,"default",{value:t,enumerable:!0}):s,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),p=require("react"),as=require("react-dom"),vt=(...t)=>t.filter(Boolean).join(" ");function cs(){return l.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M3.5 8.5l3 3 6-7",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function ds(){return l.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M4 8h8",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})}function Xe({checked:t,onChange:n,indeterminate:s=!1,variant:o="native",disabled:f=!1,label:u,"aria-label":c,id:m,name:x,indicator:_,className:F,style:b,classNames:S={},styles:g={}}){const k=s?"indeterminate":t?"checked":"unchecked";return l.jsxs("label",{className:vt("rg-checkbox",`rg-checkbox--${o}`,k==="checked"&&"rg-checkbox--checked",s&&"rg-checkbox--indeterminate",f&&"rg-checkbox--disabled",S.root,F),style:{...g.root,...b},"data-state":k,children:[o==="native"?l.jsx("input",{type:"checkbox",id:m,name:x,ref:E=>{E&&(E.indeterminate=s)},className:vt("rg-checkbox__control",S.control),style:g.control,checked:t,disabled:f,"aria-label":c,"data-state":k,onChange:E=>n(E.target.checked)}):l.jsx("button",{type:"button",role:"checkbox",id:m,className:vt("rg-checkbox__control",S.control),style:g.control,"aria-checked":s?"mixed":t,"aria-label":c,disabled:f,"data-state":k,onClick:()=>n(!t),children:l.jsx("span",{className:vt("rg-checkbox__indicator",_!==void 0&&!s&&"rg-checkbox__indicator--custom",S.indicator),style:g.indicator,"data-state":k,"aria-hidden":"true",children:s?o==="tick"?l.jsx(ds,{}):null:_!==void 0?_:o==="tick"?l.jsx(cs,{}):null})}),u!=null&&u!==!1&&u!==""&&l.jsx("span",{className:vt("rg-checkbox__label",S.label),style:g.label,children:u})]})}const us=/^(\d{4})-(\d{2})-(\d{2})$/,$r=t=>String(t).padStart(2,"0");function oe(t){const n=us.exec(t);if(!n)return null;const[s,o,f]=[Number(n[1]),Number(n[2]),Number(n[3])],u=new Date(s,o-1,f);return u.getFullYear()===s&&u.getMonth()===o-1&&u.getDate()===f?u:null}function de(t){var n;if(t instanceof Date)return Number.isNaN(t.getTime())?null:`${t.getFullYear()}-${$r(t.getMonth()+1)}-${$r(t.getDate())}`;if(typeof t=="number")return Number.isFinite(t)?de(new Date(t)):null;if(typeof t=="string"){const s=t.trim();if(s==="")return null;const o=(n=/^\d{4}-\d{2}-\d{2}/.exec(s))==null?void 0:n[0];if(o)return oe(o)?o:null;const f=Date.parse(s);return Number.isNaN(f)?null:de(new Date(f))}return null}function fs(t,n,s){const o=de(t);return o?oe(o).toLocaleDateString(n,s??{year:"numeric",month:"short",day:"numeric"}):t==null?"":String(t)}function hs(t,n){var s;return t===""?null:n instanceof Date?oe(t):typeof n=="number"?((s=oe(t))==null?void 0:s.getTime())??null:t}const O=(...t)=>t.filter(Boolean).join(" "),jt=t=>t.headerName??(t.type==="boolean"?"":t.type==="sequence"?"#":t.field),He=t=>jt(t)||t.field,Rr=t=>String(t).padStart(2,"0"),Fn=(t,n,s)=>`${t}-${Rr(n+1)}-${Rr(s)}`;function Pr(t,n,s,o){const f=[t,n==null?void 0:n.from,n==null?void 0:n.to].map(x=>x?oe(x):null).find(Boolean);if(f)return new Date(f.getFullYear(),f.getMonth(),1);const u=new Date;let c=de(u);s&&c<s&&(c=s),o&&c>o&&(c=o);const m=oe(c)??u;return new Date(m.getFullYear(),m.getMonth(),1)}function eo({value:t,range:n,min:s,max:o,onPick:f,locale:u,weekStart:c=0,hideFooter:m,keepFocus:x,className:_}){var Ce;const[F,b]=p.useState(()=>Pr(t,n,s,o)),[S,g]=p.useState(null),k=p.useRef(null),E=p.useRef({value:t,from:n==null?void 0:n.from,to:n==null?void 0:n.to});p.useEffect(()=>{const w=E.current;E.current={value:t,from:n==null?void 0:n.from,to:n==null?void 0:n.to};const H=t!==w.value?t:(n==null?void 0:n.from)!==w.from?n==null?void 0:n.from:(n==null?void 0:n.to)!==w.to?n==null?void 0:n.to:void 0,j=H?oe(H):null;j&&b(A=>A.getFullYear()===j.getFullYear()&&A.getMonth()===j.getMonth()?A:new Date(j.getFullYear(),j.getMonth(),1))},[t,n==null?void 0:n.from,n==null?void 0:n.to]);const N=de(new Date),D=F.getFullYear(),v=F.getMonth(),$=p.useMemo(()=>{const w=new Intl.DateTimeFormat(u,{weekday:"short"});return Array.from({length:7},(H,j)=>w.format(new Date(2023,0,1+(j+c)%7)))},[u,c]),V=new Intl.DateTimeFormat(u,{month:"long",year:"numeric"}).format(F),K=p.useMemo(()=>{const w=(new Date(D,v,1).getDay()-c+7)%7;return Array.from({length:42},(H,j)=>{const A=new Date(D,v,1-w+j);return{iso:Fn(A.getFullYear(),A.getMonth(),A.getDate()),day:A.getDate(),outside:A.getMonth()!==v}})},[D,v,c]),L=w=>!!s&&w<s||!!o&&w>o,Y=w=>b(new Date(D,v+w,1)),_e=w=>{const H=oe(w);H&&((H.getFullYear()!==D||H.getMonth()!==v)&&b(new Date(H.getFullYear(),H.getMonth(),1)),g(w),requestAnimationFrame(()=>{var j,A;return(A=(j=k.current)==null?void 0:j.querySelector(`[data-iso="${w}"]`))==null?void 0:A.focus()}))},De=(w,H)=>{const j=oe(H),A=ie=>{w.preventDefault(),_e(Fn(j.getFullYear(),j.getMonth(),j.getDate()+ie))};switch(w.key){case"ArrowLeft":return A(-1);case"ArrowRight":return A(1);case"ArrowUp":return A(-7);case"ArrowDown":return A(7);case"Home":return A(-((j.getDay()-c+7)%7));case"End":return A(6-(j.getDay()-c+7)%7);case"PageUp":case"PageDown":{w.preventDefault();const ie=w.key==="PageUp"?-1:1,ue=new Date(j.getFullYear(),j.getMonth()+ie+1,0).getDate();_e(Fn(j.getFullYear(),j.getMonth()+ie,Math.min(j.getDate(),ue)));return}}},Oe=w=>!!w&&K.some(H=>H.iso===w&&!H.outside),je=[S,t,N].find(w=>Oe(w)&&!L(w))??((Ce=K.find(w=>!w.outside&&!L(w.iso)))==null?void 0:Ce.iso),z=n==null?void 0:n.from,se=n==null?void 0:n.to;return l.jsxs("div",{className:O("rg-cal",_),onMouseDown:x?w=>w.preventDefault():void 0,role:"group","aria-label":`Calendar, ${V}`,children:[l.jsxs("div",{className:"rg-cal__head",children:[l.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Previous year",onClick:()=>Y(-12),children:"«"}),l.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Previous month",onClick:()=>Y(-1),children:"‹"}),l.jsx("span",{className:"rg-cal__title","aria-live":"polite",children:V}),l.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Next month",onClick:()=>Y(1),children:"›"}),l.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Next year",onClick:()=>Y(12),children:"»"})]}),l.jsxs("div",{className:"rg-cal__grid",ref:k,children:[$.map(w=>l.jsx("span",{className:"rg-cal__dow","aria-hidden":"true",children:w.slice(0,2)},w)),K.map(({iso:w,day:H,outside:j})=>{const A=w===t,ie=w===z,ue=w===se,Ue=!!z&&!!se&&w>z&&w<se;return l.jsx("button",{type:"button","data-iso":w,tabIndex:w===je?0:-1,disabled:L(w),"aria-pressed":A||ie||ue,"aria-label":new Intl.DateTimeFormat(u,{dateStyle:"full"}).format(oe(w)),className:O("rg-cal__day",j&&"rg-cal__day--outside",w===N&&"rg-cal__day--today",(A||ie||ue)&&"rg-cal__day--selected",Ue&&"rg-cal__day--in-range",z&&se&&ie&&z!==se&&"rg-cal__day--range-start",z&&se&&ue&&z!==se&&"rg-cal__day--range-end"),onClick:()=>f(w),onKeyDown:Ge=>De(Ge,w),onFocus:()=>g(w),children:H},w)})]}),!m&&l.jsxs("div",{className:"rg-cal__foot",children:[l.jsx("button",{type:"button",className:"rg-cal__link",disabled:L(N),onClick:()=>{b(Pr(N)),f(N)},children:"Today"}),l.jsx("button",{type:"button",className:"rg-cal__link",onClick:()=>f(""),children:"Clear"})]})]})}const ln=typeof window<"u"?p.useLayoutEffect:p.useEffect;function kt(t,n,s){const[o,f]=p.useState(n),u=t!==void 0,c=u?t:o,m=p.useCallback(x=>{u||f(x),s==null||s(x)},[u,s]);return[c,m]}function to(t,n){const s=p.useRef(t);s.current=t;const o=p.useRef(void 0),f=p.useRef(null),u=p.useCallback(()=>{o.current!==void 0&&clearTimeout(o.current),o.current=void 0,f.current=null},[]),c=p.useCallback(()=>{o.current!==void 0&&clearTimeout(o.current),o.current=void 0;const x=f.current;f.current=null,x&&s.current(...x)},[]),m=p.useCallback((...x)=>{if(n<=0){u(),s.current(...x);return}f.current=x,o.current!==void 0&&clearTimeout(o.current),o.current=setTimeout(c,n)},[n,u,c]);return p.useEffect(()=>c,[c]),{call:m,flush:c,cancel:u}}function un({anchorRef:t,open:n,onClose:s,label:o,theme:f,className:u,style:c,keepFocus:m,children:x}){const _=p.useRef(null),[F,b]=p.useState({top:0,left:0}),S=p.useCallback(()=>{var D;const g=t.current;if(!g)return;const k=g.getBoundingClientRect(),E=((D=_.current)==null?void 0:D.offsetWidth)??260,N=Math.max(8,Math.min(k.left,window.innerWidth-E-8));b({top:k.bottom+6,left:N})},[t]);return ln(()=>{n&&S()},[n,S]),p.useEffect(()=>{if(!n)return;const g=E=>{var D,v;const N=E.target;(D=_.current)!=null&&D.contains(N)||(v=t.current)!=null&&v.contains(N)||s()},k=E=>{var N;E.key==="Escape"&&(s(),(N=t.current)==null||N.focus())};return document.addEventListener("mousedown",g),document.addEventListener("keydown",k),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",k),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[n,s,S,t]),!n||typeof document>"u"?null:as.createPortal(l.jsx("div",{ref:_,role:"dialog",onMouseDown:m?g=>g.preventDefault():void 0,"aria-label":o,"data-rg-theme":f||void 0,className:O("rg-grid-popup",u),style:{position:"fixed",top:F.top,left:F.left,...c},children:x}),document.body)}function ps({value:t,onChange:n,onPick:s,onBlur:o,onKeyDown:f,min:u,max:c,locale:m,invalid:x,label:_,theme:F,className:b,style:S}){const g=p.useRef(null),k=E=>{const N=E.ctrlKey||E.altKey||E.metaKey,D=E.key==="ArrowUp"?{days:-7,months:0}:E.key==="ArrowDown"?{days:7,months:0}:N&&E.key==="ArrowLeft"?{days:-1,months:0}:N&&E.key==="ArrowRight"?{days:1,months:0}:E.key==="PageUp"?{days:0,months:-1}:E.key==="PageDown"?{days:0,months:1}:null;if(!D||E.shiftKey)return f(E);E.preventDefault();const v=oe(t)??new Date,$=new Date(v.getFullYear(),v.getMonth()+D.months+1,0).getDate(),V=new Date(v.getFullYear(),v.getMonth()+D.months,Math.min(v.getDate(),$)+D.days);let K=de(V);u&&K<u&&(K=u),c&&K>c&&(K=c),n(K)};return l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:g,autoFocus:!0,type:"text",inputMode:"numeric",placeholder:"YYYY-MM-DD",autoComplete:"off",className:b,style:S,value:t,"aria-label":_,"aria-invalid":x||void 0,"aria-haspopup":"dialog","aria-expanded":!0,onChange:E=>n(E.target.value.trim()),onBlur:o,onKeyDown:k,onFocus:E=>E.currentTarget.setSelectionRange(E.currentTarget.value.length,E.currentTarget.value.length)}),l.jsx(un,{anchorRef:g,open:!0,onClose:()=>{},label:_,theme:F,className:"rg-date-popup",keepFocus:!0,children:l.jsx(eo,{value:t,min:u,max:c,locale:m,onPick:s,keepFocus:!0})})]})}function Lr(t){return t.filterType?t.filterType:t.type==="number"?"number":t.type==="date"?"date":t.type==="boolean"?"select":"text"}const Or=["contains","notContains","equals","notEquals","startsWith","notStartsWith","endsWith","notEndsWith"],Ur={contains:"Contains",notContains:"Does not contain",equals:"Equals",notEquals:"Not equal",startsWith:"Starts with",notStartsWith:"Does not start with",endsWith:"Ends with",notEndsWith:"Does not end with"};function no(t){const n=t.filterOperators;if(!n)return null;if(n===!0)return Or;const s=Or.filter(o=>n.includes(o));return s.length>0?s:null}function gs(t,n){const s=no(t),o=t.filterOperator??(n==="exact"?"equals":"contains");return s&&!s.includes(o)?s[0]:o}function Ar(t,n,s){const o=n.toLowerCase(),f=s.trim().toLowerCase();switch(t){case"contains":return o.includes(f);case"notContains":return!o.includes(f);case"equals":return o===f;case"notEquals":return o!==f;case"startsWith":return o.startsWith(f);case"notStartsWith":return!o.startsWith(f);case"endsWith":return o.endsWith(f);case"notEndsWith":return!o.endsWith(f)}}const ro=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function oo(t){if(t==null)return!1;if(typeof t=="string")return t.trim()!=="";if(Array.isArray(t))return t.length>0;if(ro(t)){const n=t;return typeof n.operator=="string"?typeof n.value=="string"&&n.value.trim()!=="":typeof n.min=="number"||typeof n.max=="number"||!!n.from||!!n.to}return!1}function ms(t,n,s,o){switch(t){case"text":case"exact":{if(ro(n)){const f=n;return Ar(f.operator,s,String(f.value??""))}return Ar(t==="exact"?"equals":"contains",s,String(n))}case"number":{const{min:f,max:u}=n,c=typeof o=="number"?o:o==null||o===""?NaN:Number(o);return Number.isNaN(c)?!1:(typeof f!="number"||c>=f)&&(typeof u!="number"||c<=u)}case"date":{const{from:f,to:u}=n,c=de(o);return c?(!f||c>=f)&&(!u||c<=u):!1}case"select":return n.includes(String(o??""))}}function xs(t,n,s,o){if(t.filterOptions)return t.filterOptions.map(u=>typeof u=="string"?{value:u,label:u}:u);if(t.type==="boolean")return[{value:"true",label:"Yes"},{value:"false",label:"No"}];const f=new Map;for(const u of n){const c=s(u);if(c==null||c==="")continue;const m=String(c);f.has(m)||f.set(m,o(u))}return[...f].map(([u,c])=>({value:u,label:c})).sort((u,c)=>u.label.localeCompare(c.label,void 0,{numeric:!0}))}const Br=t=>{if(t.trim()==="")return;const n=Number(t);return Number.isFinite(n)?n:void 0},On=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function bs({value:t,onChange:n,label:s,debounce:o,inputClassName:f,inputStyle:u}){const c=On(t)?t:{},[m,x]=p.useState(c.min===void 0?"":String(c.min)),[_,F]=p.useState(c.max===void 0?"":String(c.max)),b=p.useRef(c),S=to((g,k)=>{const E=Br(g),N=Br(k);b.current={min:E,max:N},n(E===void 0&&N===void 0?void 0:{min:E,max:N})},o);return p.useEffect(()=>{c.min===b.current.min&&c.max===b.current.max||(b.current=c,S.cancel(),x(c.min===void 0?"":String(c.min)),F(c.max===void 0?"":String(c.max)))},[c.min,c.max]),l.jsxs("div",{className:"rg-grid__filter-fields",children:[l.jsxs("label",{className:"rg-grid__filter-field",children:[l.jsx("span",{children:"Min"}),l.jsx("input",{autoFocus:!0,type:"number",className:O("rg-grid__filter-input",f),style:u,value:m,"aria-label":`Minimum ${s}`,onChange:g=>{x(g.target.value),S.call(g.target.value,_)},onKeyDown:g=>g.key==="Enter"&&S.flush()})]}),l.jsxs("label",{className:"rg-grid__filter-field",children:[l.jsx("span",{children:"Max"}),l.jsx("input",{type:"number",className:O("rg-grid__filter-input",f),style:u,value:_,"aria-label":`Maximum ${s}`,onChange:g=>{F(g.target.value),S.call(m,g.target.value)},onKeyDown:g=>g.key==="Enter"&&S.flush()})]})]})}function ys({value:t,onChange:n,onEnter:s,label:o,kind:f,placeholder:u,debounce:c,inputClassName:m,inputStyle:x}){const[_,F]=p.useState(t),b=p.useRef(t),S=to(g=>{b.current=g,n(g||void 0)},c);return p.useEffect(()=>{t!==b.current&&(b.current=t,S.cancel(),F(t))},[t]),l.jsx("input",{autoFocus:!0,type:"text",className:O("rg-grid__filter-input",m),style:x,value:_,placeholder:u??(f==="exact"?"Exactly…":`Filter ${o}…`),"aria-label":`Filter text for ${o}`,onChange:g=>{F(g.target.value),S.call(g.target.value)},onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),S.flush(),s())}})}function _s({value:t,onChange:n,label:s,inputClassName:o,inputStyle:f,min:u,max:c,locale:m}){const x=On(t)?t:{},_=(D,v)=>n(!D&&!v?void 0:{from:D||void 0,to:v||void 0}),[F,b]=p.useState(x.from??""),[S,g]=p.useState(x.to??"");p.useEffect(()=>{(oe(F)?F:"")!==(x.from??"")&&b(x.from??""),(oe(S)?S:"")!==(x.to??"")&&g(x.to??"")},[x.from,x.to]);const k=(D,v)=>{if((D==="from"?b:g)(v),v!==""&&!oe(v))return;const $=v||void 0;D==="from"?_($,x.to):_(x.from,$)},E=D=>{D&&(!x.from||x.to?_(D,void 0):D<x.from?_(D,x.from):_(x.from,D))},N=(D,v,$)=>l.jsxs("label",{className:"rg-grid__filter-field",children:[l.jsx("span",{children:D==="from"?"From":"To"}),l.jsx("input",{autoFocus:$,type:"text",inputMode:"numeric",placeholder:"YYYY-MM-DD",className:O("rg-grid__filter-input",v!==""&&!oe(v)&&"rg-grid__filter-input--invalid",o),style:f,value:v,"aria-label":`${s} ${D}`,"aria-invalid":v!==""&&!oe(v)||void 0,onChange:V=>k(D,V.target.value.trim())})]});return l.jsxs("div",{className:"rg-grid__filter-fields rg-grid__filter-fields--stack",children:[l.jsxs("div",{className:"rg-grid__filter-date-row",children:[N("from",F,!0),N("to",S,!1)]}),l.jsx(eo,{range:x,min:u,max:c,locale:m,onPick:E,hideFooter:!0})]})}function ws({value:t,onChange:n,options:s}){const o=Array.isArray(t)?t:[],f=(u,c)=>{const m=c?[...o,u]:o.filter(x=>x!==u);n(m.length?m:void 0)};return l.jsxs("div",{className:"rg-grid__filter-fields rg-grid__filter-options",role:"group",children:[s.length===0&&l.jsx("span",{className:"rg-grid__filter-empty",children:"No values"}),s.map(u=>l.jsx(Xe,{checked:o.includes(u.value),onChange:c=>f(u.value,c),label:u.label??u.value},u.value))]})}function vs({value:t,options:n,onChange:s,label:o}){const[f,u]=p.useState(!1),[c,m]=p.useState(0),x=p.useId(),_=p.useRef(null),F=()=>{m(Math.max(0,n.indexOf(t))),u(!0)},b=g=>{var k;s(g),u(!1),(k=_.current)==null||k.focus()},S=g=>{if(!f){(g.key==="ArrowDown"||g.key==="ArrowUp")&&(g.preventDefault(),F());return}switch(g.key){case"ArrowDown":g.preventDefault(),m(k=>Math.min(n.length-1,k+1));break;case"ArrowUp":g.preventDefault(),m(k=>Math.max(0,k-1));break;case"Home":g.preventDefault(),m(0);break;case"End":g.preventDefault(),m(n.length-1);break;case"Enter":case" ":g.preventDefault(),b(n[c]);break;case"Escape":g.preventDefault(),g.stopPropagation(),u(!1);break;case"Tab":u(!1);break}};return l.jsxs("div",{className:"rg-op",children:[l.jsxs("button",{ref:_,type:"button",className:"rg-op__btn",role:"combobox","aria-label":`Comparison for ${o}`,"aria-haspopup":"listbox","aria-expanded":f,"aria-controls":f?x:void 0,"aria-activedescendant":f?`${x}-${c}`:void 0,onClick:()=>f?u(!1):F(),onBlur:()=>u(!1),onKeyDown:S,children:[l.jsx("span",{className:"rg-op__value",children:Ur[t]}),l.jsx("svg",{className:"rg-op__chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5"})})]}),f&&l.jsx("ul",{id:x,role:"listbox",className:"rg-op__list","aria-label":`Comparisons for ${o}`,onMouseDown:g=>g.preventDefault(),children:n.map((g,k)=>l.jsxs("li",{id:`${x}-${k}`,role:"option","aria-selected":g===t,"data-op":g,className:O("rg-op__option",g===t&&"rg-op__option--selected",k===c&&"rg-op__option--active"),onMouseEnter:()=>m(k),onClick:()=>b(g),children:[Ur[g],g===t&&l.jsx("svg",{className:"rg-op__check",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M2.5 6.5 5 9l4.5-5.5"})})]},g))})]})}function ks({column:t,label:n,kind:s,value:o,onChange:f,options:u,debounce:c=300,theme:m,indicatorClassName:x,indicatorStyle:_,popupClassName:F,popupStyle:b,inputClassName:S,inputStyle:g}){const[k,E]=p.useState(!1),N=p.useRef(null),D=oo(o),v=p.useCallback(()=>E(!1),[]),$=On(o)?o:null,V=typeof o=="string"?o:typeof($==null?void 0:$.value)=="string"?$.value:"",K=(s==="text"||s==="exact")&&!t.filterRenderer?no(t):null,[L,Y]=p.useState(()=>gs(t,s)),_e=$&&typeof $.operator=="string"?$.operator:L,De=z=>{if(z===void 0)return f(void 0);f(K?{operator:_e,value:String(z)}:z)},Oe=z=>{Y(z),V.trim()!==""&&f({operator:z,value:V})},je=()=>{if(t.filterRenderer)return p.createElement(t.filterRenderer,{column:t,value:V,onChange:z=>f(z||void 0)});switch(s){case"number":return l.jsx(bs,{value:o,onChange:f,label:n,debounce:c,inputClassName:S,inputStyle:g});case"date":return l.jsx(_s,{value:o,onChange:f,label:n,min:t.dateMin,max:t.dateMax,locale:t.dateLocale,inputClassName:S,inputStyle:g});case"select":return l.jsx(ws,{value:o,onChange:f,options:u});default:return l.jsxs("div",{className:"rg-grid__filter-stack",children:[K&&l.jsx(vs,{value:_e,options:K,onChange:Oe,label:n}),l.jsx(ys,{value:V,onChange:De,onEnter:()=>{var z;E(!1),(z=N.current)==null||z.focus()},label:n,kind:s,placeholder:t.filterPlaceholder,debounce:c,inputClassName:S,inputStyle:g})]})}};return l.jsxs(l.Fragment,{children:[l.jsx("button",{ref:N,type:"button",className:O("rg-grid__filter-btn",D&&"rg-grid__filter-btn--active",k&&"rg-grid__filter-btn--open",x),style:_,"aria-label":`Filter ${n}`,"aria-haspopup":"dialog","aria-expanded":k,"data-active":D||void 0,onClick:z=>{z.stopPropagation(),E(se=>!se)},onKeyDown:z=>z.stopPropagation(),children:t.filterIndicator?p.createElement(t.filterIndicator,{column:t,active:D,open:k}):l.jsx("span",{className:"rg-grid__filter-dot","aria-hidden":"true"})}),l.jsxs(un,{anchorRef:N,open:k,onClose:v,label:`Filter ${n}`,theme:m,className:F,style:b,children:[je(),D&&l.jsx("button",{type:"button",className:"rg-grid__filter-clear",onClick:()=>f(void 0),children:"Clear"})]})]})}function Ss({columns:t,hidden:n,onToggle:s,theme:o,className:f,style:u}){const[c,m]=p.useState(!1),x=p.useRef(null),_=p.useCallback(()=>m(!1),[]),F=t.filter(b=>!n.has(b.field)).length;return l.jsxs(l.Fragment,{children:[l.jsx("button",{ref:x,type:"button",className:O("rg-grid__tool-btn",f),style:u,"aria-haspopup":"dialog","aria-expanded":c,onClick:()=>m(b=>!b),children:"Columns"}),l.jsx(un,{anchorRef:x,open:c,onClose:_,label:"Show or hide columns",theme:o,children:l.jsx("div",{className:"rg-grid__filter-fields rg-grid__filter-options",role:"group","aria-label":"Columns",children:t.filter(b=>b.hideable!==!1).map(b=>{const S=!n.has(b.field);return l.jsx(Xe,{checked:S,disabled:S&&F<=1,onChange:g=>s(b.field,!g),label:He(b)},b.field)})})})]})}const js=/^[=+\-@\t\r]/;function Cs(t,n,s){if(t==null)return"";let o=String(t);return s&&typeof t=="string"&&js.test(o)&&!Number.isFinite(Number(o))&&(o=`'${o}`),o.includes(n)||/["\r\n]/.test(o)?`"${o.replace(/"/g,'""')}"`:o}function Ns(t,n,s={}){const{delimiter:o=",",sanitize:f=!0}=s,u=c=>c.map(m=>Cs(m,o,f)).join(o);return[u(t),...n.map(u)].join(`\r
2
- `)}function an(t,n){if(typeof document>"u")return;const s=URL.createObjectURL(t),o=document.createElement("a");o.href=s,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}function Es(t,n){an(new Blob(["\uFEFF",t],{type:"text/csv;charset=utf-8"}),n)}const so={csv:"CSV",xlsx:"Excel",json:"JSON",pdf:"PDF"},Ds={csv:".csv",xlsx:".xlsx",json:".json",pdf:".pdf"},Ts=t=>`Export ${so[t]}`;function Fs({formats:t,scopes:n,scope:s,onScopeChange:o,onExport:f,theme:u,className:c,style:m,popupClassName:x}){const[_,F]=p.useState(!1),[b,S]=p.useState(null),g=p.useRef(null),k=p.useCallback(()=>F(!1),[]),E=async N=>{var D;S(N);try{await f(N,s)}finally{S(null),F(!1),(D=g.current)==null||D.focus()}};return l.jsxs(l.Fragment,{children:[l.jsxs("button",{ref:g,type:"button",className:O("rg-grid__tool-btn",c),style:m,"aria-haspopup":"dialog","aria-expanded":_,onClick:()=>F(N=>!N),children:["Export",l.jsx("svg",{className:"rg-export__chevron",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5"})})]}),l.jsx(un,{anchorRef:g,open:_,onClose:k,label:"Export",theme:u,className:O("rg-export-popup",x),children:l.jsxs("div",{className:"rg-export",children:[n.length>1&&l.jsxs("div",{className:"rg-export__group",role:"radiogroup","aria-label":"Rows to export",children:[l.jsx("div",{className:"rg-export__title",children:"Rows to export"}),n.map(N=>{const D=N.count===0;return l.jsxs("label",{className:O("rg-export__scope",D&&"rg-export__scope--disabled",N.value===s&&"rg-export__scope--on"),children:[l.jsx("input",{type:"radio",name:"rg-export-scope",value:N.value,checked:N.value===s,disabled:D,onChange:()=>o(N.value)}),l.jsx("span",{className:"rg-export__scope-label",children:N.label}),l.jsx("span",{className:"rg-export__count",children:N.count})]},N.value)})]}),l.jsxs("div",{className:"rg-export__group",children:[l.jsx("div",{className:"rg-export__title",children:"Download as"}),t.map(N=>l.jsxs("button",{type:"button",className:"rg-export__format","data-format":N,disabled:b!==null,onClick:()=>E(N),children:[l.jsx("span",{children:so[N]}),l.jsx("span",{className:"rg-export__ext",children:b===N?"Preparing…":Ds[N]})]},N))]})]})})]})}let be;function ce(t){const n=(t??"").trim();if(!n||n==="transparent"||n==="none")return null;const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(n);if(s){let _=s[1];return _.length===3&&(_=_.split("").map(F=>F+F).join("")),[parseInt(_.slice(0,2),16),parseInt(_.slice(2,4),16),parseInt(_.slice(4,6),16)]}const o=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(n);if(o)return Wr([Number(o[1]),Number(o[2]),Number(o[3])],Ms(o[4]));if(typeof document>"u"||(be===void 0&&(be=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})),!be))return null;be.fillStyle="#000000",be.fillStyle=n;const f=String(be.fillStyle);if(be.fillStyle="#ffffff",be.fillStyle=n,f!==String(be.fillStyle))return null;be.clearRect(0,0,1,1),be.fillRect(0,0,1,1);const[u,c,m,x]=be.getImageData(0,0,1,1).data;return x===0?null:Wr([u,c,m],x/255)}const Ms=t=>t===void 0?1:t.endsWith("%")?parseFloat(t)/100:parseFloat(t);function Wr(t,n){if(!(n>0))return null;const s=Math.min(1,n);return t.map(o=>Math.round(Math.min(255,o)*s+255*(1-s)))}const Is=([t,n,s])=>(.299*t+.587*n+.114*s)/255,Mn=t=>Is(t)>.55?[31,41,55]:[243,244,246],In=72/96,Ct="Install them with: npm install jspdf jspdf-autotable (and html2canvas for header / footer elements), then pass them in exportable.pdf.libraries.";async function Kr(t,n){try{return await n()}catch(s){const o=s instanceof Error?s.message:String(s);throw new Error(`PDF export needs the package "${t}", which could not be loaded (${o}). ${Ct}`)}}function qr(t,n,s){return t.replace(/\{page\}/g,String(n)).replace(/\{pages\}/g,String(s)).replace(/\{date\}/g,new Date().toLocaleDateString())}async function $s(t){const n=Array.from(t.querySelectorAll("img")).map(s=>s.complete?Promise.resolve():new Promise(o=>{s.addEventListener("load",()=>o(),{once:!0}),s.addEventListener("error",()=>o(),{once:!0})}));await Promise.race([Promise.all(n),new Promise(s=>setTimeout(s,5e3))])}async function Rs(t,n,s,o,f){const u=s.html2canvas;if(typeof u!="function")throw new Error(`A PDF header / footer element needs html2canvas. Add it to exportable.pdf.libraries. ${Ct}`);const[c,m]=await Promise.all([Kr("react-dom/client",()=>Promise.resolve().then(()=>require("./client-40__X0_a.cjs")).then(b=>b.client)),Kr("react-dom",()=>import("react-dom"))]),x=2,_=document.createElement("div");_.style.cssText=`position:fixed;left:-10000px;top:0;width:${Math.round(n/In)}px;background:${o};color:${f};font-family:system-ui,sans-serif;font-size:14px;`,document.body.appendChild(_);const F=c.createRoot(_);try{m.flushSync(()=>F.render(t)),await $s(_),await new Promise(S=>requestAnimationFrame(()=>S(void 0)));const b=await u(_,{scale:x,backgroundColor:o,useCORS:!0,logging:!1});return{dataUrl:b.toDataURL("image/png"),width:b.width/x*In,height:b.height/x*In}}finally{F.unmount(),_.remove()}}async function $n(t,n,s,o,f,u){if(t==null||t===!1||t===!0||t==="")return null;if(typeof t=="string"||typeof t=="number")return{kind:"text",text:String(t)};const c=await Rs(t,n,o,f,u),m=Math.min(1,n/c.width,s/c.height);return{kind:"image",dataUrl:c.dataUrl,width:c.width*m,height:c.height*m}}const zr=t=>`rgb(${t[0]},${t[1]},${t[2]})`,Yr=["normal","bold","italic","bolditalic"];function Vr(t,n){return typeof t=="number"?{top:t,right:t,bottom:t,left:t}:{top:(t==null?void 0:t.top)??n,right:(t==null?void 0:t.right)??n,bottom:(t==null?void 0:t.bottom)??n,left:(t==null?void 0:t.left)??n}}function Hr(t){return Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0))}async function Ps(t,n={},s={}){var Ze,Ne;let o;try{o=typeof n.libraries=="function"?await n.libraries():n.libraries}catch(T){const G=T instanceof Error?T.message:String(T);throw new Error(`PDF export could not load jspdf / jspdf-autotable (${G}). ${Ct}`)}if(!o)throw new Error(`PDF export needs the jspdf and jspdf-autotable libraries. ${Ct}`);const f=o.jsPDF,u=o.autoTable;if(typeof f!="function"||typeof u!="function")throw new Error(`exportable.pdf.libraries must contain jsPDF (a class) and autoTable (a function). ${Ct}`);const{title:c,header:m,footer:x,headerAlign:_="left",footerAlign:F="center",orientation:b="auto",pageSize:S="a4",tableTheme:g="striped",pageNumbers:k=!0,maxImageHeight:E=90,beforeRender:N,autoTableOptions:D}=n,v={...s,...Hr({headColor:n.headColor,headTextColor:n.headTextColor,fontSize:n.fontSize,fontName:n.fontName,margin:n.margin}),...Hr(n.style??{})},$=Vr(v.margin,36),V=v.fontName??"helvetica",K=v.fontSize??9,L=ce(v.pageBackground),Y=L?Mn(L):[75,85,99],_e=ce(v.textColor)??Y,De=ce(v.titleColor)??(L?Mn(L):[17,24,39]),Oe=ce(v.headColor)??[79,70,229],je=ce(v.headTextColor)??[255,255,255],z=ce(v.bodyTextColor),se=ce((Ze=v.stripeColors)==null?void 0:Ze[0]),Ce=ce((Ne=v.stripeColors)==null?void 0:Ne[1]),w=ce(v.bodyColor)??se??L??void 0,H=ce(v.borderColor),j=new f({orientation:b==="auto"?t.headers.length>6?"landscape":"portrait":b,unit:"pt",format:S});N&&await N(j);const A=j.internal.pageSize.getWidth(),ie=j.internal.pageSize.getHeight(),ue=A-$.left-$.right,Ue=10,Ge=12,Nt=new Set,lt=T=>{!L||Nt.has(T)||(Nt.add(T),j.setFillColor(...L),j.rect(0,0,A,ie,"F"))};lt(1);const Ae=L?zr(L):"#ffffff",Be=zr(_e),le=await $n(m,ue,E,o,Ae,Be),fe=await $n(x,ue,E,o,Ae,Be);j.setFont(V,"normal"),j.setFontSize(Ue);const at=T=>T?T.kind==="image"?T.height:j.splitTextToSize(qr(T.text,99,99),ue).length*Ge:0,We=at(le),ct=at(fe),Te=Math.min(18,$.top),dt=ie-14,ut=ie-(k?26:18),Et=le?Math.max($.top,Te+We+12):$.top,ft=Math.max($.bottom,fe?ie-ut+ct+10:k?34:0);let Ke=Et;if(c&&typeof c!="string"&&typeof c!="number"&&typeof c!="boolean"){const T=await $n(c,ue,E,o,Ae,Be);T&&T.kind==="image"&&(j.addImage(T.dataUrl,"PNG",$.left,Ke,T.width,T.height),Ke+=T.height+12)}else c&&(j.setFont(V,"bold"),j.setFontSize(v.titleSize??14),j.setTextColor(...De),j.text(String(c),$.left,Ke+(v.titleSize??14)),Ke+=(v.titleSize??14)+12);const Dt={};t.fields.forEach((T,G)=>{var tt;const R=(tt=v.columns)==null?void 0:tt[T],me={},q=(R==null?void 0:R.align)??t.aligns[G];q&&(me.halign=q),(R==null?void 0:R.width)!==void 0&&(me.cellWidth=R.width);const U=ce(R==null?void 0:R.textColor);U&&(me.textColor=U);const et=ce(R==null?void 0:R.backgroundColor);et&&(me.fillColor=et),R!=null&&R.fontStyle&&Yr.includes(R.fontStyle)&&(me.fontStyle=R.fontStyle),R!=null&&R.fontSize&&(me.fontSize=R.fontSize),Object.keys(me).length>0&&(Dt[G]=me)});const ge={font:V,fontSize:K,cellPadding:Vr(v.cellPadding,4),overflow:"linebreak",valign:"middle"};z?ge.textColor=z:L&&(ge.textColor=Mn(L)),H&&(ge.lineColor=H),v.borderWidth!==void 0?ge.lineWidth=v.borderWidth:H&&(ge.lineWidth=.5),v.minRowHeight&&(ge.minCellHeight=v.minRowHeight);const ve={head:[t.headers],body:t.rows,startY:Ke,margin:{top:Et,right:$.right,bottom:ft,left:$.left},theme:g,showHead:"everyPage",styles:ge,headStyles:{fillColor:Oe,textColor:je,fontStyle:v.headFontStyle&&Yr.includes(v.headFontStyle)?v.headFontStyle:"bold",...v.headFontSize?{fontSize:v.headFontSize}:null},columnStyles:Dt,willDrawPage:()=>{var G,R;const T=typeof j.getCurrentPageInfo=="function"?j.getCurrentPageInfo():(R=(G=j.internal).getCurrentPageInfo)==null?void 0:R.call(G);T!=null&&T.pageNumber&&lt(T.pageNumber)}};w&&(ve.bodyStyles={fillColor:w}),se&&Ce?(ve.bodyStyles={fillColor:se},ve.alternateRowStyles={fillColor:Ce}):(se||w)&&(ve.alternateRowStyles={fillColor:w});const Tt={...ve,...D};for(const T of["styles","headStyles","bodyStyles","alternateRowStyles","margin"]){const G=ve[T],R=D==null?void 0:D[T];G&&R&&typeof R=="object"&&(Tt[T]={...G,...R})}u(j,Tt);const ee=typeof j.getNumberOfPages=="function"?j.getNumberOfPages():j.internal.getNumberOfPages(),Je=(T,G)=>T==="center"?(A-G)/2:T==="right"?A-$.right-G:$.left,Qe=(T,G,R,me)=>{if(!T)return;if(T.kind==="image"){j.addImage(T.dataUrl,"PNG",Je(R,T.width),G,T.width,T.height);return}j.setFont(V,"normal"),j.setFontSize(Ue),j.setTextColor(..._e);const q=j.splitTextToSize(qr(T.text,me,ee),ue),U=R==="center"?A/2:R==="right"?A-$.right:$.left;j.text(q,U,G+Ue,{align:R})};for(let T=1;T<=ee;T++)j.setPage(T),Qe(le,Te,_,T),Qe(fe,ut-ct,F,T),k&&(j.setFont(V,"normal"),j.setFontSize(8),j.setTextColor(..._e),j.text(`Page ${T} of ${ee}`,A-$.right,dt,{align:"right"}));return j.output("blob")}function Ls(t){var F;if(!t||typeof getComputedStyle>"u")return{};const n={},s=b=>b?getComputedStyle(b):null,o=b=>{var S;for(let g=b;g;g=g.parentElement){const k=(S=s(g))==null?void 0:S.backgroundColor;if(k&&ce(k))return k}},f=b=>{const S=ce(b);return S?"#"+S.map(g=>g.toString(16).padStart(2,"0")).join(""):void 0},u=b=>b?Math.round(parseFloat(b)*.75*10)/10:void 0,c=t.querySelector("thead th");if(c){const b=s(c);n.headColor=f(o(c)),n.headTextColor=f(b.color),n.headFontStyle=parseInt(b.fontWeight,10)>=600?"bold":"normal"}const m=Array.from(t.querySelectorAll("tbody tr.rg-grid__row:not(.rg-grid__row--exit)")).slice(0,2),x=(F=m[0])==null?void 0:F.querySelector("td");if(x){const b=s(x);n.bodyTextColor=f(b.color);const S=u(b.fontSize);S&&!Number.isNaN(S)&&(n.fontSize=Math.min(14,Math.max(6,S)));const g=f(o(m[0].querySelector("td"))),k=f(m[1]?o(m[1].querySelector("td")):void 0);n.bodyColor=g,g&&k&&g!==k&&(n.stripeColors=[g,k]);const E=s(x);parseFloat(E.borderBottomWidth)>0&&E.borderBottomStyle!=="none"&&(n.borderColor=f(E.borderBottomColor),n.borderWidth=.5)}const _=f(o(t));return _&&_!=="#ffffff"&&(n.pageBackground=_),n.textColor=f(s(t).color),n.fontName=void 0,Object.keys(n).forEach(b=>n[b]===void 0&&delete n[b]),n}const Os={none:0,asc:0,desc:180};function io({direction:t,size:n=14,priority:s,className:o,style:f}){const u=p.useRef(0),m=((Os[t??"none"]-u.current)%360+360)%360;return u.current+=m,l.jsxs("span",{className:O("rg-sort-arrow",t&&"rg-sort-arrow--active",o),style:f,"data-direction":t??"none",children:[l.jsxs("svg",{className:"rg-sort-arrow__icon",width:n,height:n,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{transform:`rotate(${u.current}deg)`},children:[l.jsx("path",{d:"M8 13V3"}),l.jsx("path",{d:"M3.5 7.5 8 3l4.5 4.5"})]}),t&&s!==void 0&&l.jsx("sup",{className:"rg-sort-arrow__order",children:s})]})}const lo=new TextEncoder;let sn=null;function Us(t){if(!sn){sn=new Uint32Array(256);for(let s=0;s<256;s++){let o=s;for(let f=0;f<8;f++)o=o&1?3988292384^o>>>1:o>>>1;sn[s]=o>>>0}}let n=4294967295;for(let s=0;s<t.length;s++)n=sn[(n^t[s])&255]^n>>>8;return(n^4294967295)>>>0}async function As(t){const n=globalThis.CompressionStream;if(typeof n>"u")return null;try{const s=new Blob([t]).stream().pipeThrough(new n("deflate-raw"));return new Uint8Array(await new Response(s).arrayBuffer())}catch{return null}}async function Bs(t){const n=new Date,s=n.getHours()<<11|n.getMinutes()<<5|n.getSeconds()>>1,o=n.getFullYear()-1980<<9|n.getMonth()+1<<5|n.getDate(),f=[],u=[];let c=0;for(const g of t){const k=lo.encode(g.name),E=Us(g.data),N=await As(g.data),D=N!==null&&N.length<g.data.length,v=D?N:g.data,$=D?8:0,V=new Uint8Array(30+k.length),K=new DataView(V.buffer);K.setUint32(0,67324752,!0),K.setUint16(4,20,!0),K.setUint16(6,2048,!0),K.setUint16(8,$,!0),K.setUint16(10,s,!0),K.setUint16(12,o,!0),K.setUint32(14,E,!0),K.setUint32(18,v.length,!0),K.setUint32(22,g.data.length,!0),K.setUint16(26,k.length,!0),K.setUint16(28,0,!0),V.set(k,30);const L=new Uint8Array(46+k.length),Y=new DataView(L.buffer);Y.setUint32(0,33639248,!0),Y.setUint16(4,20,!0),Y.setUint16(6,20,!0),Y.setUint16(8,2048,!0),Y.setUint16(10,$,!0),Y.setUint16(12,s,!0),Y.setUint16(14,o,!0),Y.setUint32(16,E,!0),Y.setUint32(20,v.length,!0),Y.setUint32(24,g.data.length,!0),Y.setUint16(28,k.length,!0),Y.setUint32(42,c,!0),L.set(k,46),f.push(V,v),u.push(L),c+=V.length+v.length}const m=u.reduce((g,k)=>g+k.length,0),x=new Uint8Array(22),_=new DataView(x.buffer);_.setUint32(0,101010256,!0),_.setUint16(8,t.length,!0),_.setUint16(10,t.length,!0),_.setUint32(12,m,!0),_.setUint32(16,c,!0);const F=[...f,...u,x],b=new Uint8Array(F.reduce((g,k)=>g+k.length,0));let S=0;for(const g of F)b.set(g,S),S+=g.length;return b}function dn(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F￾￿]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function cn(t){let n=t+1,s="";for(;n>0;){const o=(n-1)%26;s=String.fromCharCode(65+o)+s,n=Math.floor((n-1)/26)}return s}function Ws(t){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!n)return null;const[s,o,f]=[Number(n[1]),Number(n[2]),Number(n[3])],u=new Date(Date.UTC(s,o-1,f));return u.getUTCFullYear()!==s||u.getUTCMonth()!==o-1||u.getUTCDate()!==f?null:Math.round((u.getTime()-Date.UTC(1899,11,30))/864e5)}function Ks(t){return(t??"").replace(/[\[\]:*?/\\]/g," ").trim().slice(0,31)||"Sheet1"}const qs=1,zs=2,Ys=3,Vs=4,Hs=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";var xs=Object.create;var Wr=Object.defineProperty;var bs=Object.getOwnPropertyDescriptor;var ys=Object.getOwnPropertyNames;var _s=Object.getPrototypeOf,ws=Object.prototype.hasOwnProperty;var vs=(t,n,o,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let f of ys(n))!ws.call(t,f)&&f!==o&&Wr(t,f,{get:()=>n[f],enumerable:!(s=bs(n,f))||s.enumerable});return t};var ks=(t,n,o)=>(o=t!=null?xs(_s(t)):{},vs(n||!t||!t.__esModule?Wr(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),p=require("react"),Ss=require("react-dom"),kt=(...t)=>t.filter(Boolean).join(" ");function js(){return i.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:i.jsx("path",{d:"M3.5 8.5l3 3 6-7",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Cs(){return i.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:i.jsx("path",{d:"M4 8h8",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})}function Je({checked:t,onChange:n,indeterminate:o=!1,variant:s="native",disabled:f=!1,label:u,"aria-label":c,id:m,name:x,indicator:_,className:F,style:b,classNames:S={},styles:g={}}){const k=o?"indeterminate":t?"checked":"unchecked";return i.jsxs("label",{className:kt("rg-checkbox",`rg-checkbox--${s}`,k==="checked"&&"rg-checkbox--checked",o&&"rg-checkbox--indeterminate",f&&"rg-checkbox--disabled",S.root,F),style:{...g.root,...b},"data-state":k,children:[s==="native"?i.jsx("input",{type:"checkbox",id:m,name:x,ref:E=>{E&&(E.indeterminate=o)},className:kt("rg-checkbox__control",S.control),style:g.control,checked:t,disabled:f,"aria-label":c,"data-state":k,onChange:E=>n(E.target.checked)}):i.jsx("button",{type:"button",role:"checkbox",id:m,className:kt("rg-checkbox__control",S.control),style:g.control,"aria-checked":o?"mixed":t,"aria-label":c,disabled:f,"data-state":k,onClick:()=>n(!t),children:i.jsx("span",{className:kt("rg-checkbox__indicator",_!==void 0&&!o&&"rg-checkbox__indicator--custom",S.indicator),style:g.indicator,"data-state":k,"aria-hidden":"true",children:o?s==="tick"?i.jsx(Cs,{}):null:_!==void 0?_:s==="tick"?i.jsx(js,{}):null})}),u!=null&&u!==!1&&u!==""&&i.jsx("span",{className:kt("rg-checkbox__label",S.label),style:g.label,children:u})]})}const Ns=/^(\d{4})-(\d{2})-(\d{2})$/,Br=t=>String(t).padStart(2,"0");function re(t){const n=Ns.exec(t);if(!n)return null;const[o,s,f]=[Number(n[1]),Number(n[2]),Number(n[3])],u=new Date(o,s-1,f);return u.getFullYear()===o&&u.getMonth()===s-1&&u.getDate()===f?u:null}function ue(t){var n;if(t instanceof Date)return Number.isNaN(t.getTime())?null:`${t.getFullYear()}-${Br(t.getMonth()+1)}-${Br(t.getDate())}`;if(typeof t=="number")return Number.isFinite(t)?ue(new Date(t)):null;if(typeof t=="string"){const o=t.trim();if(o==="")return null;const s=(n=/^\d{4}-\d{2}-\d{2}/.exec(o))==null?void 0:n[0];if(s)return re(s)?s:null;const f=Date.parse(o);return Number.isNaN(f)?null:ue(new Date(f))}return null}function Es(t,n,o){const s=ue(t);return s?re(s).toLocaleDateString(n,o??{year:"numeric",month:"short",day:"numeric"}):t==null?"":String(t)}function Ds(t,n){var o;return t===""?null:n instanceof Date?re(t):typeof n=="number"?((o=re(t))==null?void 0:o.getTime())??null:t}const O=(...t)=>t.filter(Boolean).join(" "),Ct=t=>t.headerName??(t.type==="boolean"?"":t.type==="sequence"?"#":t.field),Ge=t=>Ct(t)||t.field,Kr=t=>String(t).padStart(2,"0"),Ln=(t,n,o)=>`${t}-${Kr(n+1)}-${Kr(o)}`;function qr(t,n,o,s){const f=[t,n==null?void 0:n.from,n==null?void 0:n.to].map(x=>x?re(x):null).find(Boolean);if(f)return new Date(f.getFullYear(),f.getMonth(),1);const u=new Date;let c=ue(u);o&&c<o&&(c=o),s&&c>s&&(c=s);const m=re(c)??u;return new Date(m.getFullYear(),m.getMonth(),1)}function ao({value:t,range:n,min:o,max:s,onPick:f,locale:u,weekStart:c=0,hideFooter:m,keepFocus:x,className:_}){var je;const[F,b]=p.useState(()=>qr(t,n,o,s)),[S,g]=p.useState(null),k=p.useRef(null),E=p.useRef({value:t,from:n==null?void 0:n.from,to:n==null?void 0:n.to});p.useEffect(()=>{const w=E.current;E.current={value:t,from:n==null?void 0:n.from,to:n==null?void 0:n.to};const H=t!==w.value?t:(n==null?void 0:n.from)!==w.from?n==null?void 0:n.from:(n==null?void 0:n.to)!==w.to?n==null?void 0:n.to:void 0,j=H?re(H):null;j&&b(A=>A.getFullYear()===j.getFullYear()&&A.getMonth()===j.getMonth()?A:new Date(j.getFullYear(),j.getMonth(),1))},[t,n==null?void 0:n.from,n==null?void 0:n.to]);const N=ue(new Date),T=F.getFullYear(),v=F.getMonth(),R=p.useMemo(()=>{const w=new Intl.DateTimeFormat(u,{weekday:"short"});return Array.from({length:7},(H,j)=>w.format(new Date(2023,0,1+(j+c)%7)))},[u,c]),Y=new Intl.DateTimeFormat(u,{month:"long",year:"numeric"}).format(F),K=p.useMemo(()=>{const w=(new Date(T,v,1).getDay()-c+7)%7;return Array.from({length:42},(H,j)=>{const A=new Date(T,v,1-w+j);return{iso:Ln(A.getFullYear(),A.getMonth(),A.getDate()),day:A.getDate(),outside:A.getMonth()!==v}})},[T,v,c]),U=w=>!!o&&w<o||!!s&&w>s,z=w=>b(new Date(T,v+w,1)),ye=w=>{const H=re(w);H&&((H.getFullYear()!==T||H.getMonth()!==v)&&b(new Date(H.getFullYear(),H.getMonth(),1)),g(w),requestAnimationFrame(()=>{var j,A;return(A=(j=k.current)==null?void 0:j.querySelector(`[data-iso="${w}"]`))==null?void 0:A.focus()}))},De=(w,H)=>{const j=re(H),A=le=>{w.preventDefault(),ye(Ln(j.getFullYear(),j.getMonth(),j.getDate()+le))};switch(w.key){case"ArrowLeft":return A(-1);case"ArrowRight":return A(1);case"ArrowUp":return A(-7);case"ArrowDown":return A(7);case"Home":return A(-((j.getDay()-c+7)%7));case"End":return A(6-(j.getDay()-c+7)%7);case"PageUp":case"PageDown":{w.preventDefault();const le=w.key==="PageUp"?-1:1,fe=new Date(j.getFullYear(),j.getMonth()+le+1,0).getDate();ye(Ln(j.getFullYear(),j.getMonth()+le,Math.min(j.getDate(),fe)));return}}},Oe=w=>!!w&&K.some(H=>H.iso===w&&!H.outside),Se=[S,t,N].find(w=>Oe(w)&&!U(w))??((je=K.find(w=>!w.outside&&!U(w.iso)))==null?void 0:je.iso),q=n==null?void 0:n.from,oe=n==null?void 0:n.to;return i.jsxs("div",{className:O("rg-cal",_),onMouseDown:x?w=>w.preventDefault():void 0,role:"group","aria-label":`Calendar, ${Y}`,children:[i.jsxs("div",{className:"rg-cal__head",children:[i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Previous year",onClick:()=>z(-12),children:"«"}),i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Previous month",onClick:()=>z(-1),children:"‹"}),i.jsx("span",{className:"rg-cal__title","aria-live":"polite",children:Y}),i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Next month",onClick:()=>z(1),children:"›"}),i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Next year",onClick:()=>z(12),children:"»"})]}),i.jsxs("div",{className:"rg-cal__grid",ref:k,children:[R.map(w=>i.jsx("span",{className:"rg-cal__dow","aria-hidden":"true",children:w.slice(0,2)},w)),K.map(({iso:w,day:H,outside:j})=>{const A=w===t,le=w===q,fe=w===oe,Ue=!!q&&!!oe&&w>q&&w<oe;return i.jsx("button",{type:"button","data-iso":w,tabIndex:w===Se?0:-1,disabled:U(w),"aria-pressed":A||le||fe,"aria-label":new Intl.DateTimeFormat(u,{dateStyle:"full"}).format(re(w)),className:O("rg-cal__day",j&&"rg-cal__day--outside",w===N&&"rg-cal__day--today",(A||le||fe)&&"rg-cal__day--selected",Ue&&"rg-cal__day--in-range",q&&oe&&le&&q!==oe&&"rg-cal__day--range-start",q&&oe&&fe&&q!==oe&&"rg-cal__day--range-end"),onClick:()=>f(w),onKeyDown:Qe=>De(Qe,w),onFocus:()=>g(w),children:H},w)})]}),!m&&i.jsxs("div",{className:"rg-cal__foot",children:[i.jsx("button",{type:"button",className:"rg-cal__link",disabled:U(N),onClick:()=>{b(qr(N)),f(N)},children:"Today"}),i.jsx("button",{type:"button",className:"rg-cal__link",onClick:()=>f(""),children:"Clear"})]})]})}const Nt=typeof window<"u"?p.useLayoutEffect:p.useEffect;function St(t,n,o){const[s,f]=p.useState(n),u=t!==void 0,c=u?t:s,m=p.useCallback(x=>{u||f(x),o==null||o(x)},[u,o]);return[c,m]}function co(t,n){const o=p.useRef(t);o.current=t;const s=p.useRef(void 0),f=p.useRef(null),u=p.useCallback(()=>{s.current!==void 0&&clearTimeout(s.current),s.current=void 0,f.current=null},[]),c=p.useCallback(()=>{s.current!==void 0&&clearTimeout(s.current),s.current=void 0;const x=f.current;f.current=null,x&&o.current(...x)},[]),m=p.useCallback((...x)=>{if(n<=0){u(),o.current(...x);return}f.current=x,s.current!==void 0&&clearTimeout(s.current),s.current=setTimeout(c,n)},[n,u,c]);return p.useEffect(()=>c,[c]),{call:m,flush:c,cancel:u}}function mn({anchorRef:t,open:n,onClose:o,label:s,theme:f,className:u,style:c,keepFocus:m,children:x}){const _=p.useRef(null),[F,b]=p.useState({top:0,left:0}),S=p.useCallback(()=>{var T;const g=t.current;if(!g)return;const k=g.getBoundingClientRect(),E=((T=_.current)==null?void 0:T.offsetWidth)??260,N=Math.max(8,Math.min(k.left,window.innerWidth-E-8));b({top:k.bottom+6,left:N})},[t]);return Nt(()=>{n&&S()},[n,S]),p.useEffect(()=>{if(!n)return;const g=E=>{var T,v;const N=E.target;(T=_.current)!=null&&T.contains(N)||(v=t.current)!=null&&v.contains(N)||o()},k=E=>{var N;E.key==="Escape"&&(o(),(N=t.current)==null||N.focus())};return document.addEventListener("mousedown",g),document.addEventListener("keydown",k),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",k),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[n,o,S,t]),!n||typeof document>"u"?null:Ss.createPortal(i.jsx("div",{ref:_,role:"dialog",onMouseDown:m?g=>g.preventDefault():void 0,"aria-label":s,"data-rg-theme":f||void 0,className:O("rg-grid-popup",u),style:{position:"fixed",top:F.top,left:F.left,...c},children:x}),document.body)}function Ts({value:t,onChange:n,onPick:o,onBlur:s,onKeyDown:f,min:u,max:c,locale:m,invalid:x,label:_,theme:F,className:b,style:S}){const g=p.useRef(null),k=E=>{const N=E.ctrlKey||E.altKey||E.metaKey,T=E.key==="ArrowUp"?{days:-7,months:0}:E.key==="ArrowDown"?{days:7,months:0}:N&&E.key==="ArrowLeft"?{days:-1,months:0}:N&&E.key==="ArrowRight"?{days:1,months:0}:E.key==="PageUp"?{days:0,months:-1}:E.key==="PageDown"?{days:0,months:1}:null;if(!T||E.shiftKey)return f(E);E.preventDefault();const v=re(t)??new Date,R=new Date(v.getFullYear(),v.getMonth()+T.months+1,0).getDate(),Y=new Date(v.getFullYear(),v.getMonth()+T.months,Math.min(v.getDate(),R)+T.days);let K=ue(Y);u&&K<u&&(K=u),c&&K>c&&(K=c),n(K)};return i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:g,autoFocus:!0,type:"text",inputMode:"numeric",placeholder:"YYYY-MM-DD",autoComplete:"off",className:b,style:S,value:t,"aria-label":_,"aria-invalid":x||void 0,"aria-haspopup":"dialog","aria-expanded":!0,onChange:E=>n(E.target.value.trim()),onBlur:s,onKeyDown:k,onFocus:E=>E.currentTarget.setSelectionRange(E.currentTarget.value.length,E.currentTarget.value.length)}),i.jsx(mn,{anchorRef:g,open:!0,onClose:()=>{},label:_,theme:F,className:"rg-date-popup",keepFocus:!0,children:i.jsx(ao,{value:t,min:u,max:c,locale:m,onPick:o,keepFocus:!0})})]})}function zr(t){return t.filterType?t.filterType:t.type==="number"?"number":t.type==="date"?"date":t.type==="boolean"?"select":"text"}const Yr=["contains","notContains","equals","notEquals","startsWith","notStartsWith","endsWith","notEndsWith"],Vr={contains:"Contains",notContains:"Does not contain",equals:"Equals",notEquals:"Not equal",startsWith:"Starts with",notStartsWith:"Does not start with",endsWith:"Ends with",notEndsWith:"Does not end with"};function uo(t){const n=t.filterOperators;if(!n)return null;if(n===!0)return Yr;const o=Yr.filter(s=>n.includes(s));return o.length>0?o:null}function Fs(t,n){const o=uo(t),s=t.filterOperator??(n==="exact"?"equals":"contains");return o&&!o.includes(s)?o[0]:s}function Hr(t,n,o){const s=n.toLowerCase(),f=o.trim().toLowerCase();switch(t){case"contains":return s.includes(f);case"notContains":return!s.includes(f);case"equals":return s===f;case"notEquals":return s!==f;case"startsWith":return s.startsWith(f);case"notStartsWith":return!s.startsWith(f);case"endsWith":return s.endsWith(f);case"notEndsWith":return!s.endsWith(f)}}const fo=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function ho(t){if(t==null)return!1;if(typeof t=="string")return t.trim()!=="";if(Array.isArray(t))return t.length>0;if(fo(t)){const n=t;return typeof n.operator=="string"?typeof n.value=="string"&&n.value.trim()!=="":typeof n.min=="number"||typeof n.max=="number"||!!n.from||!!n.to}return!1}function Ms(t,n,o,s){switch(t){case"text":case"exact":{if(fo(n)){const f=n;return Hr(f.operator,o,String(f.value??""))}return Hr(t==="exact"?"equals":"contains",o,String(n))}case"number":{const{min:f,max:u}=n,c=typeof s=="number"?s:s==null||s===""?NaN:Number(s);return Number.isNaN(c)?!1:(typeof f!="number"||c>=f)&&(typeof u!="number"||c<=u)}case"date":{const{from:f,to:u}=n,c=ue(s);return c?(!f||c>=f)&&(!u||c<=u):!1}case"select":return n.includes(String(s??""))}}function Is(t,n,o,s){if(t.filterOptions)return t.filterOptions.map(u=>typeof u=="string"?{value:u,label:u}:u);if(t.type==="boolean")return[{value:"true",label:"Yes"},{value:"false",label:"No"}];const f=new Map;for(const u of n){const c=o(u);if(c==null||c==="")continue;const m=String(c);f.has(m)||f.set(m,s(u))}return[...f].map(([u,c])=>({value:u,label:c})).sort((u,c)=>u.label.localeCompare(c.label,void 0,{numeric:!0}))}const Xr=t=>{if(t.trim()==="")return;const n=Number(t);return Number.isFinite(n)?n:void 0},qn=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function $s({value:t,onChange:n,label:o,debounce:s,inputClassName:f,inputStyle:u}){const c=qn(t)?t:{},[m,x]=p.useState(c.min===void 0?"":String(c.min)),[_,F]=p.useState(c.max===void 0?"":String(c.max)),b=p.useRef(c),S=co((g,k)=>{const E=Xr(g),N=Xr(k);b.current={min:E,max:N},n(E===void 0&&N===void 0?void 0:{min:E,max:N})},s);return p.useEffect(()=>{c.min===b.current.min&&c.max===b.current.max||(b.current=c,S.cancel(),x(c.min===void 0?"":String(c.min)),F(c.max===void 0?"":String(c.max)))},[c.min,c.max]),i.jsxs("div",{className:"rg-grid__filter-fields",children:[i.jsxs("label",{className:"rg-grid__filter-field",children:[i.jsx("span",{children:"Min"}),i.jsx("input",{autoFocus:!0,type:"number",className:O("rg-grid__filter-input",f),style:u,value:m,"aria-label":`Minimum ${o}`,onChange:g=>{x(g.target.value),S.call(g.target.value,_)},onKeyDown:g=>g.key==="Enter"&&S.flush()})]}),i.jsxs("label",{className:"rg-grid__filter-field",children:[i.jsx("span",{children:"Max"}),i.jsx("input",{type:"number",className:O("rg-grid__filter-input",f),style:u,value:_,"aria-label":`Maximum ${o}`,onChange:g=>{F(g.target.value),S.call(m,g.target.value)},onKeyDown:g=>g.key==="Enter"&&S.flush()})]})]})}function Rs({value:t,onChange:n,onEnter:o,label:s,kind:f,placeholder:u,debounce:c,inputClassName:m,inputStyle:x}){const[_,F]=p.useState(t),b=p.useRef(t),S=co(g=>{b.current=g,n(g||void 0)},c);return p.useEffect(()=>{t!==b.current&&(b.current=t,S.cancel(),F(t))},[t]),i.jsx("input",{autoFocus:!0,type:"text",className:O("rg-grid__filter-input",m),style:x,value:_,placeholder:u??(f==="exact"?"Exactly…":`Filter ${s}…`),"aria-label":`Filter text for ${s}`,onChange:g=>{F(g.target.value),S.call(g.target.value)},onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),S.flush(),o())}})}function Ps({value:t,onChange:n,label:o,inputClassName:s,inputStyle:f,min:u,max:c,locale:m}){const x=qn(t)?t:{},_=(T,v)=>n(!T&&!v?void 0:{from:T||void 0,to:v||void 0}),[F,b]=p.useState(x.from??""),[S,g]=p.useState(x.to??"");p.useEffect(()=>{(re(F)?F:"")!==(x.from??"")&&b(x.from??""),(re(S)?S:"")!==(x.to??"")&&g(x.to??"")},[x.from,x.to]);const k=(T,v)=>{if((T==="from"?b:g)(v),v!==""&&!re(v))return;const R=v||void 0;T==="from"?_(R,x.to):_(x.from,R)},E=T=>{T&&(!x.from||x.to?_(T,void 0):T<x.from?_(T,x.from):_(x.from,T))},N=(T,v,R)=>i.jsxs("label",{className:"rg-grid__filter-field",children:[i.jsx("span",{children:T==="from"?"From":"To"}),i.jsx("input",{autoFocus:R,type:"text",inputMode:"numeric",placeholder:"YYYY-MM-DD",className:O("rg-grid__filter-input",v!==""&&!re(v)&&"rg-grid__filter-input--invalid",s),style:f,value:v,"aria-label":`${o} ${T}`,"aria-invalid":v!==""&&!re(v)||void 0,onChange:Y=>k(T,Y.target.value.trim())})]});return i.jsxs("div",{className:"rg-grid__filter-fields rg-grid__filter-fields--stack",children:[i.jsxs("div",{className:"rg-grid__filter-date-row",children:[N("from",F,!0),N("to",S,!1)]}),i.jsx(ao,{range:x,min:u,max:c,locale:m,onPick:E,hideFooter:!0})]})}function Ls({value:t,onChange:n,options:o}){const s=Array.isArray(t)?t:[],f=(u,c)=>{const m=c?[...s,u]:s.filter(x=>x!==u);n(m.length?m:void 0)};return i.jsxs("div",{className:"rg-grid__filter-fields rg-grid__filter-options",role:"group",children:[o.length===0&&i.jsx("span",{className:"rg-grid__filter-empty",children:"No values"}),o.map(u=>i.jsx(Je,{checked:s.includes(u.value),onChange:c=>f(u.value,c),label:u.label??u.value},u.value))]})}function Os({value:t,options:n,onChange:o,label:s}){const[f,u]=p.useState(!1),[c,m]=p.useState(0),x=p.useId(),_=p.useRef(null),F=()=>{m(Math.max(0,n.indexOf(t))),u(!0)},b=g=>{var k;o(g),u(!1),(k=_.current)==null||k.focus()},S=g=>{if(!f){(g.key==="ArrowDown"||g.key==="ArrowUp")&&(g.preventDefault(),F());return}switch(g.key){case"ArrowDown":g.preventDefault(),m(k=>Math.min(n.length-1,k+1));break;case"ArrowUp":g.preventDefault(),m(k=>Math.max(0,k-1));break;case"Home":g.preventDefault(),m(0);break;case"End":g.preventDefault(),m(n.length-1);break;case"Enter":case" ":g.preventDefault(),b(n[c]);break;case"Escape":g.preventDefault(),g.stopPropagation(),u(!1);break;case"Tab":u(!1);break}};return i.jsxs("div",{className:"rg-op",children:[i.jsxs("button",{ref:_,type:"button",className:"rg-op__btn",role:"combobox","aria-label":`Comparison for ${s}`,"aria-haspopup":"listbox","aria-expanded":f,"aria-controls":f?x:void 0,"aria-activedescendant":f?`${x}-${c}`:void 0,onClick:()=>f?u(!1):F(),onBlur:()=>u(!1),onKeyDown:S,children:[i.jsx("span",{className:"rg-op__value",children:Vr[t]}),i.jsx("svg",{className:"rg-op__chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5"})})]}),f&&i.jsx("ul",{id:x,role:"listbox",className:"rg-op__list","aria-label":`Comparisons for ${s}`,onMouseDown:g=>g.preventDefault(),children:n.map((g,k)=>i.jsxs("li",{id:`${x}-${k}`,role:"option","aria-selected":g===t,"data-op":g,className:O("rg-op__option",g===t&&"rg-op__option--selected",k===c&&"rg-op__option--active"),onMouseEnter:()=>m(k),onClick:()=>b(g),children:[Vr[g],g===t&&i.jsx("svg",{className:"rg-op__check",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 6.5 5 9l4.5-5.5"})})]},g))})]})}function Us({column:t,label:n,kind:o,value:s,onChange:f,options:u,debounce:c=300,theme:m,indicatorClassName:x,indicatorStyle:_,popupClassName:F,popupStyle:b,inputClassName:S,inputStyle:g}){const[k,E]=p.useState(!1),N=p.useRef(null),T=ho(s),v=p.useCallback(()=>E(!1),[]),R=qn(s)?s:null,Y=typeof s=="string"?s:typeof(R==null?void 0:R.value)=="string"?R.value:"",K=(o==="text"||o==="exact")&&!t.filterRenderer?uo(t):null,[U,z]=p.useState(()=>Fs(t,o)),ye=R&&typeof R.operator=="string"?R.operator:U,De=q=>{if(q===void 0)return f(void 0);f(K?{operator:ye,value:String(q)}:q)},Oe=q=>{z(q),Y.trim()!==""&&f({operator:q,value:Y})},Se=()=>{if(t.filterRenderer)return p.createElement(t.filterRenderer,{column:t,value:Y,onChange:q=>f(q||void 0)});switch(o){case"number":return i.jsx($s,{value:s,onChange:f,label:n,debounce:c,inputClassName:S,inputStyle:g});case"date":return i.jsx(Ps,{value:s,onChange:f,label:n,min:t.dateMin,max:t.dateMax,locale:t.dateLocale,inputClassName:S,inputStyle:g});case"select":return i.jsx(Ls,{value:s,onChange:f,options:u});default:return i.jsxs("div",{className:"rg-grid__filter-stack",children:[K&&i.jsx(Os,{value:ye,options:K,onChange:Oe,label:n}),i.jsx(Rs,{value:Y,onChange:De,onEnter:()=>{var q;E(!1),(q=N.current)==null||q.focus()},label:n,kind:o,placeholder:t.filterPlaceholder,debounce:c,inputClassName:S,inputStyle:g})]})}};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:N,type:"button",className:O("rg-grid__filter-btn",T&&"rg-grid__filter-btn--active",k&&"rg-grid__filter-btn--open",x),style:_,"aria-label":`Filter ${n}`,"aria-haspopup":"dialog","aria-expanded":k,"data-active":T||void 0,onClick:q=>{q.stopPropagation(),E(oe=>!oe)},onKeyDown:q=>q.stopPropagation(),children:t.filterIndicator?p.createElement(t.filterIndicator,{column:t,active:T,open:k}):i.jsx("span",{className:"rg-grid__filter-dot","aria-hidden":"true"})}),i.jsxs(mn,{anchorRef:N,open:k,onClose:v,label:`Filter ${n}`,theme:m,className:F,style:b,children:[Se(),T&&i.jsx("button",{type:"button",className:"rg-grid__filter-clear",onClick:()=>f(void 0),children:"Clear"})]})]})}function As({columns:t,hidden:n,onToggle:o,theme:s,className:f,style:u}){const[c,m]=p.useState(!1),x=p.useRef(null),_=p.useCallback(()=>m(!1),[]),F=t.filter(b=>!n.has(b.field)).length;return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:x,type:"button",className:O("rg-grid__tool-btn",f),style:u,"aria-haspopup":"dialog","aria-expanded":c,onClick:()=>m(b=>!b),children:"Columns"}),i.jsx(mn,{anchorRef:x,open:c,onClose:_,label:"Show or hide columns",theme:s,children:i.jsx("div",{className:"rg-grid__filter-fields rg-grid__filter-options",role:"group","aria-label":"Columns",children:t.filter(b=>b.hideable!==!1).map(b=>{const S=!n.has(b.field);return i.jsx(Je,{checked:S,disabled:S&&F<=1,onChange:g=>o(b.field,!g),label:Ge(b)},b.field)})})})]})}const Ws=/^[=+\-@\t\r]/;function Bs(t,n,o){if(t==null)return"";let s=String(t);return o&&typeof t=="string"&&Ws.test(s)&&!Number.isFinite(Number(s))&&(s=`'${s}`),s.includes(n)||/["\r\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s}function Ks(t,n,o={}){const{delimiter:s=",",sanitize:f=!0}=o,u=c=>c.map(m=>Bs(m,s,f)).join(s);return[u(t),...n.map(u)].join(`\r
2
+ `)}function hn(t,n){if(typeof document>"u")return;const o=URL.createObjectURL(t),s=document.createElement("a");s.href=o,s.download=n,s.style.display="none",document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function qs(t,n){hn(new Blob(["\uFEFF",t],{type:"text/csv;charset=utf-8"}),n)}const po={csv:"CSV",xlsx:"Excel",json:"JSON",pdf:"PDF"},zs={csv:".csv",xlsx:".xlsx",json:".json",pdf:".pdf"},Ys=t=>`Export ${po[t]}`;function Vs({formats:t,scopes:n,scope:o,onScopeChange:s,onExport:f,theme:u,className:c,style:m,popupClassName:x}){const[_,F]=p.useState(!1),[b,S]=p.useState(null),g=p.useRef(null),k=p.useCallback(()=>F(!1),[]),E=async N=>{var T;S(N);try{await f(N,o)}finally{S(null),F(!1),(T=g.current)==null||T.focus()}};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:g,type:"button",className:O("rg-grid__tool-btn",c),style:m,"aria-haspopup":"dialog","aria-expanded":_,onClick:()=>F(N=>!N),children:["Export",i.jsx("svg",{className:"rg-export__chevron",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5"})})]}),i.jsx(mn,{anchorRef:g,open:_,onClose:k,label:"Export",theme:u,className:O("rg-export-popup",x),children:i.jsxs("div",{className:"rg-export",children:[n.length>1&&i.jsxs("div",{className:"rg-export__group",role:"radiogroup","aria-label":"Rows to export",children:[i.jsx("div",{className:"rg-export__title",children:"Rows to export"}),n.map(N=>{const T=N.count===0;return i.jsxs("label",{className:O("rg-export__scope",T&&"rg-export__scope--disabled",N.value===o&&"rg-export__scope--on"),children:[i.jsx("input",{type:"radio",name:"rg-export-scope",value:N.value,checked:N.value===o,disabled:T,onChange:()=>s(N.value)}),i.jsx("span",{className:"rg-export__scope-label",children:N.label}),i.jsx("span",{className:"rg-export__count",children:N.count})]},N.value)})]}),i.jsxs("div",{className:"rg-export__group",children:[i.jsx("div",{className:"rg-export__title",children:"Download as"}),t.map(N=>i.jsxs("button",{type:"button",className:"rg-export__format","data-format":N,disabled:b!==null,onClick:()=>E(N),children:[i.jsx("span",{children:po[N]}),i.jsx("span",{className:"rg-export__ext",children:b===N?"Preparing…":zs[N]})]},N))]})]})})]})}let xe;function de(t){const n=(t??"").trim();if(!n||n==="transparent"||n==="none")return null;const o=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(n);if(o){let _=o[1];return _.length===3&&(_=_.split("").map(F=>F+F).join("")),[parseInt(_.slice(0,2),16),parseInt(_.slice(2,4),16),parseInt(_.slice(4,6),16)]}const s=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(n);if(s)return Gr([Number(s[1]),Number(s[2]),Number(s[3])],Hs(s[4]));if(typeof document>"u"||(xe===void 0&&(xe=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})),!xe))return null;xe.fillStyle="#000000",xe.fillStyle=n;const f=String(xe.fillStyle);if(xe.fillStyle="#ffffff",xe.fillStyle=n,f!==String(xe.fillStyle))return null;xe.clearRect(0,0,1,1),xe.fillRect(0,0,1,1);const[u,c,m,x]=xe.getImageData(0,0,1,1).data;return x===0?null:Gr([u,c,m],x/255)}const Hs=t=>t===void 0?1:t.endsWith("%")?parseFloat(t)/100:parseFloat(t);function Gr(t,n){if(!(n>0))return null;const o=Math.min(1,n);return t.map(s=>Math.round(Math.min(255,s)*o+255*(1-o)))}const Xs=([t,n,o])=>(.299*t+.587*n+.114*o)/255,On=t=>Xs(t)>.55?[31,41,55]:[243,244,246],Un=72/96,Et="Install them with: npm install jspdf jspdf-autotable (and html2canvas for header / footer elements), then pass them in exportable.pdf.libraries.";async function Jr(t,n){try{return await n()}catch(o){const s=o instanceof Error?o.message:String(o);throw new Error(`PDF export needs the package "${t}", which could not be loaded (${s}). ${Et}`)}}function Qr(t,n,o){return t.replace(/\{page\}/g,String(n)).replace(/\{pages\}/g,String(o)).replace(/\{date\}/g,new Date().toLocaleDateString())}async function Gs(t){const n=Array.from(t.querySelectorAll("img")).map(o=>o.complete?Promise.resolve():new Promise(s=>{o.addEventListener("load",()=>s(),{once:!0}),o.addEventListener("error",()=>s(),{once:!0})}));await Promise.race([Promise.all(n),new Promise(o=>setTimeout(o,5e3))])}async function Js(t,n,o,s,f){const u=o.html2canvas;if(typeof u!="function")throw new Error(`A PDF header / footer element needs html2canvas. Add it to exportable.pdf.libraries. ${Et}`);const[c,m]=await Promise.all([Jr("react-dom/client",()=>Promise.resolve().then(()=>require("./client-40__X0_a.cjs")).then(b=>b.client)),Jr("react-dom",()=>import("react-dom"))]),x=2,_=document.createElement("div");_.style.cssText=`position:fixed;left:-10000px;top:0;width:${Math.round(n/Un)}px;background:${s};color:${f};font-family:system-ui,sans-serif;font-size:14px;`,document.body.appendChild(_);const F=c.createRoot(_);try{m.flushSync(()=>F.render(t)),await Gs(_),await new Promise(S=>requestAnimationFrame(()=>S(void 0)));const b=await u(_,{scale:x,backgroundColor:s,useCORS:!0,logging:!1});return{dataUrl:b.toDataURL("image/png"),width:b.width/x*Un,height:b.height/x*Un}}finally{F.unmount(),_.remove()}}async function An(t,n,o,s,f,u){if(t==null||t===!1||t===!0||t==="")return null;if(typeof t=="string"||typeof t=="number")return{kind:"text",text:String(t)};const c=await Js(t,n,s,f,u),m=Math.min(1,n/c.width,o/c.height);return{kind:"image",dataUrl:c.dataUrl,width:c.width*m,height:c.height*m}}const Zr=t=>`rgb(${t[0]},${t[1]},${t[2]})`,eo=["normal","bold","italic","bolditalic"];function to(t,n){return typeof t=="number"?{top:t,right:t,bottom:t,left:t}:{top:(t==null?void 0:t.top)??n,right:(t==null?void 0:t.right)??n,bottom:(t==null?void 0:t.bottom)??n,left:(t==null?void 0:t.left)??n}}function no(t){return Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0))}async function Qs(t,n={},o={}){var et,tt;let s;try{s=typeof n.libraries=="function"?await n.libraries():n.libraries}catch(D){const G=D instanceof Error?D.message:String(D);throw new Error(`PDF export could not load jspdf / jspdf-autotable (${G}). ${Et}`)}if(!s)throw new Error(`PDF export needs the jspdf and jspdf-autotable libraries. ${Et}`);const f=s.jsPDF,u=s.autoTable;if(typeof f!="function"||typeof u!="function")throw new Error(`exportable.pdf.libraries must contain jsPDF (a class) and autoTable (a function). ${Et}`);const{title:c,header:m,footer:x,headerAlign:_="left",footerAlign:F="center",orientation:b="auto",pageSize:S="a4",tableTheme:g="striped",pageNumbers:k=!0,maxImageHeight:E=90,beforeRender:N,autoTableOptions:T}=n,v={...o,...no({headColor:n.headColor,headTextColor:n.headTextColor,fontSize:n.fontSize,fontName:n.fontName,margin:n.margin}),...no(n.style??{})},R=to(v.margin,36),Y=v.fontName??"helvetica",K=v.fontSize??9,U=de(v.pageBackground),z=U?On(U):[75,85,99],ye=de(v.textColor)??z,De=de(v.titleColor)??(U?On(U):[17,24,39]),Oe=de(v.headColor)??[79,70,229],Se=de(v.headTextColor)??[255,255,255],q=de(v.bodyTextColor),oe=de((et=v.stripeColors)==null?void 0:et[0]),je=de((tt=v.stripeColors)==null?void 0:tt[1]),w=de(v.bodyColor)??oe??U??void 0,H=de(v.borderColor),j=new f({orientation:b==="auto"?t.headers.length>6?"landscape":"portrait":b,unit:"pt",format:S});N&&await N(j);const A=j.internal.pageSize.getWidth(),le=j.internal.pageSize.getHeight(),fe=A-R.left-R.right,Ue=10,Qe=12,Dt=new Set,it=D=>{!U||Dt.has(D)||(Dt.add(D),j.setFillColor(...U),j.rect(0,0,A,le,"F"))};it(1);const Ae=U?Zr(U):"#ffffff",We=Zr(ye),ie=await An(m,fe,E,s,Ae,We),he=await An(x,fe,E,s,Ae,We);j.setFont(Y,"normal"),j.setFontSize(Ue);const at=D=>D?D.kind==="image"?D.height:j.splitTextToSize(Qr(D.text,99,99),fe).length*Qe:0,Be=at(ie),ct=at(he),Te=Math.min(18,R.top),dt=le-14,ut=le-(k?26:18),Tt=ie?Math.max(R.top,Te+Be+12):R.top,ft=Math.max(R.bottom,he?le-ut+ct+10:k?34:0);let Ke=Tt;if(c&&typeof c!="string"&&typeof c!="number"&&typeof c!="boolean"){const D=await An(c,fe,E,s,Ae,We);D&&D.kind==="image"&&(j.addImage(D.dataUrl,"PNG",R.left,Ke,D.width,D.height),Ke+=D.height+12)}else c&&(j.setFont(Y,"bold"),j.setFontSize(v.titleSize??14),j.setTextColor(...De),j.text(String(c),R.left,Ke+(v.titleSize??14)),Ke+=(v.titleSize??14)+12);const Ft={};t.fields.forEach((D,G)=>{var It;const $=(It=v.columns)==null?void 0:It[D],se={},ze=($==null?void 0:$.align)??t.aligns[G];ze&&(se.halign=ze),($==null?void 0:$.width)!==void 0&&(se.cellWidth=$.width);const Fe=de($==null?void 0:$.textColor);Fe&&(se.textColor=Fe);const Mt=de($==null?void 0:$.backgroundColor);Mt&&(se.fillColor=Mt),$!=null&&$.fontStyle&&eo.includes($.fontStyle)&&(se.fontStyle=$.fontStyle),$!=null&&$.fontSize&&(se.fontSize=$.fontSize),Object.keys(se).length>0&&(Ft[G]=se)});const Ce={font:Y,fontSize:K,cellPadding:to(v.cellPadding,4),overflow:"linebreak",valign:"middle"};q?Ce.textColor=q:U&&(Ce.textColor=On(U)),H&&(Ce.lineColor=H),v.borderWidth!==void 0?Ce.lineWidth=v.borderWidth:H&&(Ce.lineWidth=.5),v.minRowHeight&&(Ce.minCellHeight=v.minRowHeight);const _e={head:[t.headers],body:t.rows,startY:Ke,margin:{top:Tt,right:R.right,bottom:ft,left:R.left},theme:g,showHead:"everyPage",styles:Ce,headStyles:{fillColor:Oe,textColor:Se,fontStyle:v.headFontStyle&&eo.includes(v.headFontStyle)?v.headFontStyle:"bold",...v.headFontSize?{fontSize:v.headFontSize}:null},columnStyles:Ft,willDrawPage:()=>{var G,$;const D=typeof j.getCurrentPageInfo=="function"?j.getCurrentPageInfo():($=(G=j.internal).getCurrentPageInfo)==null?void 0:$.call(G);D!=null&&D.pageNumber&&it(D.pageNumber)}};w&&(_e.bodyStyles={fillColor:w}),oe&&je?(_e.bodyStyles={fillColor:oe},_e.alternateRowStyles={fillColor:je}):(oe||w)&&(_e.alternateRowStyles={fillColor:w});const Ze={..._e,...T};for(const D of["styles","headStyles","bodyStyles","alternateRowStyles","margin"]){const G=_e[D],$=T==null?void 0:T[D];G&&$&&typeof $=="object"&&(Ze[D]={...G,...$})}u(j,Ze);const ht=typeof j.getNumberOfPages=="function"?j.getNumberOfPages():j.internal.getNumberOfPages(),ae=(D,G)=>D==="center"?(A-G)/2:D==="right"?A-R.right-G:R.left,qe=(D,G,$,se)=>{if(!D)return;if(D.kind==="image"){j.addImage(D.dataUrl,"PNG",ae($,D.width),G,D.width,D.height);return}j.setFont(Y,"normal"),j.setFontSize(Ue),j.setTextColor(...ye);const ze=j.splitTextToSize(Qr(D.text,se,ht),fe),Fe=$==="center"?A/2:$==="right"?A-R.right:R.left;j.text(ze,Fe,G+Ue,{align:$})};for(let D=1;D<=ht;D++)j.setPage(D),qe(ie,Te,_,D),qe(he,ut-ct,F,D),k&&(j.setFont(Y,"normal"),j.setFontSize(8),j.setTextColor(...ye),j.text(`Page ${D} of ${ht}`,A-R.right,dt,{align:"right"}));return j.output("blob")}function Zs(t){var F;if(!t||typeof getComputedStyle>"u")return{};const n={},o=b=>b?getComputedStyle(b):null,s=b=>{var S;for(let g=b;g;g=g.parentElement){const k=(S=o(g))==null?void 0:S.backgroundColor;if(k&&de(k))return k}},f=b=>{const S=de(b);return S?"#"+S.map(g=>g.toString(16).padStart(2,"0")).join(""):void 0},u=b=>b?Math.round(parseFloat(b)*.75*10)/10:void 0,c=t.querySelector("thead th");if(c){const b=o(c);n.headColor=f(s(c)),n.headTextColor=f(b.color),n.headFontStyle=parseInt(b.fontWeight,10)>=600?"bold":"normal"}const m=Array.from(t.querySelectorAll("tbody tr.rg-grid__row:not(.rg-grid__row--exit)")).slice(0,2),x=(F=m[0])==null?void 0:F.querySelector("td");if(x){const b=o(x);n.bodyTextColor=f(b.color);const S=u(b.fontSize);S&&!Number.isNaN(S)&&(n.fontSize=Math.min(14,Math.max(6,S)));const g=f(s(m[0].querySelector("td"))),k=f(m[1]?s(m[1].querySelector("td")):void 0);n.bodyColor=g,g&&k&&g!==k&&(n.stripeColors=[g,k]);const E=o(x);parseFloat(E.borderBottomWidth)>0&&E.borderBottomStyle!=="none"&&(n.borderColor=f(E.borderBottomColor),n.borderWidth=.5)}const _=f(s(t));return _&&_!=="#ffffff"&&(n.pageBackground=_),n.textColor=f(o(t).color),n.fontName=void 0,Object.keys(n).forEach(b=>n[b]===void 0&&delete n[b]),n}const go={none:0,asc:0,desc:180};function mo({direction:t,size:n=14,priority:o,className:s,style:f}){const u=p.useRef(0),m=((go[t??"none"]-u.current)%360+360)%360;return u.current+=m,i.jsxs("span",{className:O("rg-sort-arrow",t&&"rg-sort-arrow--active",s),style:f,"data-direction":t??"none",children:[i.jsxs("svg",{className:"rg-sort-arrow__icon",width:n,height:n,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{transform:`rotate(${u.current}deg)`},children:[i.jsx("path",{d:"M8 13V3"}),i.jsx("path",{d:"M3.5 7.5 8 3l4.5 4.5"})]}),t&&o!==void 0&&i.jsx("sup",{className:"rg-sort-arrow__order",children:o})]})}function el({direction:t,children:n}){const o=p.useRef(0),s=((go[t??"none"]-o.current)%360+360)%360;return o.current+=s,i.jsx("span",{className:"rg-sort-turn",style:{transform:`rotate(${o.current}deg)`},children:n})}const xo=new TextEncoder;let fn=null;function tl(t){if(!fn){fn=new Uint32Array(256);for(let o=0;o<256;o++){let s=o;for(let f=0;f<8;f++)s=s&1?3988292384^s>>>1:s>>>1;fn[o]=s>>>0}}let n=4294967295;for(let o=0;o<t.length;o++)n=fn[(n^t[o])&255]^n>>>8;return(n^4294967295)>>>0}async function nl(t){const n=globalThis.CompressionStream;if(typeof n>"u")return null;try{const o=new Blob([t]).stream().pipeThrough(new n("deflate-raw"));return new Uint8Array(await new Response(o).arrayBuffer())}catch{return null}}async function rl(t){const n=new Date,o=n.getHours()<<11|n.getMinutes()<<5|n.getSeconds()>>1,s=n.getFullYear()-1980<<9|n.getMonth()+1<<5|n.getDate(),f=[],u=[];let c=0;for(const g of t){const k=xo.encode(g.name),E=tl(g.data),N=await nl(g.data),T=N!==null&&N.length<g.data.length,v=T?N:g.data,R=T?8:0,Y=new Uint8Array(30+k.length),K=new DataView(Y.buffer);K.setUint32(0,67324752,!0),K.setUint16(4,20,!0),K.setUint16(6,2048,!0),K.setUint16(8,R,!0),K.setUint16(10,o,!0),K.setUint16(12,s,!0),K.setUint32(14,E,!0),K.setUint32(18,v.length,!0),K.setUint32(22,g.data.length,!0),K.setUint16(26,k.length,!0),K.setUint16(28,0,!0),Y.set(k,30);const U=new Uint8Array(46+k.length),z=new DataView(U.buffer);z.setUint32(0,33639248,!0),z.setUint16(4,20,!0),z.setUint16(6,20,!0),z.setUint16(8,2048,!0),z.setUint16(10,R,!0),z.setUint16(12,o,!0),z.setUint16(14,s,!0),z.setUint32(16,E,!0),z.setUint32(20,v.length,!0),z.setUint32(24,g.data.length,!0),z.setUint16(28,k.length,!0),z.setUint32(42,c,!0),U.set(k,46),f.push(Y,v),u.push(U),c+=Y.length+v.length}const m=u.reduce((g,k)=>g+k.length,0),x=new Uint8Array(22),_=new DataView(x.buffer);_.setUint32(0,101010256,!0),_.setUint16(8,t.length,!0),_.setUint16(10,t.length,!0),_.setUint32(12,m,!0),_.setUint32(16,c,!0);const F=[...f,...u,x],b=new Uint8Array(F.reduce((g,k)=>g+k.length,0));let S=0;for(const g of F)b.set(g,S),S+=g.length;return b}function gn(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F￾￿]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function pn(t){let n=t+1,o="";for(;n>0;){const s=(n-1)%26;o=String.fromCharCode(65+s)+o,n=Math.floor((n-1)/26)}return o}function ol(t){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!n)return null;const[o,s,f]=[Number(n[1]),Number(n[2]),Number(n[3])],u=new Date(Date.UTC(o,s-1,f));return u.getUTCFullYear()!==o||u.getUTCMonth()!==s-1||u.getUTCDate()!==f?null:Math.round((u.getTime()-Date.UTC(1899,11,30))/864e5)}function sl(t){return(t??"").replace(/[\[\]:*?/\\]/g," ").trim().slice(0,31)||"Sheet1"}const ll=1,il=2,al=3,cl=4,dl=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
3
  <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
4
4
  <numFmts count="1"><numFmt numFmtId="164" formatCode="yyyy\\-mm\\-dd"/></numFmts>
5
5
  <fonts count="2"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><color rgb="FFFFFFFF"/><name val="Calibri"/></font></fonts>
@@ -14,8 +14,8 @@
14
14
  <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment horizontal="center"/></xf>
15
15
  </cellXfs>
16
16
  <cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>
17
- </styleSheet>`;function Xs(t,n,s){if(n==null||n==="")return"";const o=s.align==="right"?Ys:s.align==="center"?Vs:0;if(typeof n=="boolean")return`<c r="${t}" t="b"${o?` s="${o}"`:""}><v>${n?1:0}</v></c>`;if(typeof n=="number")return Number.isFinite(n)?`<c r="${t}"${o?` s="${o}"`:""}><v>${n}</v></c>`:"";if(s.kind==="date"){const u=Ws(n);if(u!==null)return`<c r="${t}" s="${zs}"><v>${u}</v></c>`}if(s.kind==="number"&&n.trim()!==""&&Number.isFinite(Number(n)))return`<c r="${t}"${o?` s="${o}"`:""}><v>${Number(n)}</v></c>`;const f=dn(n.slice(0,32767));return`<c r="${t}" t="inlineStr"${o?` s="${o}"`:""}><is><t xml:space="preserve">${f}</t></is></c>`}const Xr=t=>t==null?0:typeof t=="boolean"?5:String(t).length;function Gs(t,n){const s=cn(Math.max(0,t.length-1)),o=n.length+1,f=t.map((c,m)=>{let x=Xr(c.header)+3;for(let _=0;_<Math.min(n.length,500);_++)x=Math.max(x,c.kind==="date"?11:Xr(n[_][m]));return Math.min(60,Math.max(8,x+2))}),u=[];return u.push('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'),u.push('<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">'),u.push(`<dimension ref="A1:${s}${o}"/>`),u.push('<sheetViews><sheetView workbookViewId="0"><pane ySplit="1" topLeftCell="A2" activePane="bottomLeft" state="frozen"/><selection pane="bottomLeft"/></sheetView></sheetViews>'),u.push('<sheetFormatPr defaultRowHeight="15"/>'),u.push("<cols>"+f.map((c,m)=>`<col min="${m+1}" max="${m+1}" width="${c}" customWidth="1"/>`).join("")+"</cols>"),u.push("<sheetData>"),u.push('<row r="1" ht="22" customHeight="1">'+t.map((c,m)=>`<c r="${cn(m)}1" s="${qs}" t="inlineStr"><is><t xml:space="preserve">${dn(c.header)}</t></is></c>`).join("")+"</row>"),n.forEach((c,m)=>{const x=m+2,_=t.map((F,b)=>Xs(`${cn(b)}${x}`,c[b],F)).join("");u.push(`<row r="${x}">${_}</row>`)}),u.push("</sheetData>"),u.push(`<autoFilter ref="A1:${s}${o}"/>`),u.push("</worksheet>"),u.join("")}async function Js(t,n,s={}){const o=Ks(s.sheetName),f=`'${o.replace(/'/g,"''")}'`,u=cn(Math.max(0,t.length-1)),c={"[Content_Types].xml":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
17
+ </styleSheet>`;function ul(t,n,o){if(n==null||n==="")return"";const s=o.align==="right"?al:o.align==="center"?cl:0;if(typeof n=="boolean")return`<c r="${t}" t="b"${s?` s="${s}"`:""}><v>${n?1:0}</v></c>`;if(typeof n=="number")return Number.isFinite(n)?`<c r="${t}"${s?` s="${s}"`:""}><v>${n}</v></c>`:"";if(o.kind==="date"){const u=ol(n);if(u!==null)return`<c r="${t}" s="${il}"><v>${u}</v></c>`}if(o.kind==="number"&&n.trim()!==""&&Number.isFinite(Number(n)))return`<c r="${t}"${s?` s="${s}"`:""}><v>${Number(n)}</v></c>`;const f=gn(n.slice(0,32767));return`<c r="${t}" t="inlineStr"${s?` s="${s}"`:""}><is><t xml:space="preserve">${f}</t></is></c>`}const ro=t=>t==null?0:typeof t=="boolean"?5:String(t).length;function fl(t,n){const o=pn(Math.max(0,t.length-1)),s=n.length+1,f=t.map((c,m)=>{let x=ro(c.header)+3;for(let _=0;_<Math.min(n.length,500);_++)x=Math.max(x,c.kind==="date"?11:ro(n[_][m]));return Math.min(60,Math.max(8,x+2))}),u=[];return u.push('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'),u.push('<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">'),u.push(`<dimension ref="A1:${o}${s}"/>`),u.push('<sheetViews><sheetView workbookViewId="0"><pane ySplit="1" topLeftCell="A2" activePane="bottomLeft" state="frozen"/><selection pane="bottomLeft"/></sheetView></sheetViews>'),u.push('<sheetFormatPr defaultRowHeight="15"/>'),u.push("<cols>"+f.map((c,m)=>`<col min="${m+1}" max="${m+1}" width="${c}" customWidth="1"/>`).join("")+"</cols>"),u.push("<sheetData>"),u.push('<row r="1" ht="22" customHeight="1">'+t.map((c,m)=>`<c r="${pn(m)}1" s="${ll}" t="inlineStr"><is><t xml:space="preserve">${gn(c.header)}</t></is></c>`).join("")+"</row>"),n.forEach((c,m)=>{const x=m+2,_=t.map((F,b)=>ul(`${pn(b)}${x}`,c[b],F)).join("");u.push(`<row r="${x}">${_}</row>`)}),u.push("</sheetData>"),u.push(`<autoFilter ref="A1:${o}${s}"/>`),u.push("</worksheet>"),u.join("")}async function hl(t,n,o={}){const s=sl(o.sheetName),f=`'${s.replace(/'/g,"''")}'`,u=pn(Math.max(0,t.length-1)),c={"[Content_Types].xml":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
18
18
  <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>`,"_rels/.rels":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
19
19
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>`,"xl/workbook.xml":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
20
- <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="${dn(o)}" sheetId="1" r:id="rId1"/></sheets><definedNames><definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">${dn(f)}!$A$1:$${u}$${n.length+1}</definedName></definedNames></workbook>`,"xl/_rels/workbook.xml.rels":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
21
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>`,"xl/styles.xml":Hs,"xl/worksheets/sheet1.xml":Gs(t,n)},m=await Bs(Object.entries(c).map(([x,_])=>({name:x,data:lo.encode(_)})));return new Blob([m],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}const Pn=new Set(["__proto__","prototype","constructor"]),ao=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function ye(t,n){if(t===null||typeof t!="object")return;if(ao(t,n))return t[n];let s=t;for(const o of n.split(".")){if(s==null||typeof s!="object"||Pn.has(o))return;s=s[o]}return s}function Gr(t,n,s){if(Array.isArray(t)){const o=[...t];return o[n]=s,o}return{...t,[n]:s}}function Ln(t,n,s){const o=t??{};if(ao(o,n)||!n.includes("."))return Pn.has(n)?t:Gr(o,n,s);const[f,...u]=n.split(".");if(Pn.has(f))return t;const c=o[f];return Gr(o,f,Ln(c!==null&&typeof c=="object"?c:{},u.join("."),s))}function Jr(t,n){if(n.length===0)return t.map((c,m)=>({kind:"row",entry:c,i:m}));const s=new Map;for(const c of n)s.set(c.afterId,[...s.get(c.afterId)??[],c]);const o=[],f=new Set,u=c=>{for(const m of s.get(c)??[])f.has(m.id)||(f.add(m.id),o.push({kind:"ghost",ghost:m}),u(m.id))};return u(null),t.forEach((c,m)=>{o.push({kind:"row",entry:c,i:m}),u(c.id)}),n.forEach(c=>!f.has(c.id)&&o.push({kind:"ghost",ghost:c})),o}const Qs=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,Le=38,Zs=150,Qr=10,Rn=(t,n)=>`${typeof t}:${t}\0${n}`;function St(t,n){const s=ye(n,t.field);return t.valueFormatter?t.valueFormatter(s,n):t.type==="boolean"&&typeof s=="boolean"?s?"Yes":"No":t.type==="date"?fs(s,t.dateLocale,t.dateFormat):s==null?"":s instanceof Date?s.toLocaleDateString():String(s)}function ei(t,n,s){if(s.type==="date"){const o=de(t)??"",f=de(n)??"";return o<f?-1:o>f?1:0}return typeof t=="number"&&typeof n=="number"?t-n:t instanceof Date&&n instanceof Date?t.getTime()-n.getTime():typeof t=="boolean"&&typeof n=="boolean"?Number(t)-Number(n):String(t).localeCompare(String(n),void 0,{numeric:!0,sensitivity:"base"})}const ti=t=>t?Array.isArray(t)?t:[t]:[],Zr=t=>t.type==="date"&&t.validity.badInput;function ni({columns:t,rows:n,getRowId:s,editable:o=!1,enterMovesDown:f=!0,onCellEdit:u,onRowsChange:c,rowSelection:m=!1,selectedRowIds:x,defaultSelectedRowIds:_,onSelectionChange:F,isRowSelectable:b,sort:S,defaultSort:g=null,onSortChange:k,multiSort:E=!1,searchable:N=!1,searchPlaceholder:D="Search…",search:v,onSearchChange:$,filters:V,onFiltersChange:K,pagination:L=!1,paginationPosition:Y="bottom",showToolbar:_e=!0,showFooter:De=!0,pageSize:Oe=10,pageSizeOptions:je=[5,10,25,50],page:z,onPageChange:se,onPageSizeChange:Ce,serverSide:w=!1,rowCount:H,onQueryChange:j,queryDebounce:A=250,filterDebounce:ie=300,loading:ue,loadingRows:Ue,skeletonRow:Ge,errorMessage:Nt="Could not load the data.",columnMenu:lt=!1,onColumnVisibilityChange:Ae,keyboardNavigation:Be=!1,virtualize:le=!1,rowHeight:fe=40,overscan:at=6,exportable:We=!1,onExportError:ct,apiRef:Te,onRowClick:dt,toolbar:ut,emptyMessage:Et="No rows to show",emptyComponent:ft,sortIndicator:Ke="default",striped:Dt=!1,stripeColors:ge,checkboxVariant:ve="native",animateRows:Tt=!0,rowAnimation:ee,rowAnimationDuration:Je,rowAnimationStagger:Qe,rowAnimationClassName:Ze,rowExitAnimationClassName:Ne,theme:T,maxHeight:G,className:R,style:me,classNames:q={},styles:U={},rowClassName:et,rowStyle:tt}){const J=(e,r)=>({className:O(r,q[e]),style:U[e]}),[Ft,Un]=p.useState(n),nt=p.useRef(n);p.useEffect(()=>{nt.current=n,Un(n)},[n]);const An=e=>{nt.current=e,Un(e)},[ht,Bn]=kt(v,"",$),[rt,Wn]=kt(V,{},K),[he,co]=kt(S,ti(g),k),[fn,ot]=kt(z,0,se),[te,uo]=p.useState(Oe),fo=e=>{uo(e),Ce==null||Ce(e)},[Mt,ho]=p.useState(()=>new Set(t.filter(e=>e.hidden).map(e=>e.field))),po=(e,r)=>{const i=new Set(Mt);r?i.add(e):i.delete(e),ho(i),Ae==null||Ae([...i])},[hn,Kn]=p.useState({}),[It,go]=p.useState({}),[ri,mo]=p.useState(0),pt=p.useRef(new Map),[gt,qe]=p.useState(null),Fe=p.useRef(0),$t=p.useRef(null),Rt=p.useRef(new Map),[pn,qn]=p.useState(null),gn=p.useRef(null),zn=p.useRef(null),mt=p.useRef(null),[mn,Yn]=p.useState({top:0,height:0}),B=p.useMemo(()=>{const e=t.filter(r=>!Mt.has(r.field)).map(r=>r.type==="sequence"?{...r,sortable:!1,filterable:!1,editable:!1,filterRenderer:void 0}:r);return[...e.filter(r=>r.pinned==="left"),...e.filter(r=>r.pinned!=="left"&&r.pinned!=="right"),...e.filter(r=>r.pinned==="right")]},[t,Mt]),xn=e=>e.sortable===!0,ae=m==="single"?"single":m?"multiple":null,xt=B.length+(ae?1:0),ze=p.useMemo(()=>Ft.map((e,r)=>({row:e,index:r,id:s?s(e,r):r})),[Ft,s]),Vn=p.useRef(new Map);ze.forEach(e=>Vn.current.set(e.id,e.row));const st=p.useMemo(()=>Object.entries(rt).filter(([e,r])=>{const i=B.find(a=>a.field===e);return!!i&&!!i.filterable&&oo(r)}),[rt,B]),[xo,bo]=p.useState(ht);p.useEffect(()=>{if(!w)return;const e=setTimeout(()=>bo(ht),A);return()=>clearTimeout(e)},[ht,w,A]);const Me=w?xo:ht,Hn=e=>e.filterRenderer?"text":Lr(e),Ee=p.useMemo(()=>{if(w)return ze;const e=Me.trim().toLowerCase();let r=ze.filter(({row:a})=>e&&!B.some(d=>St(d,a).toLowerCase().includes(e))?!1:st.every(([d,h])=>{const y=B.find(C=>C.field===d);return ms(Hn(y),h,St(y,a),ye(a,d))}));const i=he.map(a=>({col:B.find(d=>d.field===a.field),dir:a.direction==="asc"?1:-1})).filter(a=>!!a.col);return i.length&&(r=[...r].sort((a,d)=>{for(const{col:h,dir:y}of i){const C=ye(a.row,h.field),M=ye(d.row,h.field),P=C==null||C==="",Q=M==null||M==="";if(P||Q){if(P!==Q)return P?1:-1;continue}const pe=h.comparator?h.comparator(C,M,a.row,d.row):ei(C,M,h);if(pe!==0)return pe*y}return 0})),r},[ze,B,Me,st,he,w]),Pt=JSON.stringify([Me,rt,he,te]),Xn=p.useRef(Pt);p.useEffect(()=>{Xn.current!==Pt&&(Xn.current=Pt,ot(0))},[Pt]);const it=w?H??ze.length:Ee.length,Ie=L?Math.max(1,Math.ceil(it/te)):1,ne=Math.min(fn,Ie-1),W=L&&!w?Ee.slice(ne*te,ne*te+te):Ee,yo=it===0?0:L?ne*te+1:1,_o=L?Math.min(it,(ne+1)*te):it,bn=p.useMemo(()=>({sort:he.filter(e=>{const r=t.find(i=>i.field===e.field);return!!r&&xn(r)}),filters:Object.fromEntries(st),search:Me.trim(),page:ne,pageSize:te}),[he,t,st,Me,ne,te]),wo=JSON.stringify(bn),Lt=p.useRef(bn);Lt.current=bn;const Ot=p.useRef(j);Ot.current=j;const[vo,Ut]=p.useState(!1),[yn,_n]=p.useState(!1),wn=p.useRef(0),At=p.useCallback(e=>{var a;const r=++wn.current,i=(a=Ot.current)==null?void 0:a.call(Ot,e);i&&typeof i.then=="function"?(Ut(!0),_n(!1),i.then(()=>{r===wn.current&&Ut(!1)},()=>{r===wn.current&&(Ut(!1),_n(!0))})):(Ut(!1),_n(!1))},[]);p.useEffect(()=>{w&&At(Lt.current)},[w,wo,At]),p.useEffect(()=>{w&&L&&fn>Ie-1&&ot(Ie-1)},[w,L,fn,Ie]);const bt=ue??vo,Gn=e=>e.map(r=>Vn.current.get(r)).filter(r=>r!==void 0),[ke,Bt]=kt(x,_??[],e=>F==null?void 0:F({ids:e,rows:Gn(e)})),Wt=p.useMemo(()=>new Set(ke),[ke]),Kt=e=>b?b(e):!0,qt=p.useRef(null),Jn=p.useRef(!1),ko=(e,r)=>{if(!ae||!Kt(e.row))return;if(ae==="single"){Bt(r?[e.id]:[]),qt.current=e.id;return}const i=new Set(ke),a=Jn.current&&qt.current!==null?W.findIndex(h=>h.id===qt.current):-1,d=W.findIndex(h=>h.id===e.id);if(a>=0&&d>=0)for(let h=Math.min(a,d);h<=Math.max(a,d);h++)Kt(W[h].row)&&(r?i.add(W[h].id):i.delete(W[h].id));else r?i.add(e.id):i.delete(e.id);qt.current=e.id,Bt([...i])},yt=p.useMemo(()=>Ee.filter(e=>Kt(e.row)),[Ee,b]),Qn=yt.filter(e=>Wt.has(e.id)).length,Zn=yt.length>0&&Qn===yt.length,er=e=>{const r=new Set(ke);yt.forEach(i=>e?r.add(i.id):r.delete(i.id)),Bt([...r])},zt=(e,r,i)=>({value:ye(r,e.field),formattedValue:St(e,r),row:r,rowIndex:i,field:e.field,column:e}),vn=(e,r)=>{const i=e.editable??o;return typeof i=="function"?i(r):!!i},Yt=(e,r)=>vn(e,r)&&!(e.type==="boolean"&&!e.cellEditor),So=(e,r)=>{const i=zt(e,r.row,r.index),a=vn(e,i);return{...i,editable:a,updateValue:d=>a&&nr(r,e,{value:d})}},tr=(e,r)=>{if(!xn(e))return;const i=he.find(h=>h.field===e.field),a=i?i.direction==="asc"?"desc":null:"asc";let d;r&&E?a?i?d=he.map(h=>h.field===e.field?{...h,direction:a}:h):d=[...he,{field:e.field,direction:a}]:d=he.filter(h=>h.field!==e.field):d=a?[{field:e.field,direction:a}]:[],co(d)},Vt=(e,r)=>{var i;return(i=Rt.current.get(Rn(e,r)))==null?void 0:i.focus()},$e=()=>{Fe.current+=1,qe(null)},jo=e=>{for(const r of nt.current){const i=ye(r,e.field);if(i!=null&&i!=="")return i}},Ht=(e,r,i={})=>{if(!Yt(r,zt(r,e.row,e.index)))return!1;const a=ye(e.row,r.field);let d;return r.cellEditor?d=a:r.type==="date"?d=de(a)??"":d=i.text??(a==null?"":String(a)),$t.current=d,Fe.current+=1,qe({id:e.id,field:r.field,draft:d,session:Fe.current,select:i.select??"end",invalid:!1}),!0},nr=(e,r,i)=>{const a=nt.current[e.index]??e.row,d=ye(a,r.field);let h;if("value"in i)h=i.value;else if(r.valueParser)h=r.valueParser(i.text,a);else if(r.type==="date"){if(i.text!==""&&!oe(i.text))return!1;h=hs(i.text,d??jo(r))}else if(r.type==="number")if(i.text.trim()==="")h=null;else{const M=Number(i.text);if(!Number.isFinite(M))return!1;h=M}else h=i.text;if(r.type==="date"){if(de(h)===de(d))return!0;const M=de(h);if(M&&(r.dateMin&&M<r.dateMin||r.dateMax&&M>r.dateMax))return!1}else if(Object.is(h,d))return!0;if(r.validate&&!r.validate(h,a))return!1;const y=Ln(a,r.field,h),C=nt.current.map((M,P)=>P===e.index?y:M);return An(C),u==null||u({rowId:e.id,rowIndex:e.index,field:r.field,oldValue:d,newValue:h,row:y}),c==null||c(C),!0},rr=(e,r,i)=>{const a=W.findIndex(P=>P.id===e.id),d=B.findIndex(P=>P.field===r);if(a<0||d<0)return null;const h=(P,Q)=>Yt(Q,zt(Q,P.row,P.index));if(i==="down"||i==="up"){const P=i==="down"?1:-1;for(let Q=a+P;Q>=0&&Q<W.length;Q+=P)if(h(W[Q],B[d]))return{entry:W[Q],col:B[d]};return null}const y=i==="right"?1:-1;let C=a,M=d+y;for(;C>=0&&C<W.length;){for(;M>=0&&M<B.length;){if(h(W[C],B[M]))return{entry:W[C],col:B[M]};M+=y}C+=y,M=y>0?0:B.length-1}return null},Ye=(e,r,i,a={})=>{const{move:d="none",focus:h=!0}=a;if(!nr(e,r,i))return qe(C=>C&&{...C,invalid:!0}),!1;const y=d==="none"?null:rr(e,r.field,d);return y?Ht(y.entry,y.col,{select:"all"}):($e(),h&&Vt(e.id,r.field)),!0},or=(e,r,i)=>{if(e.nativeEvent.isComposing)return;const a=e.currentTarget.value,d=Zr(e.currentTarget);if(e.key==="Enter"){if(e.preventDefault(),d)return qe(y=>y&&{...y,invalid:!0});const h=f?e.shiftKey?"up":"down":"none";Ye(r,i,{text:a},{move:h})}else if(e.key==="Escape")e.preventDefault(),$e(),Vt(r.id,i.field);else if(e.key==="Tab"&&!d){const h=e.shiftKey?"left":"right";rr(r,i.field,h)&&(e.preventDefault(),Ye(r,i,{text:a},{move:h}))}},Co=(e,r)=>{var h;const i=W[e],a=B[r];if(!i||!a)return;qn({id:i.id,field:a.field}),gn.current=Rn(i.id,a.field);const d=mt.current;if(le&&d){const y=((h=d.querySelector("thead"))==null?void 0:h.clientHeight)??0,C=e*fe;C<d.scrollTop?d.scrollTo({top:C,behavior:"auto"}):C+fe>d.scrollTop+d.clientHeight-y&&d.scrollTo({top:C+fe-d.clientHeight+y,behavior:"auto"})}};p.useEffect(()=>{const e=gn.current;if(!e)return;const r=Rt.current.get(e);r&&(gn.current=null,r.focus())});const No=(e,r,i)=>{if(!Be)return!1;let a=W.findIndex(h=>h.id===r.id),d=B.findIndex(h=>h.field===i.field);if(a<0||d<0)return!1;switch(e.key){case"ArrowDown":a+=1;break;case"ArrowUp":a-=1;break;case"ArrowRight":d+=1;break;case"ArrowLeft":d-=1;break;case"PageDown":a+=Qr;break;case"PageUp":a-=Qr;break;case"Home":d=0,(e.ctrlKey||e.metaKey)&&(a=0);break;case"End":d=B.length-1,(e.ctrlKey||e.metaKey)&&(a=W.length-1);break;default:return!1}return e.preventDefault(),Co(Math.max(0,Math.min(W.length-1,a)),Math.max(0,Math.min(B.length-1,d))),!0},Eo=(e,r,i,a)=>{e.target===e.currentTarget&&(No(e,r,i)||Yt(i,a)&&(e.key==="Enter"||e.key==="F2"?(e.preventDefault(),Ht(r,i)):!i.cellEditor&&i.type!=="date"&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),Ht(r,i,{text:e.key}))))};ln(()=>{if(!le||!mt.current)return;const e=mt.current,r=()=>Yn(a=>a.height===e.clientHeight?a:{...a,height:e.clientHeight});if(r(),typeof ResizeObserver>"u")return;const i=new ResizeObserver(r);return i.observe(e),()=>i.disconnect()},[le]);const _t=le&&!bt&&W.length>0,Do=mn.height||(typeof G=="number"?G:400),Xt=_t?Math.max(0,Math.floor(mn.top/fe)-at):0,kn=_t?Math.min(W.length,Math.ceil((mn.top+Do)/fe)+at):W.length,sr=_t?W.slice(Xt,kn):W,To=`${ne}|${te}|${JSON.stringify(he)}|${Me}|${JSON.stringify(rt)}`,ir=p.useRef(!0);p.useEffect(()=>{if(ir.current){ir.current=!1;return}const e=mt.current;e&&typeof e.scrollTo=="function"&&e.scrollTop>0&&e.scrollTo({top:0,behavior:"smooth"})},[To]);const lr=(typeof ee=="string"?ee:ee==null?void 0:ee.enter)??"slide-up",Sn=(typeof ee=="string"?ee:(ee==null?void 0:ee.exit)??(ee==null?void 0:ee.enter))??"slide-up",jn=Tt&&!le,ar=jn&&(Sn!=="none"||!!Ne),cr=Je??380,dr=Qe??28,Gt=p.useRef(new Map);let Fo=0;const Mo=e=>{let r=Gt.current.get(e);return r===void 0&&(r=Fo++,Gt.current.set(e,r)),Math.min(r,24)},[Se,ur]=p.useState([]),fr=p.useRef({rows:[],order:[],pageKey:""}),Re=p.useRef(new Map),Cn=`${ne}|${te}|${w}`,Nn=p.useCallback(e=>{const r=Re.current.get(e);r!==void 0&&clearTimeout(r),Re.current.delete(e),ur(i=>{const a=i.find(d=>d.id===e);return a?i.filter(d=>d.id!==e).map(d=>d.afterId===e?{...d,afterId:a.afterId}:d):i})},[]);ln(()=>{const e=fr.current,r=new Set(W.map(d=>d.id));Gt.current.forEach((d,h)=>!r.has(h)&&Gt.current.delete(h));const i=!ar||bt||yn||e.pageKey!==Cn||Qs();let a=Se;if(i)a=[];else{a=a.filter(h=>!r.has(h.id));const d=e.rows.filter(h=>!r.has(h.id)&&!a.some(y=>y.id===h.id));if(d.length>0){const h=d.map((y,C)=>{const M=e.order.indexOf(y.id);return{id:y.id,entry:y,afterId:M>0?e.order[M-1]:null,batch:C}});a=[...a,...h]}}(a.length!==Se.length||a.some((d,h)=>d!==Se[h]))&&ur(a),fr.current={rows:W,order:Jr(W,a).map(d=>d.kind==="row"?d.entry.id:d.ghost.id),pageKey:Cn}},[W,Se,bt,yn,Cn,ar]),p.useEffect(()=>{const e=!!Ne;Se.forEach(r=>{if(Re.current.has(r.id))return;const i=e?2500:cr*.8+dr*Math.min(r.batch,24)+250;Re.current.set(r.id,setTimeout(()=>Nn(r.id),i))}),Re.current.forEach((r,i)=>{Se.some(a=>a.id===i)||(clearTimeout(r),Re.current.delete(i))})},[Se,cr,dr,Ne,Nn]),p.useEffect(()=>()=>{Re.current.forEach(e=>clearTimeout(e)),Re.current.clear()},[]);const Io=p.useMemo(()=>Jr(sr,Se),[sr,Se]),En=Object.keys(hn).length>0,Jt=e=>hn[e.field]??(typeof e.width=="number"?e.width:Zs),$o=e=>Math.max(40,typeof e.minWidth=="number"?e.minWidth:60),Ro=(e,r)=>{e.preventDefault(),e.stopPropagation();const i={...hn};En||B.forEach(P=>{var Q;return i[P.field]=((Q=pt.current.get(P.field))==null?void 0:Q.offsetWidth)??Jt(P)});const a=e.clientX,d=i[r.field]??Jt(r),h=e.currentTarget;h.setPointerCapture(e.pointerId),Kn(i);const y=P=>Math.min(r.maxWidth??1/0,Math.max($o(r),Math.round(P))),C=P=>Kn(Q=>({...Q,[r.field]:y(d+P.clientX-a)})),M=()=>{h.removeEventListener("pointermove",C),h.removeEventListener("pointerup",M),h.removeEventListener("pointercancel",M)};h.addEventListener("pointermove",C),h.addEventListener("pointerup",M),h.addEventListener("pointercancel",M)};ln(()=>{var d,h;const e={};let r=ae&&B.some(y=>y.pinned==="left")?Le:0;for(const y of B)y.pinned==="left"&&(e[y.field]=r,r+=((d=pt.current.get(y.field))==null?void 0:d.offsetWidth)??0);let i=0;for(const y of[...B].reverse())y.pinned==="right"&&(e[y.field]=i,i+=((h=pt.current.get(y.field))==null?void 0:h.offsetWidth)??0);const a=Object.keys(e);(a.length!==Object.keys(It).length||a.some(y=>e[y]!==It[y]))&&go(e)}),p.useEffect(()=>{const e=()=>mo(r=>r+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const hr=B.map(e=>e.pinned).lastIndexOf("left"),Po=B.findIndex(e=>e.pinned==="right"),Qt=hr>=0,pr=(e,r)=>({className:e.pinned?O("rg-grid__pinned",`rg-grid__pinned--${e.pinned}`,r===hr&&"rg-grid__pinned--edge",r===Po&&"rg-grid__pinned--edge"):void 0,style:e.pinned==="left"?{left:It[e.field]??0}:e.pinned==="right"?{right:It[e.field]??0}:void 0}),Pe=typeof We=="object"?We:{},Zt=p.useMemo(()=>{var r;const e=(r=Pe.formats)!=null&&r.length?Pe.formats:["csv"];return e.filter((i,a)=>e.indexOf(i)===a)},[We]),en=(e={})=>{const r={...Pe,...e,pdf:{...Pe.pdf,...e.pdf}},i=r.scope??"filtered",a=i==="page"||i==="visible",d=a?W:i==="selected"?ze.filter(pe=>Wt.has(pe.id)):Ee,h=r.includeHidden?t:B,y=a&&L?ne*te:0,C=h.map(pe=>jt(pe)||pe.field),M=[],P=[],Q=[];return d.forEach(({row:pe},Dn)=>{const nn=[],I=[],wt={};h.forEach((X,Tn)=>{const Z=ye(pe,X.field);let xe,re;if(X.type==="sequence"){const on=Tr(X,Dn,X.sequenceRestartEachPage?0:y);xe=on,re=on}else X.exportValue?(xe=X.exportValue(Z,pe),re=xe??null):X.type==="date"?(xe=de(Z)??"",re=xe):(xe=St(X,pe),X.type==="number"&&typeof Z=="number"&&Number.isFinite(Z)||X.type==="boolean"&&typeof Z=="boolean"?re=Z:X.valueFormatter?re=xe:Z==null?re=null:typeof Z=="string"||typeof Z=="boolean"||typeof Z=="number"&&Number.isFinite(Z)?re=Z:Z instanceof Date?re=Number.isNaN(Z.getTime())?null:Z.toISOString():re=xe);nn.push(xe),I.push(re);const rn=r.jsonKeys==="header"?C[Tn]:X.field;wt[rn]=X.type==="date"&&re===""?null:re??null}),M.push(nn),P.push(I),Q.push(wt)}),{opts:r,cols:h,headers:C,display:M,typed:P,records:Q}},tn=(e,r)=>`${e.filename??"export"}.${r}`,gr=(e={})=>{const r=en(e);return Ns(r.headers,r.display,{sanitize:r.opts.sanitize})},mr=(e={})=>{const r={...Pe,...e};Es(gr(e),tn(r,"csv"))},xr=(e={})=>{const r=en(e);return JSON.stringify(r.records,null,r.opts.jsonIndent??2)},br=(e={})=>{const r={...Pe,...e};an(new Blob([xr(e)],{type:"application/json;charset=utf-8"}),tn(r,"json"))},yr=async(e={})=>{const r=en(e),i=r.cols.map(a=>({header:jt(a)||a.field,kind:a.type==="number"||a.type==="sequence"?"number":a.type==="date"?"date":a.type==="boolean"?"boolean":"text",align:a.align??(a.type==="number"||a.type==="sequence"?"right":void 0)}));return Js(i,r.typed,{sheetName:r.opts.sheetName})},_r=async(e={})=>{const r={...Pe,...e};an(await yr(e),tn(r,"xlsx"))},wr=async(e={})=>{var i;const r=en(e);return Ps({headers:r.headers,rows:r.display.map(a=>a.map(d=>d==null?"":String(d))),aligns:r.cols.map(a=>a.align??(a.type==="number"||a.type==="sequence"?"right":void 0)),fields:r.cols.map(a=>a.field)},r.opts.pdf,(i=r.opts.pdf)!=null&&i.matchGridStyle?Ls(zn.current):void 0)},vr=async(e={})=>{const r={...Pe,...e};an(await wr(e),tn(r,"pdf"))},kr=async(e,r={})=>e==="csv"?mr(r):e==="json"?br(r):e==="xlsx"?_r(r):vr(r),Sr=async(e,r={})=>{try{await kr(e,r)}catch(i){const a=i instanceof Error?i:new Error(String(i));ct?ct(a,e):console.error(`[react-gridix] ${e.toUpperCase()} export failed:`,a)}},[jr,Lo]=p.useState("visible"),Oo=ze.filter(e=>Wt.has(e.id)).length,Cr=[{value:"visible",label:"Visible rows",count:W.length},...L?[{value:"filtered",label:"All matching rows",count:Ee.length}]:[],...ae?[{value:"selected",label:"Selected rows",count:Oo}]:[]],Uo=Cr.some(e=>e.value===jr&&e.count>0)?jr:"visible";p.useEffect(()=>{Te&&(Te.current={getCsv:gr,exportCsv:mr,getJson:xr,exportJson:br,getXlsx:yr,exportXlsx:_r,getPdf:wr,exportPdf:vr,exportAs:kr,getSelectedRows:()=>Gn(ke),getSelectedRowIds:()=>ke,selectAll:()=>er(!0),clearSelection:()=>Bt([]),refresh:()=>{w&&At(Lt.current)}})}),p.useEffect(()=>()=>{Te&&(Te.current=null)},[Te]);const Nr=e=>{var i,a,d,h,y,C,M,P;const r=e.checkbox??{};return{variant:r.variant??ve,indicator:r.indicator,className:r.className,style:r.style,classNames:{root:O(q.checkbox,(i=r.classNames)==null?void 0:i.root),control:O(q.checkboxControl,(a=r.classNames)==null?void 0:a.control),indicator:O(q.checkboxIndicator,(d=r.classNames)==null?void 0:d.indicator),label:(h=r.classNames)==null?void 0:h.label},styles:{root:{...U.checkbox,...(y=r.styles)==null?void 0:y.root},control:{...U.checkboxControl,...(C=r.styles)==null?void 0:C.control},indicator:{...U.checkboxIndicator,...(M=r.styles)==null?void 0:M.indicator},label:(P=r.styles)==null?void 0:P.label}}},Ve=e=>e.stopPropagation(),Ao=(e,r)=>l.jsx("span",{className:"rg-grid__checkbox-cell",onClick:Ve,onDoubleClick:Ve,children:l.jsx(Xe,{...Nr(e),checked:!!r.value,disabled:!r.editable,"aria-label":`Toggle ${He(e)}`,onChange:i=>r.updateValue(i)})}),Er=e=>Ee.filter(r=>vn(e,zt(e,r.row,r.index))),Bo=(e,r)=>{const i=new Map(Er(e).map(h=>[h.index,h])),a=[],d=nt.current.map((h,y)=>{const C=i.get(y);if(!C)return h;const M=ye(h,e.field);if(!!M===r||e.validate&&!e.validate(r,h))return h;const P=Ln(h,e.field,r);return a.push({rowId:C.id,rowIndex:y,field:e.field,oldValue:M,newValue:r,row:P}),P});a.length!==0&&(An(d),a.forEach(h=>u==null?void 0:u(h)),c==null||c(d))},Wo=e=>{const r=Er(e),i=r.length>0?r:Ee,a=i.filter(h=>!!ye(h.row,e.field)).length,d=i.length>0&&a===i.length;return l.jsx("span",{className:"rg-grid__header-checkbox",onClick:Ve,onDoubleClick:Ve,children:l.jsx(Xe,{...Nr(e),checked:d,indeterminate:a>0&&!d,disabled:r.length===0,label:jt(e)||void 0,"aria-label":`Select all ${He(e)}`,onChange:h=>Bo(e,h)})})},Ko=(e,r,i)=>{if(r.cellEditor)return l.jsx("div",{className:"rg-grid__custom-editor",onBlur:d=>{d.currentTarget.contains(d.relatedTarget)||i.session===Fe.current&&(Ye(e,r,{value:$t.current},{focus:!1})||$e())},onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),$e(),Vt(e.id,r.field))},children:p.createElement(r.cellEditor,{value:i.draft,row:e.row,rowIndex:e.index,field:r.field,column:r,onChange:d=>{$t.current=d,qe(h=>h&&h.session===i.session?{...h,draft:d,invalid:!1}:h)},onCommit:(d,h="none")=>{i.session===Fe.current&&Ye(e,r,{value:d===void 0?$t.current:d},{move:h})},onCancel:()=>{$e(),Vt(e.id,r.field)}})});const a=r.type==="date";return a?l.jsx(ps,{value:i.draft===null||i.draft===void 0?"":String(i.draft),label:`Edit ${He(r)}`,invalid:i.invalid,min:r.dateMin,max:r.dateMax,locale:r.dateLocale,theme:T,className:O("rg-grid__editor",i.invalid&&"rg-grid__editor--invalid",q.editor),style:{textAlign:r.align,...U.editor},onChange:d=>qe(h=>h&&{...h,draft:d,invalid:!1}),onPick:d=>{i.session===Fe.current&&Ye(e,r,{text:d},{focus:!0})},onBlur:d=>{i.session===Fe.current&&(Ye(e,r,{text:d.currentTarget.value},{focus:!1})||$e())},onKeyDown:d=>or(d,e,r)}):l.jsx("input",{autoFocus:!0,type:a?"date":"text",min:a?r.dateMin:void 0,max:a?r.dateMax:void 0,className:O("rg-grid__editor",i.invalid&&"rg-grid__editor--invalid",q.editor),style:{textAlign:r.align,...U.editor},value:i.draft===null||i.draft===void 0?"":String(i.draft),inputMode:r.type==="number"?"decimal":void 0,"aria-label":`Edit ${He(r)}`,"aria-invalid":i.invalid||void 0,onChange:d=>{const h=d.target.value;qe(y=>y&&{...y,draft:h,invalid:!1})},onFocus:d=>{const h=d.currentTarget;a||(i.select==="all"?h.select():h.setSelectionRange(h.value.length,h.value.length))},onBlur:d=>{if(i.session===Fe.current){if(Zr(d.currentTarget))return $e();Ye(e,r,{text:d.currentTarget.value},{focus:!1})||$e()}},onKeyDown:d=>or(d,e,r)})},qo=p.useMemo(()=>{const e=new Map;for(const r of B)r.filterable&&!r.filterRenderer&&Lr(r)==="select"&&e.set(r.field,xs(r,Ft,i=>ye(i,r.field),i=>St(r,i)));return e},[B,Ft]),zo={...Je!==void 0?{"--rg-row-duration":`${Je}ms`,"--rg-row-exit-duration":`${Math.round(Je*.8)}ms`}:null,...Qe!==void 0?{"--rg-row-stagger":`${Qe}ms`}:null},Yo=Dt||!!ge,Vo=ge?{"--rg-stripe-a":ge[0],"--rg-stripe-b":ge[1]}:void 0,Ho=De&&L&&(Y==="top"||Y==="both"),Xo=De&&L&&(Y==="bottom"||Y==="both"),Go=_e&&(N||!!ut||lt||!!We),Dr=e=>l.jsxs("div",{className:O("rg-grid__footer",e==="top"&&"rg-grid__footer--top",q.footer),style:U.footer,"data-position":e,children:[l.jsxs("span",{...J("rowCount","rg-grid__count"),children:[it===0?"0 rows":`${yo}–${_o} of ${it}`,ae&&ke.length>0?` · ${ke.length} selected`:""]}),l.jsxs("div",{...J("pagination","rg-grid__pagination"),children:[l.jsxs("label",{className:"rg-grid__page-size-label",children:["Rows per page",l.jsx("select",{value:te,onChange:r=>fo(Number(r.target.value)),...J("pageSize","rg-grid__page-size"),children:(je.includes(te)?je:[...je,te].sort((r,i)=>r-i)).map(r=>l.jsx("option",{value:r,children:r},r))})]}),l.jsx("button",{type:"button","aria-label":"First page",disabled:ne===0,onClick:()=>ot(0),...J("pageButton","rg-grid__page-btn"),children:"«"}),l.jsx("button",{type:"button","aria-label":"Previous page",disabled:ne===0,onClick:()=>ot(ne-1),...J("pageButton","rg-grid__page-btn"),children:"‹"}),l.jsxs("span",{...J("pageInfo","rg-grid__page-info"),children:["Page ",ne+1," of ",Ie]}),l.jsx("button",{type:"button","aria-label":"Next page",disabled:ne>=Ie-1,onClick:()=>ot(ne+1),...J("pageButton","rg-grid__page-btn"),children:"›"}),l.jsx("button",{type:"button","aria-label":"Last page",disabled:ne>=Ie-1,onClick:()=>ot(Ie-1),...J("pageButton","rg-grid__page-btn"),children:"»"})]})]}),Jo=(e,r,i)=>{const a=e.sortIndicator??Ke,d=a!=="default";return l.jsx("span",{...J("sortIndicator",O("rg-grid__sort",d&&"rg-grid__sort--custom")),"aria-hidden":"true","data-direction":r??"none",children:a==="arrow"?l.jsx(io,{direction:r,priority:i}):a!=="default"?p.createElement(a,{column:e,direction:r,priority:i}):l.jsxs(l.Fragment,{children:[r==="asc"?"▲":r==="desc"?"▼":"↕",i!==void 0&&l.jsx("sup",{className:"rg-grid__sort-order",children:i})]})})},Qo=e=>l.jsx("tr",{className:"rg-grid__tr rg-grid__skeleton-row","aria-hidden":"true",style:le?{height:fe}:void 0,children:Ge?l.jsx("td",{colSpan:xt,className:"rg-grid__td rg-grid__skeleton-cell",children:p.createElement(Ge,{rowIndex:e,columns:B})}):l.jsxs(l.Fragment,{children:[ae&&l.jsx("td",{className:"rg-grid__td",children:l.jsx("span",{...J("skeleton","rg-grid__skeleton"),style:{...U.skeleton,width:18}})}),B.map((r,i)=>l.jsx("td",{className:"rg-grid__td",style:{textAlign:r.align},children:l.jsx("span",{...J("skeleton","rg-grid__skeleton"),style:{...U.skeleton,width:`${55+(e*7+i*13)%35}%`}})},r.field))]})},`sk${e}`),Tr=(e,r,i=L&&!e.sequenceRestartEachPage?ne*te:0)=>(e.sequenceStart??1)+i+r,Fr=(e,r,i)=>{const{row:a,id:d,index:h}=e,y=!!i,C=typeof et=="function"?et(a,h):et,M=typeof tt=="function"?tt(a,h):tt,P=Wt.has(d),Q=typeof Ze=="function"?Ze(a,h):Ze,pe=typeof Ne=="function"?Ne(a,h):Ne,Dn=Q||(lr==="none"?void 0:O("rg-grid__row--enter",`rg-row-in--${lr}`)),nn=pe||O("rg-grid__row--exit",Sn!=="none"&&`rg-row-out--${Sn}`);return l.jsxs("tr",{onClick:dt&&!y?()=>dt(a,h):void 0,"aria-hidden":y||void 0,onAnimationEnd:i?I=>I.target===I.currentTarget&&Nn(i.id):void 0,"aria-selected":ae?P:void 0,className:O("rg-grid__tr","rg-grid__row",Yo&&(r%2===0?"rg-grid__row--stripe-a":"rg-grid__row--stripe-b"),jn&&!y&&Dn,y&&nn,P&&"rg-grid__row--selected",dt&&"rg-grid__row--clickable",q.row,C),style:{...jn?{"--rg-i":i?Math.min(i.batch,24):Mo(d)}:null,...le?{height:fe}:null,...U.row,...M},children:[ae&&l.jsx("td",{className:O("rg-grid__td rg-grid__select-cell",Qt&&"rg-grid__pinned rg-grid__pinned--left"),style:{width:Le,minWidth:Le,maxWidth:Le,...Qt?{left:0}:null},onClick:Ve,children:l.jsx("span",{className:"rg-grid__checkbox-cell",onClickCapture:I=>Jn.current=I.shiftKey,children:l.jsx(Xe,{variant:ve,checked:P,disabled:y||!Kt(a),"aria-label":ae==="single"?"Select row":`Select row ${h+1}`,onChange:I=>ko(e,I),classNames:{root:q.checkbox,control:q.checkboxControl,indicator:q.checkboxIndicator},styles:{root:U.checkbox,control:U.checkboxControl,indicator:U.checkboxIndicator}})})}),B.map((I,wt)=>{let X=So(I,e);if(I.type==="sequence"){const we=Tr(I,r);X={...X,value:we,formattedValue:I.valueFormatter?I.valueFormatter(we,a):String(we),editable:!1}}const Tn=typeof I.cellClassName=="function"?I.cellClassName(X):I.cellClassName,Z=typeof I.cellStyle=="function"?I.cellStyle(X):I.cellStyle,xe=gt!==null&&gt.id===d&&gt.field===I.field,re=Yt(I,X),rn=pr(I,wt),on=pn?pn.id===d&&pn.field===I.field:r===0&&wt===0;return l.jsx("td",{ref:y?void 0:we=>{const Mr=Rn(d,I.field);we?Rt.current.set(Mr,we):Rt.current.delete(Mr)},tabIndex:y?void 0:Be?on?0:-1:re?0:void 0,onFocus:Be&&!y?we=>we.target===we.currentTarget&&qn({id:d,field:I.field}):void 0,onDoubleClick:re&&!y?()=>Ht(e,I):void 0,onKeyDown:y?void 0:we=>Eo(we,e,I,X),className:O("rg-grid__td",re&&"rg-grid__td--editable",xe&&"rg-grid__td--editing",rn.className,q.cell,I.className,Tn),style:{textAlign:I.align,...U.cell,...I.style,...Z,...rn.style},children:xe&&gt&&!y?Ko(e,I,gt):I.cellRenderer?p.createElement(I.cellRenderer,X):I.type==="boolean"&&!I.cellEditor?Ao(I,X):X.formattedValue},I.field)})]},y?`ghost:${d}`:d)},Zo=Me.trim()!==""||st.length>0?"no-results":"no-data",es=Ue??(L?Math.min(te,20):5);return l.jsxs("div",{ref:zn,className:O("rg-grid",le&&"rg-grid--virtual",q.root,R),style:{...Vo,...zo,...U.root,...me},"data-rg-theme":T||void 0,"aria-busy":bt||void 0,children:[Go&&l.jsxs("div",{...J("toolbar","rg-grid__toolbar"),children:[l.jsxs("div",{className:"rg-grid__toolbar-left",children:[N&&l.jsx("input",{type:"search",value:ht,onChange:e=>Bn(e.target.value),placeholder:D,"aria-label":"Search all columns",...J("search","rg-grid__search")}),ae&&ke.length>0&&l.jsxs("span",{className:"rg-grid__selected-count",role:"status",children:[ke.length," selected"]})]}),l.jsxs("div",{className:"rg-grid__toolbar-actions",children:[ut,lt&&l.jsx(Ss,{columns:t,hidden:Mt,onToggle:po,theme:T,className:q.toolButton,style:U.toolButton}),We&&(Zt.length>1?l.jsx(Fs,{formats:Zt,scopes:Cr,scope:Uo,onScopeChange:Lo,onExport:(e,r)=>Sr(e,{scope:r}),theme:T,className:O(q.toolButton,q.exportMenu),style:{...U.toolButton,...U.exportMenu}}):l.jsx("button",{type:"button",onClick:()=>Sr(Zt[0]),...J("toolButton","rg-grid__tool-btn"),children:Ts(Zt[0])}))]})]}),Ho&&Dr("top"),l.jsx("div",{ref:mt,...J("scroll","rg-grid__scroll"),onScroll:le?e=>Yn({top:e.currentTarget.scrollTop,height:e.currentTarget.clientHeight}):void 0,style:{...U.scroll,...G!==void 0?{maxHeight:G}:le?{maxHeight:400}:null},children:l.jsxs("table",{...J("table","rg-grid__table"),role:"grid",style:En?{...U.table,tableLayout:"fixed",width:B.reduce((e,r)=>e+Jt(r),ae?Le:0),minWidth:"100%"}:U.table,children:[l.jsx("thead",{...J("thead","rg-grid__thead"),children:l.jsxs("tr",{...J("headerRow","rg-grid__tr"),children:[ae&&l.jsx("th",{scope:"col",className:O("rg-grid__th rg-grid__select-cell",Qt&&"rg-grid__pinned rg-grid__pinned--left",q.headerCell),style:{width:Le,minWidth:Le,maxWidth:Le,...Qt?{left:0}:null,...U.headerCell},children:ae==="multiple"&&l.jsx("span",{className:"rg-grid__checkbox-cell",children:l.jsx(Xe,{variant:ve,checked:Zn,indeterminate:Qn>0&&!Zn,disabled:yt.length===0,"aria-label":"Select all rows",onChange:er,classNames:{root:q.checkbox,control:q.checkboxControl,indicator:q.checkboxIndicator},styles:{root:U.checkbox,control:U.checkboxControl,indicator:U.checkboxIndicator}})})}),B.map((e,r)=>{const i=he.findIndex(C=>C.field===e.field),a=i>=0?he[i].direction:null,d=xn(e),h=Hn(e),y=pr(e,r);return l.jsxs("th",{ref:C=>{C?pt.current.set(e.field,C):pt.current.delete(e.field)},scope:"col","aria-sort":a?a==="asc"?"ascending":"descending":d?"none":void 0,tabIndex:d?0:void 0,onClick:C=>tr(e,C.shiftKey),onKeyDown:C=>{d&&C.target===C.currentTarget&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),tr(e,C.shiftKey))},className:O("rg-grid__th",d&&"rg-grid__th--sortable",y.className,q.headerCell,e.className,e.headerClassName),style:{width:En?Jt(e):e.width,minWidth:e.minWidth,textAlign:e.align,...U.headerCell,...e.style,...e.headerStyle,...y.style},children:[l.jsxs("span",{className:"rg-grid__th-content",children:[e.headerRenderer?p.createElement(e.headerRenderer,{column:e,sortDirection:a}):e.headerCheckbox&&e.type==="boolean"?Wo(e):jt(e),e.filterable&&l.jsx(ks,{column:e,label:He(e),kind:h,value:rt[e.field],onChange:C=>{const M={...rt};C===void 0?delete M[e.field]:M[e.field]=C,Wn(M)},options:qo.get(e.field)??[],debounce:e.filterDebounce??ie,theme:T,indicatorClassName:O(q.filterIndicator,e.filterIndicatorClassName),indicatorStyle:{...U.filterIndicator,...e.filterIndicatorStyle},popupClassName:O(q.filterPopup,e.filterPopupClassName),popupStyle:{...U.filterPopup,...e.filterPopupStyle},inputClassName:q.filterInput,inputStyle:U.filterInput}),d&&Jo(e,a,a&&he.length>1?i+1:void 0)]}),e.resizable&&l.jsx("span",{className:"rg-grid__resizer",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${He(e)}`,onPointerDown:C=>Ro(C,e),onClick:Ve,onDoubleClick:Ve})]},e.field)})]})}),l.jsx("tbody",{...J("tbody","rg-grid__tbody"),children:bt?Array.from({length:es},(e,r)=>Qo(r)):yn?l.jsx("tr",{children:l.jsxs("td",{colSpan:xt,...J("empty","rg-grid__empty rg-grid__error"),role:"alert",children:[Nt," ",l.jsx("button",{type:"button",className:"rg-grid__tool-btn",onClick:()=>At(Lt.current),children:"Retry"})]})}):W.length===0&&Se.length===0?l.jsx("tr",{children:l.jsx("td",{colSpan:xt,...J("empty",O("rg-grid__empty",ft&&"rg-grid__empty--custom")),children:ft?p.createElement(ft,{reason:Zo,search:Me.trim(),filters:Object.fromEntries(st),columns:B,clearAll:()=>{Bn(""),Wn({})}}):Et})}):l.jsxs(l.Fragment,{children:[_t&&Xt>0&&l.jsx("tr",{"aria-hidden":"true",className:"rg-grid__spacer",children:l.jsx("td",{colSpan:xt,style:{height:Xt*fe}})}),Io.map(e=>e.kind==="row"?Fr(e.entry,Xt+e.i):Fr(e.ghost.entry,0,e.ghost)),_t&&kn<W.length&&l.jsx("tr",{"aria-hidden":"true",className:"rg-grid__spacer",children:l.jsx("td",{colSpan:xt,style:{height:(W.length-kn)*fe}})})]})})]})}),Xo&&Dr("bottom")]})}exports.Checkbox=Xe;exports.DataGrid=ni;exports.SortArrow=io;
20
+ <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="${gn(s)}" sheetId="1" r:id="rId1"/></sheets><definedNames><definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">${gn(f)}!$A$1:$${u}$${n.length+1}</definedName></definedNames></workbook>`,"xl/_rels/workbook.xml.rels":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
21
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>`,"xl/styles.xml":dl,"xl/worksheets/sheet1.xml":fl(t,n)},m=await rl(Object.entries(c).map(([x,_])=>({name:x,data:xo.encode(_)})));return new Blob([m],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}const Bn=new Set(["__proto__","prototype","constructor"]),bo=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function be(t,n){if(t===null||typeof t!="object")return;if(bo(t,n))return t[n];let o=t;for(const s of n.split(".")){if(o==null||typeof o!="object"||Bn.has(s))return;o=o[s]}return o}function oo(t,n,o){if(Array.isArray(t)){const s=[...t];return s[n]=o,s}return{...t,[n]:o}}function Kn(t,n,o){const s=t??{};if(bo(s,n)||!n.includes("."))return Bn.has(n)?t:oo(s,n,o);const[f,...u]=n.split(".");if(Bn.has(f))return t;const c=s[f];return oo(s,f,Kn(c!==null&&typeof c=="object"?c:{},u.join("."),o))}function so(t,n){if(n.length===0)return t.map((c,m)=>({kind:"row",entry:c,i:m}));const o=new Map;for(const c of n)o.set(c.afterId,[...o.get(c.afterId)??[],c]);const s=[],f=new Set,u=c=>{for(const m of o.get(c)??[])f.has(m.id)||(f.add(m.id),s.push({kind:"ghost",ghost:m}),u(m.id))};return u(null),t.forEach((c,m)=>{s.push({kind:"row",entry:c,i:m}),u(c.id)}),n.forEach(c=>!f.has(c.id)&&s.push({kind:"ghost",ghost:c})),s}const pl=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,Ee=38,gl=150,lo=10,Wn=(t,n)=>`${typeof t}:${t}\0${n}`;function jt(t,n){const o=be(n,t.field);return t.valueFormatter?t.valueFormatter(o,n):t.type==="boolean"&&typeof o=="boolean"?o?"Yes":"No":t.type==="date"?Es(o,t.dateLocale,t.dateFormat):o==null?"":o instanceof Date?o.toLocaleDateString():String(o)}function ml(t,n,o){if(o.type==="date"){const s=ue(t)??"",f=ue(n)??"";return s<f?-1:s>f?1:0}return typeof t=="number"&&typeof n=="number"?t-n:t instanceof Date&&n instanceof Date?t.getTime()-n.getTime():typeof t=="boolean"&&typeof n=="boolean"?Number(t)-Number(n):String(t).localeCompare(String(n),void 0,{numeric:!0,sensitivity:"base"})}const xl=t=>t?Array.isArray(t)?t:[t]:[],io=t=>t.type==="date"&&t.validity.badInput;function bl({columns:t,rows:n,getRowId:o,editable:s=!1,enterMovesDown:f=!0,onCellEdit:u,onRowsChange:c,rowSelection:m=!1,selectedRowIds:x,defaultSelectedRowIds:_,onSelectionChange:F,isRowSelectable:b,sort:S,defaultSort:g=null,onSortChange:k,multiSort:E=!1,searchable:N=!1,searchPlaceholder:T="Search…",search:v,onSearchChange:R,filters:Y,onFiltersChange:K,pagination:U=!1,paginationPosition:z="bottom",showToolbar:ye=!0,showFooter:De=!0,pageSize:Oe=10,pageSizeOptions:Se=[5,10,25,50],page:q,onPageChange:oe,onPageSizeChange:je,serverSide:w=!1,rowCount:H,onQueryChange:j,queryDebounce:A=250,filterDebounce:le=300,loading:fe,loadingRows:Ue,skeletonRow:Qe,errorMessage:Dt="Could not load the data.",columnMenu:it=!1,onColumnVisibilityChange:Ae,keyboardNavigation:We=!1,virtualize:ie=!1,rowHeight:he=40,overscan:at=6,exportable:Be=!1,onExportError:ct,apiRef:Te,onRowClick:dt,toolbar:ut,emptyMessage:Tt="No rows to show",emptyComponent:ft,sortIndicator:Ke="default",sortIndicatorRotate:Ft=!0,striped:Ce=!1,stripeColors:_e,checkboxVariant:Ze="native",animateRows:ht=!0,rowAnimation:ae,rowAnimationDuration:qe,rowAnimationStagger:et,rowAnimationClassName:tt,rowExitAnimationClassName:D,theme:G,maxHeight:$,stickyToolbar:se=!1,stickyHeader:ze=!1,stickyOffset:Fe=0,scrollbar:Mt="thin",className:It,style:yo,classNames:V={},styles:W={},rowClassName:xn,rowStyle:bn}){const J=(e,r)=>({className:O(r,V[e]),style:W[e]}),[$t,zn]=p.useState(n),nt=p.useRef(n);p.useEffect(()=>{nt.current=n,zn(n)},[n]);const Yn=e=>{nt.current=e,zn(e)},[pt,Vn]=St(v,"",R),[rt,Hn]=St(Y,{},K),[pe,_o]=St(S,xl(g),k),[yn,ot]=St(q,0,oe),[ee,wo]=p.useState(Oe),vo=e=>{wo(e),je==null||je(e)},[Rt,ko]=p.useState(()=>new Set(t.filter(e=>e.hidden).map(e=>e.field))),So=(e,r)=>{const l=new Set(Rt);r?l.add(e):l.delete(e),ko(l),Ae==null||Ae([...l])},[_n,Xn]=p.useState({}),[Pt,jo]=p.useState({}),[yl,Co]=p.useState(0),gt=p.useRef(new Map),[mt,Ye]=p.useState(null),Me=p.useRef(0),Lt=p.useRef(null),Ot=p.useRef(new Map),[wn,Gn]=p.useState(null),vn=p.useRef(null),Jn=p.useRef(null),xt=p.useRef(null),[kn,Qn]=p.useState({top:0,height:0}),P=p.useMemo(()=>{const e=t.filter(r=>!Rt.has(r.field)).map(r=>r.type==="sequence"?{...r,sortable:!1,filterable:!1,editable:!1,filterRenderer:void 0}:r);return[...e.filter(r=>r.pinned==="left"),...e.filter(r=>r.pinned!=="left"&&r.pinned!=="right"),...e.filter(r=>r.pinned==="right")]},[t,Rt]),Sn=e=>e.sortable===!0,ce=m==="single"?"single":m?"multiple":null,bt=P.length+(ce?1:0),Ve=p.useMemo(()=>$t.map((e,r)=>({row:e,index:r,id:o?o(e,r):r})),[$t,o]),Zn=p.useRef(new Map);Ve.forEach(e=>Zn.current.set(e.id,e.row));const st=p.useMemo(()=>Object.entries(rt).filter(([e,r])=>{const l=P.find(a=>a.field===e);return!!l&&!!l.filterable&&ho(r)}),[rt,P]),[No,Eo]=p.useState(pt);p.useEffect(()=>{if(!w)return;const e=setTimeout(()=>Eo(pt),A);return()=>clearTimeout(e)},[pt,w,A]);const Ie=w?No:pt,er=e=>e.filterRenderer?"text":zr(e),Ne=p.useMemo(()=>{if(w)return Ve;const e=Ie.trim().toLowerCase();let r=Ve.filter(({row:a})=>e&&!P.some(d=>jt(d,a).toLowerCase().includes(e))?!1:st.every(([d,h])=>{const y=P.find(C=>C.field===d);return Ms(er(y),h,jt(y,a),be(a,d))}));const l=pe.map(a=>({col:P.find(d=>d.field===a.field),dir:a.direction==="asc"?1:-1})).filter(a=>!!a.col);return l.length&&(r=[...r].sort((a,d)=>{for(const{col:h,dir:y}of l){const C=be(a.row,h.field),M=be(d.row,h.field),L=C==null||C==="",Q=M==null||M==="";if(L||Q){if(L!==Q)return L?1:-1;continue}const ge=h.comparator?h.comparator(C,M,a.row,d.row):ml(C,M,h);if(ge!==0)return ge*y}return 0})),r},[Ve,P,Ie,st,pe,w]),Ut=JSON.stringify([Ie,rt,pe,ee]),tr=p.useRef(Ut);p.useEffect(()=>{tr.current!==Ut&&(tr.current=Ut,ot(0))},[Ut]);const lt=w?H??Ve.length:Ne.length,$e=U?Math.max(1,Math.ceil(lt/ee)):1,te=Math.min(yn,$e-1),B=U&&!w?Ne.slice(te*ee,te*ee+ee):Ne,Do=lt===0?0:U?te*ee+1:1,To=U?Math.min(lt,(te+1)*ee):lt,jn=p.useMemo(()=>({sort:pe.filter(e=>{const r=t.find(l=>l.field===e.field);return!!r&&Sn(r)}),filters:Object.fromEntries(st),search:Ie.trim(),page:te,pageSize:ee}),[pe,t,st,Ie,te,ee]),Fo=JSON.stringify(jn),At=p.useRef(jn);At.current=jn;const Wt=p.useRef(j);Wt.current=j;const[Mo,Bt]=p.useState(!1),[Cn,Nn]=p.useState(!1),En=p.useRef(0),Kt=p.useCallback(e=>{var a;const r=++En.current,l=(a=Wt.current)==null?void 0:a.call(Wt,e);l&&typeof l.then=="function"?(Bt(!0),Nn(!1),l.then(()=>{r===En.current&&Bt(!1)},()=>{r===En.current&&(Bt(!1),Nn(!0))})):(Bt(!1),Nn(!1))},[]);p.useEffect(()=>{w&&Kt(At.current)},[w,Fo,Kt]),p.useEffect(()=>{w&&U&&yn>$e-1&&ot($e-1)},[w,U,yn,$e]);const yt=fe??Mo,nr=e=>e.map(r=>Zn.current.get(r)).filter(r=>r!==void 0),[ve,qt]=St(x,_??[],e=>F==null?void 0:F({ids:e,rows:nr(e)})),zt=p.useMemo(()=>new Set(ve),[ve]),Yt=e=>b?b(e):!0,Vt=p.useRef(null),rr=p.useRef(!1),Io=(e,r)=>{if(!ce||!Yt(e.row))return;if(ce==="single"){qt(r?[e.id]:[]),Vt.current=e.id;return}const l=new Set(ve),a=rr.current&&Vt.current!==null?B.findIndex(h=>h.id===Vt.current):-1,d=B.findIndex(h=>h.id===e.id);if(a>=0&&d>=0)for(let h=Math.min(a,d);h<=Math.max(a,d);h++)Yt(B[h].row)&&(r?l.add(B[h].id):l.delete(B[h].id));else r?l.add(e.id):l.delete(e.id);Vt.current=e.id,qt([...l])},_t=p.useMemo(()=>Ne.filter(e=>Yt(e.row)),[Ne,b]),or=_t.filter(e=>zt.has(e.id)).length,sr=_t.length>0&&or===_t.length,lr=e=>{const r=new Set(ve);_t.forEach(l=>e?r.add(l.id):r.delete(l.id)),qt([...r])},Ht=(e,r,l)=>({value:be(r,e.field),formattedValue:jt(e,r),row:r,rowIndex:l,field:e.field,column:e}),Dn=(e,r)=>{const l=e.editable??s;return typeof l=="function"?l(r):!!l},Xt=(e,r)=>Dn(e,r)&&!(e.type==="boolean"&&!e.cellEditor),$o=(e,r)=>{const l=Ht(e,r.row,r.index),a=Dn(e,l);return{...l,editable:a,updateValue:d=>a&&ar(r,e,{value:d})}},ir=(e,r)=>{if(!Sn(e))return;const l=pe.find(h=>h.field===e.field),a=l?l.direction==="asc"?"desc":null:"asc";let d;r&&E?a?l?d=pe.map(h=>h.field===e.field?{...h,direction:a}:h):d=[...pe,{field:e.field,direction:a}]:d=pe.filter(h=>h.field!==e.field):d=a?[{field:e.field,direction:a}]:[],_o(d)},Gt=(e,r)=>{var l;return(l=Ot.current.get(Wn(e,r)))==null?void 0:l.focus()},Re=()=>{Me.current+=1,Ye(null)},Ro=e=>{for(const r of nt.current){const l=be(r,e.field);if(l!=null&&l!=="")return l}},Jt=(e,r,l={})=>{if(!Xt(r,Ht(r,e.row,e.index)))return!1;const a=be(e.row,r.field);let d;return r.cellEditor?d=a:r.type==="date"?d=ue(a)??"":d=l.text??(a==null?"":String(a)),Lt.current=d,Me.current+=1,Ye({id:e.id,field:r.field,draft:d,session:Me.current,select:l.select??"end",invalid:!1}),!0},ar=(e,r,l)=>{const a=nt.current[e.index]??e.row,d=be(a,r.field);let h;if("value"in l)h=l.value;else if(r.valueParser)h=r.valueParser(l.text,a);else if(r.type==="date"){if(l.text!==""&&!re(l.text))return!1;h=Ds(l.text,d??Ro(r))}else if(r.type==="number")if(l.text.trim()==="")h=null;else{const M=Number(l.text);if(!Number.isFinite(M))return!1;h=M}else h=l.text;if(r.type==="date"){if(ue(h)===ue(d))return!0;const M=ue(h);if(M&&(r.dateMin&&M<r.dateMin||r.dateMax&&M>r.dateMax))return!1}else if(Object.is(h,d))return!0;if(r.validate&&!r.validate(h,a))return!1;const y=Kn(a,r.field,h),C=nt.current.map((M,L)=>L===e.index?y:M);return Yn(C),u==null||u({rowId:e.id,rowIndex:e.index,field:r.field,oldValue:d,newValue:h,row:y}),c==null||c(C),!0},cr=(e,r,l)=>{const a=B.findIndex(L=>L.id===e.id),d=P.findIndex(L=>L.field===r);if(a<0||d<0)return null;const h=(L,Q)=>Xt(Q,Ht(Q,L.row,L.index));if(l==="down"||l==="up"){const L=l==="down"?1:-1;for(let Q=a+L;Q>=0&&Q<B.length;Q+=L)if(h(B[Q],P[d]))return{entry:B[Q],col:P[d]};return null}const y=l==="right"?1:-1;let C=a,M=d+y;for(;C>=0&&C<B.length;){for(;M>=0&&M<P.length;){if(h(B[C],P[M]))return{entry:B[C],col:P[M]};M+=y}C+=y,M=y>0?0:P.length-1}return null},He=(e,r,l,a={})=>{const{move:d="none",focus:h=!0}=a;if(!ar(e,r,l))return Ye(C=>C&&{...C,invalid:!0}),!1;const y=d==="none"?null:cr(e,r.field,d);return y?Jt(y.entry,y.col,{select:"all"}):(Re(),h&&Gt(e.id,r.field)),!0},dr=(e,r,l)=>{if(e.nativeEvent.isComposing)return;const a=e.currentTarget.value,d=io(e.currentTarget);if(e.key==="Enter"){if(e.preventDefault(),d)return Ye(y=>y&&{...y,invalid:!0});const h=f?e.shiftKey?"up":"down":"none";He(r,l,{text:a},{move:h})}else if(e.key==="Escape")e.preventDefault(),Re(),Gt(r.id,l.field);else if(e.key==="Tab"&&!d){const h=e.shiftKey?"left":"right";cr(r,l.field,h)&&(e.preventDefault(),He(r,l,{text:a},{move:h}))}},Po=(e,r)=>{var h;const l=B[e],a=P[r];if(!l||!a)return;Gn({id:l.id,field:a.field}),vn.current=Wn(l.id,a.field);const d=xt.current;if(ie&&d){const y=((h=d.querySelector("thead"))==null?void 0:h.clientHeight)??0,C=e*he;C<d.scrollTop?d.scrollTo({top:C,behavior:"auto"}):C+he>d.scrollTop+d.clientHeight-y&&d.scrollTo({top:C+he-d.clientHeight+y,behavior:"auto"})}};p.useEffect(()=>{const e=vn.current;if(!e)return;const r=Ot.current.get(e);r&&(vn.current=null,r.focus())});const Lo=(e,r,l)=>{if(!We)return!1;let a=B.findIndex(h=>h.id===r.id),d=P.findIndex(h=>h.field===l.field);if(a<0||d<0)return!1;switch(e.key){case"ArrowDown":a+=1;break;case"ArrowUp":a-=1;break;case"ArrowRight":d+=1;break;case"ArrowLeft":d-=1;break;case"PageDown":a+=lo;break;case"PageUp":a-=lo;break;case"Home":d=0,(e.ctrlKey||e.metaKey)&&(a=0);break;case"End":d=P.length-1,(e.ctrlKey||e.metaKey)&&(a=B.length-1);break;default:return!1}return e.preventDefault(),Po(Math.max(0,Math.min(B.length-1,a)),Math.max(0,Math.min(P.length-1,d))),!0},Oo=(e,r,l,a)=>{e.target===e.currentTarget&&(Lo(e,r,l)||Xt(l,a)&&(e.key==="Enter"||e.key==="F2"?(e.preventDefault(),Jt(r,l)):!l.cellEditor&&l.type!=="date"&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),Jt(r,l,{text:e.key}))))};Nt(()=>{if(!ie||!xt.current)return;const e=xt.current,r=()=>Qn(a=>a.height===e.clientHeight?a:{...a,height:e.clientHeight});if(r(),typeof ResizeObserver>"u")return;const l=new ResizeObserver(r);return l.observe(e),()=>l.disconnect()},[ie]);const wt=ie&&!yt&&B.length>0,Uo=kn.height||(typeof $=="number"?$:400),Qt=wt?Math.max(0,Math.floor(kn.top/he)-at):0,Tn=wt?Math.min(B.length,Math.ceil((kn.top+Uo)/he)+at):B.length,ur=wt?B.slice(Qt,Tn):B,Ao=`${te}|${ee}|${JSON.stringify(pe)}|${Ie}|${JSON.stringify(rt)}`,fr=p.useRef(!0);p.useEffect(()=>{if(fr.current){fr.current=!1;return}const e=xt.current;e&&typeof e.scrollTo=="function"&&e.scrollTop>0&&e.scrollTo({top:0,behavior:"smooth"})},[Ao]);const hr=(typeof ae=="string"?ae:ae==null?void 0:ae.enter)??"slide-up",Fn=(typeof ae=="string"?ae:(ae==null?void 0:ae.exit)??(ae==null?void 0:ae.enter))??"slide-up",Mn=ht&&!ie,pr=Mn&&(Fn!=="none"||!!D),gr=qe??380,mr=et??28,Zt=p.useRef(new Map);let Wo=0;const Bo=e=>{let r=Zt.current.get(e);return r===void 0&&(r=Wo++,Zt.current.set(e,r)),Math.min(r,24)},[ke,xr]=p.useState([]),br=p.useRef({rows:[],order:[],pageKey:""}),Pe=p.useRef(new Map),In=`${te}|${ee}|${w}`,$n=p.useCallback(e=>{const r=Pe.current.get(e);r!==void 0&&clearTimeout(r),Pe.current.delete(e),xr(l=>{const a=l.find(d=>d.id===e);return a?l.filter(d=>d.id!==e).map(d=>d.afterId===e?{...d,afterId:a.afterId}:d):l})},[]);Nt(()=>{const e=br.current,r=new Set(B.map(d=>d.id));Zt.current.forEach((d,h)=>!r.has(h)&&Zt.current.delete(h));const l=!pr||yt||Cn||e.pageKey!==In||pl();let a=ke;if(l)a=[];else{a=a.filter(h=>!r.has(h.id));const d=e.rows.filter(h=>!r.has(h.id)&&!a.some(y=>y.id===h.id));if(d.length>0){const h=d.map((y,C)=>{const M=e.order.indexOf(y.id);return{id:y.id,entry:y,afterId:M>0?e.order[M-1]:null,batch:C}});a=[...a,...h]}}(a.length!==ke.length||a.some((d,h)=>d!==ke[h]))&&xr(a),br.current={rows:B,order:so(B,a).map(d=>d.kind==="row"?d.entry.id:d.ghost.id),pageKey:In}},[B,ke,yt,Cn,In,pr]),p.useEffect(()=>{const e=!!D;ke.forEach(r=>{if(Pe.current.has(r.id))return;const l=e?2500:gr*.8+mr*Math.min(r.batch,24)+250;Pe.current.set(r.id,setTimeout(()=>$n(r.id),l))}),Pe.current.forEach((r,l)=>{ke.some(a=>a.id===l)||(clearTimeout(r),Pe.current.delete(l))})},[ke,gr,mr,D,$n]),p.useEffect(()=>()=>{Pe.current.forEach(e=>clearTimeout(e)),Pe.current.clear()},[]);const Ko=p.useMemo(()=>so(ur,ke),[ur,ke]),yr=p.useRef(null),[qo,zo]=p.useState(0);Nt(()=>{const e=yr.current;if(!e||!se)return;const r=()=>zo(e.offsetHeight);if(r(),typeof ResizeObserver>"u")return;const l=new ResizeObserver(r);return l.observe(e),()=>l.disconnect()},[se]);const en=Object.keys(_n).length>0,tn=e=>_n[e.field]??(typeof e.width=="number"?e.width:gl),Yo=e=>Math.max(40,typeof e.minWidth=="number"?e.minWidth:60),nn=e=>e.overflow??(typeof e.width=="number"&&e.width<40?"clip":e.width!==void 0&&e.width!==""?"wrap":void 0),_r=e=>typeof e.width=="number"&&e.width<40?{paddingLeft:0,paddingRight:0}:null,Vo=P.some(e=>e.width!==void 0&&e.width!==null&&e.width!==""),Ho=P.length>0&&P.every(e=>typeof e.width=="number"),Xo=(e,r)=>{e.preventDefault(),e.stopPropagation();const l={..._n};en||P.forEach(L=>{var Q;return l[L.field]=((Q=gt.current.get(L.field))==null?void 0:Q.offsetWidth)??tn(L)});const a=e.clientX,d=l[r.field]??tn(r),h=e.currentTarget;h.setPointerCapture(e.pointerId),Xn(l);const y=L=>Math.min(r.maxWidth??1/0,Math.max(Yo(r),Math.round(L))),C=L=>Xn(Q=>({...Q,[r.field]:y(d+L.clientX-a)})),M=()=>{h.removeEventListener("pointermove",C),h.removeEventListener("pointerup",M),h.removeEventListener("pointercancel",M)};h.addEventListener("pointermove",C),h.addEventListener("pointerup",M),h.addEventListener("pointercancel",M)};Nt(()=>{var d,h;const e={};let r=ce&&P.some(y=>y.pinned==="left")?Ee:0;for(const y of P)y.pinned==="left"&&(e[y.field]=r,r+=((d=gt.current.get(y.field))==null?void 0:d.offsetWidth)??0);let l=0;for(const y of[...P].reverse())y.pinned==="right"&&(e[y.field]=l,l+=((h=gt.current.get(y.field))==null?void 0:h.offsetWidth)??0);const a=Object.keys(e);(a.length!==Object.keys(Pt).length||a.some(y=>e[y]!==Pt[y]))&&jo(e)}),p.useEffect(()=>{const e=()=>Co(r=>r+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const wr=P.map(e=>e.pinned).lastIndexOf("left"),Go=P.findIndex(e=>e.pinned==="right"),rn=wr>=0,vr=(e,r)=>({className:e.pinned?O("rg-grid__pinned",`rg-grid__pinned--${e.pinned}`,r===wr&&"rg-grid__pinned--edge",r===Go&&"rg-grid__pinned--edge"):void 0,style:e.pinned==="left"?{left:Pt[e.field]??0}:e.pinned==="right"?{right:Pt[e.field]??0}:void 0}),Le=typeof Be=="object"?Be:{},on=p.useMemo(()=>{var r;const e=(r=Le.formats)!=null&&r.length?Le.formats:["csv"];return e.filter((l,a)=>e.indexOf(l)===a)},[Be]),sn=(e={})=>{const r={...Le,...e,pdf:{...Le.pdf,...e.pdf}},l=r.scope??"filtered",a=l==="page"||l==="visible",d=a?B:l==="selected"?Ve.filter(ge=>zt.has(ge.id)):Ne,h=r.includeHidden?t:P,y=a&&U?te*ee:0,C=h.map(ge=>Ct(ge)||ge.field),M=[],L=[],Q=[];return d.forEach(({row:ge},Rn)=>{const cn=[],I=[],vt={};h.forEach((X,Pn)=>{const Z=be(ge,X.field);let me,ne;if(X.type==="sequence"){const un=Or(X,Rn,X.sequenceRestartEachPage?0:y);me=un,ne=un}else X.exportValue?(me=X.exportValue(Z,ge),ne=me??null):X.type==="date"?(me=ue(Z)??"",ne=me):(me=jt(X,ge),X.type==="number"&&typeof Z=="number"&&Number.isFinite(Z)||X.type==="boolean"&&typeof Z=="boolean"?ne=Z:X.valueFormatter?ne=me:Z==null?ne=null:typeof Z=="string"||typeof Z=="boolean"||typeof Z=="number"&&Number.isFinite(Z)?ne=Z:Z instanceof Date?ne=Number.isNaN(Z.getTime())?null:Z.toISOString():ne=me);cn.push(me),I.push(ne);const dn=r.jsonKeys==="header"?C[Pn]:X.field;vt[dn]=X.type==="date"&&ne===""?null:ne??null}),M.push(cn),L.push(I),Q.push(vt)}),{opts:r,cols:h,headers:C,display:M,typed:L,records:Q}},ln=(e,r)=>`${e.filename??"export"}.${r}`,kr=(e={})=>{const r=sn(e);return Ks(r.headers,r.display,{sanitize:r.opts.sanitize})},Sr=(e={})=>{const r={...Le,...e};qs(kr(e),ln(r,"csv"))},jr=(e={})=>{const r=sn(e);return JSON.stringify(r.records,null,r.opts.jsonIndent??2)},Cr=(e={})=>{const r={...Le,...e};hn(new Blob([jr(e)],{type:"application/json;charset=utf-8"}),ln(r,"json"))},Nr=async(e={})=>{const r=sn(e),l=r.cols.map(a=>({header:Ct(a)||a.field,kind:a.type==="number"||a.type==="sequence"?"number":a.type==="date"?"date":a.type==="boolean"?"boolean":"text",align:a.align??(a.type==="number"||a.type==="sequence"?"right":void 0)}));return hl(l,r.typed,{sheetName:r.opts.sheetName})},Er=async(e={})=>{const r={...Le,...e};hn(await Nr(e),ln(r,"xlsx"))},Dr=async(e={})=>{var l;const r=sn(e);return Qs({headers:r.headers,rows:r.display.map(a=>a.map(d=>d==null?"":String(d))),aligns:r.cols.map(a=>a.align??(a.type==="number"||a.type==="sequence"?"right":void 0)),fields:r.cols.map(a=>a.field)},r.opts.pdf,(l=r.opts.pdf)!=null&&l.matchGridStyle?Zs(Jn.current):void 0)},Tr=async(e={})=>{const r={...Le,...e};hn(await Dr(e),ln(r,"pdf"))},Fr=async(e,r={})=>e==="csv"?Sr(r):e==="json"?Cr(r):e==="xlsx"?Er(r):Tr(r),Mr=async(e,r={})=>{try{await Fr(e,r)}catch(l){const a=l instanceof Error?l:new Error(String(l));ct?ct(a,e):console.error(`[react-gridix] ${e.toUpperCase()} export failed:`,a)}},[Ir,Jo]=p.useState("visible"),Qo=Ve.filter(e=>zt.has(e.id)).length,$r=[{value:"visible",label:"Visible rows",count:B.length},...U?[{value:"filtered",label:"All matching rows",count:Ne.length}]:[],...ce?[{value:"selected",label:"Selected rows",count:Qo}]:[]],Zo=$r.some(e=>e.value===Ir&&e.count>0)?Ir:"visible";p.useEffect(()=>{Te&&(Te.current={getCsv:kr,exportCsv:Sr,getJson:jr,exportJson:Cr,getXlsx:Nr,exportXlsx:Er,getPdf:Dr,exportPdf:Tr,exportAs:Fr,getSelectedRows:()=>nr(ve),getSelectedRowIds:()=>ve,selectAll:()=>lr(!0),clearSelection:()=>qt([]),refresh:()=>{w&&Kt(At.current)}})}),p.useEffect(()=>()=>{Te&&(Te.current=null)},[Te]);const Rr=e=>{var l,a,d,h,y,C,M,L;const r=e.checkbox??{};return{variant:r.variant??Ze,indicator:r.indicator,className:r.className,style:r.style,classNames:{root:O(V.checkbox,(l=r.classNames)==null?void 0:l.root),control:O(V.checkboxControl,(a=r.classNames)==null?void 0:a.control),indicator:O(V.checkboxIndicator,(d=r.classNames)==null?void 0:d.indicator),label:(h=r.classNames)==null?void 0:h.label},styles:{root:{...W.checkbox,...(y=r.styles)==null?void 0:y.root},control:{...W.checkboxControl,...(C=r.styles)==null?void 0:C.control},indicator:{...W.checkboxIndicator,...(M=r.styles)==null?void 0:M.indicator},label:(L=r.styles)==null?void 0:L.label}}},Xe=e=>e.stopPropagation(),es=(e,r)=>i.jsx("span",{className:"rg-grid__checkbox-cell",onClick:Xe,onDoubleClick:Xe,children:i.jsx(Je,{...Rr(e),checked:!!r.value,disabled:!r.editable,"aria-label":`Toggle ${Ge(e)}`,onChange:l=>r.updateValue(l)})}),Pr=e=>Ne.filter(r=>Dn(e,Ht(e,r.row,r.index))),ts=(e,r)=>{const l=new Map(Pr(e).map(h=>[h.index,h])),a=[],d=nt.current.map((h,y)=>{const C=l.get(y);if(!C)return h;const M=be(h,e.field);if(!!M===r||e.validate&&!e.validate(r,h))return h;const L=Kn(h,e.field,r);return a.push({rowId:C.id,rowIndex:y,field:e.field,oldValue:M,newValue:r,row:L}),L});a.length!==0&&(Yn(d),a.forEach(h=>u==null?void 0:u(h)),c==null||c(d))},ns=e=>{const r=Pr(e),l=r.length>0?r:Ne,a=l.filter(h=>!!be(h.row,e.field)).length,d=l.length>0&&a===l.length;return i.jsx("span",{className:"rg-grid__header-checkbox",onClick:Xe,onDoubleClick:Xe,children:i.jsx(Je,{...Rr(e),checked:d,indeterminate:a>0&&!d,disabled:r.length===0,label:Ct(e)||void 0,"aria-label":`Select all ${Ge(e)}`,onChange:h=>ts(e,h)})})},rs=(e,r,l)=>{if(r.cellEditor)return i.jsx("div",{className:"rg-grid__custom-editor",onBlur:d=>{d.currentTarget.contains(d.relatedTarget)||l.session===Me.current&&(He(e,r,{value:Lt.current},{focus:!1})||Re())},onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),Re(),Gt(e.id,r.field))},children:p.createElement(r.cellEditor,{value:l.draft,row:e.row,rowIndex:e.index,field:r.field,column:r,onChange:d=>{Lt.current=d,Ye(h=>h&&h.session===l.session?{...h,draft:d,invalid:!1}:h)},onCommit:(d,h="none")=>{l.session===Me.current&&He(e,r,{value:d===void 0?Lt.current:d},{move:h})},onCancel:()=>{Re(),Gt(e.id,r.field)}})});const a=r.type==="date";return a?i.jsx(Ts,{value:l.draft===null||l.draft===void 0?"":String(l.draft),label:`Edit ${Ge(r)}`,invalid:l.invalid,min:r.dateMin,max:r.dateMax,locale:r.dateLocale,theme:G,className:O("rg-grid__editor",l.invalid&&"rg-grid__editor--invalid",V.editor),style:{textAlign:r.align,...W.editor},onChange:d=>Ye(h=>h&&{...h,draft:d,invalid:!1}),onPick:d=>{l.session===Me.current&&He(e,r,{text:d},{focus:!0})},onBlur:d=>{l.session===Me.current&&(He(e,r,{text:d.currentTarget.value},{focus:!1})||Re())},onKeyDown:d=>dr(d,e,r)}):i.jsx("input",{autoFocus:!0,type:a?"date":"text",min:a?r.dateMin:void 0,max:a?r.dateMax:void 0,className:O("rg-grid__editor",l.invalid&&"rg-grid__editor--invalid",V.editor),style:{textAlign:r.align,...W.editor},value:l.draft===null||l.draft===void 0?"":String(l.draft),inputMode:r.type==="number"?"decimal":void 0,"aria-label":`Edit ${Ge(r)}`,"aria-invalid":l.invalid||void 0,onChange:d=>{const h=d.target.value;Ye(y=>y&&{...y,draft:h,invalid:!1})},onFocus:d=>{const h=d.currentTarget;a||(l.select==="all"?h.select():h.setSelectionRange(h.value.length,h.value.length))},onBlur:d=>{if(l.session===Me.current){if(io(d.currentTarget))return Re();He(e,r,{text:d.currentTarget.value},{focus:!1})||Re()}},onKeyDown:d=>dr(d,e,r)})},os=p.useMemo(()=>{const e=new Map;for(const r of P)r.filterable&&!r.filterRenderer&&zr(r)==="select"&&e.set(r.field,Is(r,$t,l=>be(l,r.field),l=>jt(r,l)));return e},[P,$t]),ss={...qe!==void 0?{"--rg-row-duration":`${qe}ms`,"--rg-row-exit-duration":`${Math.round(qe*.8)}ms`}:null,...et!==void 0?{"--rg-row-stagger":`${et}ms`}:null},ls=Ce||!!_e,is=_e?{"--rg-stripe-a":_e[0],"--rg-stripe-b":_e[1]}:void 0,as=De&&U&&(z==="top"||z==="both"),cs=De&&U&&(z==="bottom"||z==="both"),ds=ye&&(N||!!ut||it||!!Be),Lr=e=>i.jsxs("div",{className:O("rg-grid__footer",e==="top"&&"rg-grid__footer--top",V.footer),style:W.footer,"data-position":e,children:[i.jsxs("span",{...J("rowCount","rg-grid__count"),children:[lt===0?"0 rows":`${Do}–${To} of ${lt}`,ce&&ve.length>0?` · ${ve.length} selected`:""]}),i.jsxs("div",{...J("pagination","rg-grid__pagination"),children:[i.jsxs("label",{className:"rg-grid__page-size-label",children:["Rows per page",i.jsx("select",{value:ee,onChange:r=>vo(Number(r.target.value)),...J("pageSize","rg-grid__page-size"),children:(Se.includes(ee)?Se:[...Se,ee].sort((r,l)=>r-l)).map(r=>i.jsx("option",{value:r,children:r},r))})]}),i.jsx("button",{type:"button","aria-label":"First page",disabled:te===0,onClick:()=>ot(0),...J("pageButton","rg-grid__page-btn"),children:"«"}),i.jsx("button",{type:"button","aria-label":"Previous page",disabled:te===0,onClick:()=>ot(te-1),...J("pageButton","rg-grid__page-btn"),children:"‹"}),i.jsxs("span",{...J("pageInfo","rg-grid__page-info"),children:["Page ",te+1," of ",$e]}),i.jsx("button",{type:"button","aria-label":"Next page",disabled:te>=$e-1,onClick:()=>ot(te+1),...J("pageButton","rg-grid__page-btn"),children:"›"}),i.jsx("button",{type:"button","aria-label":"Last page",disabled:te>=$e-1,onClick:()=>ot($e-1),...J("pageButton","rg-grid__page-btn"),children:"»"})]})]}),us=(e,r,l)=>{const a=r===null?"default":e.sortIndicator??Ke,d=a!=="default",h=Ft&&a!=="arrow",y=a==="arrow"?i.jsx(mo,{direction:r,priority:l}):a!=="default"?p.createElement(a,{column:e,direction:r,priority:l}):h?r?"▲":"↕":r==="asc"?"▲":r==="desc"?"▼":"↕";return i.jsxs("span",{...J("sortIndicator",O("rg-grid__sort",d&&"rg-grid__sort--custom")),"aria-hidden":"true","data-direction":r??"none",children:[h?i.jsx(el,{direction:r,children:y}):y,a==="default"&&l!==void 0&&i.jsx("sup",{className:"rg-grid__sort-order",children:l})]})},fs=e=>i.jsx("tr",{className:"rg-grid__tr rg-grid__skeleton-row","aria-hidden":"true",style:ie?{height:he}:void 0,children:Qe?i.jsx("td",{colSpan:bt,className:"rg-grid__td rg-grid__skeleton-cell",children:p.createElement(Qe,{rowIndex:e,columns:P})}):i.jsxs(i.Fragment,{children:[ce&&i.jsx("td",{className:"rg-grid__td",children:i.jsx("span",{...J("skeleton","rg-grid__skeleton"),style:{...W.skeleton,width:18}})}),P.map((r,l)=>i.jsx("td",{className:"rg-grid__td",style:{textAlign:r.align},children:i.jsx("span",{...J("skeleton","rg-grid__skeleton"),style:{...W.skeleton,width:`${55+(e*7+l*13)%35}%`}})},r.field))]})},`sk${e}`),Or=(e,r,l=U&&!e.sequenceRestartEachPage?te*ee:0)=>(e.sequenceStart??1)+l+r,Ur=(e,r,l)=>{const{row:a,id:d,index:h}=e,y=!!l,C=typeof xn=="function"?xn(a,h):xn,M=typeof bn=="function"?bn(a,h):bn,L=zt.has(d),Q=typeof tt=="function"?tt(a,h):tt,ge=typeof D=="function"?D(a,h):D,Rn=Q||(hr==="none"?void 0:O("rg-grid__row--enter",`rg-row-in--${hr}`)),cn=ge||O("rg-grid__row--exit",Fn!=="none"&&`rg-row-out--${Fn}`);return i.jsxs("tr",{onClick:dt&&!y?()=>dt(a,h):void 0,"aria-hidden":y||void 0,onAnimationEnd:l?I=>I.target===I.currentTarget&&$n(l.id):void 0,"aria-selected":ce?L:void 0,className:O("rg-grid__tr","rg-grid__row",ls&&(r%2===0?"rg-grid__row--stripe-a":"rg-grid__row--stripe-b"),Mn&&!y&&Rn,y&&cn,L&&"rg-grid__row--selected",dt&&"rg-grid__row--clickable",V.row,C),style:{...Mn?{"--rg-i":l?Math.min(l.batch,24):Bo(d)}:null,...ie?{height:he}:null,...W.row,...M},children:[ce&&i.jsx("td",{className:O("rg-grid__td rg-grid__select-cell",rn&&"rg-grid__pinned rg-grid__pinned--left"),style:{width:Ee,minWidth:Ee,maxWidth:Ee,...rn?{left:0}:null},onClick:Xe,children:i.jsx("span",{className:"rg-grid__checkbox-cell",onClickCapture:I=>rr.current=I.shiftKey,children:i.jsx(Je,{variant:Ze,checked:L,disabled:y||!Yt(a),"aria-label":ce==="single"?"Select row":`Select row ${h+1}`,onChange:I=>Io(e,I),classNames:{root:V.checkbox,control:V.checkboxControl,indicator:V.checkboxIndicator},styles:{root:W.checkbox,control:W.checkboxControl,indicator:W.checkboxIndicator}})})}),P.map((I,vt)=>{let X=$o(I,e);if(I.type==="sequence"){const we=Or(I,r);X={...X,value:we,formattedValue:I.valueFormatter?I.valueFormatter(we,a):String(we),editable:!1}}const Pn=typeof I.cellClassName=="function"?I.cellClassName(X):I.cellClassName,Z=typeof I.cellStyle=="function"?I.cellStyle(X):I.cellStyle,me=mt!==null&&mt.id===d&&mt.field===I.field,ne=Xt(I,X),dn=vr(I,vt),un=wn?wn.id===d&&wn.field===I.field:r===0&&vt===0;return i.jsx("td",{ref:y?void 0:we=>{const Ar=Wn(d,I.field);we?Ot.current.set(Ar,we):Ot.current.delete(Ar)},tabIndex:y?void 0:We?un?0:-1:ne?0:void 0,onFocus:We&&!y?we=>we.target===we.currentTarget&&Gn({id:d,field:I.field}):void 0,onDoubleClick:ne&&!y?()=>Jt(e,I):void 0,onKeyDown:y?void 0:we=>Oo(we,e,I,X),className:O("rg-grid__td",ne&&"rg-grid__td--editable",me&&"rg-grid__td--editing",nn(I)&&!me&&`rg-grid__cell--${nn(I)}`,dn.className,V.cell,I.className,Pn),style:{textAlign:I.align,..._r(I),...W.cell,...I.style,...Z,...dn.style},children:me&&mt&&!y?rs(e,I,mt):I.cellRenderer?p.createElement(I.cellRenderer,X):I.type==="boolean"&&!I.cellEditor?es(I,X):X.formattedValue},I.field)})]},y?`ghost:${d}`:d)},hs=Ie.trim()!==""||st.length>0?"no-results":"no-data",ps=Ue??(U?Math.min(ee,20):5),an=(se||ze)&&$===void 0&&!ie,gs=typeof Fe=="number"?`${Fe}px`:Fe,ms=an?{"--rg-sticky-offset":gs,"--rg-sticky-toolbar-h":se?`${qo}px`:"0px"}:null;return i.jsxs("div",{ref:Jn,className:O("rg-grid",ie&&"rg-grid--virtual",an&&"rg-grid--sticky-page",an&&se&&"rg-grid--sticky-toolbar",an&&ze&&"rg-grid--sticky-header",V.root,It),style:{...is,...ss,...ms,...W.root,...yo},"data-rg-theme":G||void 0,"aria-busy":yt||void 0,children:[ds&&i.jsxs("div",{ref:yr,...J("toolbar","rg-grid__toolbar"),children:[i.jsxs("div",{className:"rg-grid__toolbar-left",children:[N&&i.jsx("input",{type:"search",value:pt,onChange:e=>Vn(e.target.value),placeholder:T,"aria-label":"Search all columns",...J("search","rg-grid__search")}),ce&&ve.length>0&&i.jsxs("span",{className:"rg-grid__selected-count",role:"status",children:[ve.length," selected"]})]}),i.jsxs("div",{className:"rg-grid__toolbar-actions",children:[ut,it&&i.jsx(As,{columns:t,hidden:Rt,onToggle:So,theme:G,className:V.toolButton,style:W.toolButton}),Be&&(on.length>1?i.jsx(Vs,{formats:on,scopes:$r,scope:Zo,onScopeChange:Jo,onExport:(e,r)=>Mr(e,{scope:r}),theme:G,className:O(V.toolButton,V.exportMenu),style:{...W.toolButton,...W.exportMenu}}):i.jsx("button",{type:"button",onClick:()=>Mr(on[0]),...J("toolButton","rg-grid__tool-btn"),children:Ys(on[0])}))]})]}),as&&Lr("top"),i.jsx("div",{ref:xt,...J("scroll",O("rg-grid__scroll",`rg-grid__scroll--${Mt}`)),onScroll:ie?e=>Qn({top:e.currentTarget.scrollTop,height:e.currentTarget.clientHeight}):void 0,style:{...W.scroll,...$!==void 0?{maxHeight:$}:ie?{maxHeight:400}:null},children:i.jsxs("table",{...J("table","rg-grid__table"),role:"grid",style:en?{...W.table,tableLayout:"fixed",width:P.reduce((e,r)=>e+tn(r),ce?Ee:0),minWidth:"100%"}:Vo?{...W.table,tableLayout:"fixed",...Ho?{width:P.reduce((e,r)=>e+r.width,ce?Ee:0)}:null}:W.table,children:[i.jsx("thead",{...J("thead","rg-grid__thead"),children:i.jsxs("tr",{...J("headerRow","rg-grid__tr"),children:[ce&&i.jsx("th",{scope:"col",className:O("rg-grid__th rg-grid__select-cell",rn&&"rg-grid__pinned rg-grid__pinned--left",V.headerCell),style:{width:Ee,minWidth:Ee,maxWidth:Ee,...rn?{left:0}:null,...W.headerCell},children:ce==="multiple"&&i.jsx("span",{className:"rg-grid__checkbox-cell",children:i.jsx(Je,{variant:Ze,checked:sr,indeterminate:or>0&&!sr,disabled:_t.length===0,"aria-label":"Select all rows",onChange:lr,classNames:{root:V.checkbox,control:V.checkboxControl,indicator:V.checkboxIndicator},styles:{root:W.checkbox,control:W.checkboxControl,indicator:W.checkboxIndicator}})})}),P.map((e,r)=>{const l=pe.findIndex(C=>C.field===e.field),a=l>=0?pe[l].direction:null,d=Sn(e),h=er(e),y=vr(e,r);return i.jsxs("th",{ref:C=>{C?gt.current.set(e.field,C):gt.current.delete(e.field)},scope:"col","aria-sort":a?a==="asc"?"ascending":"descending":d?"none":void 0,tabIndex:d?0:void 0,onClick:C=>ir(e,C.shiftKey),onKeyDown:C=>{d&&C.target===C.currentTarget&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),ir(e,C.shiftKey))},className:O("rg-grid__th",d&&"rg-grid__th--sortable",nn(e)&&`rg-grid__cell--${nn(e)}`,y.className,V.headerCell,e.className,e.headerClassName),style:{width:en?tn(e):e.width,minWidth:e.minWidth,maxWidth:en?void 0:e.maxWidth,textAlign:e.align,..._r(e),...W.headerCell,...e.style,...e.headerStyle,...y.style},children:[i.jsxs("span",{className:"rg-grid__th-content",children:[e.headerRenderer?p.createElement(e.headerRenderer,{column:e,sortDirection:a}):e.headerCheckbox&&e.type==="boolean"?ns(e):i.jsx("span",{className:"rg-grid__th-label",children:Ct(e)}),e.filterable&&i.jsx(Us,{column:e,label:Ge(e),kind:h,value:rt[e.field],onChange:C=>{const M={...rt};C===void 0?delete M[e.field]:M[e.field]=C,Hn(M)},options:os.get(e.field)??[],debounce:e.filterDebounce??le,theme:G,indicatorClassName:O(V.filterIndicator,e.filterIndicatorClassName),indicatorStyle:{...W.filterIndicator,...e.filterIndicatorStyle},popupClassName:O(V.filterPopup,e.filterPopupClassName),popupStyle:{...W.filterPopup,...e.filterPopupStyle},inputClassName:V.filterInput,inputStyle:W.filterInput}),d&&us(e,a,a&&pe.length>1?l+1:void 0)]}),e.resizable&&i.jsx("span",{className:"rg-grid__resizer",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${Ge(e)}`,onPointerDown:C=>Xo(C,e),onClick:Xe,onDoubleClick:Xe})]},e.field)})]})}),i.jsx("tbody",{...J("tbody","rg-grid__tbody"),children:yt?Array.from({length:ps},(e,r)=>fs(r)):Cn?i.jsx("tr",{children:i.jsxs("td",{colSpan:bt,...J("empty","rg-grid__empty rg-grid__error"),role:"alert",children:[Dt," ",i.jsx("button",{type:"button",className:"rg-grid__tool-btn",onClick:()=>Kt(At.current),children:"Retry"})]})}):B.length===0&&ke.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:bt,...J("empty",O("rg-grid__empty",ft&&"rg-grid__empty--custom")),children:ft?p.createElement(ft,{reason:hs,search:Ie.trim(),filters:Object.fromEntries(st),columns:P,clearAll:()=>{Vn(""),Hn({})}}):Tt})}):i.jsxs(i.Fragment,{children:[wt&&Qt>0&&i.jsx("tr",{"aria-hidden":"true",className:"rg-grid__spacer",children:i.jsx("td",{colSpan:bt,style:{height:Qt*he}})}),Ko.map(e=>e.kind==="row"?Ur(e.entry,Qt+e.i):Ur(e.ghost.entry,0,e.ghost)),wt&&Tn<B.length&&i.jsx("tr",{"aria-hidden":"true",className:"rg-grid__spacer",children:i.jsx("td",{colSpan:bt,style:{height:(B.length-Tn)*he}})})]})})]})}),cs&&Lr("bottom")]})}exports.Checkbox=Je;exports.DataGrid=bl;exports.SortArrow=mo;