mantine-datatable
Version:
The lightweight, dependency-free, dark-theme aware table component for your Mantine UI data-rich applications, featuring asynchronous data loading support, pagination, intuitive Gmail-style additive batch rows selection, column sorting, custom cell data r
1 lines • 55 kB
JavaScript
"use client";import{Box as Wl,Table as Bl}from"@mantine/core";import{useMergedRef as Ht}from"@mantine/hooks";import Co from"clsx";import{useCallback as At,useEffect as Vl,useLayoutEffect as Gl,useMemo as Fl,useRef as lt}from"react";import{parseThemeColor as Sa}from"@mantine/core";function W(e,t,n){return e?Sa({color:typeof e=="object"?e[n]:e,theme:t}).value:void 0}function Ft({theme:e,c:t,backgroundColor:n,borderColor:o,rowBorderColor:a,stripedColor:r,highlightOnHoverColor:l}){return{"--mantine-datatable-color-light":W(t,e,"light"),"--mantine-datatable-color-dark":W(t,e,"dark"),"--mantine-datatable-background-color-light":W(n,e,"light"),"--mantine-datatable-background-color-dark":W(n,e,"dark"),"--mantine-datatable-border-color-light":W(o,e,"light"),"--mantine-datatable-border-color-dark":W(o,e,"dark"),"--mantine-datatable-row-border-color-light":W(a,e,"light"),"--mantine-datatable-row-border-color-dark":W(a,e,"dark"),"--mantine-datatable-striped-color-light":W(r,e,"light"),"--mantine-datatable-striped-color-dark":W(r,e,"dark"),"--mantine-datatable-highlight-on-hover-color-light":W(l,e,"light"),"--mantine-datatable-highlight-on-hover-color-dark":W(l,e,"dark")}}function We({theme:e,paginationActiveTextColor:t,paginationActiveBackgroundColor:n}){return{"--mantine-datatable-pagination-active-text-color-light":W(t,e,"light"),"--mantine-datatable-pagination-active-text-color-dark":W(t,e,"dark"),"--mantine-datatable-pagination-active-background-color-light":W(n,e,"light"),"--mantine-datatable-pagination-active-background-color-dark":W(n,e,"dark")}}function $t({theme:e,color:t,backgroundColor:n}){return{"--mantine-datatable-row-color-light":W(t,e,"light"),"--mantine-datatable-row-color-dark":W(t,e,"dark"),"--mantine-datatable-row-background-color-light":W(n,e,"light"),"--mantine-datatable-row-background-color-dark":W(n,e,"dark")}}import{useState as Ut}from"react";import{createSafeContext as Ra}from"@mantine/core";var[Xt,Pe]=Ra("useDataTableColumnsContext must be used within DataTableColumnProvider");import{jsx as xa}from"react/jsx-runtime";var Ct=e=>{let{children:t,columnsOrder:n,setColumnsOrder:o,columnsToggle:a,setColumnsToggle:r,columnsPinning:l,setColumnsPinning:s,resetColumnsOrder:c,resetColumnsToggle:m,resetColumnsPinning:i,setColumnWidth:u,setMultipleColumnWidths:p,resetColumnsWidth:T,beginResize:d,endResize:S,pinnedMap:b}=e,[C,E]=Ut(""),[D,L]=Ut("");return xa(Xt,{value:{sourceColumn:C,setSourceColumn:E,targetColumn:D,setTargetColumn:L,columnsToggle:a,setColumnsToggle:r,columnsPinning:l,setColumnsPinning:s,swapColumns:()=>{if(!n||!o||!C||!D)return;let f=b.get(C),h=b.get(D);if(f?.logicalSide!==h?.logicalSide)return;let w=n.indexOf(C),M=n.indexOf(D);if(w!==-1&&M!==-1){let g=[...n],[R]=g.splice(w,1);g.splice(M,0,R),o(g)}},resetColumnsOrder:c,resetColumnsToggle:m,resetColumnsPinning:i,setColumnWidth:u,setMultipleColumnWidths:p,resetColumnsWidth:T,beginResize:d,endResize:S},children:t})};import{jsx as Qt}from"react/jsx-runtime";function Kt(){return Qt("tr",{className:"mantine-datatable-empty-row",children:Qt("td",{})})}import{Center as Ma,Text as ka}from"@mantine/core";import{jsx as Le,jsxs as va}from"react/jsx-runtime";function jt(){return va("svg",{width:"24",height:"24",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[Le("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Le("path",{d:"M12.983 8.978c3.955 -.182 7.017 -1.446 7.017 -2.978c0 -1.657 -3.582 -3 -8 -3c-1.661 0 -3.204 .19 -4.483 .515m-2.783 1.228c-.471 .382 -.734 .808 -.734 1.257c0 1.22 1.944 2.271 4.734 2.74"}),Le("path",{d:"M4 6v6c0 1.657 3.582 3 8 3c.986 0 1.93 -.067 2.802 -.19m3.187 -.82c1.251 -.53 2.011 -1.228 2.011 -1.99v-6"}),Le("path",{d:"M4 12v6c0 1.657 3.582 3 8 3c3.217 0 5.991 -.712 7.261 -1.74m.739 -3.26v-4"}),Le("path",{d:"M3 3l18 18"})]})}import{Fragment as Ea,jsx as Be,jsxs as La}from"react/jsx-runtime";function Jt({icon:e,text:t,active:n,children:o}){return Be(Ma,{className:"mantine-datatable-empty-state","data-active":n||void 0,children:o||La(Ea,{children:[e||Be("div",{className:"mantine-datatable-empty-state-icon",children:Be(jt,{})}),Be(ka,{component:"div",size:"sm",c:"dimmed",children:t})]})})}import{TableTfoot as dr,TableTr as mr}from"@mantine/core";import pr from"clsx";import{TableTh as lr}from"@mantine/core";import ir from"clsx";import{useCallback as fi,useRef as bi,useState as gi}from"react";import{useLocalStorage as Ia}from"@mantine/hooks";import{useEffect as Na,useMemo as Yt}from"react";function De(e){let t=e.replace(/([a-z\d])([A-Z]+)/g,"$1 $2").replace(/\W|_/g," ").trim().toLowerCase();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function Z(e,t,n){return!Array.isArray(e)||n&&!e.every(n)?t:e}function Ve(e){return typeof e=="object"&&e!==null&&typeof e.accessor=="string"}function qt(e,t,n){return e.filter(o=>!t.map(n).includes(n(o)))}function Ge(e,t){return e.filter((n,o,a)=>o===a.findIndex(r=>t(n)===t(r)))}function yt(e,t){return t?t.match(/([^[.\]])+/g).reduce((o,a)=>o&&o[a],e):void 0}function B(e,t){return typeof t=="string"?yt(e,t):t(e)}function hi(e,t){let n=structuredClone(t),o=n[e.source.index];return e.destination&&(n.splice(e.source.index,1),n.splice(e.destination.index,0,o)),n}function Ci(e,t){let n=structuredClone(t),o=e.destination;if(!o)return n;let a=n[e.source.index],r=n[o.index];return n.splice(o.index,1,a),n.splice(e.source.index,1,r),n}function Pt(e){return!e||e.length===0?0:Math.max(...e.map(t=>t.groups&&t.groups.length>0?1+Pt(t.groups):1))}function Ie(e){let t=[];for(let n of e)n.columns&&n.columns.length>0?t.push(...n.columns.filter(o=>o!=null)):n.groups&&n.groups.length>0&&t.push(...Ie(n.groups));return t.filter(n=>n!=null)}function Fe(e,t){return e.columns&&e.columns.length>0?e.columns.filter((n,o)=>n.hidden?!1:t?t[o]!==!1:!0).length:e.groups&&e.groups.length>0?e.groups.reduce((n,o)=>n+Fe(o,t),0):0}function Dt(e,t,n=0){if(n===t)return[...e];let o=[];for(let a of e)a.groups&&a.groups.length>0&&o.push(...Dt(a.groups,t,n+1));return o}function Zt(e,t,n){return n?!e||t:!1}function en({key:e,columns:t=[],getInitialValueInEffect:n=!0}){let o=Yt(()=>t.map(i=>({accessor:i.accessor,defaultPinned:i.pinned,pinnable:!!i.pinnable,pinned:i.pinned})),[t]),[a,r]=Ia({key:e?`${e}-columns-pinning`:"",defaultValue:e?o:void 0,getInitialValueInEffect:n}),l=Z(a,o,Ve);function s(i){e&&r(typeof i=="function"?u=>i(u??o):i)}let c=Yt(()=>{if(!l)return o;let i=[];return l.forEach(u=>{t.find(p=>p.accessor===u.accessor)&&i.push(u)}),t.forEach(u=>{i.find(p=>p.accessor===u.accessor)||i.push({accessor:u.accessor,defaultPinned:u.pinned,pinnable:!!u.pinnable,pinned:u.pinned})}),i},[l,t,o]);Na(()=>{e&&l&&JSON.stringify(c)!==JSON.stringify(l)&&r(c)},[e,c,l,r]);let m=()=>{s(o)};return e?{columnsPinning:c,setColumnsPinning:s,resetColumnsPinning:m}:{columnsPinning:o,setColumnsPinning:s,resetColumnsPinning:m}}import{useLocalStorage as Ha}from"@mantine/hooks";import{useEffect as Aa,useMemo as tn}from"react";function nn({key:e,columns:t=[],getInitialValueInEffect:n=!0}){let o=tn(()=>t?t.map(i=>i.accessor):[],[t]),[a,r]=Ha({key:e?`${e}-columns-order`:"",defaultValue:e?o:void 0,getInitialValueInEffect:n}),l=Z(a,o,i=>typeof i=="string");function s(i){e&&r(i)}let c=tn(()=>{if(!l)return o;let i=[];return l.forEach(u=>{t.find(p=>p.accessor===u)&&i.push(u)}),t.forEach(u=>{i.includes(u.accessor)||i.push(u.accessor)}),i},[l,t,o]);Aa(()=>{e&&l&&JSON.stringify(c)!==JSON.stringify(l)&&r(c)},[e,c,l,r]);let m=()=>{s(o)};return e?{columnsOrder:c,setColumnsOrder:s,resetColumnsOrder:m}:{columnsOrder:l,setColumnsOrder:s,resetColumnsOrder:m}}import{useLocalStorage as Oa}from"@mantine/hooks";import{useCallback as Y,useEffect as wt,useMemo as on,useRef as za,useState as an}from"react";function rn({key:e,columns:t=[],getInitialValueInEffect:n=!0,headerRef:o}){let a=on(()=>t.some(f=>f.resizable&&!f.hidden&&f.accessor!=="__selection__"),[t]),r=Y(()=>t.filter(f=>f.accessor!=="__selection__").map(f=>({[f.accessor]:f.width??"auto"})),[t]),[l,s]=Oa({key:e?`${e}-columns-width`:"",defaultValue:e?r():void 0,getInitialValueInEffect:n}),c=Z(l,[],f=>typeof f=="object"&&f!==null),[m,i]=an(()=>e&&c.length>0?c:r()),[u,p]=an(!1),T=za(!1);wt(()=>{e&&(!c||c.length===0||i(c))},[e,c]),wt(()=>{i(f=>{let h=new Set(t.filter(y=>y.accessor!=="__selection__").map(y=>String(y.accessor))),w=f.filter(y=>h.has(Object.keys(y)[0])),M=new Set(w.map(y=>Object.keys(y)[0])),g=!1;for(let y of t){if(y.accessor==="__selection__")continue;let v=String(y.accessor);M.has(v)||(w.push({[v]:y.width??"auto"}),g=!0)}return w.length!==f.length||g?w:f})},[t]);let d=Y(f=>{let h=f.filter(w=>w.accessor!=="__selection__");h.length!==0&&(T.current=!0,i(w=>w.map(M=>{let g=Object.keys(M)[0],R=h.find(y=>y.accessor===g);return R?{[g]:R.width}:M})))},[]);wt(()=>{!e||!T.current||u||(T.current=!1,s(m))},[e,m,u,s]);let S=Y((f,h)=>{d([{accessor:f,width:h}])},[d]),b=Y(f=>{d(f)},[d]),C=Y(()=>{p(!0);let f=o?.current;if(!f)return;let h=Array.from(f.querySelectorAll("th[data-accessor]"));if(h.length===0)return;let w=[];for(let M of h){let g=M.getAttribute("data-accessor");if(!g||g==="__selection__")continue;let R=Math.round(M.getBoundingClientRect().width);w.push({[g]:`${R}px`})}T.current=!0,i(w)},[o]),E=Y(()=>{p(!1)},[]),D=Y(()=>{let f=r();T.current=!0,i(f),p(!1)},[r]),L=on(()=>{if(!a)return!1;let f=t.filter(h=>h.resizable&&!h.hidden&&h.accessor!=="__selection__");return m.filter(h=>{let w=Object.keys(h)[0];return f.some(M=>M.accessor===w)}).every(h=>{let w=Object.values(h)[0];return w==="auto"||w==="initial"})},[a,t,m]),N=Y(()=>{},[]);return{columnsWidth:m,setColumnsWidth:d,setColumnWidth:S,setMultipleColumnWidths:b,resetColumnsWidth:D,hasResizableColumns:a,allResizableWidthsInitial:L,measureAndSetColumnWidths:N,isResizing:u,beginResize:C,endResize:E}}import{useMemo as St}from"react";import{useLocalStorage as _a}from"@mantine/hooks";import{useEffect as Wa,useMemo as ln}from"react";function sn({key:e,columns:t=[],getInitialValueInEffect:n=!0}){let o=ln(()=>t?.map(i=>({accessor:i.accessor,defaultToggle:i.defaultToggle||!0,toggleable:i.toggleable,toggled:i.defaultToggle===void 0?!0:i.defaultToggle})),[t]),[a,r]=_a({key:e?`${e}-columns-toggle`:"",defaultValue:e?o:void 0,getInitialValueInEffect:n}),l=Z(a,o,Ve);function s(i){e&&r(i)}let c=ln(()=>{if(!l)return o;let i=[];return l.forEach(u=>{t.find(p=>p.accessor===u.accessor)&&i.push(u)}),t.forEach(u=>{i.find(p=>p.accessor===u.accessor)||i.push({accessor:u.accessor,defaultToggle:u.defaultToggle||!0,toggleable:u.toggleable,toggled:u.defaultToggle===void 0?!0:u.defaultToggle})}),i},[l,t,o]);Wa(()=>{e&&l&&JSON.stringify(c)!==JSON.stringify(l)&&r(c)},[e,c,l,r]);let m=()=>{s(o)};return e?{columnsToggle:c,setColumnsToggle:s,resetColumnsToggle:m}:{columnsToggle:l,setColumnsToggle:s,resetColumnsToggle:m}}var cn=({key:e,columns:t=[],getInitialValueInEffect:n=!0,headerRef:o,scrollViewportRef:a})=>{let{columnsOrder:r,setColumnsOrder:l,resetColumnsOrder:s}=nn({key:e,columns:t,getInitialValueInEffect:n}),{columnsToggle:c,setColumnsToggle:m,resetColumnsToggle:i}=sn({key:e,columns:t,getInitialValueInEffect:n}),{columnsPinning:u,setColumnsPinning:p,resetColumnsPinning:T}=en({key:e,columns:t,getInitialValueInEffect:n}),{columnsWidth:d,setColumnsWidth:S,setColumnWidth:b,setMultipleColumnWidths:C,resetColumnsWidth:E,hasResizableColumns:D,allResizableWidthsInitial:L,measureAndSetColumnWidths:N,isResizing:f,beginResize:h,endResize:w}=rn({key:e,columns:t,getInitialValueInEffect:n,headerRef:o,scrollViewportRef:a}),M=St(()=>{let y;r?y=r.map(P=>t.find(A=>A.accessor===P)).map(P=>{let A=u.find(z=>z.accessor===P?.accessor),_=P?.pinnable?A?.pinned:P?.pinned;return{...P,hidden:P?.hidden||!c.find(z=>z.accessor===P?.accessor)?.toggled,pinned:_}}):y=t;let v=y.filter(P=>P.pinned==="left"),H=y.filter(P=>!P.pinned),k=y.filter(P=>P.pinned==="right");return[...v,...H,...k].map(P=>{if(P?.accessor==="__selection__")return P;let A=P?.accessor,_=d.find(K=>A in K);if(!_)return P;let z=_[A];return z===void 0||z==="auto"||z==="initial"?P:{...P,width:z}})},[t,r,c,u,d]),g=St(()=>{let y=M.filter(v=>!v.hidden&&v.accessor!=="__selection__");return y.length===0?!1:y.every(v=>typeof v.width=="string"&&/px$/.test(v.width))},[M]),R=St(()=>{if(!g)return null;let y=0;for(let v of M){if(v.hidden||v.accessor==="__selection__")continue;let H=v.width;if(typeof H!="string")continue;let k=parseInt(H,10);Number.isNaN(k)||(y+=k)}return y>0?y:null},[g,M]);return{effectiveColumns:M,setColumnsOrder:l,columnsOrder:r,resetColumnsOrder:s,columnsToggle:c,setColumnsToggle:m,resetColumnsToggle:i,columnsPinning:u,setColumnsPinning:p,resetColumnsPinning:T,columnsWidth:d,setColumnsWidth:S,setColumnWidth:b,setMultipleColumnWidths:C,resetColumnsWidth:E,hasResizableColumns:D,allResizableWidthsInitial:L,measureAndSetColumnWidths:N,isResizing:f,isLocked:g,tableWidth:R,beginResize:h,endResize:w}};import{rem as Fa}from"@mantine/core";import{useCallback as $a,useEffect as xt,useRef as ee}from"react";import{useEffect as Ba,useLayoutEffect as Va}from"react";var be=typeof window<"u"?Va:Ba;import{useRef as Ga}from"react";function Rt(e){let t=Ga(e);return t.current=e,t}var un="--mantine-datatable-header-height",dn="--mantine-datatable-footer-height",mn="--mantine-datatable-selection-column-width",pn="--mantine-datatable-last-row-border-bottom";function X(e,t,n){e?.style.setProperty(t,n)}function Mt(e){let t=e.borderBoxSize?.[0]||e.contentBoxSize?.[0];return t?{width:t.inlineSize,height:t.blockSize}:{width:e.contentRect.width,height:e.contentRect.height}}function vt(e,t,n){if(e){let o=new ResizeObserver(a=>{let r=a[0];r&&t(Mt(r))});return o.observe(e),()=>{o.disconnect(),n()}}}function fn({scrollCallbacks:e,withRowBorders:t}){let n={root:ee(null),table:ee(null),scrollViewport:ee(null),header:ee(null),footer:ee(null),selectionColumnHeader:ee(null)},{root:o,table:a,scrollViewport:r,header:l,footer:s,selectionColumnHeader:c}=n,m=Rt({withRowBorders:t}),i=Rt(e),u=ee(()=>{}),p=ee(()=>{}),T=$a(d=>{i.current.onScroll?.(d),u.current()},[]);return xt(()=>vt(l.current,d=>{X(o.current,un,`${d.height}px`)},()=>X(o.current,un,"0")),[l.current]),xt(()=>vt(s.current,d=>{X(o.current,dn,`${d.height}px`)},()=>X(o.current,dn,"0")),[s.current]),xt(()=>vt(c.current,d=>{X(o.current,mn,`${d.width}px`)},()=>X(o.current,mn,"0")),[c.current]),be(()=>{if(typeof window>"u")return;let d={top:!0,bottom:!0,left:!0,right:!0},S={width:0,height:0},b={width:0,height:0};function C(f,h){let w=d[f];return d[f]=h,X(o.current,`--mantine-datatable-${f}-shadow-opacity`,h?"0":"1"),w}function E(){let f=S.height-b.height,h=f<0;X(o.current,"--mantine-datatable-footer-position",h?"relative":"sticky"),X(o.current,"--mantine-datatable-footer-bottom",h?`${f}px`:"0")}function D(){m.current.withRowBorders&&S.height<b.height?X(o.current,pn,`${Fa("1px")} solid var(--mantine-datatable-border-color)`):X(o.current,pn,"unset")}p.current=D;function L(){let f=i.current,h=r.current,w=h?.scrollTop??0,M=h?.scrollLeft??0,g=w===0,R=S.height-w-b.height<1,y=C("top",g),v=C("bottom",R);g&&g!==y&&f.onScrollToTop?.(),R&&R!==v&&f.onScrollToBottom?.();let H=h?getComputedStyle(h).direction==="rtl":!1,k=(h?.scrollWidth??0)-b.width,x,P;if(H){let z=Math.abs(M);P=z<1,x=k-z<1}else x=M<1,P=S.width-M-b.width<1;let A=C("left",x),_=C("right",P);x&&x!==A&&f.onScrollToLeft?.(),P&&P!==_&&f.onScrollToRight?.()}u.current=L;let N=new ResizeObserver(f=>{for(let h of f)switch(h.target.tagName){case"TABLE":{S=Mt(h);break}case"DIV":{b=Mt(h);break}}L(),E(),D()});return N.observe(a.current),N.observe(r.current),()=>{N.disconnect()}},[]),be(()=>{p.current()},[t]),{refs:n,onScroll:T}}import{useCallback as Xa,useEffect as Ua,useState as Qa}from"react";function bn({columns:e,theadRef:t,tbodyRef:n,selectionColumnHeaderRef:o,selectionVisible:a,pinFirstColumn:r,pinLastColumn:l}){let[s,c]=Qa(new Map),m=Xa(()=>{if(!r&&!l&&!e.some(g=>g.pinned))return;let p=t.current??n.current;if(!p)return;let T=!!t.current,d=T?p.querySelector("tr:last-of-type"):p.querySelector("tr:first-of-type");if(!d)return;let S=getComputedStyle(p).direction==="rtl",b=new Map;if(T)d.querySelectorAll("th[data-accessor]").forEach(g=>{let R=g.dataset.accessor;if(R){let y=g.getBoundingClientRect().width;y>0&&b.set(R,y)}});else{let g=e.filter(y=>!y.hidden);d.querySelectorAll("td:not(.mantine-datatable-row-selector-cell):not(.mantine-datatable-row-expansion-cell)").forEach((y,v)=>{if(g[v]){let H=y.getBoundingClientRect().width;H>0&&b.set(String(g[v].accessor),H)}})}let C=0;if(a){let g=o.current??p.querySelector(T?".mantine-datatable-header-selector-cell":".mantine-datatable-row-selector-cell");g&&(C=g.getBoundingClientRect().width)}let E=e.filter(g=>!g.hidden&&b.has(String(g.accessor))).map(g=>String(g.accessor)),D=new Map;for(let g of e){let R=String(g.accessor);E.includes(R)&&(g.pinned?D.set(R,g.pinned):r&&R===E[0]&&!D.has(R)?D.set(R,"left"):l&&R===E[E.length-1]&&!D.has(R)&&D.set(R,"right"))}let L=E.filter(g=>D.get(g)==="left"),N=E.filter(g=>D.get(g)==="right"),f=new Map,h=C;L.forEach((g,R)=>{f.set(g,{position:S?"right":"left",logicalSide:"left",offset:h,isBoundary:R===L.length-1}),h+=b.get(g)||0});let w=-.4,M=[...N].reverse();M.forEach((g,R)=>{f.set(g,{position:S?"left":"right",logicalSide:"right",offset:w,isBoundary:R===M.length-1}),w+=b.get(g)||0}),c(g=>{if(g.size!==f.size)return f;for(let[R,y]of f){let v=g.get(R);if(!v||v.position!==y.position||v.logicalSide!==y.logicalSide||v.offset!==y.offset||v.isBoundary!==y.isBoundary)return f}return g})},[e,a,t,n,o,r,l]);Ua(()=>{if(!r&&!l&&!e.some(b=>b.pinned))return;let p=t.current??n.current;if(!p)return;let T=!!t.current,d=T?p.querySelector("tr:last-of-type"):p.querySelector("tr:first-of-type");if(!d)return;let S=new ResizeObserver(m);return d.querySelectorAll(T?"th":"td").forEach(b=>{S.observe(b)}),()=>S.disconnect()},[t,n,m]),be(m,[m]);let i=[...s.values()].some(p=>p.logicalSide==="left"),u=[...s.values()].some(p=>p.logicalSide==="right");return{pinnedMap:s,hasLeftPinned:i,hasRightPinned:u}}import{useEffect as Ka,useState as ja}from"react";function gn(e){let[t,n]=ja(null),o=e?.join(":")||"";return Ka(()=>{n(null)},[o]),{lastSelectionChangeIndex:t,setLastSelectionChangeIndex:n}}import{useEffect as Ja,useRef as qa,useState as Za}from"react";function Ya(e,t){let n=()=>{t(e.map(a=>a.matches))},o=e.map(a=>{try{return a.addEventListener("change",n),()=>a.removeEventListener("change",n)}catch{return a.addListener(n),()=>a.removeListener(n)}});return()=>{o.forEach(a=>{a()})}}function er(e,t){return t||(typeof window<"u"&&"matchMedia"in window?e.map(n=>window.matchMedia(n).matches):e.map(()=>!1))}function Tn(e,t,{getInitialValueInEffect:n}={getInitialValueInEffect:!0}){let[o,a]=Za(n?t:er(e,t)),r=qa(null);return Ja(()=>{if("matchMedia"in window)return r.current=e.map(l=>window.matchMedia(l)),a(r.current.map(l=>l.matches)),Ya(r.current,l=>{a(l)})},[e]),o}import{useMantineTheme as tr}from"@mantine/core";import{useMemo as hn}from"react";function Cn(e){let t=tr(),n=hn(()=>e.map(a=>(typeof a=="function"?a(t):a)??""),[e,t]),o=hn(()=>e.map(()=>!0),[e]);return Tn(n,o)}import{useMantineTheme as nr}from"@mantine/core";import{useMediaQuery as or}from"@mantine/hooks";function te(e){let t=nr(),n=typeof e=="function"?e(t):e;return or(n||"",!0)}import{useState as ar}from"react";function yn({rowExpansion:e,records:t,idAccessor:n}){let o=[];if(e&&t){let{trigger:s,allowMultiple:c,initiallyExpanded:m}=e;t&&s==="always"?o=t.map(i=>B(i,n)):m&&(o=t.filter((i,u)=>m({record:i,index:u})).map(i=>B(i,n)),c||(o=[o[0]]))}let a,r,l=ar(o);if(e){let{expandable:s,trigger:c,allowMultiple:m,collapseProps:i,content:u}=e;e.expanded?{recordIds:a,onRecordIdsChange:r}=e.expanded:[a,r]=l;let p=T=>r?.(a.filter(d=>d!==B(T,n)));return{expandOnClick:c!=="always"&&c!=="never",isRowExpanded:T=>c==="always"?!0:a.includes(B(T,n)),isExpandable:({record:T,index:d})=>s?s({record:T,index:d}):!0,expandRow:T=>{let d=B(T,n);r?.(m?[...a,d]:[d])},collapseRow:p,collapseProps:i,content:({record:T,index:d})=>()=>u({record:T,index:d,collapse:()=>p(T)})}}}import{useTimeout as Pn}from"@mantine/hooks";import{useEffect as rr,useState as Dn}from"react";function wn(e,t){let[n,o]=Dn(e),[a,r]=Dn(e),l=Pn(()=>o(!0),0),s=Pn(()=>r(!1),t||200);return rr(()=>{e?(s.clear(),r(!0),l.start()):(l.clear(),o(!1),s.start())},[l,s,e]),{expanded:n,visible:a}}var we="mantine-datatable-nowrap",Se="mantine-datatable-ellipsis",Q="mantine-datatable-pointer-cursor",$e="mantine-datatable-context-menu-cursor",Sn="mantine-datatable-text-selection-disabled",ne="mantine-datatable-text-align-left",oe="mantine-datatable-text-align-center",ae="mantine-datatable-text-align-right";import{jsx as sr}from"react/jsx-runtime";function Rn({className:e,style:t,pinnedInfo:n,visibleMediaQuery:o,title:a,noWrap:r,ellipsis:l,textAlign:s,width:c}){return te(o)?sr(lr,{"data-pinned":n?.position,"data-pinned-shadow":n?.isBoundary?n.position:void 0,className:ir({[we]:r||l,[Se]:l,[ne]:s==="left",[oe]:s==="center",[ae]:s==="right"},e),style:[{width:c,minWidth:c,maxWidth:c},t,n&&{position:"sticky",[n.position]:n.offset,overflow:"visible"}],children:a}):null}import{TableTh as cr}from"@mantine/core";import{jsx as ur}from"react/jsx-runtime";function xn({shadowVisible:e}){return ur(cr,{className:"mantine-datatable-footer-selector-placeholder-cell","data-shadow-visible":e||void 0})}import{jsx as kt,jsxs as fr}from"react/jsx-runtime";function vn({className:e,style:t,columns:n,defaultColumnProps:o,pinnedMap:a,selectionVisible:r,selectorCellShadowVisible:l,ref:s}){return kt(dr,{ref:s,className:pr("mantine-datatable-footer",e),style:t,children:fr(mr,{children:[r&&kt(xn,{shadowVisible:l}),n.map(({hidden:c,...m})=>{if(c)return null;let{accessor:i,visibleMediaQuery:u,textAlign:p,width:T,footer:d,footerClassName:S,footerStyle:b,noWrap:C,ellipsis:E}={...o,...m};return kt(Rn,{pinnedInfo:a.get(String(i)),className:S,style:b,visibleMediaQuery:u,textAlign:p,width:T,title:d,noWrap:C,ellipsis:E},i)})]})})}import{Checkbox as qr,Group as Zr,Popover as Yr,PopoverDropdown as el,PopoverTarget as tl,Stack as nl,TableThead as ol,TableTr as qn}from"@mantine/core";import al from"clsx";import{useState as rl}from"react";import{TableTh as br}from"@mantine/core";import gr from"clsx";import{useMemo as Xe}from"react";import{jsx as Tr}from"react/jsx-runtime";function Mn({group:{id:e,columns:t,groups:n,title:o,textAlign:a,className:r,style:l},pinnedInfo:s,maxDepth:c,currentDepth:m,previousGroups:i,isLastGroup:u,withColumnBorders:p=!1,totalTableColumns:T}){let d=Xe(()=>t&&t.length>0?t:n&&n.length>0?Ie([{id:e,columns:t,groups:n}]):[],[t,n,e]),S=Xe(()=>d.map(({visibleMediaQuery:h})=>h),[d]),b=Cn(S),C=Xe(()=>Fe({id:e,columns:t,groups:n},b),[e,t,n,b]),E=Xe(()=>i.reduce((h,w)=>h+Fe(w,b),0),[i,b]),L=n&&n.length>0?1:c-m,N=E+C<T,f=Zt(u,N,p);return C>0?Tr(br,{colSpan:C,rowSpan:L>1?L:void 0,"data-pinned":s?.position,"data-pinned-shadow":s?.isBoundary?s.position:void 0,className:gr("mantine-datatable-column-group-header-cell",{[ne]:a==="left",[oe]:a==="center",[ae]:a==="right","mantine-datatable-column-group-header-cell--needs-border":f},r),style:[l,s&&{position:"sticky",[s.position]:s.offset,overflow:"visible"}],children:o??De(e)}):null}import{ActionIcon as Qn,Box as Gr,Center as et,Flex as Fr,Group as $r,TableTh as Xr}from"@mantine/core";import tt from"clsx";import{useRef as Ur,useState as Qr}from"react";import{ActionIcon as yr,Popover as Pr,PopoverDropdown as Dr,PopoverTarget as wr}from"@mantine/core";import{useClickOutside as Sr,useDisclosure as Rr}from"@mantine/hooks";import{jsx as kn,jsxs as hr}from"react/jsx-runtime";function En(){return hr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[kn("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),kn("path",{d:"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z"})]})}import{jsx as Ln,jsxs as Cr}from"react/jsx-runtime";function In(){return Cr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[Ln("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ln("path",{d:"M20 3h-16a1 1 0 0 0 -1 1v2.227l.008 .223a3 3 0 0 0 .772 1.795l4.22 4.641v8.114a1 1 0 0 0 1.316 .949l6 -2l.108 -.043a1 1 0 0 0 .576 -.906v-6.586l4.121 -4.12a3 3 0 0 0 .879 -2.123v-2.171a1 1 0 0 0 -1 -1z",strokeWidth:"0",fill:"currentColor"})]})}import{jsx as Ue,jsxs as xr}from"react/jsx-runtime";function Nn({children:e,isActive:t,filterPopoverProps:n,filterPopoverDisableClickOutside:o}){let[a,{close:r,toggle:l}]=Rr(!1),s=t?In:En,c=Sr(r);return o&&(c=void 0),xr(Pr,{withArrow:!0,shadow:"md",trapFocus:!0,...n,opened:a,onClose:r,onDismiss:r,children:[Ue(wr,{children:Ue(yr,{className:"mantine-datatable-header-cell-filter-action-icon","data-active":t||void 0,size:"sm",variant:"default",onClick:m=>{m.preventDefault(),l()},onKeyDown:m=>m.stopPropagation(),children:Ue(s,{})})}),Ue(Dr,{ref:c,onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),children:typeof e=="function"?e({close:r}):e})]})}import{ActionIcon as qe,Center as Lr,Group as Ir,Popover as Lt}from"@mantine/core";import{useCallback as Nr,useEffect as Hr,useRef as Ar,useState as zn}from"react";import{jsx as Qe,jsxs as vr}from"react/jsx-runtime";function Hn(){return vr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[Qe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Qe("path",{d:"M5 12l14 0"}),Qe("path",{d:"M5 12l6 6"}),Qe("path",{d:"M5 12l6 -6"})]})}import{jsx as Ke,jsxs as Mr}from"react/jsx-runtime";function An(){return Mr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[Ke("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ke("path",{d:"M5 12l14 0"}),Ke("path",{d:"M19 12l-6 6"}),Ke("path",{d:"M19 12l-6 -6"})]})}import{jsx as je,jsxs as kr}from"react/jsx-runtime";function On(){return kr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[je("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),je("path",{d:"M9 4v6l-2 4v2h10v-2l-2-4v-6"}),je("path",{d:"M12 16v5"}),je("path",{d:"M8 4h8"})]})}import{jsx as Et,jsxs as Er}from"react/jsx-runtime";function Je(){return Er("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[Et("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Et("path",{d:"M18 6l-12 12"}),Et("path",{d:"M6 6l12 12"})]})}import{jsx as U,jsxs as _n}from"react/jsx-runtime";function Wn({currentPinned:e,onPinChange:t}){let[n,o]=zn(!1),a=Ar(null),[r,l]=zn(!1),s=Nr(()=>{if(a.current){let p=getComputedStyle(a.current).direction;l(p==="rtl")}},[]);be(()=>{s()},[s]),Hr(()=>{n&&s()},[n,s]);let c=r?"right":"left",m=r?"left":"right",i=e===c,u=e===m;return _n(Lt,{opened:n,onChange:o,position:"bottom",withArrow:!0,shadow:"sm",children:[U(Lt.Target,{children:U(Lr,{ref:a,className:"mantine-datatable-header-cell-pinnable-icon",role:"button","aria-label":"Pin column",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:U(qe,{size:"xs",variant:"light",onClick:p=>p.stopPropagation(),children:U(On,{})})})}),U(Lt.Dropdown,{onClick:p=>p.stopPropagation(),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),className:"mantine-datatable-pinnable-dropdown",children:_n(Ir,{gap:4,children:[U(qe,{size:"sm",variant:i?"filled":"light",onClick:()=>t(i?void 0:c),"aria-label":"Pin left",children:U(Hn,{})}),U(qe,{size:"sm",variant:u?"filled":"light",onClick:()=>t(u?void 0:m),"aria-label":"Pin right",children:U(An,{})}),e&&U(qe,{size:"sm",variant:"light",color:"red",onClick:()=>t(void 0),"aria-label":"Unpin",children:U(Je,{})})]})})]})}import{useDirection as Or}from"@mantine/core";import{useCallback as Bn,useRef as Vn,useState as zr}from"react";import{jsx as _r}from"react/jsx-runtime";var Gn=50,Fn=e=>{let{accessor:t,columnRef:n}=e,[o,a]=zr(!1),r=Vn(0),l=Vn({current:0,next:0}),{dir:s}=Or(),c=s==="rtl",{setMultipleColumnWidths:m,beginResize:i,endResize:u}=Pe(),p=Bn(d=>{if(d.preventDefault(),d.stopPropagation(),!n.current)return;let S=n.current,b=S.nextElementSibling;for(;b;){let f=b.getAttribute("data-accessor");if(f&&f!=="__selection__")break;b=b.nextElementSibling}if(!b)return;let C=b.getAttribute("data-accessor");if(!C)return;let E=S.offsetWidth,D=b.offsetWidth;i(),a(!0),r.current=d.clientX,l.current={current:E,next:D};let L=f=>{let h=f.clientX-r.current;c&&(h=-h);let w=l.current.current-Gn,M=l.current.next-Gn,g=Math.max(-w,Math.min(h,M)),R=l.current.current+g,y=l.current.next-g;m([{accessor:t,width:`${R}px`},{accessor:C,width:`${y}px`}])},N=()=>{a(!1),document.body.style.cursor="initial",document.body.style.userSelect="initial",u(),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",N)};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",L),document.addEventListener("mouseup",N)},[t,n,c,m,i,u]),T=Bn(()=>{if(!n.current)return;let S=n.current.nextElementSibling,b=[{accessor:t,width:"auto"}];if(S){let C=S.getAttribute("data-accessor");C&&C!=="__selection__"&&b.push({accessor:C,width:"auto"})}m(b)},[t,n,m]);return _r("div",{className:"mantine-datatable-header-resizable-handle",style:{cursor:o?"col-resize":void 0},onMouseDown:p,onDoubleClick:T,onClick:d=>d.stopPropagation(),title:"Drag to resize column, double-click to reset"})};import{jsx as Ze,jsxs as Wr}from"react/jsx-runtime";function $n(){return Wr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[Ze("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ze("path",{d:"M8 7l4 -4l4 4"}),Ze("path",{d:"M8 17l4 4l4 -4"}),Ze("path",{d:"M12 3l0 18"})]})}import{jsx as Ye,jsxs as Br}from"react/jsx-runtime";function Xn(){return Br("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[Ye("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ye("path",{d:"M12 5l0 14"}),Ye("path",{d:"M16 9l-4 -4"}),Ye("path",{d:"M8 9l4 -4"})]})}import{jsx as ge,jsxs as Vr}from"react/jsx-runtime";function Un(){return Vr("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[ge("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ge("path",{d:"M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),ge("path",{d:"M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),ge("path",{d:"M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),ge("path",{d:"M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),ge("path",{d:"M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),ge("path",{d:"M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]})}import{jsx as G,jsxs as It}from"react/jsx-runtime";function Kn({className:e,style:t,pinnedInfo:n,accessor:o,visibleMediaQuery:a,title:r,sortable:l,draggable:s,toggleable:c,pinnable:m,resizable:i,sortIcons:u,textAlign:p,width:T,sortStatus:d,onSortStatusChange:S,filter:b,filterPopoverProps:C,filterPopoverDisableClickOutside:E,filtering:D,sortKey:L}){let{setSourceColumn:N,setTargetColumn:f,swapColumns:h,columnsToggle:w,setColumnsToggle:M,columnsPinning:g,setColumnsPinning:R}=Pe(),[y,v]=Qr(!1),H=Ur(null),x=g?.find(O=>O.accessor===o)?.pinned;if(!te(a))return null;let P=r??De(o),A=typeof P=="string"?P:void 0,_=l&&S?O=>{O?.defaultPrevented||S({sortKey:L,columnAccessor:o,direction:d?.columnAccessor===o?d.direction==="asc"?"desc":"asc":d?.direction??"asc"})}:void 0,z=O=>{O.stopPropagation(),N(o),v(!1)},K=O=>{O.preventDefault(),f(o),v(!0)},le=()=>{f(o),v(!1),h()},ie=()=>{v(!0)},se=()=>{v(!1)},ce=O=>{O.stopPropagation(),M(w.map($=>$.accessor===o?{...$,toggled:!1}:$))},ue=O=>{R($=>$.map(j=>j.accessor===o?{...j,pinned:O}:j))};return It(Xr,{"data-accessor":o,"data-pinned":n?.position,"data-pinned-shadow":n?.isBoundary?n.position:void 0,className:tt({"mantine-datatable-header-cell-sortable":l,"mantine-datatable-header-cell-toggleable":c,"mantine-datatable-header-cell-pinnable":m,"mantine-datatable-header-cell-resizable":i},e),style:[{width:T,...i?{}:{minWidth:T,maxWidth:T}},t,n&&{position:"sticky",[n.position]:n.offset,overflow:"visible"}],role:l?"button":void 0,tabIndex:l?0:void 0,onClick:_,onKeyDown:O=>O.key==="Enter"&&_?.(),ref:H,children:[It($r,{className:"mantine-datatable-header-cell-sortable-group",justify:"space-between",wrap:"nowrap",children:[It(Fr,{align:"center",w:"100%",className:tt({"mantine-datatable-header-cell-draggable":s,"mantine-datatable-header-cell-drag-over":y}),draggable:s,onDragStart:s?z:void 0,onDragEnter:s?ie:void 0,onDragOver:s?K:void 0,onDrop:s?le:void 0,onDragLeave:s?se:void 0,children:[s?G(et,{role:"img","aria-label":"Drag column",children:G(Qn,{className:"mantine-datatable-header-cell-draggable-action-icon",variant:"subtle",size:"xs",onClick:O=>{O.stopPropagation()},children:G(Un,{})})}):null,G(Gr,{className:tt("mantine-datatable-header-cell-sortable-text",{[ne]:p==="left",[oe]:p==="center",[ae]:p==="right"},we,Se),title:A,children:P})]}),m?G(Wn,{currentPinned:x,onPinChange:ue}):null,c?G(et,{className:"mantine-datatable-header-cell-toggleable-icon",role:"img","aria-label":"Toggle column",children:G(Qn,{size:"xs",variant:"light",onClick:ce,children:G(Je,{})})}):null,l||d?.columnAccessor===o?d?.columnAccessor===o?G(et,{className:tt("mantine-datatable-header-cell-sortable-icon",{"mantine-datatable-header-cell-sortable-icon-reversed":d.direction==="desc"}),role:"img","aria-label":`Sorted ${d.direction==="desc"?"descending":"ascending"}`,children:u?.sorted||G(Xn,{})}):G(et,{className:"mantine-datatable-header-cell-sortable-unsorted-icon",role:"img","aria-label":"Not sorted",children:u?.unsorted||G($n,{})}):null,b?G(Nn,{filterPopoverProps:C,isActive:!!D,filterPopoverDisableClickOutside:E,children:b}):null]}),i&&o!=="__selection__"?G(Fn,{accessor:o,columnRef:H}):null]})}import{Checkbox as Kr,TableTh as jr}from"@mantine/core";import Jr from"clsx";import{jsx as jn}from"react/jsx-runtime";function Jn({className:e,style:t,trigger:n,shadowVisible:o,checked:a,indeterminate:r,checkboxProps:l,onChange:s,rowSpan:c,ref:m}){let i=!l.disabled;return jn(jr,{ref:m,className:Jr("mantine-datatable-header-selector-cell",{[Q]:n==="cell"&&i},e),style:t,rowSpan:c,"data-shadow-visible":o||void 0,"data-accessor":"__selection__",onClick:n==="cell"&&i?s:void 0,children:jn(Kr,{classNames:i?{input:Q}:void 0,checked:a,indeterminate:r,onChange:s,...l,disabled:!(s||l.onChange)||l.disabled})})}import{jsx as re,jsxs as nt}from"react/jsx-runtime";function ll(e,t){let o=(e.columns??[]).filter(u=>!u.hidden).map(u=>String(u.accessor)),a=o.map(u=>t.get(u)).filter(Boolean);if(a.length===0||a.length!==o.length)return;let r=new Set(a.map(u=>u.logicalSide));if(r.size>1)return;let l=[...r][0],s=l==="left"?o[0]:o[o.length-1],c=t.get(s);if(!c)return;let m=l==="left"?o[o.length-1]:o[0],i=t.get(m);return{...c,isBoundary:i?.isBoundary??!1}}function Zn({selectionColumnHeaderRef:e,className:t,style:n,sortStatus:o,sortIcons:a,onSortStatusChange:r,columns:l,defaultColumnProps:s,groups:c,pinnedMap:m,selectionTrigger:i,selectionVisible:u,selectionChecked:p,selectionIndeterminate:T,onSelectionChange:d,selectionCheckboxProps:S,selectorCellShadowVisible:b,selectionColumnClassName:C,selectionColumnStyle:E,withColumnBorders:D=!1,ref:L}){let N=c?Pt(c):0,f=N>0?N+1:1,h=u?re(Jn,{ref:e,className:C,style:E,trigger:i,shadowVisible:b,checked:p,indeterminate:T,checkboxProps:S,onChange:d,rowSpan:c?f:void 0}):null,{columnsToggle:w,setColumnsToggle:M}=Pe(),[g,R]=rl(!1),y=l.some(k=>k.toggleable),v=y?Object.fromEntries(l.map(({accessor:k,title:x})=>[k,x??De(String(k))])):void 0,H=nt(ol,{className:al("mantine-datatable-header",t),style:n,ref:L,onContextMenu:y?k=>{k.preventDefault(),R(x=>!x)}:void 0,children:[c&&Array.from({length:N},(k,x)=>{let P=Dt(c,x);return nt(qn,{children:[x===0&&h,P.map((A,_)=>re(Mn,{group:A,pinnedInfo:ll(A,m),maxDepth:N,currentDepth:x,previousGroups:P.slice(0,_),isLastGroup:_===P.length-1,withColumnBorders:D,totalTableColumns:l.length},A.id))]},`group-depth-${x}`)}),nt(qn,{children:[!c&&h,l.map(({hidden:k,...x},P)=>{if(k)return null;let{accessor:A,visibleMediaQuery:_,textAlign:z,width:K,title:le,sortable:ie,draggable:se,toggleable:ce,pinnable:ue,resizable:O,titleClassName:$,titleStyle:j,filter:J,filterPopoverProps:it,filterPopoverDisableClickOutside:st,filtering:ct,sortKey:ut}={...s,...x};return re(Kn,{accessor:A,pinnedInfo:m.get(String(A)),className:$,style:j,visibleMediaQuery:_,textAlign:z,width:K,title:le,sortable:ie,draggable:se,toggleable:ce,pinnable:ue,resizable:O&&P<l.length-1,sortStatus:o,sortIcons:a,sortKey:ut,onSortStatusChange:r,filter:J,filterPopoverProps:it,filterPopoverDisableClickOutside:st,filtering:ct},A)})]})]});return y?nt(Yr,{position:"bottom",withArrow:!0,shadow:"md",opened:g,onChange:R,children:[re(tl,{children:H}),re(el,{children:re(nl,{children:w.filter(k=>k.toggleable).map(k=>re(Zr,{children:re(qr,{classNames:{label:"mantine-datatable-header-column-toggle-checkbox-label"},size:"xs",label:v[k.accessor],checked:k.toggled,onChange:x=>{M(w.map(P=>P.accessor===k.accessor?{...P,toggled:x.currentTarget.checked}:P))}})},k.accessor))})})]}):H}import{Center as il,Loader as sl}from"@mantine/core";import cl from"clsx";import{jsx as Yn}from"react/jsx-runtime";function eo({fetching:e,customContent:t,backgroundBlur:n,size:o,type:a,color:r}){return Yn(il,{className:cl("mantine-datatable-loader",{"mantine-datatable-loader-fetching":e}),style:[{backdropFilter:n?`blur(${n}px)`:void 0}],children:e&&(t||Yn(sl,{size:o,type:a,color:r}))})}import{Box as hl,Pagination as Cl,rem as yl,Text as Pl}from"@mantine/core";import lo from"clsx";import{Button as dl,Group as ml,Menu as pl,MenuDropdown as fl,MenuItem as bl,MenuTarget as gl,rem as Ne,Text as no}from"@mantine/core";import Tl from"clsx";import{jsx as Nt,jsxs as ul}from"react/jsx-runtime";function to(){return ul("svg",{width:"14",height:"14",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[Nt("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Nt("path",{d:"M8 9l4 -4l4 4"}),Nt("path",{d:"M16 15l-4 4l-4 -4"})]})}import{jsx as Te,jsxs as ao}from"react/jsx-runtime";var oo={xs:Ne(22),sm:Ne(26),md:Ne(32),lg:Ne(38),xl:Ne(44)};function ro({size:e,label:t,values:n,value:o,activeTextColor:a,activeBackgroundColor:r,onChange:l}){return ao(ml,{gap:"xs",children:[Te(no,{component:"div",size:e,children:t}),ao(pl,{withinPortal:!0,withArrow:!0,offset:2,classNames:{arrow:"mantine-datatable-page-size-selector-menu-arrow"},children:[Te(gl,{children:Te(dl,{size:e,variant:"default",classNames:{section:"mantine-datatable-page-size-selector-button-icon"},rightSection:Te(to,{}),style:[{fontWeight:"normal"},s=>({height:oo[e],paddingLeft:s.spacing[e],paddingRight:s.spacing[e]})],children:o})}),Te(fl,{children:n.map(s=>{let c=s===o;return Te(bl,{className:Tl({"mantine-datatable-page-size-selector-active":c}),style:[{height:oo[e]},c&&(a||r)?m=>We({theme:m,paginationActiveTextColor:a,paginationActiveBackgroundColor:r}):void 0],disabled:c,onClick:()=>l(s),children:Te(no,{component:"div",size:e,children:s})},s)})})]})]})}import{Fragment as Dl,jsx as he,jsxs as wl}from"react/jsx-runtime";function io({className:e,style:t,fetching:n,page:o,onPageChange:a,paginationWithEdges:r,paginationWithControls:l,paginationActiveTextColor:s,paginationActiveBackgroundColor:c,paginationSize:m,loadingText:i,noRecordsText:u,paginationText:p,totalRecords:T,recordsPerPage:d,onRecordsPerPageChange:S,recordsPerPageLabel:b,recordsPerPageOptions:C,recordsLength:E,horizontalSpacing:D,paginationWrapBreakpoint:L,getPaginationControlProps:N,getPaginationItemProps:f,renderPagination:h}){let w;if(T){let x=(o-1)*d+1,P=x+(E||0)-1;w=p({from:x,to:P,totalRecords:T})}else w=n?i:u;let M=T&&d?Math.max(1,Math.ceil(T/d)):1,g=T?(o-1)*(d??0)+1:void 0,R=T?(g??1)+(E??0)-1:void 0,v=!te(({breakpoints:x})=>`(min-width: ${typeof L=="number"?`${yl(L)}rem`:x[L]||L})`),H={Text:x=>he(Pl,{component:"div",className:"mantine-datatable-pagination-text",size:m,...x,children:w}),PageSizeSelector:x=>C?he(ro,{activeTextColor:s,activeBackgroundColor:c,size:m,label:b,values:C,value:d,onChange:S,...x}):null,Pagination:x=>he(Cl,{classNames:{root:lo("mantine-datatable-pagination-pages",{"mantine-datatable-pagination-pages-fetching":n||!E}),control:"mantine-datatable-pagination-pages-control"},style:s||c?P=>We({theme:P,paginationActiveTextColor:s,paginationActiveBackgroundColor:c}):void 0,withEdges:r,withControls:l,value:o,onChange:a,size:m,total:M,getControlProps:N,getItemProps:f,...x})},k={state:{paginationSize:m,page:o,totalPages:M,totalRecords:T,recordsPerPage:d,recordsLength:E,fetching:n,from:g,to:R,isWrapped:v},actions:{setPage:x=>a?.(x),setRecordsPerPage:S?x=>S(x):void 0},Controls:H};return he(hl,{px:D??"xs",py:"xs",className:lo("mantine-datatable-pagination",e),style:[{flexDirection:v?"column":"row"},t],children:typeof h=="function"?h(k):wl(Dl,{children:[he(H.Text,{}),he(H.PageSizeSelector,{}),he(H.Pagination,{})]})})}import{TableTr as Hl}from"@mantine/core";import Al from"clsx";import{TableTd as Sl}from"@mantine/core";import Rl from"clsx";import{jsx as xl}from"react/jsx-runtime";function so({className:e,style:t,pinnedInfo:n,visibleMediaQuery:o,record:a,index:r,onClick:l,onDoubleClick:s,onContextMenu:c,noWrap:m,ellipsis:i,textAlign:u,width:p,accessor:T,render:d,defaultRender:S,customCellAttributes:b}){return te(o)?xl(Sl,{"data-pinned":n?.position,"data-pinned-shadow":n?.isBoundary?n.position:void 0,className:Rl({[we]:m||i,[Se]:i,[Q]:l||s,[$e]:c,[ne]:u==="left",[oe]:u==="center",[ae]:u==="right"},e),style:[{width:p,minWidth:p,maxWidth:p},t,n&&{position:"sticky",[n.position]:n.offset,overflow:"visible"}],onClick:l,onDoubleClick:s,onContextMenu:c,...b?.(a,r),children:d?d(a,r):S?S(a,r,T):yt(a,T)}):null}import{Collapse as vl,TableTd as Ml,TableTr as co}from"@mantine/core";import{Fragment as kl,jsx as He,jsxs as El}from"react/jsx-runtime";function uo({open:e,colSpan:t,content:n,collapseProps:o}){let{expanded:a,visible:r}=wn(e,o?.transitionDuration);return r?El(kl,{children:[He(co,{}),He(co,{children:He(Ml,{className:"mantine-datatable-row-expansion-cell",colSpan:t,children:He(vl,{expanded:a,...o,children:He("div",{className:"mantine-datatable-row-expansion-cell-content",children:n()})})})})]}):null}import{Checkbox as Ll,TableTd as Il}from"@mantine/core";import Nl from"clsx";import{jsx as mo}from"react/jsx-runtime";function po({className:e,style:t,record:n,index:o,trigger:a,onChange:r,withRightShadow:l,checkboxProps:s,getCheckboxProps:c,...m}){let i={...s,...c(n,o)},u=!m.disabled&&!i.disabled,p=T=>{T.stopPropagation(),a==="cell"&&u&&r?.(T)};return mo(Il,{className:Nl("mantine-datatable-row-selector-cell",{[Q]:a==="cell"&&u},e),style:t,"data-shadow-visible":l||void 0,onClick:p,children:mo(Ll,{classNames:u?{input:Q}:void 0,onChange:r,...m,...i})})}import{Fragment as fo,jsx as ot,jsxs as bo}from"react/jsx-runtime";function go({record:e,index:t,columns:n,defaultColumnProps:o,pinnedMap:a,defaultColumnRender:r,selectionTrigger:l,selectionVisible:s,selectionChecked:c,onSelectionChange:m,isRecordSelectable:i,selectionCheckboxProps:u,getSelectionCheckboxProps:p,onClick:T,onDoubleClick:d,onContextMenu:S,onCellClick:b,onCellDoubleClick:C,onCellContextMenu:E,expansion:D,customAttributes:L,color:N,backgroundColor:f,className:h,style:w,selectorCellShadowVisible:M,selectionColumnClassName:g,selectionColumnStyle:R,rowFactory:y}){let v=bo(fo,{children:[s&&ot(po,{className:g,style:R,record:e,index:t,trigger:l,withRightShadow:M,checked:c,disabled:!m||(i?!i(e,t):!1),onChange:m,checkboxProps:u,getCheckboxProps:p}),n.map(({hidden:x,hiddenContent:P,...A},_)=>{if(x||P)return null;let{accessor:z,visibleMediaQuery:K,textAlign:le,noWrap:ie,ellipsis:se,width:ce,render:ue,cellsClassName:O,cellsStyle:$,customCellAttributes:j}={...o,...A};return ot(so,{pinnedInfo:a.get(String(z)),className:typeof O=="function"?O(e,t):O,style:$?.(e,t),visibleMediaQuery:K,record:e,index:t,onClick:b?J=>b({event:J,record:e,index:t,column:A,columnIndex:_}):void 0,onDoubleClick:C?J=>C({event:J,record:e,index:t,column:A,columnIndex:_}):void 0,onContextMenu:E?J=>E({event:J,record:e,index:t,column:A,columnIndex:_}):void 0,accessor:z,textAlign:le,noWrap:ie,ellipsis:se,width:ce,render:ue,defaultRender:r,customCellAttributes:j},z)})]}),H=D&&ot(uo,{colSpan:n.filter(({hidden:x})=>!x).length+(s?1:0),open:D.isRowExpanded(e),content:D.content({record:e,index:t}),collapseProps:D.collapseProps}),k=Ol({record:e,index:t,selectionChecked:c,onClick:T,onDoubleClick:d,onContextMenu:S,expansion:D,customAttributes:L,color:N,backgroundColor:f,className:h,style:w});return y?y({record:e,index:t,rowProps:k,children:v,expandedElement:H}):bo(fo,{children:[ot(Hl,{...k,children:v}),H]})}function Ol({record:e,index:t,selectionChecked:n,onClick:o,onDoubleClick:a,onContextMenu:r,expansion:l,customAttributes:s,color:c,backgroundColor:m,className:i,style:u}){return{className:Al("mantine-datatable-row",{[Q]:o||a||l?.isExpandable({record:e,index:t})&&l?.expandOnClick},{[$e]:r},typeof i=="function"?i(e,t):i),"data-selected":n||void 0,onClick:p=>{if(l){let{isExpandable:T,isRowExpanded:d,expandOnClick:S,expandRow:b,collapseRow:C}=l;T({record:e,index:t})&&S&&(d(e)?C(e):b(e))}o?.({event:p,record:e,index:t})},onDoubleClick:a?p=>a({event:p,record:e,index:t}):void 0,onContextMenu:r?p=>r({event:p,record:e,index:t}):void 0,style:[c||m?p=>{let T=c?.(e,t),d=m?.(e,t);return $t({theme:p,color:T,backgroundColor:d})}:void 0,u?.(e,t)],...s?.(e,t)??{}}}import{Box as To,ScrollArea as zl}from"@mantine/core";import at from"clsx";import{jsx as rt,jsxs as _l}from"react/jsx-runtime";function ho({leftShadowBehind:e,rightShadowBehind:t,onScrollPositionChange:n,children:o,viewportRef:a,scrollAreaProps:r}){return _l(zl,{...r,viewportRef:a,classNames:{root:"mantine-datatable-scroll-area",scrollbar:"mantine-datatable-scroll-area-scrollbar",thumb:"mantine-datatable-scroll-area-thumb",corner:"mantine-datatable-scroll-area-corner"},onScrollPositionChange:n,children:[o,rt(To,{className:at("mantine-datatable-scroll-area-shadow","mantine-datatable-scroll-area-top-shadow")}),rt("div",{className:at("mantine-datatable-scroll-area-shadow","mantine-datatable-scroll-area-left-shadow",{"mantine-datatable-scroll-area-shadow-behind":e})}),rt("div",{className:at("mantine-datatable-scroll-area-shadow","mantine-datatable-scroll-area-right-shadow",{"mantine-datatable-scroll-area-shadow-behind":t})}),rt(To,{className:at("mantine-datatable-scroll-area-shadow","mantine-datatable-scroll-area-bottom-shadow")})]})}import{jsx as F,jsxs as yo}from"react/jsx-runtime";function $l({withTableBorder:e,borderRadius:t,textSelectionDisabled:n,height:o="100%",minHeight:a,maxHeight:r,shadow:l,verticalAlign:s="center",fetching:c,columns:m,storeColumnsKey:i,groups:u,pinFirstColumn:p,pinLastColumn:T,defaultColumnProps:d,defaultColumnRender:S,idAccessor:b="id",records:C,selectionTrigger:E="checkbox",selectedRecords:D,onSelectedRecordsChange:L,selectionColumnClassName:N,selectionColumnStyle:f,isRecordSelectable:h,selectionCheckboxProps:w,allRecordsSelectionCheckboxProps:M={"aria-label":"Select all records"},getRecordSelectionCheckboxProps:g=(de,V)=>({"aria-label":`Select record ${V+1}`}),sortStatus:R,sortIcons:y,onSortStatusChange:v,horizontalSpacing:H,page:k,onPageChange:x,totalRecords:P,recordsPerPage:A,onRecordsPerPageChange:_,recordsPerPageOptions:z,recordsPerPageLabel:K="Records per page",paginationWithEdges:le,paginationWithControls:ie,paginationActiveTextColor:se,paginationActiveBackgroundColor:ce,paginationSize:ue="sm",paginationText:O=({from:de,to:V,totalRecords:pt})=>`${de} - ${V} / ${pt}`,paginationWrapBreakpoint:$="sm",getPaginationControlProps:j=de=>de==="previous"?{"aria-label":"Previous page"}:de==="next"?{"aria-label":"Next page"}:{},getPaginationItemProps:J,renderPagination:it,loaderBackgroundBlur:st,customLoader:ct,loaderSize:ut,loaderType:Po,loaderColor:Do,loadingText:wo="...",emptyState:So,noRecordsText:Ot="No records",noRecordsIcon:Ro,highlightOnHover:xo,striped:vo,noHeader:Mo,onRowClick:ko,onRowDoubleClick:Eo,onRowContextMenu:Lo,onCellClick:Io,onCellDoubleClick:No,onCellContextMenu:Ho,onScroll:Ao,onScrollToTop:Oo,onScrollToBottom:zo,onScrollToLeft:_o,onScrollToRight:Wo,c:Bo,backgroundColor:Vo,borderColor:Go,rowBorderColor:Fo,stripedColor:$o,highlightOnHoverColor:Xo,rowColor:Uo,rowBackgroundColor:Qo,rowExpansion:Ko,rowClassName:jo,rowStyle:Jo,customRowAttributes:qo,scrollViewportRef:Zo,scrollAreaProps:Yo,tableRef:ea,bodyRef:ta,m:na,my:oa,mx:aa,mt:ra,mb:la,ml:ia,mr:sa,className:ca,classNames:Re,style:ua,styles:xe,rowFactory:da,tableWrapper:dt,...mt}){let de=Fl(()=>u?Ie(u):m,[m,u]),{refs:V,onScroll:pt}=fn({scrollCallbacks:{onScroll:Ao,onScrollToTop:Oo,onScrollToBottom:zo,onScrollToLeft:_o,onScrollToRight:Wo},withRowBorders:mt.withRowBorders}),q=cn({key:i,columns:de,headerRef:V.header,scrollViewportRef:V.scrollViewport}),ve=q.effectiveColumns,ma=Ht(V.table,ea),pa=Ht(V.scrollViewport,Zo),zt=lt(null),fa=Ht(zt,ta),ba=yn({rowExpansion:Ko,records:C,idAccessor:b}),{pinnedMap:Me,hasLeftPinned:_t,hasRightPinned:ga}=bn({columns:ve,theadRef:V.header,tbodyRef:zt,selectionColumnHeaderRef:V.selectionColumnHeader,selectionVisible:!!D,pinFirstColumn:p,pinLastColumn:T}),Ae=lt(!1),Wt=lt(k),ft=lt(C),Ta=At(I=>{Ae.current=!0,ft.current=C,x(I)},[x,C]);Vl(()=>{Wt.current!==k&&(Ae.current=!0,ft.current=C,Wt.current=k)},[k,C]);let ke=C?.length;Gl(()=>{if(!Ae.current||c||C===ft.current)return;let I=V.scrollViewport.current;if(!I)return;let me=requestAnimationFrame(()=>{I.scrollTo({top:0,left:0}),Ae.current=!1});return()=>cancelAnimationFrame(me)},[c,C,V.scr