react-gridix 0.2.3 → 0.2.5

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.
@@ -1,2 +1,21 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),u=require("react"),Tn=require("react-dom"),Le=(...r)=>r.filter(Boolean).join(" ");function Rn(){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 In(){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 xe({checked:r,onChange:n,indeterminate:d=!1,variant:c="native",disabled:h=!1,label:g,"aria-label":f,id:j,name:y,indicator:C,className:F,style:D,classNames:k={},styles:_={}}){const R=d?"indeterminate":r?"checked":"unchecked";return i.jsxs("label",{className:Le("rg-checkbox",`rg-checkbox--${c}`,R==="checked"&&"rg-checkbox--checked",d&&"rg-checkbox--indeterminate",h&&"rg-checkbox--disabled",k.root,F),style:{..._.root,...D},"data-state":R,children:[c==="native"?i.jsx("input",{type:"checkbox",id:j,name:y,ref:v=>{v&&(v.indeterminate=d)},className:Le("rg-checkbox__control",k.control),style:_.control,checked:r,disabled:h,"aria-label":f,"data-state":R,onChange:v=>n(v.target.checked)}):i.jsx("button",{type:"button",role:"checkbox",id:j,className:Le("rg-checkbox__control",k.control),style:_.control,"aria-checked":d?"mixed":r,"aria-label":f,disabled:h,"data-state":R,onClick:()=>n(!r),children:i.jsx("span",{className:Le("rg-checkbox__indicator",C!==void 0&&!d&&"rg-checkbox__indicator--custom",k.indicator),style:_.indicator,"data-state":R,"aria-hidden":"true",children:d?c==="tick"?i.jsx(In,{}):null:C!==void 0?C:c==="tick"?i.jsx(Rn,{}):null})}),g!=null&&g!==!1&&g!==""&&i.jsx("span",{className:Le("rg-checkbox__label",k.label),style:_.label,children:g})]})}const Ln=/^(\d{4})-(\d{2})-(\d{2})$/,jr=r=>String(r).padStart(2,"0");function q(r){const n=Ln.exec(r);if(!n)return null;const[d,c,h]=[Number(n[1]),Number(n[2]),Number(n[3])],g=new Date(d,c-1,h);return g.getFullYear()===d&&g.getMonth()===c-1&&g.getDate()===h?g:null}function z(r){var n;if(r instanceof Date)return Number.isNaN(r.getTime())?null:`${r.getFullYear()}-${jr(r.getMonth()+1)}-${jr(r.getDate())}`;if(typeof r=="number")return Number.isFinite(r)?z(new Date(r)):null;if(typeof r=="string"){const d=r.trim();if(d==="")return null;const c=(n=/^\d{4}-\d{2}-\d{2}/.exec(d))==null?void 0:n[0];if(c)return q(c)?c:null;const h=Date.parse(d);return Number.isNaN(h)?null:z(new Date(h))}return null}function $n(r,n,d){const c=z(r);return c?q(c).toLocaleDateString(n,d??{year:"numeric",month:"short",day:"numeric"}):r==null?"":String(r)}function Pn(r,n){var d;return r===""?null:n instanceof Date?q(r):typeof n=="number"?((d=q(r))==null?void 0:d.getTime())??null:r}const P=(...r)=>r.filter(Boolean).join(" "),ft=r=>r.headerName??(r.type==="boolean"?"":r.type==="sequence"?"#":r.field),be=r=>ft(r)||r.field,Dr=r=>String(r).padStart(2,"0"),Pt=(r,n,d)=>`${r}-${Dr(n+1)}-${Dr(d)}`;function Nr(r,n,d,c){const h=[r,n==null?void 0:n.from,n==null?void 0:n.to].map(y=>y?q(y):null).find(Boolean);if(h)return new Date(h.getFullYear(),h.getMonth(),1);const g=new Date;let f=z(g);d&&f<d&&(f=d),c&&f>c&&(f=c);const j=q(f)??g;return new Date(j.getFullYear(),j.getMonth(),1)}function Tr({value:r,range:n,min:d,max:c,onPick:h,locale:g,weekStart:f=0,hideFooter:j,keepFocus:y,className:C}){var _e;const[F,D]=u.useState(()=>Nr(r,n,d,c)),[k,_]=u.useState(null),R=u.useRef(null),v=u.useRef({value:r,from:n==null?void 0:n.from,to:n==null?void 0:n.to});u.useEffect(()=>{const b=v.current;v.current={value:r,from:n==null?void 0:n.from,to:n==null?void 0:n.to};const Y=r!==b.value?r:(n==null?void 0:n.from)!==b.from?n==null?void 0:n.from:(n==null?void 0:n.to)!==b.to?n==null?void 0:n.to:void 0,T=Y?q(Y):null;T&&D(L=>L.getFullYear()===T.getFullYear()&&L.getMonth()===T.getMonth()?L:new Date(T.getFullYear(),T.getMonth(),1))},[r,n==null?void 0:n.from,n==null?void 0:n.to]);const S=z(new Date),N=F.getFullYear(),E=F.getMonth(),H=u.useMemo(()=>{const b=new Intl.DateTimeFormat(g,{weekday:"short"});return Array.from({length:7},(Y,T)=>b.format(new Date(2023,0,1+(T+f)%7)))},[g,f]),te=new Intl.DateTimeFormat(g,{month:"long",year:"numeric"}).format(F),O=u.useMemo(()=>{const b=(new Date(N,E,1).getDay()-f+7)%7;return Array.from({length:42},(Y,T)=>{const L=new Date(N,E,1-b+T);return{iso:Pt(L.getFullYear(),L.getMonth(),L.getDate()),day:L.getDate(),outside:L.getMonth()!==E}})},[N,E,f]),W=b=>!!d&&b<d||!!c&&b>c,oe=b=>D(new Date(N,E+b,1)),Ae=b=>{const Y=q(b);Y&&((Y.getFullYear()!==N||Y.getMonth()!==E)&&D(new Date(Y.getFullYear(),Y.getMonth(),1)),_(b),requestAnimationFrame(()=>{var T,L;return(L=(T=R.current)==null?void 0:T.querySelector(`[data-iso="${b}"]`))==null?void 0:L.focus()}))},Ke=(b,Y)=>{const T=q(Y),L=re=>{b.preventDefault(),Ae(Pt(T.getFullYear(),T.getMonth(),T.getDate()+re))};switch(b.key){case"ArrowLeft":return L(-1);case"ArrowRight":return L(1);case"ArrowUp":return L(-7);case"ArrowDown":return L(7);case"Home":return L(-((T.getDay()-f+7)%7));case"End":return L(6-(T.getDay()-f+7)%7);case"PageUp":case"PageDown":{b.preventDefault();const re=b.key==="PageUp"?-1:1,ge=new Date(T.getFullYear(),T.getMonth()+re+1,0).getDate();Ae(Pt(T.getFullYear(),T.getMonth()+re,Math.min(T.getDate(),ge)));return}}},gt=b=>!!b&&O.some(Y=>Y.iso===b&&!Y.outside),Ne=[k,r,S].find(b=>gt(b)&&!W(b))??((_e=O.find(b=>!b.outside&&!W(b.iso)))==null?void 0:_e.iso),ie=n==null?void 0:n.from,se=n==null?void 0:n.to;return i.jsxs("div",{className:P("rg-cal",C),onMouseDown:y?b=>b.preventDefault():void 0,role:"group","aria-label":`Calendar, ${te}`,children:[i.jsxs("div",{className:"rg-cal__head",children:[i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Previous year",onClick:()=>oe(-12),children:"«"}),i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Previous month",onClick:()=>oe(-1),children:"‹"}),i.jsx("span",{className:"rg-cal__title","aria-live":"polite",children:te}),i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Next month",onClick:()=>oe(1),children:"›"}),i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Next year",onClick:()=>oe(12),children:"»"})]}),i.jsxs("div",{className:"rg-cal__grid",ref:R,children:[H.map(b=>i.jsx("span",{className:"rg-cal__dow","aria-hidden":"true",children:b.slice(0,2)},b)),O.map(({iso:b,day:Y,outside:T})=>{const L=b===r,re=b===ie,ge=b===se,ht=!!ie&&!!se&&b>ie&&b<se;return i.jsx("button",{type:"button","data-iso":b,tabIndex:b===Ne?0:-1,disabled:W(b),"aria-pressed":L||re||ge,"aria-label":new Intl.DateTimeFormat(g,{dateStyle:"full"}).format(q(b)),className:P("rg-cal__day",T&&"rg-cal__day--outside",b===S&&"rg-cal__day--today",(L||re||ge)&&"rg-cal__day--selected",ht&&"rg-cal__day--in-range",ie&&se&&re&&ie!==se&&"rg-cal__day--range-start",ie&&se&&ge&&ie!==se&&"rg-cal__day--range-end"),onClick:()=>h(b),onKeyDown:Oe=>Ke(Oe,b),onFocus:()=>_(b),children:Y},b)})]}),!j&&i.jsxs("div",{className:"rg-cal__foot",children:[i.jsx("button",{type:"button",className:"rg-cal__link",disabled:W(S),onClick:()=>{D(Nr(S)),h(S)},children:"Today"}),i.jsx("button",{type:"button",className:"rg-cal__link",onClick:()=>h(""),children:"Clear"})]})]})}const Kt=typeof window<"u"?u.useLayoutEffect:u.useEffect;function $e(r,n,d){const[c,h]=u.useState(n),g=r!==void 0,f=g?r:c,j=u.useCallback(y=>{g||h(y),d==null||d(y)},[g,d]);return[f,j]}function Rr(r,n){const d=u.useRef(r);d.current=r;const c=u.useRef(void 0),h=u.useRef(null),g=u.useCallback(()=>{c.current!==void 0&&clearTimeout(c.current),c.current=void 0,h.current=null},[]),f=u.useCallback(()=>{c.current!==void 0&&clearTimeout(c.current),c.current=void 0;const y=h.current;h.current=null,y&&d.current(...y)},[]),j=u.useCallback((...y)=>{if(n<=0){g(),d.current(...y);return}h.current=y,c.current!==void 0&&clearTimeout(c.current),c.current=setTimeout(f,n)},[n,g,f]);return u.useEffect(()=>f,[f]),{call:j,flush:f,cancel:g}}function Yt({anchorRef:r,open:n,onClose:d,label:c,theme:h,className:g,style:f,keepFocus:j,children:y}){const C=u.useRef(null),[F,D]=u.useState({top:0,left:0}),k=u.useCallback(()=>{var N;const _=r.current;if(!_)return;const R=_.getBoundingClientRect(),v=((N=C.current)==null?void 0:N.offsetWidth)??260,S=Math.max(8,Math.min(R.left,window.innerWidth-v-8));D({top:R.bottom+6,left:S})},[r]);return Kt(()=>{n&&k()},[n,k]),u.useEffect(()=>{if(!n)return;const _=v=>{var N,E;const S=v.target;(N=C.current)!=null&&N.contains(S)||(E=r.current)!=null&&E.contains(S)||d()},R=v=>{var S;v.key==="Escape"&&(d(),(S=r.current)==null||S.focus())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",R),window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",R),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}},[n,d,k,r]),!n||typeof document>"u"?null:Tn.createPortal(i.jsx("div",{ref:C,role:"dialog",onMouseDown:j?_=>_.preventDefault():void 0,"aria-label":c,"data-rg-theme":h||void 0,className:P("rg-grid-popup",g),style:{position:"fixed",top:F.top,left:F.left,...f},children:y}),document.body)}function An({value:r,onChange:n,onPick:d,onBlur:c,onKeyDown:h,min:g,max:f,locale:j,invalid:y,label:C,theme:F,className:D,style:k}){const _=u.useRef(null),R=v=>{const S=v.ctrlKey||v.altKey||v.metaKey,N=v.key==="ArrowUp"?{days:-7,months:0}:v.key==="ArrowDown"?{days:7,months:0}:S&&v.key==="ArrowLeft"?{days:-1,months:0}:S&&v.key==="ArrowRight"?{days:1,months:0}:v.key==="PageUp"?{days:0,months:-1}:v.key==="PageDown"?{days:0,months:1}:null;if(!N||v.shiftKey)return h(v);v.preventDefault();const E=q(r)??new Date,H=new Date(E.getFullYear(),E.getMonth()+N.months+1,0).getDate(),te=new Date(E.getFullYear(),E.getMonth()+N.months,Math.min(E.getDate(),H)+N.days);let O=z(te);g&&O<g&&(O=g),f&&O>f&&(O=f),n(O)};return i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:_,autoFocus:!0,type:"text",inputMode:"numeric",placeholder:"YYYY-MM-DD",autoComplete:"off",className:D,style:k,value:r,"aria-label":C,"aria-invalid":y||void 0,"aria-haspopup":"dialog","aria-expanded":!0,onChange:v=>n(v.target.value.trim()),onBlur:c,onKeyDown:R,onFocus:v=>v.currentTarget.setSelectionRange(v.currentTarget.value.length,v.currentTarget.value.length)}),i.jsx(Yt,{anchorRef:_,open:!0,onClose:()=>{},label:C,theme:F,className:"rg-date-popup",keepFocus:!0,children:i.jsx(Tr,{value:r,min:g,max:f,locale:j,onPick:d,keepFocus:!0})})]})}function Er(r){return r.filterType?r.filterType:r.type==="number"?"number":r.type==="date"?"date":r.type==="boolean"?"select":"text"}const Kn=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function Ir(r){if(r==null)return!1;if(typeof r=="string")return r.trim()!=="";if(Array.isArray(r))return r.length>0;if(Kn(r)){const n=r;return typeof n.min=="number"||typeof n.max=="number"||!!n.from||!!n.to}return!1}function On(r,n,d,c){switch(r){case"text":return d.toLowerCase().includes(String(n).trim().toLowerCase());case"exact":return d.toLowerCase()===String(n).trim().toLowerCase();case"number":{const{min:h,max:g}=n,f=typeof c=="number"?c:c==null||c===""?NaN:Number(c);return Number.isNaN(f)?!1:(typeof h!="number"||f>=h)&&(typeof g!="number"||f<=g)}case"date":{const{from:h,to:g}=n,f=z(c);return f?(!h||f>=h)&&(!g||f<=g):!1}case"select":return n.includes(String(c??""))}}function Bn(r,n,d,c){if(r.filterOptions)return r.filterOptions.map(g=>typeof g=="string"?{value:g,label:g}:g);if(r.type==="boolean")return[{value:"true",label:"Yes"},{value:"false",label:"No"}];const h=new Map;for(const g of n){const f=d(g);if(f==null||f==="")continue;const j=String(f);h.has(j)||h.set(j,c(g))}return[...h].map(([g,f])=>({value:g,label:f})).sort((g,f)=>g.label.localeCompare(f.label,void 0,{numeric:!0}))}const Mr=r=>{if(r.trim()==="")return;const n=Number(r);return Number.isFinite(n)?n:void 0},Lr=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function Yn({value:r,onChange:n,label:d,debounce:c,inputClassName:h,inputStyle:g}){const f=Lr(r)?r:{},[j,y]=u.useState(f.min===void 0?"":String(f.min)),[C,F]=u.useState(f.max===void 0?"":String(f.max)),D=u.useRef(f),k=Rr((_,R)=>{const v=Mr(_),S=Mr(R);D.current={min:v,max:S},n(v===void 0&&S===void 0?void 0:{min:v,max:S})},c);return u.useEffect(()=>{f.min===D.current.min&&f.max===D.current.max||(D.current=f,k.cancel(),y(f.min===void 0?"":String(f.min)),F(f.max===void 0?"":String(f.max)))},[f.min,f.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:P("rg-grid__filter-input",h),style:g,value:j,"aria-label":`Minimum ${d}`,onChange:_=>{y(_.target.value),k.call(_.target.value,C)},onKeyDown:_=>_.key==="Enter"&&k.flush()})]}),i.jsxs("label",{className:"rg-grid__filter-field",children:[i.jsx("span",{children:"Max"}),i.jsx("input",{type:"number",className:P("rg-grid__filter-input",h),style:g,value:C,"aria-label":`Maximum ${d}`,onChange:_=>{F(_.target.value),k.call(j,_.target.value)},onKeyDown:_=>_.key==="Enter"&&k.flush()})]})]})}function Wn({value:r,onChange:n,onEnter:d,label:c,kind:h,placeholder:g,debounce:f,inputClassName:j,inputStyle:y}){const[C,F]=u.useState(r),D=u.useRef(r),k=Rr(_=>{D.current=_,n(_||void 0)},f);return u.useEffect(()=>{r!==D.current&&(D.current=r,k.cancel(),F(r))},[r]),i.jsx("input",{autoFocus:!0,type:"text",className:P("rg-grid__filter-input",j),style:y,value:C,placeholder:g??(h==="exact"?"Exactly…":`Filter ${c}…`),"aria-label":`Filter text for ${c}`,onChange:_=>{F(_.target.value),k.call(_.target.value)},onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),k.flush(),d())}})}function qn({value:r,onChange:n,label:d,inputClassName:c,inputStyle:h,min:g,max:f,locale:j}){const y=Lr(r)?r:{},C=(N,E)=>n(!N&&!E?void 0:{from:N||void 0,to:E||void 0}),[F,D]=u.useState(y.from??""),[k,_]=u.useState(y.to??"");u.useEffect(()=>{(q(F)?F:"")!==(y.from??"")&&D(y.from??""),(q(k)?k:"")!==(y.to??"")&&_(y.to??"")},[y.from,y.to]);const R=(N,E)=>{if((N==="from"?D:_)(E),E!==""&&!q(E))return;const H=E||void 0;N==="from"?C(H,y.to):C(y.from,H)},v=N=>{N&&(!y.from||y.to?C(N,void 0):N<y.from?C(N,y.from):C(y.from,N))},S=(N,E,H)=>i.jsxs("label",{className:"rg-grid__filter-field",children:[i.jsx("span",{children:N==="from"?"From":"To"}),i.jsx("input",{autoFocus:H,type:"text",inputMode:"numeric",placeholder:"YYYY-MM-DD",className:P("rg-grid__filter-input",E!==""&&!q(E)&&"rg-grid__filter-input--invalid",c),style:h,value:E,"aria-label":`${d} ${N}`,"aria-invalid":E!==""&&!q(E)||void 0,onChange:te=>R(N,te.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:[S("from",F,!0),S("to",k,!1)]}),i.jsx(Tr,{range:y,min:g,max:f,locale:j,onPick:v,hideFooter:!0})]})}function Un({value:r,onChange:n,options:d}){const c=Array.isArray(r)?r:[],h=(g,f)=>{const j=f?[...c,g]:c.filter(y=>y!==g);n(j.length?j:void 0)};return i.jsxs("div",{className:"rg-grid__filter-fields rg-grid__filter-options",role:"group",children:[d.length===0&&i.jsx("span",{className:"rg-grid__filter-empty",children:"No values"}),d.map(g=>i.jsx(xe,{checked:c.includes(g.value),onChange:f=>h(g.value,f),label:g.label??g.value},g.value))]})}function Vn({column:r,label:n,kind:d,value:c,onChange:h,options:g,debounce:f=300,theme:j,indicatorClassName:y,indicatorStyle:C,popupClassName:F,popupStyle:D,inputClassName:k,inputStyle:_}){const[R,v]=u.useState(!1),S=u.useRef(null),N=Ir(c),E=u.useCallback(()=>v(!1),[]),H=typeof c=="string"?c:"",te=()=>{if(r.filterRenderer)return u.createElement(r.filterRenderer,{column:r,value:H,onChange:O=>h(O||void 0)});switch(d){case"number":return i.jsx(Yn,{value:c,onChange:h,label:n,debounce:f,inputClassName:k,inputStyle:_});case"date":return i.jsx(qn,{value:c,onChange:h,label:n,min:r.dateMin,max:r.dateMax,locale:r.dateLocale,inputClassName:k,inputStyle:_});case"select":return i.jsx(Un,{value:c,onChange:h,options:g});default:return i.jsx(Wn,{value:H,onChange:h,onEnter:()=>{var O;v(!1),(O=S.current)==null||O.focus()},label:n,kind:d,placeholder:r.filterPlaceholder,debounce:f,inputClassName:k,inputStyle:_})}};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:S,type:"button",className:P("rg-grid__filter-btn",N&&"rg-grid__filter-btn--active",R&&"rg-grid__filter-btn--open",y),style:C,"aria-label":`Filter ${n}`,"aria-haspopup":"dialog","aria-expanded":R,"data-active":N||void 0,onClick:O=>{O.stopPropagation(),v(W=>!W)},onKeyDown:O=>O.stopPropagation(),children:r.filterIndicator?u.createElement(r.filterIndicator,{column:r,active:N,open:R}):i.jsx("span",{className:"rg-grid__filter-dot","aria-hidden":"true"})}),i.jsxs(Yt,{anchorRef:S,open:R,onClose:E,label:`Filter ${n}`,theme:j,className:F,style:D,children:[te(),N&&i.jsx("button",{type:"button",className:"rg-grid__filter-clear",onClick:()=>h(void 0),children:"Clear"})]})]})}function zn({columns:r,hidden:n,onToggle:d,theme:c,className:h,style:g}){const[f,j]=u.useState(!1),y=u.useRef(null),C=u.useCallback(()=>j(!1),[]),F=r.filter(D=>!n.has(D.field)).length;return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:y,type:"button",className:P("rg-grid__tool-btn",h),style:g,"aria-haspopup":"dialog","aria-expanded":f,onClick:()=>j(D=>!D),children:"Columns"}),i.jsx(Yt,{anchorRef:y,open:f,onClose:C,label:"Show or hide columns",theme:c,children:i.jsx("div",{className:"rg-grid__filter-fields rg-grid__filter-options",role:"group","aria-label":"Columns",children:r.filter(D=>D.hideable!==!1).map(D=>{const k=!n.has(D.field);return i.jsx(xe,{checked:k,disabled:k&&F<=1,onChange:_=>d(D.field,!_),label:be(D)},D.field)})})})]})}const Hn=/^[=+\-@\t\r]/;function Jn(r,n,d){if(r==null)return"";let c=String(r);return d&&typeof r=="string"&&Hn.test(c)&&!Number.isFinite(Number(c))&&(c=`'${c}`),c.includes(n)||/["\r\n]/.test(c)?`"${c.replace(/"/g,'""')}"`:c}function Gn(r,n,d={}){const{delimiter:c=",",sanitize:h=!0}=d,g=f=>f.map(j=>Jn(j,c,h)).join(c);return[g(r),...n.map(g)].join(`\r
2
- `)}function Xn(r,n){if(typeof document>"u")return;const d=new Blob(["\uFEFF",r],{type:"text/csv;charset=utf-8"}),c=URL.createObjectURL(d),h=document.createElement("a");h.href=c,h.download=n,h.style.display="none",document.body.appendChild(h),h.click(),h.remove(),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Ot=new Set(["__proto__","prototype","constructor"]),$r=(r,n)=>Object.prototype.hasOwnProperty.call(r,n);function Q(r,n){if(r===null||typeof r!="object")return;if($r(r,n))return r[n];let d=r;for(const c of n.split(".")){if(d==null||typeof d!="object"||Ot.has(c))return;d=d[c]}return d}function Sr(r,n,d){if(Array.isArray(r)){const c=[...r];return c[n]=d,c}return{...r,[n]:d}}function Bt(r,n,d){const c=r??{};if($r(c,n)||!n.includes("."))return Ot.has(n)?r:Sr(c,n,d);const[h,...g]=n.split(".");if(Ot.has(h))return r;const f=c[h];return Sr(c,h,Bt(f!==null&&typeof f=="object"?f:{},g.join("."),d))}const fe=38,Qn=150,Cr=10,At=(r,n)=>`${typeof r}:${r}\0${n}`;function Pe(r,n){const d=Q(n,r.field);return r.valueFormatter?r.valueFormatter(d,n):r.type==="boolean"&&typeof d=="boolean"?d?"Yes":"No":r.type==="date"?$n(d,r.dateLocale,r.dateFormat):d==null?"":d instanceof Date?d.toLocaleDateString():String(d)}function Zn(r,n,d){if(d.type==="date"){const c=z(r)??"",h=z(n)??"";return c<h?-1:c>h?1:0}return typeof r=="number"&&typeof n=="number"?r-n:r instanceof Date&&n instanceof Date?r.getTime()-n.getTime():typeof r=="boolean"&&typeof n=="boolean"?Number(r)-Number(n):String(r).localeCompare(String(n),void 0,{numeric:!0,sensitivity:"base"})}const eo=r=>r?Array.isArray(r)?r:[r]:[],Fr=r=>r.type==="date"&&r.validity.badInput;function to({columns:r,rows:n,getRowId:d,editable:c=!1,enterMovesDown:h=!0,onCellEdit:g,onRowsChange:f,rowSelection:j=!1,selectedRowIds:y,defaultSelectedRowIds:C,onSelectionChange:F,isRowSelectable:D,sort:k,defaultSort:_=null,onSortChange:R,multiSort:v=!1,searchable:S=!1,searchPlaceholder:N="Search…",search:E,onSearchChange:H,filters:te,onFiltersChange:O,pagination:W=!1,paginationPosition:oe="bottom",showToolbar:Ae=!0,showFooter:Ke=!0,pageSize:gt=10,pageSizeOptions:Ne=[5,10,25,50],page:ie,onPageChange:se,onPageSizeChange:_e,serverSide:b=!1,rowCount:Y,onQueryChange:T,queryDebounce:L=250,filterDebounce:re=300,loading:ge,loadingRows:ht,skeletonRow:Oe,errorMessage:Pr="Could not load the data.",columnMenu:Wt=!1,onColumnVisibilityChange:pt,keyboardNavigation:mt=!1,virtualize:Z=!1,rowHeight:le=40,overscan:qt=6,exportable:Be=!1,apiRef:Ee,onRowClick:bt,toolbar:Ut,emptyMessage:Ar="No rows to show",striped:Kr=!1,stripeColors:Ye,checkboxVariant:xt="native",animateRows:Vt=!0,rowAnimationClassName:_t,theme:We,maxHeight:qe,className:Or,style:Br,classNames:A={},styles:I={},rowClassName:yt,rowStyle:vt}){const B=(e,t)=>({className:P(t,A[e]),style:I[e]}),[Ue,zt]=u.useState(n),ye=u.useRef(n);u.useEffect(()=>{ye.current=n,zt(n)},[n]);const Ht=e=>{ye.current=e,zt(e)},[Me,Yr]=$e(E,"",H),[ve,Wr]=$e(te,{},O),[J,qr]=$e(k,eo(_),R),[kt,ke]=$e(ie,0,se),[U,Ur]=u.useState(gt),Vr=e=>{Ur(e),_e==null||_e(e)},[Ve,zr]=u.useState(()=>new Set(r.filter(e=>e.hidden).map(e=>e.field))),Hr=(e,t)=>{const o=new Set(Ve);t?o.add(e):o.delete(e),zr(o),pt==null||pt([...o])},[wt,Jt]=u.useState({}),[ze,Jr]=u.useState({}),[ro,Gr]=u.useState(0),Se=u.useRef(new Map),[Ce,he]=u.useState(null),ae=u.useRef(0),He=u.useRef(null),Je=u.useRef(new Map),[jt,Gt]=u.useState(null),Dt=u.useRef(null),Fe=u.useRef(null),[Nt,Xt]=u.useState({top:0,height:0}),M=u.useMemo(()=>{const e=r.filter(t=>!Ve.has(t.field)).map(t=>t.type==="sequence"?{...t,sortable:!1,filterable:!1,editable:!1,filterRenderer:void 0}:t);return[...e.filter(t=>t.pinned==="left"),...e.filter(t=>t.pinned!=="left"&&t.pinned!=="right"),...e.filter(t=>t.pinned==="right")]},[r,Ve]),Et=e=>e.sortable===!0,G=j==="single"?"single":j?"multiple":null,Te=M.length+(G?1:0),we=u.useMemo(()=>Ue.map((e,t)=>({row:e,index:t,id:d?d(e,t):t})),[Ue,d]),Qt=u.useRef(new Map);we.forEach(e=>Qt.current.set(e.id,e.row));const Ge=u.useMemo(()=>Object.entries(ve).filter(([e,t])=>{const o=M.find(a=>a.field===e);return!!o&&!!o.filterable&&Ir(t)}),[ve,M]),[Xr,Qr]=u.useState(Me);u.useEffect(()=>{if(!b)return;const e=setTimeout(()=>Qr(Me),L);return()=>clearTimeout(e)},[Me,b,L]);const je=b?Xr:Me,Zt=e=>e.filterRenderer?"text":Er(e),ce=u.useMemo(()=>{if(b)return we;const e=je.trim().toLowerCase();let t=we.filter(({row:a})=>e&&!M.some(s=>Pe(s,a).toLowerCase().includes(e))?!1:Ge.every(([s,l])=>{const x=M.find(m=>m.field===s);return On(Zt(x),l,Pe(x,a),Q(a,s))}));const o=J.map(a=>({col:M.find(s=>s.field===a.field),dir:a.direction==="asc"?1:-1})).filter(a=>!!a.col);return o.length&&(t=[...t].sort((a,s)=>{for(const{col:l,dir:x}of o){const m=Q(a.row,l.field),w=Q(s.row,l.field),p=m==null||m==="",K=w==null||w==="";if(p||K){if(p!==K)return p?1:-1;continue}const X=l.comparator?l.comparator(m,w,a.row,s.row):Zn(m,w,l);if(X!==0)return X*x}return 0})),t},[we,M,je,Ge,J,b]),Xe=JSON.stringify([je,ve,J,U]),er=u.useRef(Xe);u.useEffect(()=>{er.current!==Xe&&(er.current=Xe,ke(0))},[Xe]);const De=b?Y??we.length:ce.length,de=W?Math.max(1,Math.ceil(De/U)):1,V=Math.min(kt,de-1),$=W&&!b?ce.slice(V*U,V*U+U):ce,Zr=De===0?0:W?V*U+1:1,en=W?Math.min(De,(V+1)*U):De,Mt=u.useMemo(()=>({sort:J.filter(e=>{const t=r.find(o=>o.field===e.field);return!!t&&Et(t)}),filters:Object.fromEntries(Ge),search:je.trim(),page:V,pageSize:U}),[J,r,Ge,je,V,U]),tn=JSON.stringify(Mt),Qe=u.useRef(Mt);Qe.current=Mt;const Ze=u.useRef(T);Ze.current=T;const[rn,et]=u.useState(!1),[nn,St]=u.useState(!1),Ct=u.useRef(0),tt=u.useCallback(e=>{var a;const t=++Ct.current,o=(a=Ze.current)==null?void 0:a.call(Ze,e);o&&typeof o.then=="function"?(et(!0),St(!1),o.then(()=>{t===Ct.current&&et(!1)},()=>{t===Ct.current&&(et(!1),St(!0))})):(et(!1),St(!1))},[]);u.useEffect(()=>{b&&tt(Qe.current)},[b,tn,tt]),u.useEffect(()=>{b&&W&&kt>de-1&&ke(de-1)},[b,W,kt,de]);const Ft=ge??rn,tr=e=>e.map(t=>Qt.current.get(t)).filter(t=>t!==void 0),[ne,rt]=$e(y,C??[],e=>F==null?void 0:F({ids:e,rows:tr(e)})),Tt=u.useMemo(()=>new Set(ne),[ne]),nt=e=>D?D(e):!0,ot=u.useRef(null),rr=u.useRef(!1),on=(e,t)=>{if(!G||!nt(e.row))return;if(G==="single"){rt(t?[e.id]:[]),ot.current=e.id;return}const o=new Set(ne),a=rr.current&&ot.current!==null?$.findIndex(l=>l.id===ot.current):-1,s=$.findIndex(l=>l.id===e.id);if(a>=0&&s>=0)for(let l=Math.min(a,s);l<=Math.max(a,s);l++)nt($[l].row)&&(t?o.add($[l].id):o.delete($[l].id));else t?o.add(e.id):o.delete(e.id);ot.current=e.id,rt([...o])},Re=u.useMemo(()=>ce.filter(e=>nt(e.row)),[ce,D]),nr=Re.filter(e=>Tt.has(e.id)).length,or=Re.length>0&&nr===Re.length,ir=e=>{const t=new Set(ne);Re.forEach(o=>e?t.add(o.id):t.delete(o.id)),rt([...t])},it=(e,t,o)=>({value:Q(t,e.field),formattedValue:Pe(e,t),row:t,rowIndex:o,field:e.field,column:e}),Rt=(e,t)=>{const o=e.editable??c;return typeof o=="function"?o(t):!!o},st=(e,t)=>Rt(e,t)&&!(e.type==="boolean"&&!e.cellEditor),sn=(e,t)=>{const o=it(e,t.row,t.index),a=Rt(e,o);return{...o,editable:a,updateValue:s=>a&&lr(t,e,{value:s})}},sr=(e,t)=>{if(!Et(e))return;const o=J.find(l=>l.field===e.field),a=o?o.direction==="asc"?"desc":null:"asc";let s;t&&v?a?o?s=J.map(l=>l.field===e.field?{...l,direction:a}:l):s=[...J,{field:e.field,direction:a}]:s=J.filter(l=>l.field!==e.field):s=a?[{field:e.field,direction:a}]:[],qr(s)},lt=(e,t)=>{var o;return(o=Je.current.get(At(e,t)))==null?void 0:o.focus()},ue=()=>{ae.current+=1,he(null)},ln=e=>{for(const t of ye.current){const o=Q(t,e.field);if(o!=null&&o!=="")return o}},at=(e,t,o={})=>{if(!st(t,it(t,e.row,e.index)))return!1;const a=Q(e.row,t.field);let s;return t.cellEditor?s=a:t.type==="date"?s=z(a)??"":s=o.text??(a==null?"":String(a)),He.current=s,ae.current+=1,he({id:e.id,field:t.field,draft:s,session:ae.current,select:o.select??"end",invalid:!1}),!0},lr=(e,t,o)=>{const a=ye.current[e.index]??e.row,s=Q(a,t.field);let l;if("value"in o)l=o.value;else if(t.valueParser)l=t.valueParser(o.text,a);else if(t.type==="date"){if(o.text!==""&&!q(o.text))return!1;l=Pn(o.text,s??ln(t))}else if(t.type==="number")if(o.text.trim()==="")l=null;else{const w=Number(o.text);if(!Number.isFinite(w))return!1;l=w}else l=o.text;if(t.type==="date"){if(z(l)===z(s))return!0;const w=z(l);if(w&&(t.dateMin&&w<t.dateMin||t.dateMax&&w>t.dateMax))return!1}else if(Object.is(l,s))return!0;if(t.validate&&!t.validate(l,a))return!1;const x=Bt(a,t.field,l),m=ye.current.map((w,p)=>p===e.index?x:w);return Ht(m),g==null||g({rowId:e.id,rowIndex:e.index,field:t.field,oldValue:s,newValue:l,row:x}),f==null||f(m),!0},ar=(e,t,o)=>{const a=$.findIndex(p=>p.id===e.id),s=M.findIndex(p=>p.field===t);if(a<0||s<0)return null;const l=(p,K)=>st(K,it(K,p.row,p.index));if(o==="down"||o==="up"){const p=o==="down"?1:-1;for(let K=a+p;K>=0&&K<$.length;K+=p)if(l($[K],M[s]))return{entry:$[K],col:M[s]};return null}const x=o==="right"?1:-1;let m=a,w=s+x;for(;m>=0&&m<$.length;){for(;w>=0&&w<M.length;){if(l($[m],M[w]))return{entry:$[m],col:M[w]};w+=x}m+=x,w=x>0?0:M.length-1}return null},pe=(e,t,o,a={})=>{const{move:s="none",focus:l=!0}=a;if(!lr(e,t,o))return he(m=>m&&{...m,invalid:!0}),!1;const x=s==="none"?null:ar(e,t.field,s);return x?at(x.entry,x.col,{select:"all"}):(ue(),l&&lt(e.id,t.field)),!0},cr=(e,t,o)=>{if(e.nativeEvent.isComposing)return;const a=e.currentTarget.value,s=Fr(e.currentTarget);if(e.key==="Enter"){if(e.preventDefault(),s)return he(x=>x&&{...x,invalid:!0});const l=h?e.shiftKey?"up":"down":"none";pe(t,o,{text:a},{move:l})}else if(e.key==="Escape")e.preventDefault(),ue(),lt(t.id,o.field);else if(e.key==="Tab"&&!s){const l=e.shiftKey?"left":"right";ar(t,o.field,l)&&(e.preventDefault(),pe(t,o,{text:a},{move:l}))}},an=(e,t)=>{var l;const o=$[e],a=M[t];if(!o||!a)return;Gt({id:o.id,field:a.field}),Dt.current=At(o.id,a.field);const s=Fe.current;if(Z&&s){const x=((l=s.querySelector("thead"))==null?void 0:l.clientHeight)??0,m=e*le;m<s.scrollTop?s.scrollTo({top:m,behavior:"auto"}):m+le>s.scrollTop+s.clientHeight-x&&s.scrollTo({top:m+le-s.clientHeight+x,behavior:"auto"})}};u.useEffect(()=>{const e=Dt.current;if(!e)return;const t=Je.current.get(e);t&&(Dt.current=null,t.focus())});const cn=(e,t,o)=>{if(!mt)return!1;let a=$.findIndex(l=>l.id===t.id),s=M.findIndex(l=>l.field===o.field);if(a<0||s<0)return!1;switch(e.key){case"ArrowDown":a+=1;break;case"ArrowUp":a-=1;break;case"ArrowRight":s+=1;break;case"ArrowLeft":s-=1;break;case"PageDown":a+=Cr;break;case"PageUp":a-=Cr;break;case"Home":s=0,(e.ctrlKey||e.metaKey)&&(a=0);break;case"End":s=M.length-1,(e.ctrlKey||e.metaKey)&&(a=$.length-1);break;default:return!1}return e.preventDefault(),an(Math.max(0,Math.min($.length-1,a)),Math.max(0,Math.min(M.length-1,s))),!0},dn=(e,t,o,a)=>{e.target===e.currentTarget&&(cn(e,t,o)||st(o,a)&&(e.key==="Enter"||e.key==="F2"?(e.preventDefault(),at(t,o)):!o.cellEditor&&o.type!=="date"&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),at(t,o,{text:e.key}))))};Kt(()=>{if(!Z||!Fe.current)return;const e=Fe.current,t=()=>Xt(a=>a.height===e.clientHeight?a:{...a,height:e.clientHeight});if(t(),typeof ResizeObserver>"u")return;const o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[Z]);const Ie=Z&&!Ft&&$.length>0,un=Nt.height||(typeof qe=="number"?qe:400),ct=Ie?Math.max(0,Math.floor(Nt.top/le)-qt):0,It=Ie?Math.min($.length,Math.ceil((Nt.top+un)/le)+qt):$.length,fn=Ie?$.slice(ct,It):$,dr=`${V}|${U}|${JSON.stringify(J)}|${je}|${JSON.stringify(ve)}`,ur=u.useRef(!0);u.useEffect(()=>{if(ur.current){ur.current=!1;return}const e=Fe.current;e&&typeof e.scrollTo=="function"&&e.scrollTop>0&&e.scrollTo({top:0,behavior:"smooth"})},[dr]);const Lt=Object.keys(wt).length>0,dt=e=>wt[e.field]??(typeof e.width=="number"?e.width:Qn),gn=e=>Math.max(40,typeof e.minWidth=="number"?e.minWidth:60),hn=(e,t)=>{e.preventDefault(),e.stopPropagation();const o={...wt};Lt||M.forEach(p=>{var K;return o[p.field]=((K=Se.current.get(p.field))==null?void 0:K.offsetWidth)??dt(p)});const a=e.clientX,s=o[t.field]??dt(t),l=e.currentTarget;l.setPointerCapture(e.pointerId),Jt(o);const x=p=>Math.min(t.maxWidth??1/0,Math.max(gn(t),Math.round(p))),m=p=>Jt(K=>({...K,[t.field]:x(s+p.clientX-a)})),w=()=>{l.removeEventListener("pointermove",m),l.removeEventListener("pointerup",w),l.removeEventListener("pointercancel",w)};l.addEventListener("pointermove",m),l.addEventListener("pointerup",w),l.addEventListener("pointercancel",w)};Kt(()=>{var s,l;const e={};let t=G&&M.some(x=>x.pinned==="left")?fe:0;for(const x of M)x.pinned==="left"&&(e[x.field]=t,t+=((s=Se.current.get(x.field))==null?void 0:s.offsetWidth)??0);let o=0;for(const x of[...M].reverse())x.pinned==="right"&&(e[x.field]=o,o+=((l=Se.current.get(x.field))==null?void 0:l.offsetWidth)??0);const a=Object.keys(e);(a.length!==Object.keys(ze).length||a.some(x=>e[x]!==ze[x]))&&Jr(e)}),u.useEffect(()=>{const e=()=>Gr(t=>t+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const fr=M.map(e=>e.pinned).lastIndexOf("left"),pn=M.findIndex(e=>e.pinned==="right"),ut=fr>=0,gr=(e,t)=>({className:e.pinned?P("rg-grid__pinned",`rg-grid__pinned--${e.pinned}`,t===fr&&"rg-grid__pinned--edge",t===pn&&"rg-grid__pinned--edge"):void 0,style:e.pinned==="left"?{left:ze[e.field]??0}:e.pinned==="right"?{right:ze[e.field]??0}:void 0}),hr=typeof Be=="object"?Be:{},pr=(e={})=>{const t={...hr,...e},o=t.scope??"filtered",a=o==="page"?$:o==="selected"?we.filter(m=>Tt.has(m.id)):ce,s=t.includeHidden?r:M,l=s.map(m=>ft(m)||m.field),x=a.map(({row:m},w)=>s.map(p=>{if(p.type==="sequence")return yr(p,w,o==="page"&&W&&!p.sequenceRestartEachPage?V*U:0);const K=Q(m,p.field);return p.exportValue?p.exportValue(K,m):p.type==="date"?z(K)??"":Pe(p,m)}));return Gn(l,x,{sanitize:t.sanitize})},mr=(e={})=>{const t={...hr,...e};Xn(pr(e),`${t.filename??"export"}.csv`)};u.useEffect(()=>{Ee&&(Ee.current={getCsv:pr,exportCsv:mr,getSelectedRows:()=>tr(ne),getSelectedRowIds:()=>ne,selectAll:()=>ir(!0),clearSelection:()=>rt([]),refresh:()=>{b&&tt(Qe.current)}})}),u.useEffect(()=>()=>{Ee&&(Ee.current=null)},[Ee]);const br=e=>{var o,a,s,l,x,m,w,p;const t=e.checkbox??{};return{variant:t.variant??xt,indicator:t.indicator,className:t.className,style:t.style,classNames:{root:P(A.checkbox,(o=t.classNames)==null?void 0:o.root),control:P(A.checkboxControl,(a=t.classNames)==null?void 0:a.control),indicator:P(A.checkboxIndicator,(s=t.classNames)==null?void 0:s.indicator),label:(l=t.classNames)==null?void 0:l.label},styles:{root:{...I.checkbox,...(x=t.styles)==null?void 0:x.root},control:{...I.checkboxControl,...(m=t.styles)==null?void 0:m.control},indicator:{...I.checkboxIndicator,...(w=t.styles)==null?void 0:w.indicator},label:(p=t.styles)==null?void 0:p.label}}},me=e=>e.stopPropagation(),mn=(e,t)=>i.jsx("span",{className:"rg-grid__checkbox-cell",onClick:me,onDoubleClick:me,children:i.jsx(xe,{...br(e),checked:!!t.value,disabled:!t.editable,"aria-label":`Toggle ${be(e)}`,onChange:o=>t.updateValue(o)})}),xr=e=>ce.filter(t=>Rt(e,it(e,t.row,t.index))),bn=(e,t)=>{const o=new Map(xr(e).map(l=>[l.index,l])),a=[],s=ye.current.map((l,x)=>{const m=o.get(x);if(!m)return l;const w=Q(l,e.field);if(!!w===t||e.validate&&!e.validate(t,l))return l;const p=Bt(l,e.field,t);return a.push({rowId:m.id,rowIndex:x,field:e.field,oldValue:w,newValue:t,row:p}),p});a.length!==0&&(Ht(s),a.forEach(l=>g==null?void 0:g(l)),f==null||f(s))},xn=e=>{const t=xr(e),o=t.length>0?t:ce,a=o.filter(l=>!!Q(l.row,e.field)).length,s=o.length>0&&a===o.length;return i.jsx("span",{className:"rg-grid__header-checkbox",onClick:me,onDoubleClick:me,children:i.jsx(xe,{...br(e),checked:s,indeterminate:a>0&&!s,disabled:t.length===0,label:ft(e)||void 0,"aria-label":`Select all ${be(e)}`,onChange:l=>bn(e,l)})})},_n=(e,t,o)=>{if(t.cellEditor)return i.jsx("div",{className:"rg-grid__custom-editor",onBlur:s=>{s.currentTarget.contains(s.relatedTarget)||o.session===ae.current&&(pe(e,t,{value:He.current},{focus:!1})||ue())},onKeyDown:s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),ue(),lt(e.id,t.field))},children:u.createElement(t.cellEditor,{value:o.draft,row:e.row,rowIndex:e.index,field:t.field,column:t,onChange:s=>{He.current=s,he(l=>l&&l.session===o.session?{...l,draft:s,invalid:!1}:l)},onCommit:(s,l="none")=>{o.session===ae.current&&pe(e,t,{value:s===void 0?He.current:s},{move:l})},onCancel:()=>{ue(),lt(e.id,t.field)}})});const a=t.type==="date";return a?i.jsx(An,{value:o.draft===null||o.draft===void 0?"":String(o.draft),label:`Edit ${be(t)}`,invalid:o.invalid,min:t.dateMin,max:t.dateMax,locale:t.dateLocale,theme:We,className:P("rg-grid__editor",o.invalid&&"rg-grid__editor--invalid",A.editor),style:{textAlign:t.align,...I.editor},onChange:s=>he(l=>l&&{...l,draft:s,invalid:!1}),onPick:s=>{o.session===ae.current&&pe(e,t,{text:s},{focus:!0})},onBlur:s=>{o.session===ae.current&&(pe(e,t,{text:s.currentTarget.value},{focus:!1})||ue())},onKeyDown:s=>cr(s,e,t)}):i.jsx("input",{autoFocus:!0,type:a?"date":"text",min:a?t.dateMin:void 0,max:a?t.dateMax:void 0,className:P("rg-grid__editor",o.invalid&&"rg-grid__editor--invalid",A.editor),style:{textAlign:t.align,...I.editor},value:o.draft===null||o.draft===void 0?"":String(o.draft),inputMode:t.type==="number"?"decimal":void 0,"aria-label":`Edit ${be(t)}`,"aria-invalid":o.invalid||void 0,onChange:s=>{const l=s.target.value;he(x=>x&&{...x,draft:l,invalid:!1})},onFocus:s=>{const l=s.currentTarget;a||(o.select==="all"?l.select():l.setSelectionRange(l.value.length,l.value.length))},onBlur:s=>{if(o.session===ae.current){if(Fr(s.currentTarget))return ue();pe(e,t,{text:s.currentTarget.value},{focus:!1})||ue()}},onKeyDown:s=>cr(s,e,t)})},yn=u.useMemo(()=>{const e=new Map;for(const t of M)t.filterable&&!t.filterRenderer&&Er(t)==="select"&&e.set(t.field,Bn(t,Ue,o=>Q(o,t.field),o=>Pe(t,o)));return e},[M,Ue]),vn=Kr||!!Ye,kn=Ye?{"--rg-stripe-a":Ye[0],"--rg-stripe-b":Ye[1]}:void 0,wn=Ke&&W&&(oe==="top"||oe==="both"),jn=Ke&&W&&(oe==="bottom"||oe==="both"),Dn=Ae&&(S||!!Ut||Wt||!!Be),_r=e=>i.jsxs("div",{className:P("rg-grid__footer",e==="top"&&"rg-grid__footer--top",A.footer),style:I.footer,"data-position":e,children:[i.jsxs("span",{...B("rowCount","rg-grid__count"),children:[De===0?"0 rows":`${Zr}–${en} of ${De}`,G&&ne.length>0?` · ${ne.length} selected`:""]}),i.jsxs("div",{...B("pagination","rg-grid__pagination"),children:[i.jsxs("label",{className:"rg-grid__page-size-label",children:["Rows per page",i.jsx("select",{value:U,onChange:t=>Vr(Number(t.target.value)),...B("pageSize","rg-grid__page-size"),children:(Ne.includes(U)?Ne:[...Ne,U].sort((t,o)=>t-o)).map(t=>i.jsx("option",{value:t,children:t},t))})]}),i.jsx("button",{type:"button","aria-label":"First page",disabled:V===0,onClick:()=>ke(0),...B("pageButton","rg-grid__page-btn"),children:"«"}),i.jsx("button",{type:"button","aria-label":"Previous page",disabled:V===0,onClick:()=>ke(V-1),...B("pageButton","rg-grid__page-btn"),children:"‹"}),i.jsxs("span",{...B("pageInfo","rg-grid__page-info"),children:["Page ",V+1," of ",de]}),i.jsx("button",{type:"button","aria-label":"Next page",disabled:V>=de-1,onClick:()=>ke(V+1),...B("pageButton","rg-grid__page-btn"),children:"›"}),i.jsx("button",{type:"button","aria-label":"Last page",disabled:V>=de-1,onClick:()=>ke(de-1),...B("pageButton","rg-grid__page-btn"),children:"»"})]})]}),Nn=e=>i.jsx("tr",{className:"rg-grid__tr rg-grid__skeleton-row","aria-hidden":"true",style:Z?{height:le}:void 0,children:Oe?i.jsx("td",{colSpan:Te,className:"rg-grid__td rg-grid__skeleton-cell",children:u.createElement(Oe,{rowIndex:e,columns:M})}):i.jsxs(i.Fragment,{children:[G&&i.jsx("td",{className:"rg-grid__td",children:i.jsx("span",{...B("skeleton","rg-grid__skeleton"),style:{...I.skeleton,width:18}})}),M.map((t,o)=>i.jsx("td",{className:"rg-grid__td",style:{textAlign:t.align},children:i.jsx("span",{...B("skeleton","rg-grid__skeleton"),style:{...I.skeleton,width:`${55+(e*7+o*13)%35}%`}})},t.field))]})},`sk${e}`),yr=(e,t,o=W&&!e.sequenceRestartEachPage?V*U:0)=>(e.sequenceStart??1)+o+t,En=(e,t)=>{const{row:o,id:a,index:s}=e,l=typeof yt=="function"?yt(o,s):yt,x=typeof vt=="function"?vt(o,s):vt,m=Tt.has(a),w=typeof _t=="function"?_t(o,s):_t;return i.jsxs("tr",{onClick:bt?()=>bt(o,s):void 0,"aria-selected":G?m:void 0,className:P("rg-grid__tr","rg-grid__row",vn&&(t%2===0?"rg-grid__row--stripe-a":"rg-grid__row--stripe-b"),Vt&&!Z&&(w||"rg-grid__row--enter"),m&&"rg-grid__row--selected",bt&&"rg-grid__row--clickable",A.row,l),style:{...Vt&&!Z?{"--rg-i":Math.min(t,24)}:null,...Z?{height:le}:null,...I.row,...x},children:[G&&i.jsx("td",{className:P("rg-grid__td rg-grid__select-cell",ut&&"rg-grid__pinned rg-grid__pinned--left"),style:{width:fe,minWidth:fe,maxWidth:fe,...ut?{left:0}:null},onClick:me,children:i.jsx("span",{className:"rg-grid__checkbox-cell",onClickCapture:p=>rr.current=p.shiftKey,children:i.jsx(xe,{variant:xt,checked:m,disabled:!nt(o),"aria-label":G==="single"?"Select row":`Select row ${s+1}`,onChange:p=>on(e,p),classNames:{root:A.checkbox,control:A.checkboxControl,indicator:A.checkboxIndicator},styles:{root:I.checkbox,control:I.checkboxControl,indicator:I.checkboxIndicator}})})}),M.map((p,K)=>{let X=sn(p,e);if(p.type==="sequence"){const ee=yr(p,t);X={...X,value:ee,formattedValue:p.valueFormatter?p.valueFormatter(ee,o):String(ee),editable:!1}}const Sn=typeof p.cellClassName=="function"?p.cellClassName(X):p.cellClassName,Cn=typeof p.cellStyle=="function"?p.cellStyle(X):p.cellStyle,vr=Ce!==null&&Ce.id===a&&Ce.field===p.field,$t=st(p,X),kr=gr(p,K),Fn=jt?jt.id===a&&jt.field===p.field:t===0&&K===0;return i.jsx("td",{ref:ee=>{const wr=At(a,p.field);ee?Je.current.set(wr,ee):Je.current.delete(wr)},tabIndex:mt?Fn?0:-1:$t?0:void 0,onFocus:mt?ee=>ee.target===ee.currentTarget&&Gt({id:a,field:p.field}):void 0,onDoubleClick:$t?()=>at(e,p):void 0,onKeyDown:ee=>dn(ee,e,p,X),className:P("rg-grid__td",$t&&"rg-grid__td--editable",vr&&"rg-grid__td--editing",kr.className,A.cell,p.className,Sn),style:{textAlign:p.align,...I.cell,...p.style,...Cn,...kr.style},children:vr&&Ce?_n(e,p,Ce):p.cellRenderer?u.createElement(p.cellRenderer,X):p.type==="boolean"&&!p.cellEditor?mn(p,X):X.formattedValue},p.field)})]},a)},Mn=ht??(W?Math.min(U,20):5);return i.jsxs("div",{className:P("rg-grid",Z&&"rg-grid--virtual",A.root,Or),style:{...kn,...I.root,...Br},"data-rg-theme":We||void 0,"aria-busy":Ft||void 0,children:[Dn&&i.jsxs("div",{...B("toolbar","rg-grid__toolbar"),children:[i.jsxs("div",{className:"rg-grid__toolbar-left",children:[S&&i.jsx("input",{type:"search",value:Me,onChange:e=>Yr(e.target.value),placeholder:N,"aria-label":"Search all columns",...B("search","rg-grid__search")}),G&&ne.length>0&&i.jsxs("span",{className:"rg-grid__selected-count",role:"status",children:[ne.length," selected"]})]}),i.jsxs("div",{className:"rg-grid__toolbar-actions",children:[Ut,Wt&&i.jsx(zn,{columns:r,hidden:Ve,onToggle:Hr,theme:We,className:A.toolButton,style:I.toolButton}),Be&&i.jsx("button",{type:"button",onClick:()=>mr(),...B("toolButton","rg-grid__tool-btn"),children:"Export CSV"})]})]}),wn&&_r("top"),i.jsx("div",{ref:Fe,...B("scroll","rg-grid__scroll"),onScroll:Z?e=>Xt({top:e.currentTarget.scrollTop,height:e.currentTarget.clientHeight}):void 0,style:{...I.scroll,...qe!==void 0?{maxHeight:qe}:Z?{maxHeight:400}:null},children:i.jsxs("table",{...B("table","rg-grid__table"),role:"grid",style:Lt?{...I.table,tableLayout:"fixed",width:M.reduce((e,t)=>e+dt(t),G?fe:0),minWidth:"100%"}:I.table,children:[i.jsx("thead",{...B("thead","rg-grid__thead"),children:i.jsxs("tr",{...B("headerRow","rg-grid__tr"),children:[G&&i.jsx("th",{scope:"col",className:P("rg-grid__th rg-grid__select-cell",ut&&"rg-grid__pinned rg-grid__pinned--left",A.headerCell),style:{width:fe,minWidth:fe,maxWidth:fe,...ut?{left:0}:null,...I.headerCell},children:G==="multiple"&&i.jsx("span",{className:"rg-grid__checkbox-cell",children:i.jsx(xe,{variant:xt,checked:or,indeterminate:nr>0&&!or,disabled:Re.length===0,"aria-label":"Select all rows",onChange:ir,classNames:{root:A.checkbox,control:A.checkboxControl,indicator:A.checkboxIndicator},styles:{root:I.checkbox,control:I.checkboxControl,indicator:I.checkboxIndicator}})})}),M.map((e,t)=>{const o=J.findIndex(m=>m.field===e.field),a=o>=0?J[o].direction:null,s=Et(e),l=Zt(e),x=gr(e,t);return i.jsxs("th",{ref:m=>{m?Se.current.set(e.field,m):Se.current.delete(e.field)},scope:"col","aria-sort":a?a==="asc"?"ascending":"descending":s?"none":void 0,tabIndex:s?0:void 0,onClick:m=>sr(e,m.shiftKey),onKeyDown:m=>{s&&m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),sr(e,m.shiftKey))},className:P("rg-grid__th",s&&"rg-grid__th--sortable",x.className,A.headerCell,e.className,e.headerClassName),style:{width:Lt?dt(e):e.width,minWidth:e.minWidth,textAlign:e.align,...I.headerCell,...e.style,...e.headerStyle,...x.style},children:[i.jsxs("span",{className:"rg-grid__th-content",children:[e.headerRenderer?u.createElement(e.headerRenderer,{column:e,sortDirection:a}):e.headerCheckbox&&e.type==="boolean"?xn(e):ft(e),e.filterable&&i.jsx(Vn,{column:e,label:be(e),kind:l,value:ve[e.field],onChange:m=>{const w={...ve};m===void 0?delete w[e.field]:w[e.field]=m,Wr(w)},options:yn.get(e.field)??[],debounce:e.filterDebounce??re,theme:We,indicatorClassName:P(A.filterIndicator,e.filterIndicatorClassName),indicatorStyle:{...I.filterIndicator,...e.filterIndicatorStyle},popupClassName:P(A.filterPopup,e.filterPopupClassName),popupStyle:{...I.filterPopup,...e.filterPopupStyle},inputClassName:A.filterInput,inputStyle:I.filterInput}),s&&i.jsxs("span",{className:"rg-grid__sort","aria-hidden":"true",children:[a==="asc"?"▲":a==="desc"?"▼":"↕",a&&J.length>1&&i.jsx("sup",{className:"rg-grid__sort-order",children:o+1})]})]}),e.resizable&&i.jsx("span",{className:"rg-grid__resizer",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${be(e)}`,onPointerDown:m=>hn(m,e),onClick:me,onDoubleClick:me})]},e.field)})]})}),i.jsx("tbody",{...B("tbody","rg-grid__tbody"),children:Ft?Array.from({length:Mn},(e,t)=>Nn(t)):nn?i.jsx("tr",{children:i.jsxs("td",{colSpan:Te,...B("empty","rg-grid__empty rg-grid__error"),role:"alert",children:[Pr," ",i.jsx("button",{type:"button",className:"rg-grid__tool-btn",onClick:()=>tt(Qe.current),children:"Retry"})]})}):$.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:Te,...B("empty","rg-grid__empty"),children:Ar})}):i.jsxs(i.Fragment,{children:[Ie&&ct>0&&i.jsx("tr",{"aria-hidden":"true",className:"rg-grid__spacer",children:i.jsx("td",{colSpan:Te,style:{height:ct*le}})}),fn.map((e,t)=>En(e,ct+t)),Ie&&It<$.length&&i.jsx("tr",{"aria-hidden":"true",className:"rg-grid__spacer",children:i.jsx("td",{colSpan:Te,style:{height:($.length-It)*le}})})]})},dr)]})}),jn&&_r("bottom")]})}exports.Checkbox=xe;exports.DataGrid=to;
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"?>
3
+ <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
4
+ <numFmts count="1"><numFmt numFmtId="164" formatCode="yyyy\\-mm\\-dd"/></numFmts>
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>
6
+ <fills count="3"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill><fill><patternFill patternType="solid"><fgColor rgb="FF4F46E5"/><bgColor indexed="64"/></patternFill></fill></fills>
7
+ <borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>
8
+ <cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>
9
+ <cellXfs count="5">
10
+ <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
11
+ <xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0" applyFont="1" applyFill="1" applyAlignment="1"><alignment vertical="center"/></xf>
12
+ <xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" applyAlignment="1"><alignment horizontal="right"/></xf>
13
+ <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment horizontal="right"/></xf>
14
+ <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment horizontal="center"/></xf>
15
+ </cellXfs>
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"?>
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
+ <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;