import{_ as L}from"./vendor-pdf-b2a5d8b1.js";import{j as e}from"./vendor-mui-69397583.js";import{r as f}from"./vendor-react-ece1c85f.js";import{n as P,M as C,F as O,H as W,S as q,k as N,P as V,b as $,C as J,d as K,e as Q,f as U,T as X,I as w,g as j,l as Y,m as Z}from"./vendor-devex-33a39e11.js";import{F as ee}from"./FileSaver.min-20f3f13a.js";const re=d=>{const l={},h=[];d.forEach(t=>{l[t.id]={...t,children:[]}}),d.forEach(t=>{t.parentId===null?h.push(l[t.id]):l[t.parentId]&&l[t.parentId].children.push(l[t.id])});const p=t=>{t.sort((c,m)=>(c.sequence??0)-(m.sequence??0)),t.forEach(c=>c.children&&p(c.children))};return p(h),h},le=({dataSource:d,keyExpr:l="ID",mode:h="select",showFilterRow:p=!0,currentFilter:t="auto",showHeaderFilter:c=!0,searchEnabled:m=!0,searchEditorOptions:F={},allowSelectAll:y=!0,selectByClick:M=!0,recursive:_=!0,actionColumn:x,stateStorageKey:b="MenuTable",columns:I=[],isDetailsRow:g=!1,height:k,isReorder:T=!1,onReorder:u,tableID:B})=>{const R=f.useRef(null),[E,S]=f.useState([]),A=[50,100,250,500,1e3];f.useEffect(()=>{S(g?re(d):d)},[d,g]);const z=async r=>{const{Workbook:s}=await L(()=>import("./vendor-excel-ee8fc4e5.js").then(n=>n.e),["assets/vendor-excel-ee8fc4e5.js","assets/vendor-react-ece1c85f.js","assets/vendor-devex-33a39e11.js","assets/vendor-mui-69397583.js"]),o=new s,a=o.addWorksheet("Main sheet");Z({component:r.component,worksheet:a}).then(()=>{o.xlsx.writeBuffer().then(n=>{ee.saveAs(new Blob([n],{type:"application/octet-stream"}),`${b}.xlsx`)})}),r.cancel=!0},G=()=>I.map((r,s)=>e.jsx(j,{dataField:r.dataField,caption:r.caption,dataType:r.dataType,allowSorting:r.allowSorting,allowFiltering:r.allowFiltering,allowEditing:r.allowEditing,allowSearch:r.allowSearch,cellRender:r.cellRender,...r.extraProps},s)),v=({data:r})=>{var s;return(s=r==null?void 0:r.children)!=null&&s.length?e.jsxs(P,{dataSource:r.children,keyExpr:"id",showBorders:!1,showColumnHeaders:!1,rowAlternationEnabled:!0,rowDragging:{allowReordering:!0,showDragIcons:!0,onReorder:o=>{const a=o.fromIndex,n=o.toIndex,i=[...r.children],D=i[a],H=i[n];i.splice(a,1),i.splice(n,0,D),r.children=i,u==null||u({movedItem:D,replacedItem:H,fromIndex:a,toIndex:n})}},children:[I.map((o,a)=>e.jsx(j,{...o},a)),e.jsx(C,{enabled:!0,render:({data:o})=>e.jsx(v,{data:o})})]}):null};return e.jsx("div",{children:e.jsxs(P,{id:B,ref:R,dataSource:E,keyExpr:l,showBorders:!1,showColumnLines:!1,showRowLines:!0,rowAlternationEnabled:!0,allowColumnResizing:!0,columnAutoWidth:!0,allowColumnReordering:!0,remoteOperations:!0,height:k||void 0,onExporting:z,stateStoring:{enabled:!1,type:"localStorage",storageKey:b},rowDragging:T?{allowReordering:!0,showDragIcons:!0,onReorder:r=>{const s=[...E],o=r.fromIndex,a=r.toIndex,n=s[o],i=s[a];s.splice(o,1),s.splice(a,0,n),S(s),u==null||u({movedItem:n,replacedItem:i,fromIndex:o,toIndex:a})}}:void 0,children:[g&&e.jsx(C,{enabled:!0,autoExpandAll:!1,render:({data:r})=>e.jsx(v,{data:r})}),e.jsx(O,{visible:p,applyFilter:t}),e.jsx(W,{visible:c}),e.jsx(q,{visible:!0,width:240,placeholder:"Search..."}),e.jsx(N,{defaultPageSize:50}),e.jsx(V,{showPageSizeSelector:!0,allowedPageSizes:A,showNavigationButtons:!0,displayMode:"full",visible:!0}),e.jsx($,{mode:"virtual",rowRenderingMode:"virtual"}),e.jsxs(J,{height:"340px",enabled:!0,mode:h,children:[e.jsx(K,{my:"right top",at:"right bottom",of:".dx-datagrid-column-chooser-button"}),e.jsx(Q,{enabled:m,editorOptions:F}),e.jsx(U,{allowSelectAll:y,selectByClick:M,recursive:_})]}),e.jsxs(X,{children:[e.jsx(w,{location:"before",name:"searchPanel"}),e.jsx(w,{name:"exportButton"}),e.jsx(w,{name:"columnChooserButton"})]}),x&&e.jsx(j,{dataField:x.dataField,caption:x.caption,cellRender:x.cellRender}),G(),e.jsx(Y,{enabled:!0,allowExportSelectedData:!1})]})})};export{le as M};
