dts-universal-report-module 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +2 -5
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -17118,16 +17118,13 @@ function Ba({ reportEngine: e }) {
|
|
|
17118
17118
|
if (!(r != null && r.uploadedData)) return;
|
|
17119
17119
|
const ot = [...r.uploadedData];
|
|
17120
17120
|
ot.splice(We + 1, 0, { ...Pe }), Dr(r.id, { uploadedData: ot });
|
|
17121
|
-
}, [r, Dr]);
|
|
17122
|
-
if (!r || !r.schemaLocked || !r.schema || !r.uploadedData || !r.views)
|
|
17123
|
-
return null;
|
|
17124
|
-
const q = Cn(), { handleDevConfigChange: be } = Vo(), [Xe, de] = N(!1);
|
|
17121
|
+
}, [r, Dr]), q = Cn(), { handleDevConfigChange: be } = Vo(), [Xe, de] = N(!1);
|
|
17125
17122
|
return _e(() => {
|
|
17126
17123
|
const We = (Pe) => {
|
|
17127
17124
|
Pe.ctrlKey && Pe.shiftKey && Pe.key === "D" && (Pe.preventDefault(), de(!0));
|
|
17128
17125
|
};
|
|
17129
17126
|
return document.addEventListener("keydown", We), () => document.removeEventListener("keydown", We);
|
|
17130
|
-
}, []), /* @__PURE__ */ c(
|
|
17127
|
+
}, []), !r || !r.schemaLocked || !r.schema || !r.uploadedData || !r.views ? null : /* @__PURE__ */ c(
|
|
17131
17128
|
u,
|
|
17132
17129
|
{
|
|
17133
17130
|
sx: {
|
package/dist/index.js
CHANGED
|
@@ -112,4 +112,4 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
|
|
|
112
112
|
"Region": "Europe",
|
|
113
113
|
"Subscription Type": "Basic"
|
|
114
114
|
}
|
|
115
|
-
]`})})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Number:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),", ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Boolean:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),", ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"String:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),", ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Date:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),e.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[e.jsx("li",{children:"Each object in the array represents one row in the report."}),e.jsx("li",{children:"The keys of the JSON objects become report columns."}),e.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),e.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),e.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Got it"})})]}):null}function kc({onFileUpload:t,onError:r,isUploading:n}){const[i,a]=u.useState(!1),[c,l]=u.useState(""),[d,f]=u.useState(!1),h=u.useRef(null),m=async s=>{if(!s.name.endsWith(".json")){r("Please upload a valid JSON file");return}l(s.name);try{const T=await s.text(),I=JSON.parse(T);if(!Array.isArray(I)){r("JSON must be an array of objects");return}if(I.length===0){r("JSON array is empty");return}t(I)}catch{r("Invalid JSON format. Please check your file and try again.")}finally{l("")}},g=s=>{s.preventDefault(),a(!0)},y=s=>{s.preventDefault(),a(!1)},S=s=>{s.preventDefault(),a(!1);const T=s.dataTransfer.files[0];T&&m(T)},C=()=>{var s;(s=h.current)==null||s.click()},x=s=>{var I;const T=(I=s.target.files)==null?void 0:I[0];T&&m(T)},E=s=>{s.stopPropagation(),f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{onDragOver:g,onDragLeave:y,onDrop:S,onClick:C,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?s=>N(s.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[e.jsx(o.Box,{component:"input",ref:h,type:"file",accept:".json",onChange:x,sx:{display:"none"}}),n?e.jsxs(e.Fragment,{children:[e.jsx(o.CircularProgress,{size:32,sx:{mb:2}}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:.5},children:"Uploading..."}),c&&e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:c})]}):e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:s=>N(s.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(j.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),e.jsx(o.IconButton,{onClick:E,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(j.InfoOutlined,{sx:{fontSize:16}})})]}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),e.jsx(mi,{isOpen:d,onClose:()=>f(!1)})]})}function Tc({schema:t,onConfirm:r,hasConflicts:n}){return e.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[e.jsxs(o.Box,{sx:{mb:2},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontWeight:600,mb:.5},children:"Schema Preview"}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&e.jsxs(o.Alert,{severity:"warning",sx:{mb:2},children:[e.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),e.jsx(o.TableContainer,{sx:{mb:3},children:e.jsxs(o.Table,{children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{sx:{bgcolor:"action.hover"},children:[e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),e.jsx(o.TableBody,{children:t.map(i=>e.jsxs(o.TableRow,{sx:{bgcolor:i.hasConflict?a=>N(a.palette.warning.main,.12):"transparent"},children:[e.jsxs(o.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&e.jsx(o.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),e.jsx(o.TableCell,{children:e.jsx(o.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),e.jsx(o.TableCell,{children:e.jsx(o.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(j.Lock,{sx:{fontSize:16}}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),e.jsx(o.Button,{variant:"contained",onClick:r,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function zc({error:t,onRetry:r}){return e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>N(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[e.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>N(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(j.ErrorOutline,{color:"error",sx:{fontSize:32}})}),e.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:600,mb:1},children:"Upload Failed"}),e.jsx(o.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:t}),e.jsx(o.Button,{variant:"contained",color:"error",startIcon:e.jsx(j.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function gi({title:t,description:r,showIcon:n=!0}){return e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&e.jsx(o.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>N(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(j.Description,{sx:{fontSize:36,color:"primary.main"}})}),e.jsx(o.Typography,{variant:"h5",sx:{fontWeight:500,mb:1,color:"text.primary",fontSize:"1.125rem"},children:t}),e.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:"0.875rem",lineHeight:1.5},children:r})]})}function Ic({value:t,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:a,onDeleteHistory:c,disabled:l}){const[d,f]=u.useState(!1),[h,m]=u.useState(!1),[g,y]=u.useState(-1),S=u.useRef(null),C=u.useRef(null);u.useEffect(()=>{function w(O){S.current&&!S.current.contains(O.target)&&(f(!1),m(!1))}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const x=u.useCallback(()=>{m(!0),y(-1),n.length>0&&f(!0)},[n.length]),E=u.useCallback(w=>{r(w),y(-1)},[r]),s=u.useCallback(w=>{var O;r(w),i(w),f(!1),(O=C.current)==null||O.blur()},[r,i]),T=u.useCallback(w=>{y(-1),s(w)},[s]),I=u.useCallback(w=>{var O;w.key==="Enter"?g>=0&&g<n.length?(w.preventDefault(),T(n[g].query)):t.trim()&&s(t.trim()):w.key==="Escape"?(f(!1),y(-1),(O=C.current)==null||O.blur()):w.key==="ArrowDown"?(w.preventDefault(),n.length>0&&(d||f(!0),y(V=>V<n.length-1?V+1:V))):w.key==="ArrowUp"&&(w.preventDefault(),y(V=>V>0?V-1:-1))},[g,n,t,d,T,s]),A=u.useCallback(()=>{var w;r(""),(w=C.current)==null||w.focus()},[r]),v=u.useMemo(()=>n.filter(w=>w.isFavourite),[n]),W=u.useMemo(()=>n.filter(w=>!w.isFavourite),[n]),U=d&&n.length>0;return e.jsxs(o.Box,{sx:{position:"relative",width:240},ref:S,children:[e.jsx(o.TextField,{inputRef:C,size:"small",fullWidth:!0,value:t,onChange:w=>E(w.target.value),onFocus:x,onKeyDown:I,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"#ffffff",height:"36px","& fieldset":{borderColor:"#dadce0",transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:"#dadce0"},"&.Mui-focused":{bgcolor:"#ffffff"},"&.Mui-focused fieldset":{borderColor:"#2932e5",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px"}},InputProps:{startAdornment:e.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:e.jsx(j.Search,{sx:{fontSize:18,color:"#5f6368"}})}),endAdornment:t?e.jsx(o.InputAdornment,{position:"end",children:e.jsx(o.IconButton,{size:"small",onClick:A,edge:"end",sx:{mr:-.5},children:e.jsx(j.Close,{sx:{fontSize:16}})})}):null}}),U&&e.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[v.length>0&&e.jsxs(o.Box,{sx:{py:1},children:[e.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),v.map((w,O)=>e.jsx(Dn,{entry:w,isSelected:g===O,onClick:()=>T(w.query),onToggleFavourite:()=>a(w.query),onDelete:()=>c(w.query)},`fav-${w.query}`))]}),W.length>0&&e.jsxs(o.Box,{sx:{py:1},children:[v.length>0&&e.jsx(o.Divider,{}),e.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),W.map((w,O)=>{const V=v.length+O;return e.jsx(Dn,{entry:w,isSelected:g===V,onClick:()=>T(w.query),onToggleFavourite:()=>a(w.query),onDelete:()=>c(w.query)},`recent-${w.query}`)})]})]})]})}const Dn=u.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:a,onDelete:c}){const l=u.useCallback(f=>{f.stopPropagation(),a()},[a]),d=u.useCallback(f=>{f.stopPropagation(),c()},[c]);return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?f=>N(f.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?f=>N(f.palette.primary.main,.12):"action.hover"}},children:[e.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:e.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[e.jsx(o.IconButton,{size:"small",onClick:l,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?e.jsx(j.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(j.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(o.IconButton,{size:"small",onClick:d,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(j.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function Ec({views:t,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:a,onManageViews:c,onToggleDefault:l,onToggleFavorite:d,onRestoreView:f,onPermanentDelete:h,isReadOnly:m}){const g=jc(),[y,S]=u.useState(!1),[C,x]=u.useState(!1),[E,s]=u.useState({top:0,left:0}),T=u.useRef(null),I=u.useRef(null),A=t.find(_=>_.id===r),v=A==null?void 0:A.isDefault,W=t.filter(_=>_.isDefault&&!_.isDeleted),U=t.filter(_=>!_.isDefault&&!_.isDeleted).sort((_,F)=>(F.updatedAt||0)-(_.updatedAt||0)),w=t.filter(_=>_.isFavorite&&!_.isDeleted).sort((_,F)=>(F.updatedAt||0)-(_.updatedAt||0)),O=t.filter(_=>_.isDeleted);u.useEffect(()=>{if(y&&I.current){const _=I.current.getBoundingClientRect();s({top:_.bottom+window.scrollY+8,left:_.right+window.scrollX-320})}},[y]),u.useEffect(()=>{const _=F=>{T.current&&!T.current.contains(F.target)&&I.current&&!I.current.contains(F.target)&&S(!1)};return y&&document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[y]);const V=_=>{i(_),S(!1)},X=(_,F=!1)=>e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===_.id?g.palette.primary.light+"20":"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===_.id?g.palette.primary.light+"20":g.palette.grey[50]}},children:[e.jsxs(o.Button,{onClick:()=>V(_.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,textTransform:"none",justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[r===_.id&&e.jsx(j.Check,{sx:{fontSize:16,flexShrink:0}}),r!==_.id&&e.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===_.id?g.palette.primary.dark:g.palette.text.primary,fontWeight:r===_.id?500:400},children:_.name}),F&&e.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:g.palette.text.secondary,backgroundColor:g.palette.grey[100],px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[d&&e.jsx(o.IconButton,{onClick:oe=>{oe.stopPropagation(),d(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:_.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(j.Star,{sx:{fontSize:16}})}),l&&!_.isDefault&&e.jsx(o.IconButton,{onClick:oe=>{oe.stopPropagation(),l(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:"Set as default",children:e.jsx(j.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},_.id),p=_=>e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:g.palette.grey[50]},children:[e.jsx(o.Typography,{sx:{color:g.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:_.name}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[f&&e.jsx(o.IconButton,{onClick:F=>{F.stopPropagation(),f(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:"Restore view",children:e.jsx(j.Undo,{sx:{fontSize:16,color:"success.main"}})}),h&&e.jsx(o.IconButton,{onClick:F=>{F.stopPropagation(),h(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:"Delete permanently",children:e.jsx(j.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},_.id),L=n||!v,$=n;return e.jsxs(o.Box,{sx:{position:"relative"},children:[e.jsxs(o.IconButton,{ref:I,onClick:()=>S(!y),size:"small",sx:{position:"relative",color:L?"warning.main":"text.secondary",bgcolor:L?N(g.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:L?N(g.palette.warning.main,.2):N(g.palette.text.primary,.06),color:L?"warning.dark":"text.primary"}},title:`View: ${(A==null?void 0:A.name)||"Default View"}`,children:[e.jsx(j.Visibility,{sx:{fontSize:20}}),$&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),y&&_n.createPortal(e.jsxs(o.Box,{ref:T,sx:{position:"fixed",width:"320px",backgroundColor:g.palette.background.paper,border:`1px solid ${g.palette.divider}`,borderRadius:1,boxShadow:g.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:E.top,left:E.left},children:[W.length>0&&e.jsxs(o.Box,{sx:{py:.5},children:[e.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Default Views"}),W.map(_=>X(_,!0))]}),w.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Box,{sx:{py:.5},children:[e.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(j.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),w.map(_=>X(_))]})]}),U.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Box,{sx:{py:.5},children:[e.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom Views"}),U.map(_=>X(_))]})]}),O.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Box,{sx:{py:.5},children:[e.jsxs(o.Button,{onClick:()=>x(!C),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[50]}},children:[e.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",O.length,")"]}),e.jsx(j.ChevronRight,{sx:{fontSize:16}})]}),C&&e.jsx(o.Box,{sx:{backgroundColor:g.palette.grey[50]},children:O.map(_=>p(_))})]})]}),e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Button,{onClick:()=>{a(),S(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:g.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[50]}},children:[e.jsx(j.Add,{sx:{fontSize:16}}),e.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(o.Button,{onClick:()=>{c(),S(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:g.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[50]}},children:[e.jsx(j.Settings,{sx:{fontSize:16}}),e.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body)]})}function Bc({columnName:t,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:a,position:c,onSort:l,onRemoveSort:d,onSortAscending:f,onSortDescending:h,onFilter:m,onClearFilter:g,onHideColumn:y,onManageColumns:S,onManageViews:C,onResetLayout:x,onClose:E}){const s=u.useRef(null);u.useEffect(()=>{const I=v=>{s.current&&!s.current.contains(v.target)&&E()},A=v=>{v.key==="Escape"&&E()};return document.addEventListener("mousedown",I),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",I),document.removeEventListener("keydown",A)}},[E]);const T=()=>n?n.direction==="asc"?r==="number"?"(0→9)":r==="boolean"?"(False→True)":"(A→Z)":r==="number"?"(9→0)":r==="boolean"?"(True→False)":"(Z→A)":"";return _n.createPortal(e.jsxs(o.Paper,{ref:s,sx:{position:"fixed",left:`${c.x}px`,top:`${c.y}px`,zIndex:100,minWidth:240},elevation:3,children:[e.jsxs(o.Box,{sx:{px:2,py:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:"Sorting"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(o.IconButton,{size:"small",onClick:()=>{f?f(t):(n==null?void 0:n.direction)!=="asc"&&(l(t),(n==null?void 0:n.direction)==="desc"&&setTimeout(()=>l(t),0))},title:"Sort Ascending",sx:{p:.75},children:e.jsx(j.ArrowUpward,{color:(n==null?void 0:n.direction)==="asc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>{h?h(t):n?n.direction==="asc"&&l(t):(l(t),setTimeout(()=>l(t),0))},title:"Sort Descending",sx:{p:.75},children:e.jsx(j.ArrowDownward,{color:(n==null?void 0:n.direction)==="desc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>d(t),title:"Clear sorting",disabled:!n,sx:{p:.75,"&:hover":{color:"error.main"}},children:e.jsx(j.Close,{sx:{fontSize:16}})})]})]}),n&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5},children:[e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:T()}),e.jsx(o.Chip,{label:`Level ${n.priority}`,size:"small",color:"primary",sx:{height:20,fontSize:"caption.fontSize"}})]})]}),e.jsx(o.Divider,{}),e.jsxs(o.MenuList,{dense:!0,children:[e.jsxs(o.MenuItem,{onClick:()=>{m(t),E()},children:[e.jsx(j.FilterList,{sx:{fontSize:16,mr:1}}),"Filter this column",i&&e.jsx(o.Chip,{label:"Active",size:"small",color:"primary",sx:{ml:"auto",height:20,fontSize:"caption.fontSize"}})]}),i&&e.jsxs(o.MenuItem,{onClick:()=>{g(t),E()},sx:{color:"warning.main"},children:[e.jsx(j.FilterListOff,{sx:{fontSize:16,mr:1}}),"Clear Filters"]})]}),e.jsx(o.Divider,{}),e.jsx(o.MenuList,{dense:!0,children:e.jsxs(o.MenuItem,{onClick:()=>{y(t),E()},children:[e.jsx(j.VisibilityOff,{sx:{fontSize:16,mr:1}}),"Hide column"]})}),e.jsx(o.Divider,{}),e.jsxs(o.MenuList,{dense:!0,children:[e.jsxs(o.MenuItem,{onClick:()=>{S(),E()},children:[e.jsx(j.Settings,{sx:{fontSize:16,mr:1}}),"Column Settings"]}),e.jsxs(o.MenuItem,{onClick:()=>{C(),E()},children:[e.jsx(j.Description,{sx:{fontSize:16,mr:1}}),"View Setup"]}),e.jsxs(o.MenuItem,{onClick:()=>{x(),E()},children:[e.jsx(j.Undo,{sx:{fontSize:16,mr:1}}),"Reset to Default Layout"]})]})]}),document.body)}const Dc=150,On="COLUMN_HEADER",Oc=u.memo(function({column:r,index:n,sortRule:i,hasFilters:a,isInSortStack:c,width:l,onColumnClick:d,onMoveColumn:f,onResizeStart:h,onSort:m,onRemoveSort:g,onSortAscending:y,onSortDescending:S,onOpenFilterForColumn:C,onClearFiltersForColumn:x,onHideColumn:E,onManageColumns:s,onManageViews:T,onResetLayout:I}){const A=u.useRef(null),[v,W]=u.useState(!1),[U,w]=u.useState({x:0,y:0}),[{handlerId:O,isOver:V},X]=vt.useDrop({accept:On,collect(R){return{handlerId:R.getHandlerId(),isOver:R.isOver()}},hover(R,q){var ae;if(!A.current)return;const ee=R.index,te=n;if(ee===te)return;const re=(ae=A.current)==null?void 0:ae.getBoundingClientRect(),ne=(re.right-re.left)/2,Z=q.getClientOffset(),Q=((Z==null?void 0:Z.x)??0)-re.left;ee<te&&Q<ne||ee>te&&Q>ne||(f(ee,te),R.index=te)}}),[{isDragging:p},L]=vt.useDrag({type:On,item:()=>({index:n,columnName:r.name}),collect:R=>({isDragging:R.isDragging()})});L(X(A));const $=u.useCallback(R=>{R.preventDefault(),R.stopPropagation(),w({x:R.clientX,y:R.clientY}),W(!0)},[]),_=u.useCallback(()=>{W(!1)},[]),F=u.useCallback(()=>{d(r.name)},[d,r.name]),oe=u.useCallback(R=>{R.stopPropagation(),C(r.name)},[C,r.name]),ue=u.useCallback(()=>i?e.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25,color:"primary.main"},children:[i.direction==="asc"?e.jsx(j.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(j.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),e.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"#fff",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),Ee=u.useCallback(()=>a?e.jsx(o.Box,{onClick:oe,title:"Active filters on this column",sx:{ml:.75,width:7,height:7,borderRadius:"50%",bgcolor:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.25)"},transition:"transform 0.12s ease"}}):null,[a,oe]);return e.jsxs(e.Fragment,{children:[e.jsxs(o.TableCell,{ref:A,"data-handler-id":O,"data-column-index":n,onClick:F,onContextMenu:$,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:p?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:V?R=>N(R.palette.primary.main,.08):"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0",py:0,px:2,height:34,"&:hover":{bgcolor:"#e8eaed",color:"primary.dark"},width:l?`${l}px`:`${Dc}px`},children:[e.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center"},children:[St(r.name),ue(),Ee()]}),e.jsx(o.Box,{sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:10,"&:hover":{bgcolor:"primary.light"}},onMouseDown:R=>{R.stopPropagation(),h(R,r.name)},onClick:R=>R.stopPropagation()}),V&&e.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),v&&e.jsx(Bc,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:a,isInSortStack:c,position:U,onSort:m,onRemoveSort:g,onSortAscending:y,onSortDescending:S,onFilter:C,onClearFilter:x,onHideColumn:E,onManageColumns:s,onManageViews:T,onResetLayout:I,onClose:_})]})});function Ac({selectedCount:t,selectedRowIds:r,searchedData:n,resolvedFavoritesSet:i,onExportSelected:a,onClearSelection:c,onBulkSetFavorites:l}){const[d,f]=u.useState(null),h=u.useMemo(()=>Array.from(r),[r]),m=u.useMemo(()=>h.filter(s=>{const T=n[s];return T!==void 0&&i.has(T)}),[h,n,i]),g=u.useMemo(()=>h.filter(s=>{const T=n[s];return T!==void 0&&!i.has(T)}),[h,n,i]),y=m.length>0,S=g.length>0;if(t===0)return null;const C=()=>{l&&l(h,!0)},x=()=>{l&&l(h,!1)},E=s=>{a(s),f(null)};return e.jsx(o.Box,{sx:{width:"100%",flexShrink:0,bgcolor:s=>N(s.palette.primary.main,.08),borderBottom:s=>`1px solid ${N(s.palette.primary.main,.25)}`,zIndex:10},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"primary.main"},children:[t," ",t===1?"row":"rows"," selected"]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Button,{onClick:c,startIcon:e.jsx(j.Close,{sx:{fontSize:16}}),size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:s=>N(s.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(o.Button,{onClick:s=>f(s.currentTarget),startIcon:e.jsx(j.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:s=>N(s.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:s=>N(s.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(o.Menu,{anchorEl:d,open:!!d,onClose:()=>f(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:180,borderRadius:1.5}},children:[e.jsx(o.MenuItem,{dense:!0,onClick:()=>E("csv"),sx:{py:1,px:2},children:"Export as CSV"}),e.jsx(o.MenuItem,{dense:!0,onClick:()=>E("excel"),sx:{py:1,px:2},children:"Export as Excel"}),e.jsx(o.MenuItem,{dense:!0,onClick:()=>E("json"),sx:{py:1,px:2},children:"Export as JSON"})]}),l&&S&&e.jsx(o.Button,{onClick:C,startIcon:e.jsx(j.StarBorder,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:s=>N(s.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:s=>N(s.palette.warning.main,.06)}},children:"Add to Favorites"}),l&&y&&e.jsx(o.Button,{onClick:x,startIcon:e.jsx(j.Star,{sx:{fontSize:16,color:"#fbbc04"}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:s=>N(s.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:s=>N(s.palette.warning.main,.06)}},children:"Remove from Favorites"})]})]})})}const Mc={active:{bg:"#e6f4ea",color:"#137333"},completed:{bg:"#e6f4ea",color:"#137333"},approved:{bg:"#e6f4ea",color:"#137333"},success:{bg:"#e6f4ea",color:"#137333"},done:{bg:"#e6f4ea",color:"#137333"},contract:{bg:"#e8eaf6",color:"#3949ab"},"in progress":{bg:"#e8eaf6",color:"#3949ab"},"in review":{bg:"#e8eaf6",color:"#3949ab"},review:{bg:"#e8eaf6",color:"#3949ab"},pending:{bg:"#e8eaf6",color:"#3949ab"},"on leave":{bg:"#fce8e6",color:"#c5221f"},"on hold":{bg:"#fff8e1",color:"#e65100"},probation:{bg:"#fff8e1",color:"#e65100"},cancelled:{bg:"#fce8e6",color:"#c5221f"},rejected:{bg:"#fce8e6",color:"#c5221f"},blocked:{bg:"#fce8e6",color:"#c5221f"},inactive:{bg:"#f1f3f4",color:"#5f6368"},"not started":{bg:"#f1f3f4",color:"#5f6368"},paused:{bg:"#f1f3f4",color:"#5f6368"}},Rc={low:"#5f6368",medium:"#e65100",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function Wc(t){const r=t.toLowerCase().trim(),n=Mc[r]||{bg:"#f1f3f4",color:"#5f6368"};return e.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:500,bgcolor:n.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function Pc(t,r){if(r==null||r==="")return e.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.8125rem"},children:"—"});const n=String(r),i=t.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Wc(n);if(/\b(priority|severity|urgency)\b/.test(i)){const a=Rc[n.toLowerCase().trim()];return a?e.jsx(o.Box,{component:"span",sx:{color:a,fontWeight:600,fontSize:"0.8125rem"},children:n}):e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}return typeof r=="boolean"?e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:r?"Yes":"No"}):typeof r=="object"?e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:JSON.stringify(r)}):e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}function _c(t){const r=t.find(a=>{const c=a.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(c)})||t[0]||null,n=t.find(a=>{const c=a.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(c)&&a!==r})||null,i=t.filter(a=>a!==r&&a!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function $c({row:t,rowIndex:r,visibleColumns:n,isSelected:i,isFavorite:a,isReadOnly:c,onToggleSelection:l,onToggleFavorite:d,onView:f,onEdit:h,onDuplicate:m,onDelete:g}){const[y,S]=u.useState(null),[C,x]=u.useState(!1),{primaryCol:E,idCol:s,bodyColumns:T}=u.useMemo(()=>_c(n),[n]),I=E?t[E.name]:null,A=s?t[s.name]:null,v=C||i||a||!!y;return e.jsxs(o.Box,{onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),onClick:()=>l(r),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":W=>N(W.palette.divider,.8),borderWidth:i?2:1,borderRadius:"12px",cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?W=>`0 0 0 3px ${N(W.palette.primary.main,.15)}, 0 2px 8px ${N(W.palette.common.black,.08)}`:C?"0 4px 16px rgba(60,64,67,0.15), 0 1px 4px rgba(60,64,67,0.08)":"0 1px 3px rgba(60,64,67,0.08), 0 1px 2px rgba(60,64,67,0.06)",transform:C&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:W=>N(W.palette.primary.main,.03)}},children:[e.jsx(o.Box,{sx:{px:2,pt:2,pb:1.5},children:e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,fontSize:"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:I!=null&&I!==""?String(I):e.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})}),e.jsx(o.Box,{sx:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}),e.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"flex",flexDirection:"column",gap:1},children:[T.map(W=>e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minHeight:22},children:[e.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:500,fontSize:"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",minWidth:68,flexShrink:0,lineHeight:1},children:St(W.name)}),e.jsx(o.Box,{sx:{flex:1,lineHeight:1},children:Pc(W,t[W.name])})]},W.name)),T.length===0&&e.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic"},children:"No additional fields visible"})]}),e.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:W=>N(W.palette.action.hover,.1),minHeight:40},children:[e.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:A?.85:0,userSelect:"none"},children:A?String(A):" "}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:v?1:0,transition:"opacity 0.15s ease"},onClick:W=>W.stopPropagation(),children:[d&&e.jsx(o.Tooltip,{title:a?"Remove from favorites":"Add to favorites",placement:"top",children:e.jsx(o.IconButton,{size:"small",onClick:W=>{W.stopPropagation(),d(r)},sx:{width:28,height:28,color:a?"#fbbc04":"action.disabled","&:hover":{bgcolor:W=>N(W.palette.warning.main,.1),color:"#fbbc04"}},children:a?e.jsx(j.Star,{sx:{fontSize:17}}):e.jsx(j.StarBorder,{sx:{fontSize:17}})})}),e.jsx(o.Tooltip,{title:"More actions",placement:"top",children:e.jsx(o.IconButton,{size:"small",onClick:W=>{W.stopPropagation(),S(W.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:W=>N(W.palette.text.primary,.08)}},children:e.jsx(j.MoreVert,{sx:{fontSize:17}})})})]})]}),e.jsxs(o.Popover,{open:!!y,anchorEl:y,onClose:()=>S(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:"0 4px 20px rgba(60,64,67,0.15), 0 1px 6px rgba(60,64,67,0.1)"}},onClick:W=>W.stopPropagation(),children:[e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{f(t),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(j.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"View"})]}),!c&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{h(t,r),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(j.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!c&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{m(r,t),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(j.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),!c&&e.jsxs(e.Fragment,{children:[e.jsx(o.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{g(r,t),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(j.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Fc({row:t,grouping:r,onToggleCollapse:n}){var i;return e.jsxs(o.Box,{onClick:()=>n(t.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:"0 1px 2px rgba(60,64,67,0.06)","&:hover":{bgcolor:a=>N(a.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(j.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(j.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Vn(t.groupLevel,((i=r==null?void 0:r.levels[t.groupLevel])==null?void 0:i.column)||"",t.groupValue)}),e.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:a=>N(a.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[t.rowCount," ",t.rowCount===1?"row":"rows"]}),Object.keys(t.aggregates).length>0&&e.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(t.aggregates).map(([a,c])=>Nn(c)).filter(Boolean).join(" • ")})]})}function Lc({data:t,visibleColumns:r,grouping:n,selectedRowIds:i,resolvedFavoritesSet:a,isReadOnly:c,isGrouped:l,onToggleRowSelection:d,onToggleRowFavorite:f,onToggleGroupCollapse:h,onViewRow:m,onEditRow:g,onDuplicateRow:y,onDeleteRow:S}){return t.length===0?e.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):e.jsx(o.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(272px, 1fr))",gap:1.5,alignContent:"start"},children:t.map((C,x)=>l&&C.isGroupHeader?e.jsx(Fc,{row:C,grouping:n,onToggleCollapse:h||(()=>{})},`group-${C.groupKey}`):e.jsx($c,{row:C,rowIndex:x,visibleColumns:r,isSelected:i.has(x),isFavorite:a.has(C),isReadOnly:c,onToggleSelection:d,onToggleFavorite:f,onView:m,onEdit:g,onDuplicate:y,onDelete:S},`card-${x}`))})}const An=[10,15,25,50,100];function Nc({currentPage:t,pageSize:r,totalRows:n,totalFields:i,onPageChange:a,onPageSizeChange:c}){const l=Math.ceil(n/r);if(n<=Math.min(...An))return null;const d=()=>{t>1&&a(t-1)},f=()=>{t<l&&a(t+1)},h=(t-1)*r+1,m=Math.min(t*r,n);return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data: ",e.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields: ",e.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),e.jsx(o.Select,{value:r,onChange:g=>c(Number(g.target.value)),size:"small",MenuProps:{PaperProps:{sx:{maxHeight:300}},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"}},sx:{minWidth:70,fontSize:"0.8125rem",color:"text.primary","& .MuiSelect-select":{py:.5,px:1.5},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},children:An.map(g=>e.jsx(o.MenuItem,{value:g,sx:{fontSize:"0.8125rem"},children:g},g))})]}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:[h,"–",m," of ",n]}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Page ",t," of ",l]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(o.IconButton,{onClick:d,disabled:t===1,size:"small",title:"Previous page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:e.jsx(j.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(o.IconButton,{onClick:f,disabled:t===l,size:"small",title:"Next page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:e.jsx(j.ChevronRight,{sx:{fontSize:20}})})]})]})]})}function Vc(){return e.jsx(o.Chip,{icon:e.jsx(j.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}function Hc(t,r){if(t==null||t==="")return"—";if(r==="boolean")return t?"True":"False";if(r==="object"||r==="array")try{return JSON.stringify(t,null,2)}catch{return String(t)}return String(t)}function Uc({open:t,onClose:r,row:n,schema:i,reportName:a}){if(!n)return null;const c=i.filter(l=>l.name in n);return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08)"}},children:[e.jsxs(o.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(o.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(j.Visibility,{sx:{fontSize:18,color:"primary.main"}}),e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124"},children:"View Record"})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]}),e.jsx(o.DialogContent,{sx:{p:0,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(o.Box,{children:c.map(l=>{const d=n[l.name],f=Hc(d,l.type),h=f==="—";return e.jsxs(o.Box,{sx:{px:2,py:1.25,borderBottom:"1px solid divider",bgcolor:"#fff",transition:"background-color 0.15s ease","&:hover":{bgcolor:"grey.50"},"&:last-child":{borderBottom:"none"}},children:[e.jsx(o.Typography,{variant:"caption",sx:{color:"#5f6368",fontSize:"0.6875rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.02em",display:"block",mb:.5},children:St(l.name)}),e.jsx(o.Typography,{variant:"body2",sx:{color:h?"#9e9e9e":"#202124",fontStyle:h?"italic":"normal",fontSize:"0.875rem",wordBreak:"break-word",whiteSpace:l.type==="object"||l.type==="array"?"pre-wrap":"normal",fontFamily:l.type==="number"?"monospace":"inherit",fontWeight:400,lineHeight:1.5},children:f})]},l.name)})})}),e.jsx(o.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,bgcolor:"primary.main",color:"#fff",px:2.5,py:.625,minHeight:32,borderRadius:"4px",boxShadow:"none","&:hover":{bgcolor:"primary.dark",boxShadow:"none"}},children:"Close"})})]})}function Gc({open:t,onClose:r,onConfirm:n,rowPreview:i}){return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[e.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:"#fce8e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(j.WarningAmberRounded,{sx:{fontSize:22,color:"#d93025"}})}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),e.jsxs(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:[i?`"${i}"`:"This record"," will be permanently removed."]})]})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{sx:{px:3,pb:2},children:e.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:"#fce8e6",border:"1px solid #f28b82"},children:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#d93025",fontWeight:500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),e.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:e.jsx(j.DeleteForever,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#d93025",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Yc({open:t,onClose:r,onSave:n,row:i,schema:a,reportName:c}){const[l,d]=u.useState({});if(u.useEffect(()=>{t&&i&&d({...i})},[t,i]),!i)return null;const f=a.filter(y=>y.name in i),h=(y,S)=>{d(C=>({...C,[y]:S}))},m=()=>{const y={...l};f.forEach(S=>{const C=l[S.name];if(S.type==="number"){const x=Number(C);y[S.name]=isNaN(x)?i[S.name]:x}else S.type==="boolean"&&(y[S.name]=!!C)}),n(y),r()},g=y=>{const S=l[y.name],C=St(y.name);return y.type==="boolean"?e.jsx(o.FormControlLabel,{control:e.jsx(o.Switch,{checked:!!S,onChange:x=>h(y.name,x.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}}),label:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.primary",fontWeight:500},children:C}),sx:{m:0,bgcolor:"#fff",px:2,py:1,borderRadius:"4px",border:"1px solid #dadce0"}},y.name):e.jsx(o.TextField,{label:C,value:S??"",onChange:x=>h(y.name,x.target.value),type:y.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"outlined",InputLabelProps:y.type==="string"&&String(S).match(/^\d{4}-\d{2}-\d{2}/)?{shrink:!0}:void 0,sx:{"& .MuiOutlinedInput-root":{fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"#ffffff","& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputLabel-root":{fontSize:"0.8125rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiInputBase-input":{color:"text.primary",py:1}}},y.name)};return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08)"}},children:[e.jsxs(o.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(o.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(j.Edit,{sx:{fontSize:18,color:"#ea8600"}}),e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124"},children:"Edit Record"})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]}),e.jsx(o.DialogContent,{sx:{p:2,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(o.Stack,{spacing:1.5,children:f.map(y=>e.jsx(o.Box,{children:g(y)},y.name))})}),e.jsxs(o.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"text.secondary",px:2,py:.625,minHeight:32,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsx(o.Button,{onClick:m,variant:"contained",startIcon:e.jsx(j.Save,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,bgcolor:"primary.main",color:"#fff",px:2.5,py:.625,minHeight:32,borderRadius:"4px",boxShadow:"none","&:hover":{bgcolor:"primary.dark",boxShadow:"none"}},children:"Save"})]})]})}const Jc=160,qc={active:{bg:"#e6f4ea",color:"#137333"},completed:{bg:"#e6f4ea",color:"#137333"},approved:{bg:"#e6f4ea",color:"#137333"},success:{bg:"#e6f4ea",color:"#137333"},done:{bg:"#e6f4ea",color:"#137333"},contract:{bg:"#e8eaf6",color:"#2932e5"},"in progress":{bg:"#e8eaf6",color:"#2932e5"},"in review":{bg:"#e8eaf6",color:"#2932e5"},review:{bg:"#e8eaf6",color:"#2932e5"},pending:{bg:"#e8eaf6",color:"#2932e5"},"on leave":{bg:"#fce8e6",color:"#c5221f"},"on hold":{bg:"#fef7e0",color:"#b06000"},probation:{bg:"#fef7e0",color:"#b06000"},cancelled:{bg:"#fce8e6",color:"#c5221f"},rejected:{bg:"#fce8e6",color:"#c5221f"},blocked:{bg:"#fce8e6",color:"#c5221f"},inactive:{bg:"#f1f3f4",color:"#5f6368"},"not started":{bg:"#f1f3f4",color:"#5f6368"},paused:{bg:"#f1f3f4",color:"#5f6368"}},Kc={low:"#5f6368",medium:"#b06000",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function Xc(t){const r=t.toLowerCase().trim(),n=qc[r]||{bg:"grey.100",color:"grey.600"};return e.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:500,bgcolor:n.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function Qc(t){const r=t.toLowerCase().trim(),n=Kc[r];return n?e.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function Zc(t){return e.jsx(o.Box,{component:"span",sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.8125rem",fontWeight:400,letterSpacing:"0.04em"},children:t})}function ed(t,r){const n=t.name.toLowerCase().replace(/[_\s-]/g,""),i=t.name.toLowerCase(),a=r.findIndex(h=>h.name===t.name),c=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(n),l=i.includes("name")||i.includes("task")||i.includes("title")||i.includes("label")||i.includes("subject")||i.includes("description")||i.includes("filename"),d=i.includes("assignee")||i.includes("assigned")||i.includes("owner")||i.includes("author")||i.includes("creator")||i.includes("member")||i.includes("contact")||i.includes("recipient")||i.includes("sender"),f=a===0&&t.type!=="boolean"&&!i.includes("status")&&!i.includes("state");return c||l&&!d||f&&!d}function td(t){return e.jsx(o.Box,{component:"span",sx:{fontWeight:700,color:"text.primary",fontSize:"inherit"},children:t})}function rd(t,r,n=!1){if(r==null||r==="")return e.jsx(o.Box,{component:"span",sx:{color:"grey.400"},children:"—"});const i=String(r),a=t.name.toLowerCase().replace(/[_\s-]/g,""),c=/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase());if(c)return Xc(i);const l=/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase());if(l)return Qc(i);const d=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(a)||/^[A-Z]{2,8}-\d{2,}$/.test(i);return d?Zc(i):n&&!c&&!l&&!d?td(i):t.type==="number"&&typeof r=="number"?r.toLocaleString():typeof r=="boolean"?r?"Yes":"No":typeof r=="object"?JSON.stringify(r):i}function od({schema:t,data:r,sortStack:n=[],filters:i=[],views:a=[],activeViewId:c="",isDirty:l=!1,isExporting:d=!1,columnVisibility:f={},columnOrder:h=[],columnWidths:m={},grouping:g=null,onSort:y,onSortAscending:S,onSortDescending:C,onOpenFilters:x,onOpenSort:E,onOpenFilterForColumn:s,onSelectView:T,onCreateView:I,onManageViews:A,onUpdateCurrentView:v,onSaveAsNewView:W,onToggleDefault:U,onToggleFavorite:w,onRestoreView:O,onPermanentDelete:V,onExport:X,onOpenColumns:p,onUpdateColumnWidth:L,onUpdateColumnOrder:$,onUpdateColumnVisibility:_,onClearFiltersForColumn:F,onResetLayout:oe,onOpenGroup:ue,onToggleGroupCollapse:Ee,onOpenAuditHistory:R,onOpenSharePreset:q,searchQuery:ee,searchHistory:te=[],onAddToSearchHistory:re,onToggleSearchFavourite:ne,onDeleteSearchHistory:Z,selectedRowIds:Q=new Set,onSearchChange:ae,onToggleRowSelection:ce,onToggleAllRows:le,onRangeSelection:je,onClearSelection:G,onExportSelected:Me,currentPage:Ye=1,pageSize:jt=15,totalRowsBeforePagination:tt=r.length,onPageChange:$e,onPageSizeChange:Je,isReadOnly:Ae=!1,userRole:wt,reportName:Yt,onEditRow:pt,onDuplicateRow:rt,onDeleteRow:kt,favoriteRowIndices:Tt=[],resolvedFavoritesSet:ft=new Set,showFavoritesOnly:Fe=!1,onToggleRowFavorite:qe,onBulkSetFavorites:Jt,showDevPanel:Be=!1,onOpenDevConfig:zt,onToggleFavoritesFilter:Ke}){const[ot,qt]=u.useState(null),[xt,Pr]=u.useState(0),[mr,nt]=u.useState(0),[_t,gr]=u.useState(null),[$t,It]=u.useState(null),[Ce,Et]=u.useState(null),[yr,Ve]=u.useState(!1),[P,He]=u.useState(!1),[de,Re]=u.useState(null),[br,Ft]=u.useState(""),[Bt,Lt]=u.useState(!1),[Nt,ht]=u.useState(null),[Kt,Vt]=u.useState(null),[ie,H]=u.useState(null),[it,xe]=u.useState(null),[Le,Xt]=u.useState("list"),[vr,Qt]=u.useState(!1);u.useRef(null);const Zt=u.useMemo(()=>h.length>0?h.map(D=>t.find(Y=>Y.name===D)).filter(D=>D!==void 0):t,[h,t]),Ne=u.useMemo(()=>Zt.filter(D=>f[D.name]!==!1),[Zt,f]),st=u.useMemo(()=>t.filter(D=>f[D.name]===!1).length,[t,f]),er=u.useMemo(()=>t.map(D=>D.name),[t]),mt=u.useMemo(()=>JSON.stringify(h)!==JSON.stringify(er),[h,er]),Sr=u.useCallback((D,Y)=>{D.preventDefault(),D.stopPropagation(),qt(Y),Pr(D.clientX),nt(m[Y]||150)},[m]);u.useEffect(()=>{if(!ot)return;const D=pe=>{const Pe=pe.clientX-xt,se=Math.max(100,mr+Pe);L==null||L(ot,se)},Y=()=>{qt(null)};return document.addEventListener("mousemove",D),document.addEventListener("mouseup",Y),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",Y)}},[ot,xt,mr,L]);const tr=u.useCallback(D=>D==null?"-":typeof D=="object"?JSON.stringify(D):typeof D=="boolean"?D?"true":"false":String(D),[]);u.useCallback(D=>{const Y=n.find(pe=>pe.column===D);return Y?e.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[Y.direction==="asc"?e.jsx(j.ArrowUpward,{sx:{fontSize:14}}):e.jsx(j.ArrowDownward,{sx:{fontSize:14}}),e.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"caption.fontSize",fontWeight:"bold",borderRadius:"50%"},children:Y.priority})]}):null},[n]),u.useCallback(D=>i.some(pe=>pe.column===D)?e.jsx(o.IconButton,{size:"small",onClick:pe=>{pe.stopPropagation(),s==null||s(D)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(j.FilterList,{sx:{fontSize:14}})}):null,[i,s]);const rr=u.useCallback(D=>{y&&y(D)},[y]),or=u.useCallback((D,Y)=>{if(!$)return;const pe=[...h.length>0?h:t.map(se=>se.name)],[Pe]=pe.splice(D,1);pe.splice(Y,0,Pe),$(pe)},[$,h,t]),Cr=u.useCallback(D=>{if(!y)return;const Y=n.find(pe=>pe.column===D);(!Y||Y.direction!=="asc")&&y(D)},[y,n]),gt=u.useCallback(D=>{if(!y)return;const Y=n.find(pe=>pe.column===D);Y?Y.direction==="asc"&&y(D):(y(D),setTimeout(()=>y(D),0))},[y,n]),at=u.useCallback(D=>{if(!y)return;const Y=n.find(pe=>pe.column===D);Y&&(Y.direction==="asc"?(y(D),setTimeout(()=>y(D),0)):Y.direction==="desc"&&y(D))},[y,n]),nr=u.useCallback(D=>{_&&_(D,!1)},[_]),ir=(g==null?void 0:g.enabled)&&r.length>0&&r[0]&&"isGroupHeader"in r[0],sr=u.useMemo(()=>Ne.map(D=>D.name),[Ne]),We=u.useMemo(()=>ee&&ee.trim()?Xn(r,t,ee,sr):r,[r,t,ee,sr]);u.useEffect(()=>{const D=Y=>{!le||!G||Y.target instanceof HTMLInputElement||Y.target instanceof HTMLTextAreaElement||((Y.ctrlKey||Y.metaKey)&&Y.key==="a"&&(Y.preventDefault(),le(!0,We.length)),Y.key==="Escape"&&(Y.preventDefault(),G()))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[le,G,We.length]);const ar=u.useCallback((D,Y)=>{ce&&(Y.shiftKey&&_t!==null?(Y.preventDefault(),je&&je(_t,D)):(ce(D),gr(D)))},[ce,_t,je]),jr=u.useMemo(()=>We.length>0&&Q.size>0&&We.every((D,Y)=>Q.has(Y)),[We,Q]);Q.size>0;const Dt=ce&&le,wr=u.useCallback(D=>{var Pe;const Y=D.groupLevel,pe=Y*24;return e.jsx(o.TableRow,{onClick:()=>Ee==null?void 0:Ee(D.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(o.TableCell,{colSpan:Ne.length+(Dt?1:0),sx:{pl:`${pe+24}px`},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[D.isCollapsed?e.jsx(j.ChevronRight,{sx:{fontSize:16}}):e.jsx(j.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:Vn(Y,((Pe=g==null?void 0:g.levels[Y])==null?void 0:Pe.column)||"",D.groupValue)}),e.jsxs(o.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:se=>N(se.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[D.rowCount," ",D.rowCount===1?"row":"rows"]}),Object.keys(D.aggregates).length>0&&e.jsx(o.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(D.aggregates).map(([se,Ot])=>Nn(Ot)).filter(Boolean).join(" • ")})]})})},D.groupKey)},[Ne,Dt,g,Ee]),lr=u.useCallback((D,Y)=>{const pe=Q.has(Y),Pe=$t===Y;return e.jsxs(o.TableRow,{"data-row-index":Y,onMouseEnter:()=>It(Y),onMouseLeave:()=>It(null),onClick:se=>{!ce||se.target.closest("[data-row-action]")||ar(Y,se)},onContextMenu:se=>{se.preventDefault(),se.stopPropagation(),H({mouseX:se.clientX,mouseY:se.clientY,row:D,rowIndex:Y})},sx:{height:34,cursor:"pointer",bgcolor:pe?se=>N(se.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:pe?se=>N(se.palette.warning.main,.2):"#f8f9fa"},borderBottom:"1px solid",borderColor:"#e0e0e0"},children:[Ne.map((se,Ot)=>e.jsx(o.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,fontSize:"0.8125rem",fontWeight:400,color:"#202124",borderBottom:"none",minWidth:m[se.name]?`${m[se.name]}px`:`${Jc}px`},children:rd(se,D[se.name],ed(se,Ne))},se.name)),e.jsxs(o.TableCell,{"data-row-action":"true",onClick:se=>se.stopPropagation(),sx:{position:"sticky",right:0,width:qe?76:40,minWidth:qe?76:40,maxWidth:qe?76:40,p:0,border:"none",bgcolor:"transparent",opacity:Pe?1:0,transition:"opacity 0.12s ease",zIndex:2,verticalAlign:"middle",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:.25},children:[qe&&e.jsx(o.IconButton,{size:"small",onClick:se=>{se.stopPropagation(),se.preventDefault(),qe(Y)},title:ft.has(D)?"Remove from favorites":"Add to favorites",sx:{color:ft.has(D)?"#fbbc04":"text.secondary","&:hover":{bgcolor:se=>N(se.palette.warning.main,.08),color:"#fbbc04"}},children:ft.has(D)?e.jsx(j.Star,{sx:{fontSize:18}}):e.jsx(j.StarBorder,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:se=>{se.stopPropagation(),se.preventDefault(),H({anchorEl:se.currentTarget,row:D,rowIndex:Y})},sx:{color:"text.secondary","&:hover":{bgcolor:se=>N(se.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(j.MoreVert,{sx:{fontSize:18}})})]})]},Y)},[Q,$t,ar,Ne,m,tr,pt,rt,kt,ce,Et,Ve,H]);return e.jsxs(vt.DndProvider,{backend:zo.HTML5Backend,children:[e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[Dt&&Me&&G&&e.jsx(Ac,{selectedCount:Q.size,selectedRowIds:Q,searchedData:We,resolvedFavoritesSet:ft,onExportSelected:Me,onClearSelection:G,onBulkSetFavorites:Jt}),e.jsxs(o.Box,{sx:{position:"sticky",top:0,zIndex:10,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",px:2,py:0,height:56,display:"flex",alignItems:"center",gap:1},children:[Ae&&e.jsx(Vc,{}),ae&&re&&ne&&Z&&e.jsx(Ic,{value:ee||"",onChange:ae,searchHistory:te,onAddToHistory:re,onToggleFavourite:ne,onDeleteHistory:Z,disabled:Ae}),e.jsx(o.Tooltip,{title:"JSON format guide",children:e.jsx(o.IconButton,{size:"small",onClick:()=>Qt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:D=>N(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(j.InfoOutlined,{sx:{fontSize:20}})})}),Ke&&e.jsx(o.Tooltip,{title:Fe?"Show all data":"Show favorites only",children:e.jsxs(o.IconButton,{onClick:Ke,size:"small",disabled:Ae,sx:{position:"relative",color:Fe?"warning.main":"text.secondary",bgcolor:Fe?D=>N(D.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Fe?D=>N(D.palette.warning.main,.2):D=>N(D.palette.text.primary,.06),color:Fe?"warning.main":"text.primary"},"&.Mui-disabled":{color:"action.disabled"}},children:[Fe?e.jsx(j.Star,{sx:{fontSize:20}}):e.jsx(j.StarBorder,{sx:{fontSize:20}}),Fe&&Tt.length>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"warning.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:Tt.length})]})}),Be&&zt&&e.jsx(o.Tooltip,{title:"Developer configuration",children:e.jsx(o.IconButton,{size:"small",onClick:zt,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:D=>N(D.palette.text.secondary,.3),"&:hover":{bgcolor:D=>N(D.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(j.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(o.Box,{sx:{flexGrow:1}}),T&&I&&A&&v&&a.length>0&&e.jsx(Ec,{views:a||[],activeViewId:c||"",isDirty:l,onSelectView:T,onCreateView:I,onManageViews:A,onToggleDefault:U,onToggleFavorite:w,onRestoreView:O,onPermanentDelete:V,isReadOnly:Ae}),!Ae&&E&&e.jsx(o.Tooltip,{title:"Sort",children:e.jsxs(o.IconButton,{onClick:E,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(j.SwapVert,{sx:{fontSize:20}}),n.length>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Ae&&x&&e.jsx(o.Tooltip,{title:"Filter",children:e.jsxs(o.IconButton,{onClick:x,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(j.FilterList,{sx:{fontSize:20}}),i.length>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:i.length})]})}),!Ae&&p&&e.jsx(o.Tooltip,{title:"Columns",children:e.jsxs(o.IconButton,{onClick:p,size:"small",sx:{position:"relative",color:st>0||mt?"primary.main":"text.secondary",bgcolor:st>0||mt?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:st>0||mt?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:st>0||mt?"primary.main":"text.primary"}},children:[e.jsx(j.ViewColumn,{sx:{fontSize:20}}),st>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:st})]})}),e.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(o.Tooltip,{title:"List view",children:e.jsx(o.IconButton,{size:"small",onClick:()=>Xt("list"),sx:{borderRadius:1,color:Le==="list"?"primary.main":"text.secondary",bgcolor:Le==="list"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="list"?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:Le==="list"?"primary.main":"text.primary"}},children:e.jsx(j.TableRows,{sx:{fontSize:20}})})}),e.jsx(o.Tooltip,{title:"Grid view",children:e.jsx(o.IconButton,{size:"small",onClick:()=>Xt("grid"),sx:{borderRadius:1,color:Le==="grid"?"primary.main":"text.secondary",bgcolor:Le==="grid"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="grid"?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:Le==="grid"?"primary.main":"text.primary"}},children:e.jsx(j.GridView,{sx:{fontSize:20}})})}),e.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(o.Tooltip,{title:"Settings",children:e.jsx(o.IconButton,{onClick:D=>xe(D.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:D=>N(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(j.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(o.Popover,{open:!!it,anchorEl:it,onClose:()=>xe(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:200,py:.5,borderRadius:1.5,boxShadow:3}},children:[X&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{X(),xe(null)},disabled:d,sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Ae&&ue&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ue(),xe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),R&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{R(),xe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),q&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{q(),xe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Share,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Share Report State"})]})]}),e.jsxs(o.Box,{sx:{position:"relative",overflow:"hidden",flex:1,display:"flex",flexDirection:"column"},children:[Le==="grid"&&e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:D=>N("#d8dee4",.2)},children:e.jsx(Lc,{data:We,visibleColumns:Ne,grouping:g,selectedRowIds:Q,resolvedFavoritesSet:ft,isReadOnly:Ae,isGrouped:!!ir,onToggleRowSelection:ce||(()=>{}),onToggleRowFavorite:qe,onToggleGroupCollapse:Ee,onViewRow:D=>{Et(D),Ve(!0)},onEditRow:(D,Y)=>{ht(D),Vt(Y),Lt(!0)},onDuplicateRow:(D,Y)=>rt==null?void 0:rt(D,Y),onDeleteRow:(D,Y)=>{Re(D);const pe=Object.values(Y).find(Pe=>Pe!=null&&Pe!=="");Ft(pe?String(pe):""),He(!0)}})}),Le==="list"&&e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"auto",position:"relative",bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:D=>D.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:D=>D.palette.mode==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)"}}},children:e.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",width:"100%",minWidth:"100%"},stickyHeader:!0,children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{sx:{height:34,bgcolor:"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0"},children:[Ne.map((D,Y)=>e.jsx(Oc,{column:D,index:Y,sortRule:n.find(pe=>pe.column===D.name),hasFilters:i.some(pe=>pe.column===D.name),isInSortStack:n.some(pe=>pe.column===D.name),width:m[D.name],onColumnClick:rr,onMoveColumn:or,onResizeStart:Sr,onSort:rr,onRemoveSort:at,onSortAscending:Cr,onSortDescending:gt,onOpenFilterForColumn:s||(()=>{}),onClearFiltersForColumn:F||(()=>{}),onHideColumn:nr,onManageColumns:p||(()=>{}),onManageViews:A||(()=>{}),onResetLayout:oe||(()=>{})},D.name)),e.jsx(o.TableCell,{sx:{position:"sticky",top:0,right:0,width:qe?76:40,minWidth:qe?76:40,p:0,border:"none",bgcolor:"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0",zIndex:6}})]})}),e.jsx(o.TableBody,{children:We.length===0?e.jsx(o.TableRow,{children:e.jsx(o.TableCell,{colSpan:Ne.length+(Dt?1:0),align:"center",sx:{py:4},children:e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):ir?We.map((D,Y)=>D.isGroupHeader?wr(D):lr(D,Y)):We.map((D,Y)=>lr(D,Y))})]})}),$e&&Je&&e.jsx(Nc,{currentPage:Ye,pageSize:jt,totalRows:tt,totalFields:t.length,onPageChange:$e,onPageSizeChange:Je}),!($e&&Je)&&e.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",We.length," ",We.length===1?"row":"rows"]})})]})]}),e.jsxs(o.Popover,{open:!!ie,onClose:()=>H(null),anchorEl:(ie==null?void 0:ie.anchorEl)||null,anchorReference:ie!=null&&ie.anchorEl?"anchorEl":"anchorPosition",anchorPosition:ie&&!ie.anchorEl?{top:ie.mouseY,left:ie.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:ie!=null&&ie.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie&&(Et(ie.row),Ve(!0)),H(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"View"})]}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie&&(ht(ie.row),Vt(ie.rowIndex),Lt(!0)),H(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie&&(rt==null||rt(ie.rowIndex,ie.row)),H(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{if(ie){Re(ie.rowIndex);const D=Object.values(ie.row).find(Y=>Y!=null&&Y!=="");Ft(D?String(D):""),He(!0)}H(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(j.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Uc,{open:yr,onClose:()=>{Ve(!1),Et(null)},row:Ce,schema:t,reportName:Yt}),e.jsx(Yc,{open:Bt,onClose:()=>{Lt(!1),ht(null),Vt(null)},onSave:D=>{Kt!==null&&(pt==null||pt(Kt,D))},row:Nt,schema:t,reportName:Yt}),e.jsx(Gc,{open:P,onClose:()=>{He(!1),Re(null)},onConfirm:()=>{de!==null&&(kt==null||kt(de))},rowPreview:br}),e.jsx(mi,{isOpen:vr,onClose:()=>Qt(!1)})]})}function nd({schema:t,filters:r,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:a,onClearAll:c,onClose:l,focusColumn:d}){const[f,h]=u.useState(""),[m,g]=u.useState(""),[y,S]=u.useState(""),[C,x]=u.useState([]),E=Mr();u.useEffect(()=>{x([...r])},[r]),u.useEffect(()=>{d&&h(d)},[d]);const s=u.useCallback(()=>{h(""),g(""),S("")},[]),T=u.useMemo(()=>t.filter(p=>p.type!=="mixed"&&p.type!=="null"&&p.type!=="array"&&p.type!=="object"),[t]),I=t.find(p=>p.name===f),A=u.useMemo(()=>{const p=I?rn(I.type):[],L=E.filter.allowedOperators;return L.length>0?p.filter($=>L.includes($.value)):p},[I]),v=u.useCallback(()=>!(!f||!m||Nr(m)&&!y.trim()||C.length>=E.filter.maxConditions),[f,m,y,C,E]),W=u.useCallback(()=>{if(!v())return;const p={column:f,operator:m};if(Nr(m)){const $=I==null?void 0:I.type;p.value=$==="number"?Number(y):y}if(C.some($=>$.column===p.column&&$.operator===p.operator&&$.value===p.value)){s();return}x([...C,p]),s()},[v,f,m,I,y,C,s]),U=u.useCallback(p=>{x(C.filter((L,$)=>$!==p))},[C]),w=u.useMemo(()=>C.length!==r.length?!0:JSON.stringify(C)!==JSON.stringify(r),[C,r]),O=u.useCallback(()=>{c(),C.forEach(p=>n(p)),l()},[C,n,c,l]),V=u.useCallback(()=>{x([...r]),s(),l()},[r,s,l]),X=u.useCallback(p=>{var F;const L=t.find(oe=>oe.name===p.column);if(!L)return"";const _=((F=rn(L.type).find(oe=>oe.value===p.operator))==null?void 0:F.label)||p.operator;return Nr(p.operator)?`${p.column} ${_.toLowerCase()} "${p.value}"`:`${p.column} ${_.toLowerCase()}`},[t]);return e.jsx(o.Box,{onClick:V,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:p=>p.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Filter columns"}),e.jsx(o.IconButton,{onClick:V,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:[e.jsxs(o.Box,{sx:{mb:2.5},children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add filter"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(o.Select,{value:f,onChange:p=>{h(p.target.value),g(""),S("")},label:"Column",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:T.map(p=>e.jsxs(o.MenuItem,{value:p.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:L=>N(L.palette.primary.main,.2)}}},children:[St(p.name)," (",p.type,")"]},p.name))})]}),f&&e.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Operator"}),e.jsx(o.Select,{value:m,onChange:p=>{g(p.target.value),S("")},label:"Operator",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:A.map(p=>e.jsx(o.MenuItem,{value:p.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:L=>N(L.palette.primary.main,.2)}}},children:p.label},p.value))})]}),m&&Nr(m)&&e.jsx(o.TextField,{size:"small",fullWidth:!0,type:(I==null?void 0:I.type)==="number"?"number":"text",value:y,onChange:p=>S(p.target.value),label:"Value",placeholder:"Enter value...",sx:{"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1,color:"text.primary"}}})]}),e.jsx(o.Button,{onClick:W,disabled:!v(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add another filter"})]}),C.length>0&&e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Active filters (",C.length,")"]}),e.jsx(o.Button,{onClick:()=>x([]),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:C.map((p,L)=>e.jsx(o.Chip,{label:X(p),onDelete:()=>U(L),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:$=>`1px solid ${N($.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:$=>N($.palette.primary.main,.2),borderColor:"#aecbfa"},"& .MuiChip-label":{px:1.5,color:"primary.main"},"& .MuiChip-deleteIcon":{color:"primary.main",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"primary.dark"}}}},L))})]})]}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:V,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:O,disabled:!w,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"grey.300",color:"grey.500"}},children:"Apply filter"})]})]})})}const Mn="SORT_RULE";function id({rule:t,index:r,onToggleDirection:n,onRemove:i,onMove:a}){const c=u.useRef(null),[{handlerId:l},d]=vt.useDrop({accept:Mn,collect(m){return{handlerId:m.getHandlerId()}},hover(m,g){var T;if(!c.current)return;const y=m.index,S=r;if(y===S)return;const C=(T=c.current)==null?void 0:T.getBoundingClientRect(),x=(C.bottom-C.top)/2,E=g.getClientOffset(),s=((E==null?void 0:E.y)??0)-C.top;y<S&&s<x||y>S&&s>x||(a(y,S),m.index=S)}}),[{isDragging:f},h]=vt.useDrag({type:Mn,item:()=>({index:r}),collect:m=>({isDragging:m.isDragging()})});return h(d(c)),e.jsxs(o.Box,{ref:c,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:f?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)",transform:"translateY(-1px)"}},children:[e.jsx(o.Chip,{label:t.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)","& .MuiChip-label":{px:0}}}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[e.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",fontWeight:400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:t.column}),e.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:e.jsxs(o.Select,{value:t.direction,onChange:m=>n(r,m.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"text.primary",fontWeight:400}},children:[e.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:m=>N(m.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:m=>N(m.palette.primary.main,.2)}}},children:"Descending"})]})}),e.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:"rgba(217, 48, 37, 0.08)",transform:"scale(1.1)"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]})}function sd({schema:t,sortStack:r,onUpdateSortStack:n,onClose:i}){const[a,c]=u.useState(""),[l,d]=u.useState([]);u.useEffect(()=>{d([...r])},[r]);const f=Mr(),h=u.useCallback(()=>!(l.length>=f.sort.maxLevels||!a||l.some(T=>T.column===a)),[l,a]),m=u.useCallback(()=>{if(!h())return;const T=l.length+1,I={column:a,direction:"asc",priority:T};d([...l,I]),c("")},[h,a,l]),g=u.useCallback(T=>{const A=l.filter((v,W)=>W!==T).map((v,W)=>({...v,priority:W+1}));d(A)},[l]),y=u.useCallback((T,I)=>{const A=[...l];A[T]={...A[T],direction:I},d(A)},[l]),S=u.useCallback((T,I)=>{const A=[...l],[v]=A.splice(T,1);A.splice(I,0,v);const W=A.map((U,w)=>({...U,priority:w+1}));d(W)},[l]),C=u.useCallback(()=>{d([])},[]),x=u.useCallback(()=>{n(l),i()},[l,n,i]),E=u.useCallback(()=>{d([...r]),c(""),i()},[r,i]),s=t.filter(T=>!l.some(I=>I.column===T.name));return e.jsx(vt.DndProvider,{backend:zo.HTML5Backend,children:e.jsx(o.Box,{onClick:E,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:T=>T.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),e.jsx(o.IconButton,{onClick:E,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:[e.jsxs(o.Box,{sx:{mb:2.5},children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),e.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=f.sort.maxLevels,children:[e.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),e.jsxs(o.Select,{value:a,onChange:T=>c(T.target.value),label:"Select column...",displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:[e.jsx(o.MenuItem,{value:"",disabled:!0,sx:{display:"none"},children:e.jsx("em",{children:"Select column..."})}),s.map(T=>e.jsx(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:I=>N(I.palette.primary.main,.2)}}},children:St(T.name)},T.name))]})]}),e.jsx(o.Button,{onClick:m,disabled:!h(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add sort column"})]}),l.length>0&&e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",f.sort.maxLevels,")"]}),e.jsx(o.Button,{onClick:C,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((T,I)=>e.jsx(id,{rule:T,index:I,onToggleDirection:y,onRemove:g,onMove:S},`${T.column}-${I}`))})]})]}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:E,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:x,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function ad({views:t,activeViewId:r,onSelectView:n,onCreateView:i,onEditView:a,onDeleteView:c,onRestoreView:l,onPermanentDelete:d,onClose:f}){return e.jsxs(o.Dialog,{open:!0,onClose:f,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Manage Views",e.jsx(o.IconButton,{onClick:f,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.DialogContent,{children:[e.jsx(o.Box,{sx:{mb:2},children:e.jsx(o.Button,{onClick:i,variant:"contained",startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",children:"Create New Report View"})}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:t.map(h=>e.jsx(o.Paper,{sx:{p:2,border:1,borderColor:h.isDeleted?"error.light":r===h.id?"primary.main":"divider",bgcolor:h.isDeleted?m=>N(m.palette.error.main,.12):r===h.id?m=>N(m.palette.primary.main,.12):"background.paper",opacity:h.isDeleted?.75:1,cursor:h.isDeleted?"default":"pointer","&:hover":h.isDeleted?{}:{bgcolor:"action.hover"}},onClick:()=>!h.isDeleted&&n(h.id),elevation:0,children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,textDecoration:h.isDeleted?"line-through":"none",color:h.isDeleted?"text.secondary":"text.primary"},children:h.name}),h.isDeleted&&e.jsx(o.Chip,{label:"Deleted",size:"small",color:"error",sx:{height:20}}),h.isDefault&&e.jsx(o.Chip,{label:"Default",size:"small",color:"primary",sx:{height:20}}),h.isFavorite&&e.jsx(o.Chip,{label:"★ Favorite",size:"small",sx:{height:20}})]}),h.description&&e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:h.description})]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[!h.isDeleted&&e.jsxs(e.Fragment,{children:[e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),a(h.id)},title:"Edit view",children:e.jsx(j.Edit,{sx:{fontSize:16}})}),e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),c(h.id)},title:"Delete view",sx:{"&:hover":{color:"error.main"}},children:e.jsx(j.Delete,{sx:{fontSize:16}})})]}),h.isDeleted&&l&&e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),l(h.id)},title:"Restore view",sx:{color:"success.main"},children:e.jsx(j.Undo,{sx:{fontSize:16}})}),h.isDeleted&&d&&e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),d(h.id)},title:"Delete permanently",sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:16}})})]})]})},h.id))})]}),e.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:f,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function Rn({currentSnapshot:t,onSave:r,onClose:n,isEditMode:i=!1,initialName:a="",initialDescription:c="",initialIsDefault:l=!1}){const[d,f]=u.useState(a),[h,m]=u.useState(c),[g,y]=u.useState(l),S=()=>{d.trim()&&(r(d.trim(),h.trim(),g),n())},C=E=>{E.key==="Enter"&&!E.shiftKey?S():E.key==="Escape"&&n()},x=()=>i&&a?`Update ${a} view`:"Create New Report View";return e.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[x(),e.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[e.jsx(o.TextField,{label:"View Name",required:!0,value:d,onChange:E=>f(E.target.value),onKeyDown:C,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small"}),e.jsx(o.TextField,{label:"Description (optional)",value:h,onChange:E=>m(E.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),e.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1},children:"This view will capture:"}),e.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[e.jsxs("li",{children:[t.filters.length," filter",t.filters.length!==1?"s":""]}),e.jsxs("li",{children:["Sorting: ",bs(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:g,onChange:E=>y(E.target.checked),size:"small"}),label:e.jsx(o.Typography,{variant:"body2",children:"Set as default view"})})]})}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:S,disabled:!d.trim(),variant:"contained",startIcon:e.jsx(j.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:i?"Save Changes":"Create Report View"})]})]})}function ld({viewName:t,onConfirm:r,onCancel:n}){return e.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Delete View",e.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[e.jsx(j.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),e.jsxs(o.Box,{children:[e.jsxs(o.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",e.jsxs("strong",{children:['"',t,'"']}),"?"]}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#d93025",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete View"})]})]})}const yi=80,bi=600,Wn="COLUMN";function cd({column:t,index:r,isVisible:n,width:i,onToggleVisibility:a,onWidthChange:c,moveColumn:l}){const d=u.useRef(null),[f,h]=u.useState(i.toString());u.useEffect(()=>{h(i.toString())},[i]);const[{handlerId:m},g]=vt.useDrop({accept:Wn,collect(T){return{handlerId:T.getHandlerId()}},hover(T,I){var V;if(!d.current)return;const A=T.index,v=r;if(A===v)return;const W=(V=d.current)==null?void 0:V.getBoundingClientRect(),U=(W.bottom-W.top)/2,w=I.getClientOffset(),O=((w==null?void 0:w.y)??0)-W.top;A<v&&O<U||A>v&&O>U||(l(A,v),T.index=v)}}),[{isDragging:y},S]=vt.useDrag({type:Wn,item:()=>({index:r}),collect:T=>({isDragging:T.isDragging()})});S(g(d));const C=()=>{const T=parseInt(f);if(isNaN(T)){h(i.toString());return}const I=Math.max(yi,Math.min(bi,T));h(I.toString()),c(t.name,I)},x=T=>{(T===""||/^\d+$/.test(T))&&h(T)},E=T=>{T.key==="Enter"&&(T.preventDefault(),C(),T.target.blur())},s=T=>({string:"primary.main",number:"#188038",boolean:"#9334e6",array:"#ea8600",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[T]||"text.secondary";return e.jsxs(o.TableRow,{ref:d,"data-handler-id":m,sx:{opacity:y?.4:1,bgcolor:n?"background.paper":"grey.50",transition:"all 0.2s ease","&:hover":{bgcolor:n?"grey.50":"grey.100"},cursor:"move",height:56,borderBottom:"1px solid divider"},children:[e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(o.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:e.jsx(j.DragIndicator,{sx:{fontSize:20}})}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:St(t.name)})]})}),e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsx(o.Chip,{label:t.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${s(t.type)}15`,color:s(t.type),border:`1px solid ${s(t.type)}30`,"& .MuiChip-label":{px:1}}})}),e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.TextField,{type:"text",value:f,onChange:T=>x(T.target.value),onBlur:C,onKeyDown:E,placeholder:"150",size:"small",sx:{width:80,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"}}}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:"px"})]})}),e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(o.IconButton,{onClick:()=>a(t.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:n?"primary.dark":"primary.main"}},children:n?e.jsx(j.Visibility,{sx:{fontSize:20}}):e.jsx(j.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?"#e6f4ea":"grey.100",color:n?"#188038":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function dd({schema:t,columnVisibility:r,columnOrder:n,columnWidths:i={},views:a=[],activeViewId:c="",onUpdateColumnVisibility:l,onUpdateColumnOrder:d,onUpdateColumnWidth:f,onResetLayout:h,onSaveToCurrentView:m,onSaveToAllViews:g,onSelectView:y,onClose:S}){const[C,x]=u.useState(!1),[E,s]=u.useState(n),[T,I]=u.useState("all"),[A,v]=u.useState(null);u.useEffect(()=>{s(n)},[n]);const W=(F,oe)=>{const ue=[...E],[Ee]=ue.splice(F,1);ue.splice(oe,0,Ee),s(ue),d(ue)},U=()=>{h(),x(!1)},O=E.map(F=>t.find(oe=>oe.name===F)).filter(F=>F!==void 0).filter(F=>{const oe=r[F.name]??!0;return T==="active"?oe:T==="hidden"?!oe:!0}),V=Object.values(r).filter(F=>F).length,X=t.length,p=a.find(F=>F.id===c),L=a.filter(F=>!F.isDeleted),$=L.length>1,_=u.useMemo(()=>{if(!p)return!1;const F=p.snapshot,oe=JSON.stringify(r)!==JSON.stringify(F.columnVisibility),ue=JSON.stringify(n)!==JSON.stringify(F.columnOrder),Ee=JSON.stringify(i)!==JSON.stringify(F.columnWidths);return oe||ue||Ee},[p,r,n,i]);return e.jsx(vt.DndProvider,{backend:zo.HTML5Backend,children:e.jsx(o.Box,{onClick:S,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:F=>F.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage columns"}),e.jsxs(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5},children:[V," of ",X," columns visible • Drag to reorder"]})]}),L.length>0&&y&&e.jsxs(o.Box,{sx:{ml:2},children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",color:"text.secondary",mb:.75,display:"block",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.1em"},children:"View:"}),e.jsx(o.Button,{onClick:F=>v(F.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(j.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",textTransform:"none",fontSize:"0.875rem",fontWeight:400,color:"text.primary",borderColor:"grey.300",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:e.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(p==null?void 0:p.name)||"Select View"})}),e.jsx(o.Menu,{anchorEl:A,open:!!A,onClose:()=>v(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:"0 2px 6px rgba(60, 64, 67, 0.15)"}},children:L.map(F=>e.jsx(o.MenuItem,{onClick:()=>{y(F.id),v(null)},selected:F.id===c,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:oe=>N(oe.palette.primary.main,.2)}}},children:F.name},F.id))})]}),e.jsx(o.IconButton,{onClick:S,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.Tabs,{value:T,onChange:(F,oe)=>I(oe),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:"primary.main",height:3}},children:[e.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}})]})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{children:[e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Column name"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Type"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",e.jsx(o.Tooltip,{title:`Column width in pixels (min: ${yi}px, max: ${bi}px)`,arrow:!0,placement:"top",children:e.jsx(j.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),e.jsx(o.TableBody,{children:O.length===0?e.jsx(o.TableRow,{children:e.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):O.map((F,oe)=>e.jsx(cd,{column:F,index:oe,isVisible:r[F.name]??!0,width:i[F.name]||150,onToggleVisibility:l,onWidthChange:f||(()=>{}),moveColumn:W},F.name))})]})}),e.jsxs(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:()=>x(!0),disabled:!_,variant:"outlined",startIcon:e.jsx(j.Undo,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",px:2.5,py:.875,minHeight:36,borderRadius:"4px","&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Reset to default"}),e.jsxs(o.Stack,{direction:"row",spacing:1.25,children:[m&&e.jsx(o.Button,{onClick:()=>{m(),S()},disabled:!_,variant:"contained",startIcon:e.jsx(j.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to current view"}),g&&$&&e.jsx(o.Button,{onClick:()=>{g(),S()},disabled:!_||!$,variant:"contained",startIcon:e.jsx(j.GridView,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#188038",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#0d652d",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to all views"})]})]}),C&&e.jsx(o.Box,{onClick:()=>x(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1400},children:e.jsxs(o.Paper,{onClick:F=>F.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:"12px",bgcolor:"background.paper",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"},children:[e.jsxs(o.Box,{sx:{px:3,py:2.5},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:()=>x(!1),variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,borderRadius:"4px","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:U,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function ud({schema:t,grouping:r,onApply:n,onClose:i}){var W;const[a,c]=u.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,d]=u.useState(""),[f,h]=u.useState(null),m=u.useMemo(()=>fs(t),[t]),g=u.useMemo(()=>m.filter(U=>!a.levels.some((w,O)=>w.column===U.name&&O!==f)),[m,a.levels,f]),y=Mr(),S=a.levels.length<y.grouping.maxLevels&&g.length>0,C=u.useCallback(()=>{!S||!l||(c({...a,levels:[...a.levels,{column:l}],enabled:!0}),d(""))},[S,l,a]),x=u.useCallback(U=>{const w=a.levels.filter((O,V)=>V!==U);if(w.length===0){n(null),i();return}c({...a,levels:w,enabled:w.length>0})},[a,n,i]),E=u.useCallback(U=>{h(U),d(a.levels[U].column)},[a.levels]),s=u.useCallback(()=>{if(f===null||!l)return;const U=[...a.levels];U[f]={column:l},c({...a,levels:U}),h(null),d("")},[f,l,a]),T=u.useCallback(()=>{h(null),d("")},[]),I=u.useCallback((U,w)=>{const O=w==="up"?U-1:U+1;if(O<0||O>=a.levels.length)return;const V=[...a.levels],[X]=V.splice(U,1);V.splice(O,0,X),c({...a,levels:V})},[a]),A=u.useCallback(()=>{n(null),i()},[n,i]),v=u.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return e.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:U=>U.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),e.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(o.Stack,{spacing:2.5,children:[f===null&&e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),e.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(o.Select,{value:l,onChange:U=>d(U.target.value),disabled:!S,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:[e.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),g.map(U=>e.jsxs(o.MenuItem,{value:U.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:w=>N(w.palette.primary.main,.2)}}},children:[St(U.name)," (",U.type.toUpperCase(),")"]},U.name))]})}),e.jsx(o.Button,{onClick:C,disabled:!S||!l,variant:"outlined",startIcon:e.jsx(j.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",bgcolor:"grey.50"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Add group level"}),a.levels.length>=y.grouping.maxLevels&&e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),m.length===0&&e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),f!==null&&e.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"}},children:[e.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"text.primary"},children:["Edit Group Level ",f+1]}),e.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(o.Select,{value:l,onChange:U=>d(U.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[e.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),e.jsxs(o.MenuItem,{value:a.levels[f].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[a.levels[f].column," (",(W=t.find(U=>U.name===a.levels[f].column))==null?void 0:W.type.toUpperCase(),")"]}),g.filter(U=>U.name!==a.levels[f].column).map(U=>e.jsxs(o.MenuItem,{value:U.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[St(U.name)," (",U.type.toUpperCase(),")"]},U.name))]})}),e.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[e.jsx(o.Button,{onClick:s,disabled:!l,variant:"contained",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#ea8600",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"#c96e00",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)"}},children:"Save"}),e.jsx(o.Button,{onClick:T,variant:"outlined",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",py:.875,"&:hover":{borderColor:"grey.400",bgcolor:"grey.50"}},children:"Cancel"})]})]}),a.levels.length>0&&f===null&&e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),e.jsx(o.Button,{onClick:A,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(o.Stack,{spacing:1.5,children:a.levels.map((U,w)=>{const O=t.find(V=>V.name===U.column);return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)"}},children:[e.jsx(o.Chip,{label:`L${w+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)"}}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:U.column}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:O==null?void 0:O.type.toUpperCase()})]}),e.jsxs(o.Stack,{direction:"row",spacing:.5,children:[e.jsx(o.IconButton,{size:"small",onClick:()=>I(w,"up"),disabled:w===0,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(j.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>I(w,"down"),disabled:w===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(j.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>E(w),sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100",color:"primary.main"}},children:e.jsx(j.Edit,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>x(w),sx:{color:"text.secondary","&:hover":{bgcolor:"rgba(217, 48, 37, 0.08)",color:"error.main"}},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]})]},w)})})]})]})}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:i,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:v,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const pd={filters:j.FilterList,sorting:j.UnfoldMore,visibility:j.Visibility,order:j.ViewColumn,widths:j.Straighten,grouping:j.Layers};function fd({changes:t,onClose:r}){const n=i=>({filters:"primary",sorting:"secondary",visibility:"success",order:"warning",widths:"info",grouping:"error"})[i]||"default";return e.jsxs(o.Dialog,{open:!0,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["View Changes Summary",e.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{dividers:!0,children:t.length===0?e.jsx(o.Box,{sx:{textAlign:"center",py:4},children:e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No changes detected"})}):e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"The following modifications have been made to this view:"}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:t.map((i,a)=>{const c=pd[i.category];return e.jsxs(o.Paper,{elevation:0,sx:{display:"flex",gap:1.5,p:1.5,border:1,borderColor:"divider",borderRadius:1},children:[e.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:1,bgcolor:`${n(i.category)}.lighter`,color:`${n(i.category)}.main`,flexShrink:0},children:e.jsx(c,{sx:{fontSize:16}})}),e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:i.label}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:i.description})]})]},a)})})]})}),e.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function xd({viewName:t,isDefaultView:r,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:a,onCancel:c}){const[l,d]=u.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{width:"100%",flexShrink:0,bgcolor:"primary.lighter",borderBottom:f=>`1px solid ${N(f.palette.primary.main,.3)}`,zIndex:10},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:"#3c4043"},children:['Unsaved changes to "',t,'"']}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Button,{onClick:c,variant:"text",size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"#5f6368",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:"rgba(60, 64, 67, 0.08)",color:"#202124"}},children:"Discard"}),e.jsx(o.Button,{onClick:a,variant:"contained",size:"small",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,py:.625,borderRadius:"18px",minHeight:32,boxShadow:"none","&:hover":{boxShadow:"0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px rgba(60, 64, 67, 0.15)"}},children:"Save as new view"})]})]})}),l&&e.jsx(fd,{changes:n,onClose:()=>d(!1)})]})}function hd({onExportAnyway:t,onSaveAndExport:r,onCancel:n}){return e.jsx(o.Box,{sx:{mb:2,mx:3,mt:2},children:e.jsxs(o.Alert,{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}}),action:e.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(j.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[e.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:"You are exporting with unsaved view changes"}),e.jsx(o.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Button,{onClick:r,variant:"contained",color:"primary",startIcon:e.jsx(j.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(o.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(j.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}function md({auditHistory:t,onClose:r}){const[n,i]=u.useState(new Set),a=l=>{i(d=>{const f=new Set(d);return f.has(l)?f.delete(l):f.add(l),f})},c=[...t].sort((l,d)=>new Date(d.timestamp).getTime()-new Date(l.timestamp).getTime());return e.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:l=>l.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Audit history"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[c.length," event",c.length!==1?"s":""," recorded"]})]}),e.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:c.length===0?e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,textAlign:"center"},children:[e.jsx(j.AccessTime,{sx:{fontSize:64,color:"divider",mb:2}}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",mb:.5},children:"No audit events recorded yet"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"grey.400"},children:"Changes to this report will appear here"})]}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:c.map(l=>{const d=n.has(l.id),f=Ms(l.feature);return e.jsxs(o.Paper,{elevation:0,sx:{border:"1px solid divider",borderRadius:"8px",overflow:"hidden",transition:"all 0.2s ease","&:hover":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)",borderColor:"grey.300"}},children:[e.jsxs(o.Box,{onClick:()=>a(l.id),sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",gap:1.5,cursor:"pointer",bgcolor:"background.paper",transition:"background-color 0.2s ease","&:hover":{bgcolor:"grey.50"}},children:[e.jsx(o.Box,{sx:{flexShrink:0,color:"text.secondary",transition:"transform 0.2s ease",transform:"rotate(0deg)"},children:d?e.jsx(j.KeyboardArrowDown,{sx:{fontSize:20}}):e.jsx(j.ChevronRight,{sx:{fontSize:20}})}),e.jsx(o.Chip,{label:As(l.feature),size:"small",sx:{height:24,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${f}15`,color:f,border:`1px solid ${f}30`,"& .MuiChip-label":{px:1}}}),e.jsx(o.Typography,{variant:"body2",sx:{flex:1,fontWeight:400,fontSize:"0.875rem",color:"text.primary"},children:Os(l.action)}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(j.AccessTime,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:Rs(l.timestamp)})]}),l.user&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(j.Person,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:l.user})]})]}),e.jsx(o.Collapse,{in:d,timeout:200,children:e.jsxs(o.Box,{sx:{px:2.5,pb:2,pt:1.5,borderTop:"1px solid divider",bgcolor:"grey.50"},children:[l.previousState&&e.jsxs(o.Box,{sx:{mb:2},children:[e.jsx(o.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"Previous state"}),e.jsx(o.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"background.paper",border:"1px solid grey.300",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"text.primary",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:3}},children:qo(l.previousState)})]}),l.newState&&e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"New state"}),e.jsx(o.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"background.paper",border:"1px solid grey.300",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"text.primary",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:3}},children:qo(l.newState)})]})]})})]},l.id)})})})]})})}function gd({onSave:t,onClose:r}){const[n,i]=u.useState(""),[a,c]=u.useState(""),[l,d]=u.useState(""),[f,h]=u.useState([]),[m,g]=u.useState(""),[y,S]=u.useState(""),C=v=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),x=()=>{const v=l.trim();if(v){if(!C(v)){S("Please enter a valid email address");return}if(f.includes(v)){S("This email is already added");return}h([...f,v]),d(""),S("")}},E=v=>{h(f.filter(W=>W!==v))},s=v=>{v.key==="Enter"&&(v.preventDefault(),x())},T=()=>{if(!n.trim()){g("Preset name is required");return}t(n.trim(),a.trim(),f.length>0?f:void 0)},I=v=>{i(v),m&&g("")},A=v=>{d(v),y&&S("")};return e.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:v=>v.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),e.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(o.Alert,{severity:"info",icon:e.jsx(j.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:v=>`1px solid ${N(v.palette.primary.main,.3)}`,bgcolor:"primary.lighter","& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),e.jsx(o.TextField,{required:!0,value:n,onChange:v=>I(v.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!m,helperText:m,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),e.jsx(o.TextField,{value:a,onChange:v=>c(v.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[e.jsx(o.TextField,{value:l,onChange:v=>A(v.target.value),onKeyPress:s,placeholder:"Enter email address",error:!!y,helperText:y,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(j.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}}),e.jsx(o.Button,{onClick:x,variant:"outlined",startIcon:e.jsx(j.Add,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",px:2,py:1.25,minHeight:40,borderRadius:"4px",flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:"Add"})]}),f.length>0&&e.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:f.map(v=>e.jsx(o.Chip,{label:v,onDelete:()=>E(v),deleteIcon:e.jsx(j.Delete,{sx:{fontSize:16}}),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},v))}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:f.length>0?`An email with the shareable link will be sent to ${f.length} recipient${f.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:T,variant:"contained",startIcon:e.jsx(j.Share,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function yd({presetName:t,shareUrl:r,onCopyLink:n,onOpenPreset:i,onDeletePreset:a,onClose:c}){const[l,d]=u.useState(!1),f=()=>{n(),d(!0),setTimeout(()=>d(!1),2e3)};return e.jsx(o.Box,{onClick:c,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:h=>h.stopPropagation(),elevation:0,sx:{position:"relative",width:580,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Shareable link generated"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5,display:"block"},children:["Preset: ",t]})]}),e.jsx(o.IconButton,{onClick:c,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsxs(o.Alert,{severity:"success",icon:e.jsx(j.Check,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #ceead6",bgcolor:"#e6f4ea","& .MuiAlert-icon":{color:"#188038"},"& .MuiAlert-message":{fontSize:"0.875rem",color:"#3c4043"}},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043",mb:.5},children:"Preset created successfully!"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#5f6368",lineHeight:1.5},children:"Share the link below with anyone who needs access to this report configuration."})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Shareable URL"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[e.jsx(o.TextField,{value:r,size:"small",fullWidth:!0,InputProps:{readOnly:!0},onClick:h=>h.target.select(),sx:{"& .MuiOutlinedInput-root":{fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"#f8f9fa",fontFamily:'"Roboto Mono", "Courier New", monospace',"& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"#1967d2",cursor:"pointer"}}}),e.jsx(o.Button,{onClick:f,variant:"contained",startIcon:l?e.jsx(j.Check,{sx:{fontSize:18}}):e.jsx(j.ContentCopy,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:l?"#188038":"#1967d2",color:"#ffffff",px:3,py:1.25,minWidth:110,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:l?"#0d652d":"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:l?"Copied!":"Copy"})]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[e.jsx(o.Button,{onClick:i,variant:"outlined",startIcon:e.jsx(j.OpenInNew,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",py:1,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:"Open link"}),e.jsx(o.Button,{onClick:a,variant:"outlined",startIcon:e.jsx(j.Delete,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#d93025",borderColor:"#dadce0",py:1,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{borderColor:"#d93025",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete preset"})]})]})}),e.jsx(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:e.jsx(o.Button,{onClick:c,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Done"})})]})})}function bd({presetName:t,onClear:r}){return e.jsx(o.Chip,{icon:e.jsx(j.Link,{sx:{fontSize:14}}),label:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset: ",e.jsx(o.Box,{component:"span",sx:{fontWeight:600},children:t})]}),onDelete:r,deleteIcon:e.jsx(o.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:e.jsx(j.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>N(n.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function vd({presets:t,reportId:r,onOpenPreset:n,onCopyLink:i,onDeletePreset:a,onClose:c}){const[l,d]=u.useState(null),f=(m,g)=>{i(m,g),d(m),setTimeout(()=>d(null),2e3)},h=m=>new Date(m).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx(o.Box,{onClick:c,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:m=>m.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5,display:"block"},children:[t.length," saved ",t.length===1?"preset":"presets"]})]}),e.jsx(o.IconButton,{onClick:c,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:t.length===0?e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(j.Share,{sx:{fontSize:48,color:"#dadce0",mb:2}}),e.jsx(o.Typography,{variant:"body1",sx:{fontSize:"0.875rem",color:"#5f6368",textAlign:"center"},children:"No presets created yet"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#80868b",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:t.map(m=>e.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid #e8eaed",borderRadius:"8px",bgcolor:"#ffffff",transition:"all 0.2s ease","&:hover":{borderColor:"#dadce0",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsx(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124",mb:.5},children:m.name}),m.description&&e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#5f6368",lineHeight:1.5},children:m.description})]})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(o.Chip,{label:`Created ${h(m.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"#5f6368","& .MuiChip-label":{px:1}}}),e.jsx(o.Chip,{label:`By ${m.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"#5f6368","& .MuiChip-label":{px:1}}})]}),e.jsx(o.Divider,{sx:{my:1.5,borderColor:"#f1f3f4"}}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Button,{onClick:()=>n(m.id),variant:"outlined",size:"small",startIcon:e.jsx(j.OpenInNew,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:"Open"}),e.jsx(o.Button,{onClick:()=>f(m.id,m.name),variant:"outlined",size:"small",startIcon:l===m.id?e.jsx(j.Check,{sx:{fontSize:16}}):e.jsx(j.ContentCopy,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:l===m.id?"#188038":"#5f6368",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#5f6368",bgcolor:"#f8f9fa"}},children:l===m.id?"Copied!":"Copy link"}),e.jsx(o.Button,{onClick:()=>a(m.id,m.name),variant:"outlined",size:"small",startIcon:e.jsx(j.Delete,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"#d93025",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#d93025",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete"})]})]},m.id))})}),e.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end",display:"flex"},children:e.jsx(o.Button,{onClick:c,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})})}function Sd({totalRows:t,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:a,onExport:c,onClose:l}){const d=Mr(),[f,h]=u.useState(d.export.allowedFormats[0]||"csv"),[m,g]=u.useState("visible"),[y,S]=u.useState("visible"),C=t>5e4,x=m==="visible"?r:t,E=y==="visible"?i:a,s=()=>{c({format:f,scope:m,columnScope:y}),l()},T={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"};return e.jsx(o.Box,{onClick:l,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Export report"}),e.jsx(o.IconButton,{onClick:l,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[C&&e.jsxs(o.Alert,{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"},"& .MuiAlertTitle-root":{fontSize:"0.875rem",fontWeight:500,color:"#3c4043",mb:.5},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"#5f6368"}},children:[e.jsx(o.AlertTitle,{children:"Large dataset warning"}),"This export contains over 50,000 rows. Processing may take a few moments."]}),e.jsxs(o.FormControl,{component:"fieldset",children:[e.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Format"}),e.jsxs(o.RadioGroup,{value:f,onChange:I=>h(I.target.value),children:[d.export.allowedFormats.includes("csv")&&e.jsx(o.FormControlLabel,{value:"csv",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"CSV"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Comma-separated values, compatible with Excel"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),d.export.allowedFormats.includes("excel")&&e.jsx(o.FormControlLabel,{value:"excel",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Excel (.xlsx)"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Native Excel format with formatting support"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),d.export.allowedFormats.includes("json")&&e.jsx(o.FormControlLabel,{value:"json",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"JSON"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Structured data with metadata and filters"})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(o.FormControl,{component:"fieldset",children:[e.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Rows"}),e.jsxs(o.RadioGroup,{value:m,onChange:I=>g(I.target.value),children:[e.jsx(o.FormControlLabel,{value:"visible",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Visible rows"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",r.toLocaleString()," rows (filtered and searched)"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),e.jsx(o.FormControlLabel,{value:"all",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"All rows"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",t.toLocaleString()," rows (complete original dataset)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(o.FormControl,{component:"fieldset",children:[e.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Columns"}),e.jsxs(o.RadioGroup,{value:y,onChange:I=>S(I.target.value),children:[e.jsx(o.FormControlLabel,{value:"visible",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Visible columns only"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",i," visible columns"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),e.jsx(o.FormControlLabel,{value:"all",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"All columns"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export all ",a," columns (including hidden)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(o.Box,{sx:{pt:1},children:[e.jsx(o.Divider,{sx:{mb:2,borderColor:"#e8eaed"}}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Format:"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:T[f]})]}),e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Rows to export:"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:x.toLocaleString()})]}),e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Columns to export:"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:E})]})]})]})]})}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[e.jsx(o.Button,{onClick:l,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),e.jsxs(o.Button,{onClick:s,variant:"contained",startIcon:e.jsx(j.Download,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:["Download ",T[f]]})]})]})})}function Cd({warning:t,onDismiss:r}){return e.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(o.Alert,{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}}),action:e.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:e.jsx(j.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[e.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),e.jsx(o.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:t.message}),e.jsxs(o.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some ",t.type==="filter"?"filters":t.type==="sort"?"sort levels":"grouping levels"," before adding more."]})]})})}function jd({error:t,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=5e3}){u.useEffect(()=>{if(n){const d=setTimeout(()=>{r()},i);return()=>clearTimeout(d)}},[n,i,r]);const c=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(j.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(j.InfoOutlined,{sx:{fontSize:20}})}}})(),l=Js(t);return e.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(o.Alert,{severity:c.severity,icon:c.icon,action:e.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${c.severity}.main`},children:e.jsx(j.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${c.severity}.main`,boxShadow:3},children:[e.jsxs(o.AlertTitle,{sx:{fontWeight:600},children:[t.context.charAt(0).toUpperCase()+t.context.slice(1)," Error"]}),e.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:l}),t.details&&process.env.NODE_ENV==="development"&&e.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(t.details,null,2)})]})})}class wd extends u.Component{constructor(r){super(r),this.handleReset=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,n){console.error("[ErrorBoundary] Caught error:",r,n),this.props.onError&&this.props.onError(r,n)}render(){var r,n;return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx(o.Paper,{sx:{bgcolor:i=>N(i.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(j.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:600},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),e.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((r=this.state.error)==null?void 0:r.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&e.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:i=>N(i.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:160},children:(n=this.state.error)==null?void 0:n.stack}),e.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(j.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function zr({children:t,feature:r,onError:n}){return e.jsx(wd,{context:r,onError:(i,a)=>{n&&n(i)},fallback:e.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(j.Warning,{sx:{fontSize:20}}),children:[e.jsxs(o.AlertTitle,{children:[r," temporarily unavailable"]}),"Other features continue to work normally"]}),children:t})}const Pn=[{value:"equals",label:"Equals",group:"Text"},{value:"contains",label:"Contains",group:"Text"},{value:"startsWith",label:"Starts with",group:"Text"},{value:"endsWith",label:"Ends with",group:"Text"},{value:"gt",label:"Greater than (>)",group:"Numeric"},{value:"lt",label:"Less than (<)",group:"Numeric"},{value:"gte",label:"At least (≥)",group:"Numeric"},{value:"lte",label:"At most (≤)",group:"Numeric"},{value:"isTrue",label:"Is true",group:"Boolean"},{value:"isFalse",label:"Is false",group:"Boolean"},{value:"NULL",label:"Is empty (NULL)",group:"Null checks"},{value:"NOT_NULL",label:"Is not empty",group:"Null checks"}],kd=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"}];function Qe({children:t,type:r}){return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"6px",fontSize:"0.6875rem",fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",bgcolor:r==="constraint"?n=>N(n.palette.error.main,.1):n=>N(n.palette.success.main,.1),color:r==="constraint"?"error.dark":"success.dark"},children:r==="constraint"?"Constraint":"Default"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:t})]})}function Ir({children:t,active:r}){return e.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5},children:t})}function Td({open:t,onClose:r,config:n,onApply:i}){const[a,c]=u.useState(0),[l,d]=u.useState(n),f=()=>d(n),h=()=>d(_e),m=()=>{i(l),r()},g={sort:w=>d(O=>({...O,sort:{...O.sort,...w}})),filter:w=>d(O=>({...O,filter:{...O.filter,...w}})),columns:w=>d(O=>({...O,columns:{...O.columns,...w}})),grouping:w=>d(O=>({...O,grouping:{...O.grouping,...w}})),export:w=>d(O=>({...O,export:{...O.export,...w}}))},y=w=>{const O=l.filter.allowedOperators,V=O.includes(w)?O.filter(X=>X!==w):[...O,w];V.length!==0&&g.filter({allowedOperators:V})},S=w=>{const O=l.export.allowedFormats,V=O.includes(w)?O.filter(X=>X!==w):[...O,w];V.length!==0&&g.export({allowedFormats:V})},C=()=>g.sort({defaultSortStack:[...l.sort.defaultSortStack,{column:"",direction:"asc"}]}),x=w=>g.sort({defaultSortStack:l.sort.defaultSortStack.filter((O,V)=>V!==w)}),E=(w,O,V)=>{const X=[...l.sort.defaultSortStack];X[w]={...X[w],[O]:V},g.sort({defaultSortStack:X})},s=()=>g.filter({defaultFilters:[...l.filter.defaultFilters,{column:"",operator:"equals",value:""}]}),T=w=>g.filter({defaultFilters:l.filter.defaultFilters.filter((O,V)=>V!==w)}),I=(w,O,V)=>{const X=[...l.filter.defaultFilters];X[w]={...X[w],[O]:V},g.filter({defaultFilters:X})},A=()=>{const w=l.grouping.defaultGrouping||[];w.length>=l.grouping.maxLevels||g.grouping({defaultGrouping:[...w,{column:""}]})},v=w=>{const V=(l.grouping.defaultGrouping||[]).filter((X,p)=>p!==w);g.grouping({defaultGrouping:V.length?V:null})},W=(w,O)=>{const V=[...l.grouping.defaultGrouping||[]];V[w]={column:O},g.grouping({defaultGrouping:V})},U=[{label:"Sort",icon:e.jsx(j.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(j.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(j.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(j.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(j.Download,{sx:{fontSize:17}})}];return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:f},PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(720px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(60,64,67,0.2), 0 2px 8px rgba(60,64,67,0.12)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Box,{sx:{width:28,height:28,borderRadius:"6px",bgcolor:w=>N(w.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(o.Typography,{sx:{fontSize:"1rem"},children:"⚙️"})}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Constraints · Defaults · Ctrl+Shift+D"})]})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(o.Tabs,{value:a,onChange:(w,O)=>c(O),variant:"fullWidth",sx:{minHeight:42,"& .MuiTab-root":{minHeight:42,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:U.map((w,O)=>e.jsx(o.Tab,{label:w.label,icon:w.icon,iconPosition:"start"},O))})}),e.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Ir,{active:a===0,children:[e.jsx(Qe,{type:"constraint",children:"Max sort levels"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[e.jsx(o.Slider,{value:l.sort.maxLevels,onChange:(w,O)=>g.sort({maxLevels:O}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on",sx:{flex:1}}),e.jsx(o.Chip,{label:l.sort.maxLevels===_e.sort.maxLevels?"Default":"Custom",size:"small",color:l.sort.maxLevels===_e.sort.maxLevels?"default":"primary",sx:{minWidth:68}})]}),e.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Users can sort by at most ",l.sort.maxLevels," column",l.sort.maxLevels!==1?"s":""," simultaneously."]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default sort on load"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"These sort rules are applied automatically when a report first loads. Use exact column key names."}),l.sort.defaultSortStack.map((w,O)=>e.jsxs(o.Box,{sx:{display:"flex",gap:1,mb:1,alignItems:"center"},children:[e.jsx(o.TextField,{size:"small",label:"Column name",value:w.column,onChange:V=>E(O,"column",V.target.value),sx:{flex:1}}),e.jsxs(o.FormControl,{size:"small",sx:{minWidth:130},children:[e.jsx(o.InputLabel,{children:"Direction"}),e.jsxs(o.Select,{value:w.direction,label:"Direction",onChange:V=>E(O,"direction",V.target.value),children:[e.jsx(o.MenuItem,{value:"asc",children:"Ascending ↑"}),e.jsx(o.MenuItem,{value:"desc",children:"Descending ↓"})]})]}),e.jsx(o.IconButton,{size:"small",onClick:()=>x(O),sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]},O)),l.sort.defaultSortStack.length<l.sort.maxLevels&&e.jsx(o.Button,{startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",onClick:C,sx:{textTransform:"none",fontSize:"0.8125rem",mt:.5},children:"Add default sort level"})]}),e.jsxs(Ir,{active:a===1,children:[e.jsx(Qe,{type:"constraint",children:"Max filter conditions"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[e.jsx(o.Slider,{value:l.filter.maxConditions,onChange:(w,O)=>g.filter({maxConditions:O}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on",sx:{flex:1}}),e.jsx(o.Chip,{label:l.filter.maxConditions===_e.filter.maxConditions?"Default":"Custom",size:"small",color:l.filter.maxConditions===_e.filter.maxConditions?"default":"primary",sx:{minWidth:68}})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"constraint",children:"Allowed operators"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(w=>e.jsxs(o.Box,{sx:{mb:1.5},children:[e.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:w}),e.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:Pn.filter(O=>O.group===w).map(O=>e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{size:"small",checked:l.filter.allowedOperators.includes(O.value),onChange:()=>y(O.value)}),label:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:O.label}),sx:{mr:1.5}},O.value))})]},w)),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default filters on load"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"These filters are pre-applied when a report first loads. Use exact column key names."}),l.filter.defaultFilters.map((w,O)=>e.jsxs(o.Box,{sx:{display:"flex",gap:1,mb:1,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(o.TextField,{size:"small",label:"Column",value:w.column,onChange:V=>I(O,"column",V.target.value),sx:{flex:1,minWidth:120}}),e.jsxs(o.FormControl,{size:"small",sx:{minWidth:130},children:[e.jsx(o.InputLabel,{children:"Operator"}),e.jsx(o.Select,{value:w.operator,label:"Operator",onChange:V=>I(O,"operator",V.target.value),children:Pn.map(V=>e.jsx(o.MenuItem,{value:V.value,children:V.label},V.value))})]}),e.jsx(o.TextField,{size:"small",label:"Value",value:w.value||"",onChange:V=>I(O,"value",V.target.value),sx:{flex:1,minWidth:100}}),e.jsx(o.IconButton,{size:"small",onClick:()=>T(O),sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]},O)),l.filter.defaultFilters.length<l.filter.maxConditions&&e.jsx(o.Button,{startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",onClick:s,sx:{textTransform:"none",fontSize:"0.8125rem",mt:.5},children:"Add default filter"})]}),e.jsxs(Ir,{active:a===2,children:[e.jsx(Qe,{type:"constraint",children:"Max visible columns"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:.5},children:[e.jsx(o.Slider,{value:l.columns.maxVisible,onChange:(w,O)=>g.columns({maxVisible:O}),min:1,max:50,step:1,valueLabelDisplay:"on",sx:{flex:1}}),e.jsx(o.Chip,{label:l.columns.maxVisible===_e.columns.maxVisible?"Default":"Custom",size:"small",color:l.columns.maxVisible===_e.columns.maxVisible?"default":"primary",sx:{minWidth:68}})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"constraint",children:"Column width range (px)"}),e.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[e.jsx(o.TextField,{label:"Min width",type:"number",size:"small",value:l.columns.minColumnWidth,onChange:w=>g.columns({minColumnWidth:Math.max(40,Math.min(400,Number(w.target.value)))}),inputProps:{min:40,max:400,step:10},sx:{flex:1}}),e.jsx(o.TextField,{label:"Max width",type:"number",size:"small",value:l.columns.maxColumnWidth,onChange:w=>g.columns({maxColumnWidth:Math.max(100,Math.min(2e3,Number(w.target.value)))}),inputProps:{min:100,max:2e3,step:50},sx:{flex:1}})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default hidden columns"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1},children:"Comma-separated exact column key names to hide on first load."}),e.jsx(o.TextField,{size:"small",fullWidth:!0,multiline:!0,rows:2,placeholder:"e.g. id, created_at, internal_notes",value:l.columns.defaultHiddenColumns.join(", "),onChange:w=>g.columns({defaultHiddenColumns:w.target.value.split(",").map(O=>O.trim()).filter(Boolean)})}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default column order"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1},children:"Comma-separated column key names in display order. Omitted columns appear at the end."}),e.jsx(o.TextField,{size:"small",fullWidth:!0,multiline:!0,rows:2,placeholder:"e.g. name, status, assignee, due_date",value:l.columns.defaultColumnOrder.join(", "),onChange:w=>g.columns({defaultColumnOrder:w.target.value.split(",").map(O=>O.trim()).filter(Boolean)})})]}),e.jsxs(Ir,{active:a===3,children:[e.jsx(Qe,{type:"constraint",children:"Max group levels"}),e.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:1},children:[1,2,3].map(w=>e.jsxs(o.Box,{onClick:()=>g.grouping({maxLevels:w}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",borderColor:l.grouping.maxLevels===w?"primary.main":"divider",bgcolor:l.grouping.maxLevels===w?O=>N(O.palette.primary.main,.06):"transparent",textAlign:"center",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light"}},children:[e.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:l.grouping.maxLevels===w?"primary.main":"text.secondary"},children:w}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][w-1]})]},w))}),e.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:l.grouping.allowNested,onChange:w=>g.grouping({allowNested:w.target.checked})}),label:e.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:l.grouping.allowCollapse,onChange:w=>g.grouping({allowCollapse:w.target.checked})}),label:e.jsx(o.Typography,{variant:"body2",children:"Allow collapse/expand"})})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default grouping on load"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"These group levels are applied automatically on first load. Use exact column key names."}),(l.grouping.defaultGrouping||[]).map((w,O)=>e.jsxs(o.Box,{sx:{display:"flex",gap:1,mb:1,alignItems:"center"},children:[e.jsx(o.Chip,{label:`L${O+1}`,size:"small",color:"primary",sx:{minWidth:36,fontWeight:700}}),e.jsx(o.TextField,{size:"small",label:"Column name",value:w.column,onChange:V=>W(O,V.target.value),sx:{flex:1}}),e.jsx(o.IconButton,{size:"small",onClick:()=>v(O),sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]},O)),(l.grouping.defaultGrouping||[]).length<l.grouping.maxLevels&&e.jsx(o.Button,{startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",onClick:A,sx:{textTransform:"none",fontSize:"0.8125rem",mt:.5},children:"Add default group level"})]}),e.jsxs(Ir,{active:a===4,children:[e.jsx(Qe,{type:"constraint",children:"Allowed export formats"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog. At least one must remain checked."}),e.jsx(o.FormGroup,{sx:{gap:1},children:kd.map(w=>e.jsxs(o.Box,{onClick:()=>S(w.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(w.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(w.value)?O=>N(O.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(o.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(w.value),onChange:()=>S(w.value),onClick:O=>O.stopPropagation()}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:w.label}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:w.desc})]})]},w.value))}),e.jsx(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem",mt:1},children:'Export constraints apply to both the Export dialog and the bulk "Export Selected" action bar.'})]})]}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:w=>N(w.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(o.Button,{startIcon:e.jsx(j.RestartAlt,{sx:{fontSize:18}}),onClick:h,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:w=>N(w.palette.text.primary,.06)}},children:"Reset to defaults"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Button,{onClick:r,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(o.Button,{onClick:m,size:"small",variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}function vi({reportEngine:t}){var Ot,_r;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:a,tableEngine:c,activeView:l,isDirty:d,currentTableState:f,viewChanges:h,showFilterPanel:m,setShowFilterPanel:g,filterFocusColumn:y,handleAddFilter:S,handleUpdateFilter:C,handleRemoveFilter:x,handleClearAllFilters:E,handleOpenFilterForColumn:s,handleCloseFilterPanel:T,handleClearFiltersForColumn:I,showSortPanel:A,setShowSortPanel:v,handleSort:W,handleUpdateSortStack:U,handleSortAscending:w,handleSortDescending:O,showManageViews:V,setShowManageViews:X,showCreateViewModal:p,setShowCreateViewModal:L,showEditViewModal:$,setShowEditViewModal:_,showDeleteConfirmation:F,setShowDeleteConfirmation:oe,editingView:ue,deletingView:Ee,handleSelectView:R,handleCreateView:q,handleUpdateCurrentView:ee,handleSaveColumnConfigToCurrentView:te,handleSaveColumnConfigToAllViews:re,handleSaveAsNewView:ne,handleRevertChanges:Z,handleToggleDefault:Q,handleToggleFavorite:ae,handleSoftDelete:ce,handleRestoreView:le,handlePermanentDelete:je,handleEditView:G,handleSaveEditView:Me,handleConfirmDelete:Ye,showManageColumns:jt,setShowManageColumns:tt,handleUpdateColumnVisibility:$e,handleUpdateColumnOrder:Je,handleUpdateColumnWidth:Ae,handleResetColumnLayout:wt,showGroupPanel:Yt,setShowGroupPanel:pt,handleGroup:rt,handleToggleGroupCollapse:kt,searchQuery:Tt,searchHistory:ft,handleSearchChange:Fe,handleAddToSearchHistory:qe,handleToggleSearchFavourite:Jt,handleDeleteSearchHistory:Be,selectedRowIds:zt,handleToggleRowSelection:Ke,handleToggleAllRows:ot,handleRangeSelection:qt,handleClearSelection:xt,currentPage:Pr,pageSize:mr,paginationEngine:nt,handlePageChange:_t,handlePageSizeChange:gr,isExporting:$t,showExportModal:It,setShowExportModal:Ce,showDirtyExportWarning:Et,handleExport:yr,handleExportWithConfig:Ve,handleExportSelected:P,handleExportAnyway:He,handleSaveAndExport:de,handleCancelExport:Re,showAuditHistory:br,setShowAuditHistory:Ft,showCreatePreset:Bt,setShowCreatePreset:Lt,showShareLink:Nt,setShowShareLink:ht,showManagePresets:Kt,setShowManagePresets:Vt,generatedPreset:ie,activePreset:H,handleOpenSharePreset:it,handleOpenManagePresets:xe,handleCreatePreset:Le,handleCopyPresetLink:Xt,handleOpenPreset:vr,handleDeletePreset:Qt,handleClearActivePreset:Zt,handleOpenPresetById:Ne,handleCopyPresetLinkById:st,handleDeletePresetById:er,isViewerRole:mt,userRole:Sr,featureLimitWarning:tr,setFeatureLimitWarning:rr,reportError:or,setReportError:Cr,handleError:gt,updateReport:at,showSnack:nr,favoriteRowIndices:ir,resolvedFavoritesSet:sr,showFavoritesOnly:We,handleToggleRowFavorite:ar,handleBulkSetFavorites:jr,handleToggleFavoritesFilter:Dt}=t,wr=u.useCallback((ke,Te)=>{if(!(r!=null&&r.uploadedData))return;const At=[...r.uploadedData];At[ke]=Te,at(r.id,{uploadedData:At})},[r,at]),lr=u.useCallback(ke=>{if(!(r!=null&&r.uploadedData))return;const Te=r.uploadedData.filter((At,po)=>po!==ke);at(r.id,{uploadedData:Te})},[r,at]),D=u.useCallback((ke,Te)=>{if(!(r!=null&&r.uploadedData))return;const At=[...r.uploadedData];At.splice(ke+1,0,{...Te}),at(r.id,{uploadedData:At})},[r,at]);if(!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views)return null;const Y=Mr(),{handleDevConfigChange:pe}=Kr(),[Pe,se]=u.useState(!1);return u.useEffect(()=>{const ke=Te=>{Te.ctrlKey&&Te.shiftKey&&Te.key==="D"&&(Te.preventDefault(),se(!0))};return document.addEventListener("keydown",ke),()=>document.removeEventListener("keydown",ke)},[]),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:[!mt&&d&&l&&e.jsx(xd,{viewName:l.name,isDefaultView:l.isDefault,changes:h,onSaveToCurrentView:l.isDefault?void 0:ee,onSaveAsNewView:ne,onCancel:Z}),e.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",position:"relative"},children:[tr&&e.jsx(Cd,{warning:tr,onDismiss:()=>rr(null)}),or&&e.jsx(jd,{error:or,onDismiss:()=>Cr(null)}),Et&&e.jsx(hd,{onExportAnyway:He,onSaveAndExport:de,onCancel:Re}),e.jsx(od,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:d,isExporting:$t,columnVisibility:r.columnVisibility||(l==null?void 0:l.snapshot.columnVisibility),columnOrder:r.columnOrder||(l==null?void 0:l.snapshot.columnOrder),columnWidths:r.columnWidths||(l==null?void 0:l.snapshot.columnWidths),grouping:r.grouping,onSort:W,onSortAscending:w,onSortDescending:O,onOpenFilters:()=>g(!0),onOpenSort:()=>v(!0),onOpenFilterForColumn:s,onSelectView:R,onCreateView:()=>L(!0),onManageViews:()=>X(!0),onUpdateCurrentView:ee,onSaveAsNewView:ne,onToggleDefault:Q,onToggleFavorite:ae,onRestoreView:le,onPermanentDelete:je,onExport:yr,onOpenColumns:()=>tt(!0),onUpdateColumnWidth:Ae,onUpdateColumnOrder:Je,onUpdateColumnVisibility:$e,onClearFiltersForColumn:I,onResetLayout:wt,onOpenGroup:()=>pt(!0),onToggleGroupCollapse:kt,onOpenAuditHistory:()=>Ft(!0),onOpenSharePreset:it,searchQuery:Tt,searchHistory:ft,onAddToSearchHistory:qe,onToggleSearchFavourite:Jt,onDeleteSearchHistory:Be,selectedRowIds:zt,onSearchChange:Fe,onToggleRowSelection:Ke,onToggleAllRows:ot,onRangeSelection:qt,onClearSelection:xt,onExportSelected:P,currentPage:(nt==null?void 0:nt.currentPage)||Pr,pageSize:(nt==null?void 0:nt.pageSize)||mr,onPageChange:_t,onPageSizeChange:gr,totalRowsBeforePagination:(a==null?void 0:a.searchedRows)||i.length,isReadOnly:mt,userRole:Sr,reportName:r.name,onEditRow:wr,onDeleteRow:lr,onDuplicateRow:D,favoriteRowIndices:ir,resolvedFavoritesSet:sr,showFavoritesOnly:We,onToggleRowFavorite:ar,onBulkSetFavorites:jr,onToggleFavoritesFilter:Dt,showDevPanel:Y.display.showDevPanel,onOpenDevConfig:()=>se(!0)})]}),m&&e.jsx(zr,{feature:"Filters",onError:ke=>{const Te=bt("ui","filters",ke);gt(Te)},children:e.jsx(nd,{schema:r.schema,filters:r.filters??[],onAddFilter:S,onUpdateFilter:C,onRemoveFilter:x,onClearAll:E,onClose:T,focusColumn:y})}),A&&e.jsx(zr,{feature:"Sorting",onError:ke=>{const Te=bt("ui","sorting",ke);gt(Te)},children:e.jsx(sd,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:U,onClose:()=>v(!1)})}),V&&e.jsx(zr,{feature:"Views",onError:ke=>{const Te=bt("ui","views",ke);gt(Te)},children:e.jsx(ad,{views:r.views,activeViewId:r.activeViewId??"",onSelectView:R,onCreateView:()=>{X(!1),L(!0)},onEditView:G,onDeleteView:ce,onRestoreView:le,onPermanentDelete:je,onClose:()=>X(!1)})}),p&&f&&e.jsx(Rn,{currentSnapshot:f,onSave:q,onClose:()=>L(!1)}),$&&ue&&e.jsx(Rn,{currentSnapshot:ue.snapshot,onSave:Me,onClose:()=>{_(!1)},isEditMode:!0,initialName:ue.name,initialDescription:ue.description,initialIsDefault:ue.isDefault}),F&&Ee&&e.jsx(ld,{viewName:Ee.name,onConfirm:Ye,onCancel:()=>{oe(!1)}}),jt&&l&&e.jsx(dd,{schema:r.schema,columnVisibility:r.columnVisibility||l.snapshot.columnVisibility,columnOrder:r.columnOrder||l.snapshot.columnOrder,columnWidths:r.columnWidths||l.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:$e,onUpdateColumnOrder:Je,onUpdateColumnWidth:Ae,onResetLayout:wt,onSelectView:ke=>{R(ke)},onSaveToCurrentView:()=>{te(),tt(!1)},onSaveToAllViews:()=>{re(),tt(!1)},onClose:()=>tt(!1)}),Yt&&e.jsx(zr,{feature:"Grouping",onError:ke=>{const Te=bt("ui","grouping",ke);gt(Te)},children:e.jsx(ud,{schema:r.schema,grouping:r.grouping||null,onApply:rt,onClose:()=>pt(!1)})}),br&&e.jsx(md,{auditHistory:r.auditHistory||[],onClose:()=>Ft(!1)}),Bt&&e.jsx(gd,{onSave:Le,onClose:()=>Lt(!1)}),Nt&&ie&&e.jsx(yd,{presetName:ie.preset.name,shareUrl:ie.url,onCopyLink:Xt,onOpenPreset:vr,onDeletePreset:Qt,onClose:()=>{ht(!1)}}),Kt&&e.jsx(vd,{presets:r.presets||[],reportId:r.id,onOpenPreset:Ne,onCopyLink:st,onDeletePreset:er,onClose:()=>Vt(!1)}),H&&e.jsx(o.Box,{sx:{mt:2},children:e.jsx(bd,{presetName:H.name,onClear:Zt})}),It&&e.jsx(zr,{feature:"Export",onError:ke=>{const Te=bt("ui","export",ke);gt(Te)},children:e.jsx(Sd,{totalRows:(a==null?void 0:a.totalRows)||((Ot=r.uploadedData)==null?void 0:Ot.length)||0,visibleRows:(a==null?void 0:a.searchedRows)||i.length,visibleColumnsCount:((_r=c==null?void 0:c.columnEngine)==null?void 0:_r.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(a==null?void 0:a.isGrouped)||!1,onExport:Ve,onClose:()=>{Ce(!1)}})}),e.jsx(Td,{open:Pe,onClose:()=>se(!1),config:Y,onApply:pe})]})}function Si({open:t,message:r,severity:n,onClose:i}){return e.jsx(o.Snackbar,{open:t,autoHideDuration:4e3,onClose:i,anchorOrigin:{vertical:"top",horizontal:"right"},children:e.jsx(o.Alert,{onClose:i,severity:n,variant:"filled",sx:{width:"100%",boxShadow:3},children:r})})}function Ci(){const t=Kr(),{reports:r,activeReportId:n,activeReport:i,uploadState:a,schema:c,hasSchemaConflicts:l,isModalOpen:d,setIsModalOpen:f,setActiveReportId:h,createReport:m,handleFileUpload:g,handleUploadError:y,handleRetry:S,handleConfirm:C,snack:x,handleSnackClose:E}=t;return e.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(ha,{onCreateReport:()=>f(!0),reports:r,activeReportId:n,onReportClick:h}),e.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:r.length===0?e.jsx(gi,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):i?e.jsx(e.Fragment,{children:i.schemaLocked&&i.schema&&i.uploadedData&&i.views?e.jsx(vi,{reportEngine:t}):e.jsx(o.Box,{sx:{p:3},children:a==="preview"&&i.schema&&i.uploadedData?e.jsx(Tc,{schema:i.schema,onConfirm:C,hasConflicts:l}):i.uploadError?e.jsx(zc,{error:i.uploadError,onRetry:S}):e.jsx(kc,{onFileUpload:g,onError:y,isUploading:a==="uploading"})})}):null}),e.jsx(wc,{isOpen:d,onClose:()=>f(!1),onCreate:m}),e.jsx(Si,{open:x.open,message:x.message,severity:x.severity,onClose:E})]})}function zd(){return e.jsx(Bo,{children:e.jsx(Ci,{})})}function ji(){const t=Kr(),{snack:r,handleSnackClose:n}=t;return e.jsxs(o.Box,{sx:{minHeight:"100vh"},children:[e.jsx(o.Box,{component:"main",children:t.activeReport?e.jsx(vi,{reportEngine:t}):e.jsx(gi,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(Si,{open:r.open,message:r.message,severity:r.severity,onClose:n})]})}function Id({data:t,autoLoad:r=!0,config:n}){return e.jsx(Bo,{data:t,mode:"viewer",autoLoad:r,config:n,children:e.jsx(ji,{})})}exports.URMBuilder=zd;exports.URMBuilderRaw=Ci;exports.URMProvider=Bo;exports.URMViewer=Id;exports.URMViewerRaw=ji;exports.useURMContext=Kr;
|
|
115
|
+
]`})})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Number:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),", ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Boolean:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),", ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"String:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),", ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Date:"}),e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g., ",e.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),e.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[e.jsx("li",{children:"Each object in the array represents one row in the report."}),e.jsx("li",{children:"The keys of the JSON objects become report columns."}),e.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),e.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),e.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Got it"})})]}):null}function kc({onFileUpload:t,onError:r,isUploading:n}){const[i,a]=u.useState(!1),[c,l]=u.useState(""),[d,f]=u.useState(!1),h=u.useRef(null),m=async s=>{if(!s.name.endsWith(".json")){r("Please upload a valid JSON file");return}l(s.name);try{const T=await s.text(),I=JSON.parse(T);if(!Array.isArray(I)){r("JSON must be an array of objects");return}if(I.length===0){r("JSON array is empty");return}t(I)}catch{r("Invalid JSON format. Please check your file and try again.")}finally{l("")}},g=s=>{s.preventDefault(),a(!0)},y=s=>{s.preventDefault(),a(!1)},S=s=>{s.preventDefault(),a(!1);const T=s.dataTransfer.files[0];T&&m(T)},C=()=>{var s;(s=h.current)==null||s.click()},x=s=>{var I;const T=(I=s.target.files)==null?void 0:I[0];T&&m(T)},E=s=>{s.stopPropagation(),f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{onDragOver:g,onDragLeave:y,onDrop:S,onClick:C,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?s=>N(s.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[e.jsx(o.Box,{component:"input",ref:h,type:"file",accept:".json",onChange:x,sx:{display:"none"}}),n?e.jsxs(e.Fragment,{children:[e.jsx(o.CircularProgress,{size:32,sx:{mb:2}}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:.5},children:"Uploading..."}),c&&e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:c})]}):e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:s=>N(s.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(j.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),e.jsx(o.IconButton,{onClick:E,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(j.InfoOutlined,{sx:{fontSize:16}})})]}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),e.jsx(mi,{isOpen:d,onClose:()=>f(!1)})]})}function Tc({schema:t,onConfirm:r,hasConflicts:n}){return e.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[e.jsxs(o.Box,{sx:{mb:2},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontWeight:600,mb:.5},children:"Schema Preview"}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&e.jsxs(o.Alert,{severity:"warning",sx:{mb:2},children:[e.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),e.jsx(o.TableContainer,{sx:{mb:3},children:e.jsxs(o.Table,{children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{sx:{bgcolor:"action.hover"},children:[e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),e.jsx(o.TableBody,{children:t.map(i=>e.jsxs(o.TableRow,{sx:{bgcolor:i.hasConflict?a=>N(a.palette.warning.main,.12):"transparent"},children:[e.jsxs(o.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&e.jsx(o.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),e.jsx(o.TableCell,{children:e.jsx(o.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),e.jsx(o.TableCell,{children:e.jsx(o.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(j.Lock,{sx:{fontSize:16}}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),e.jsx(o.Button,{variant:"contained",onClick:r,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function zc({error:t,onRetry:r}){return e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>N(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[e.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>N(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(j.ErrorOutline,{color:"error",sx:{fontSize:32}})}),e.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:600,mb:1},children:"Upload Failed"}),e.jsx(o.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:t}),e.jsx(o.Button,{variant:"contained",color:"error",startIcon:e.jsx(j.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function gi({title:t,description:r,showIcon:n=!0}){return e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&e.jsx(o.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>N(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(j.Description,{sx:{fontSize:36,color:"primary.main"}})}),e.jsx(o.Typography,{variant:"h5",sx:{fontWeight:500,mb:1,color:"text.primary",fontSize:"1.125rem"},children:t}),e.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:"0.875rem",lineHeight:1.5},children:r})]})}function Ic({value:t,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:a,onDeleteHistory:c,disabled:l}){const[d,f]=u.useState(!1),[h,m]=u.useState(!1),[g,y]=u.useState(-1),S=u.useRef(null),C=u.useRef(null);u.useEffect(()=>{function w(O){S.current&&!S.current.contains(O.target)&&(f(!1),m(!1))}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const x=u.useCallback(()=>{m(!0),y(-1),n.length>0&&f(!0)},[n.length]),E=u.useCallback(w=>{r(w),y(-1)},[r]),s=u.useCallback(w=>{var O;r(w),i(w),f(!1),(O=C.current)==null||O.blur()},[r,i]),T=u.useCallback(w=>{y(-1),s(w)},[s]),I=u.useCallback(w=>{var O;w.key==="Enter"?g>=0&&g<n.length?(w.preventDefault(),T(n[g].query)):t.trim()&&s(t.trim()):w.key==="Escape"?(f(!1),y(-1),(O=C.current)==null||O.blur()):w.key==="ArrowDown"?(w.preventDefault(),n.length>0&&(d||f(!0),y(V=>V<n.length-1?V+1:V))):w.key==="ArrowUp"&&(w.preventDefault(),y(V=>V>0?V-1:-1))},[g,n,t,d,T,s]),A=u.useCallback(()=>{var w;r(""),(w=C.current)==null||w.focus()},[r]),v=u.useMemo(()=>n.filter(w=>w.isFavourite),[n]),W=u.useMemo(()=>n.filter(w=>!w.isFavourite),[n]),U=d&&n.length>0;return e.jsxs(o.Box,{sx:{position:"relative",width:240},ref:S,children:[e.jsx(o.TextField,{inputRef:C,size:"small",fullWidth:!0,value:t,onChange:w=>E(w.target.value),onFocus:x,onKeyDown:I,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"#ffffff",height:"36px","& fieldset":{borderColor:"#dadce0",transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:"#dadce0"},"&.Mui-focused":{bgcolor:"#ffffff"},"&.Mui-focused fieldset":{borderColor:"#2932e5",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px"}},InputProps:{startAdornment:e.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:e.jsx(j.Search,{sx:{fontSize:18,color:"#5f6368"}})}),endAdornment:t?e.jsx(o.InputAdornment,{position:"end",children:e.jsx(o.IconButton,{size:"small",onClick:A,edge:"end",sx:{mr:-.5},children:e.jsx(j.Close,{sx:{fontSize:16}})})}):null}}),U&&e.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[v.length>0&&e.jsxs(o.Box,{sx:{py:1},children:[e.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),v.map((w,O)=>e.jsx(Dn,{entry:w,isSelected:g===O,onClick:()=>T(w.query),onToggleFavourite:()=>a(w.query),onDelete:()=>c(w.query)},`fav-${w.query}`))]}),W.length>0&&e.jsxs(o.Box,{sx:{py:1},children:[v.length>0&&e.jsx(o.Divider,{}),e.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),W.map((w,O)=>{const V=v.length+O;return e.jsx(Dn,{entry:w,isSelected:g===V,onClick:()=>T(w.query),onToggleFavourite:()=>a(w.query),onDelete:()=>c(w.query)},`recent-${w.query}`)})]})]})]})}const Dn=u.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:a,onDelete:c}){const l=u.useCallback(f=>{f.stopPropagation(),a()},[a]),d=u.useCallback(f=>{f.stopPropagation(),c()},[c]);return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?f=>N(f.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?f=>N(f.palette.primary.main,.12):"action.hover"}},children:[e.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:e.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[e.jsx(o.IconButton,{size:"small",onClick:l,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?e.jsx(j.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(j.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(o.IconButton,{size:"small",onClick:d,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(j.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function Ec({views:t,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:a,onManageViews:c,onToggleDefault:l,onToggleFavorite:d,onRestoreView:f,onPermanentDelete:h,isReadOnly:m}){const g=jc(),[y,S]=u.useState(!1),[C,x]=u.useState(!1),[E,s]=u.useState({top:0,left:0}),T=u.useRef(null),I=u.useRef(null),A=t.find(_=>_.id===r),v=A==null?void 0:A.isDefault,W=t.filter(_=>_.isDefault&&!_.isDeleted),U=t.filter(_=>!_.isDefault&&!_.isDeleted).sort((_,F)=>(F.updatedAt||0)-(_.updatedAt||0)),w=t.filter(_=>_.isFavorite&&!_.isDeleted).sort((_,F)=>(F.updatedAt||0)-(_.updatedAt||0)),O=t.filter(_=>_.isDeleted);u.useEffect(()=>{if(y&&I.current){const _=I.current.getBoundingClientRect();s({top:_.bottom+window.scrollY+8,left:_.right+window.scrollX-320})}},[y]),u.useEffect(()=>{const _=F=>{T.current&&!T.current.contains(F.target)&&I.current&&!I.current.contains(F.target)&&S(!1)};return y&&document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[y]);const V=_=>{i(_),S(!1)},X=(_,F=!1)=>e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===_.id?g.palette.primary.light+"20":"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===_.id?g.palette.primary.light+"20":g.palette.grey[50]}},children:[e.jsxs(o.Button,{onClick:()=>V(_.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,textTransform:"none",justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[r===_.id&&e.jsx(j.Check,{sx:{fontSize:16,flexShrink:0}}),r!==_.id&&e.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===_.id?g.palette.primary.dark:g.palette.text.primary,fontWeight:r===_.id?500:400},children:_.name}),F&&e.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:g.palette.text.secondary,backgroundColor:g.palette.grey[100],px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[d&&e.jsx(o.IconButton,{onClick:oe=>{oe.stopPropagation(),d(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:_.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(j.Star,{sx:{fontSize:16}})}),l&&!_.isDefault&&e.jsx(o.IconButton,{onClick:oe=>{oe.stopPropagation(),l(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:"Set as default",children:e.jsx(j.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},_.id),p=_=>e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:g.palette.grey[50]},children:[e.jsx(o.Typography,{sx:{color:g.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:_.name}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[f&&e.jsx(o.IconButton,{onClick:F=>{F.stopPropagation(),f(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:"Restore view",children:e.jsx(j.Undo,{sx:{fontSize:16,color:"success.main"}})}),h&&e.jsx(o.IconButton,{onClick:F=>{F.stopPropagation(),h(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[200]}},title:"Delete permanently",children:e.jsx(j.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},_.id),L=n||!v,$=n;return e.jsxs(o.Box,{sx:{position:"relative"},children:[e.jsxs(o.IconButton,{ref:I,onClick:()=>S(!y),size:"small",sx:{position:"relative",color:L?"warning.main":"text.secondary",bgcolor:L?N(g.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:L?N(g.palette.warning.main,.2):N(g.palette.text.primary,.06),color:L?"warning.dark":"text.primary"}},title:`View: ${(A==null?void 0:A.name)||"Default View"}`,children:[e.jsx(j.Visibility,{sx:{fontSize:20}}),$&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),y&&_n.createPortal(e.jsxs(o.Box,{ref:T,sx:{position:"fixed",width:"320px",backgroundColor:g.palette.background.paper,border:`1px solid ${g.palette.divider}`,borderRadius:1,boxShadow:g.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:E.top,left:E.left},children:[W.length>0&&e.jsxs(o.Box,{sx:{py:.5},children:[e.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Default Views"}),W.map(_=>X(_,!0))]}),w.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Box,{sx:{py:.5},children:[e.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(j.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),w.map(_=>X(_))]})]}),U.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Box,{sx:{py:.5},children:[e.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom Views"}),U.map(_=>X(_))]})]}),O.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Box,{sx:{py:.5},children:[e.jsxs(o.Button,{onClick:()=>x(!C),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:g.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[50]}},children:[e.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",O.length,")"]}),e.jsx(j.ChevronRight,{sx:{fontSize:16}})]}),C&&e.jsx(o.Box,{sx:{backgroundColor:g.palette.grey[50]},children:O.map(_=>p(_))})]})]}),e.jsx(o.Box,{sx:{borderTop:`1px solid ${g.palette.divider}`}}),e.jsxs(o.Button,{onClick:()=>{a(),S(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:g.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[50]}},children:[e.jsx(j.Add,{sx:{fontSize:16}}),e.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(o.Button,{onClick:()=>{c(),S(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:g.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:g.palette.grey[50]}},children:[e.jsx(j.Settings,{sx:{fontSize:16}}),e.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body)]})}function Bc({columnName:t,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:a,position:c,onSort:l,onRemoveSort:d,onSortAscending:f,onSortDescending:h,onFilter:m,onClearFilter:g,onHideColumn:y,onManageColumns:S,onManageViews:C,onResetLayout:x,onClose:E}){const s=u.useRef(null);u.useEffect(()=>{const I=v=>{s.current&&!s.current.contains(v.target)&&E()},A=v=>{v.key==="Escape"&&E()};return document.addEventListener("mousedown",I),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",I),document.removeEventListener("keydown",A)}},[E]);const T=()=>n?n.direction==="asc"?r==="number"?"(0→9)":r==="boolean"?"(False→True)":"(A→Z)":r==="number"?"(9→0)":r==="boolean"?"(True→False)":"(Z→A)":"";return _n.createPortal(e.jsxs(o.Paper,{ref:s,sx:{position:"fixed",left:`${c.x}px`,top:`${c.y}px`,zIndex:100,minWidth:240},elevation:3,children:[e.jsxs(o.Box,{sx:{px:2,py:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:"Sorting"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(o.IconButton,{size:"small",onClick:()=>{f?f(t):(n==null?void 0:n.direction)!=="asc"&&(l(t),(n==null?void 0:n.direction)==="desc"&&setTimeout(()=>l(t),0))},title:"Sort Ascending",sx:{p:.75},children:e.jsx(j.ArrowUpward,{color:(n==null?void 0:n.direction)==="asc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>{h?h(t):n?n.direction==="asc"&&l(t):(l(t),setTimeout(()=>l(t),0))},title:"Sort Descending",sx:{p:.75},children:e.jsx(j.ArrowDownward,{color:(n==null?void 0:n.direction)==="desc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>d(t),title:"Clear sorting",disabled:!n,sx:{p:.75,"&:hover":{color:"error.main"}},children:e.jsx(j.Close,{sx:{fontSize:16}})})]})]}),n&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5},children:[e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:T()}),e.jsx(o.Chip,{label:`Level ${n.priority}`,size:"small",color:"primary",sx:{height:20,fontSize:"caption.fontSize"}})]})]}),e.jsx(o.Divider,{}),e.jsxs(o.MenuList,{dense:!0,children:[e.jsxs(o.MenuItem,{onClick:()=>{m(t),E()},children:[e.jsx(j.FilterList,{sx:{fontSize:16,mr:1}}),"Filter this column",i&&e.jsx(o.Chip,{label:"Active",size:"small",color:"primary",sx:{ml:"auto",height:20,fontSize:"caption.fontSize"}})]}),i&&e.jsxs(o.MenuItem,{onClick:()=>{g(t),E()},sx:{color:"warning.main"},children:[e.jsx(j.FilterListOff,{sx:{fontSize:16,mr:1}}),"Clear Filters"]})]}),e.jsx(o.Divider,{}),e.jsx(o.MenuList,{dense:!0,children:e.jsxs(o.MenuItem,{onClick:()=>{y(t),E()},children:[e.jsx(j.VisibilityOff,{sx:{fontSize:16,mr:1}}),"Hide column"]})}),e.jsx(o.Divider,{}),e.jsxs(o.MenuList,{dense:!0,children:[e.jsxs(o.MenuItem,{onClick:()=>{S(),E()},children:[e.jsx(j.Settings,{sx:{fontSize:16,mr:1}}),"Column Settings"]}),e.jsxs(o.MenuItem,{onClick:()=>{C(),E()},children:[e.jsx(j.Description,{sx:{fontSize:16,mr:1}}),"View Setup"]}),e.jsxs(o.MenuItem,{onClick:()=>{x(),E()},children:[e.jsx(j.Undo,{sx:{fontSize:16,mr:1}}),"Reset to Default Layout"]})]})]}),document.body)}const Dc=150,On="COLUMN_HEADER",Oc=u.memo(function({column:r,index:n,sortRule:i,hasFilters:a,isInSortStack:c,width:l,onColumnClick:d,onMoveColumn:f,onResizeStart:h,onSort:m,onRemoveSort:g,onSortAscending:y,onSortDescending:S,onOpenFilterForColumn:C,onClearFiltersForColumn:x,onHideColumn:E,onManageColumns:s,onManageViews:T,onResetLayout:I}){const A=u.useRef(null),[v,W]=u.useState(!1),[U,w]=u.useState({x:0,y:0}),[{handlerId:O,isOver:V},X]=vt.useDrop({accept:On,collect(R){return{handlerId:R.getHandlerId(),isOver:R.isOver()}},hover(R,q){var ae;if(!A.current)return;const ee=R.index,te=n;if(ee===te)return;const re=(ae=A.current)==null?void 0:ae.getBoundingClientRect(),ne=(re.right-re.left)/2,Z=q.getClientOffset(),Q=((Z==null?void 0:Z.x)??0)-re.left;ee<te&&Q<ne||ee>te&&Q>ne||(f(ee,te),R.index=te)}}),[{isDragging:p},L]=vt.useDrag({type:On,item:()=>({index:n,columnName:r.name}),collect:R=>({isDragging:R.isDragging()})});L(X(A));const $=u.useCallback(R=>{R.preventDefault(),R.stopPropagation(),w({x:R.clientX,y:R.clientY}),W(!0)},[]),_=u.useCallback(()=>{W(!1)},[]),F=u.useCallback(()=>{d(r.name)},[d,r.name]),oe=u.useCallback(R=>{R.stopPropagation(),C(r.name)},[C,r.name]),ue=u.useCallback(()=>i?e.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25,color:"primary.main"},children:[i.direction==="asc"?e.jsx(j.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(j.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),e.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"#fff",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),Ee=u.useCallback(()=>a?e.jsx(o.Box,{onClick:oe,title:"Active filters on this column",sx:{ml:.75,width:7,height:7,borderRadius:"50%",bgcolor:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.25)"},transition:"transform 0.12s ease"}}):null,[a,oe]);return e.jsxs(e.Fragment,{children:[e.jsxs(o.TableCell,{ref:A,"data-handler-id":O,"data-column-index":n,onClick:F,onContextMenu:$,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:p?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:V?R=>N(R.palette.primary.main,.08):"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0",py:0,px:2,height:34,"&:hover":{bgcolor:"#e8eaed",color:"primary.dark"},width:l?`${l}px`:`${Dc}px`},children:[e.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center"},children:[St(r.name),ue(),Ee()]}),e.jsx(o.Box,{sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:10,"&:hover":{bgcolor:"primary.light"}},onMouseDown:R=>{R.stopPropagation(),h(R,r.name)},onClick:R=>R.stopPropagation()}),V&&e.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),v&&e.jsx(Bc,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:a,isInSortStack:c,position:U,onSort:m,onRemoveSort:g,onSortAscending:y,onSortDescending:S,onFilter:C,onClearFilter:x,onHideColumn:E,onManageColumns:s,onManageViews:T,onResetLayout:I,onClose:_})]})});function Ac({selectedCount:t,selectedRowIds:r,searchedData:n,resolvedFavoritesSet:i,onExportSelected:a,onClearSelection:c,onBulkSetFavorites:l}){const[d,f]=u.useState(null),h=u.useMemo(()=>Array.from(r),[r]),m=u.useMemo(()=>h.filter(s=>{const T=n[s];return T!==void 0&&i.has(T)}),[h,n,i]),g=u.useMemo(()=>h.filter(s=>{const T=n[s];return T!==void 0&&!i.has(T)}),[h,n,i]),y=m.length>0,S=g.length>0;if(t===0)return null;const C=()=>{l&&l(h,!0)},x=()=>{l&&l(h,!1)},E=s=>{a(s),f(null)};return e.jsx(o.Box,{sx:{width:"100%",flexShrink:0,bgcolor:s=>N(s.palette.primary.main,.08),borderBottom:s=>`1px solid ${N(s.palette.primary.main,.25)}`,zIndex:10},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"primary.main"},children:[t," ",t===1?"row":"rows"," selected"]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Button,{onClick:c,startIcon:e.jsx(j.Close,{sx:{fontSize:16}}),size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:s=>N(s.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(o.Button,{onClick:s=>f(s.currentTarget),startIcon:e.jsx(j.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:s=>N(s.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:s=>N(s.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(o.Menu,{anchorEl:d,open:!!d,onClose:()=>f(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:180,borderRadius:1.5}},children:[e.jsx(o.MenuItem,{dense:!0,onClick:()=>E("csv"),sx:{py:1,px:2},children:"Export as CSV"}),e.jsx(o.MenuItem,{dense:!0,onClick:()=>E("excel"),sx:{py:1,px:2},children:"Export as Excel"}),e.jsx(o.MenuItem,{dense:!0,onClick:()=>E("json"),sx:{py:1,px:2},children:"Export as JSON"})]}),l&&S&&e.jsx(o.Button,{onClick:C,startIcon:e.jsx(j.StarBorder,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:s=>N(s.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:s=>N(s.palette.warning.main,.06)}},children:"Add to Favorites"}),l&&y&&e.jsx(o.Button,{onClick:x,startIcon:e.jsx(j.Star,{sx:{fontSize:16,color:"#fbbc04"}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:s=>N(s.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:s=>N(s.palette.warning.main,.06)}},children:"Remove from Favorites"})]})]})})}const Mc={active:{bg:"#e6f4ea",color:"#137333"},completed:{bg:"#e6f4ea",color:"#137333"},approved:{bg:"#e6f4ea",color:"#137333"},success:{bg:"#e6f4ea",color:"#137333"},done:{bg:"#e6f4ea",color:"#137333"},contract:{bg:"#e8eaf6",color:"#3949ab"},"in progress":{bg:"#e8eaf6",color:"#3949ab"},"in review":{bg:"#e8eaf6",color:"#3949ab"},review:{bg:"#e8eaf6",color:"#3949ab"},pending:{bg:"#e8eaf6",color:"#3949ab"},"on leave":{bg:"#fce8e6",color:"#c5221f"},"on hold":{bg:"#fff8e1",color:"#e65100"},probation:{bg:"#fff8e1",color:"#e65100"},cancelled:{bg:"#fce8e6",color:"#c5221f"},rejected:{bg:"#fce8e6",color:"#c5221f"},blocked:{bg:"#fce8e6",color:"#c5221f"},inactive:{bg:"#f1f3f4",color:"#5f6368"},"not started":{bg:"#f1f3f4",color:"#5f6368"},paused:{bg:"#f1f3f4",color:"#5f6368"}},Rc={low:"#5f6368",medium:"#e65100",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function Wc(t){const r=t.toLowerCase().trim(),n=Mc[r]||{bg:"#f1f3f4",color:"#5f6368"};return e.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:500,bgcolor:n.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function Pc(t,r){if(r==null||r==="")return e.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.8125rem"},children:"—"});const n=String(r),i=t.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Wc(n);if(/\b(priority|severity|urgency)\b/.test(i)){const a=Rc[n.toLowerCase().trim()];return a?e.jsx(o.Box,{component:"span",sx:{color:a,fontWeight:600,fontSize:"0.8125rem"},children:n}):e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}return typeof r=="boolean"?e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:r?"Yes":"No"}):typeof r=="object"?e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:JSON.stringify(r)}):e.jsx(o.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}function _c(t){const r=t.find(a=>{const c=a.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(c)})||t[0]||null,n=t.find(a=>{const c=a.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(c)&&a!==r})||null,i=t.filter(a=>a!==r&&a!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function $c({row:t,rowIndex:r,visibleColumns:n,isSelected:i,isFavorite:a,isReadOnly:c,onToggleSelection:l,onToggleFavorite:d,onView:f,onEdit:h,onDuplicate:m,onDelete:g}){const[y,S]=u.useState(null),[C,x]=u.useState(!1),{primaryCol:E,idCol:s,bodyColumns:T}=u.useMemo(()=>_c(n),[n]),I=E?t[E.name]:null,A=s?t[s.name]:null,v=C||i||a||!!y;return e.jsxs(o.Box,{onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),onClick:()=>l(r),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":W=>N(W.palette.divider,.8),borderWidth:i?2:1,borderRadius:"12px",cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?W=>`0 0 0 3px ${N(W.palette.primary.main,.15)}, 0 2px 8px ${N(W.palette.common.black,.08)}`:C?"0 4px 16px rgba(60,64,67,0.15), 0 1px 4px rgba(60,64,67,0.08)":"0 1px 3px rgba(60,64,67,0.08), 0 1px 2px rgba(60,64,67,0.06)",transform:C&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:W=>N(W.palette.primary.main,.03)}},children:[e.jsx(o.Box,{sx:{px:2,pt:2,pb:1.5},children:e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,fontSize:"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:I!=null&&I!==""?String(I):e.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})}),e.jsx(o.Box,{sx:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}),e.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"flex",flexDirection:"column",gap:1},children:[T.map(W=>e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minHeight:22},children:[e.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:500,fontSize:"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",minWidth:68,flexShrink:0,lineHeight:1},children:St(W.name)}),e.jsx(o.Box,{sx:{flex:1,lineHeight:1},children:Pc(W,t[W.name])})]},W.name)),T.length===0&&e.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic"},children:"No additional fields visible"})]}),e.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:W=>N(W.palette.action.hover,.1),minHeight:40},children:[e.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:A?.85:0,userSelect:"none"},children:A?String(A):" "}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:v?1:0,transition:"opacity 0.15s ease"},onClick:W=>W.stopPropagation(),children:[d&&e.jsx(o.Tooltip,{title:a?"Remove from favorites":"Add to favorites",placement:"top",children:e.jsx(o.IconButton,{size:"small",onClick:W=>{W.stopPropagation(),d(r)},sx:{width:28,height:28,color:a?"#fbbc04":"action.disabled","&:hover":{bgcolor:W=>N(W.palette.warning.main,.1),color:"#fbbc04"}},children:a?e.jsx(j.Star,{sx:{fontSize:17}}):e.jsx(j.StarBorder,{sx:{fontSize:17}})})}),e.jsx(o.Tooltip,{title:"More actions",placement:"top",children:e.jsx(o.IconButton,{size:"small",onClick:W=>{W.stopPropagation(),S(W.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:W=>N(W.palette.text.primary,.08)}},children:e.jsx(j.MoreVert,{sx:{fontSize:17}})})})]})]}),e.jsxs(o.Popover,{open:!!y,anchorEl:y,onClose:()=>S(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:"0 4px 20px rgba(60,64,67,0.15), 0 1px 6px rgba(60,64,67,0.1)"}},onClick:W=>W.stopPropagation(),children:[e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{f(t),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(j.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"View"})]}),!c&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{h(t,r),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(j.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!c&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{m(r,t),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(j.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),!c&&e.jsxs(e.Fragment,{children:[e.jsx(o.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{g(r,t),S(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(j.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Fc({row:t,grouping:r,onToggleCollapse:n}){var i;return e.jsxs(o.Box,{onClick:()=>n(t.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:"0 1px 2px rgba(60,64,67,0.06)","&:hover":{bgcolor:a=>N(a.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(j.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(j.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Vn(t.groupLevel,((i=r==null?void 0:r.levels[t.groupLevel])==null?void 0:i.column)||"",t.groupValue)}),e.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:a=>N(a.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[t.rowCount," ",t.rowCount===1?"row":"rows"]}),Object.keys(t.aggregates).length>0&&e.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(t.aggregates).map(([a,c])=>Nn(c)).filter(Boolean).join(" • ")})]})}function Lc({data:t,visibleColumns:r,grouping:n,selectedRowIds:i,resolvedFavoritesSet:a,isReadOnly:c,isGrouped:l,onToggleRowSelection:d,onToggleRowFavorite:f,onToggleGroupCollapse:h,onViewRow:m,onEditRow:g,onDuplicateRow:y,onDeleteRow:S}){return t.length===0?e.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):e.jsx(o.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(272px, 1fr))",gap:1.5,alignContent:"start"},children:t.map((C,x)=>l&&C.isGroupHeader?e.jsx(Fc,{row:C,grouping:n,onToggleCollapse:h||(()=>{})},`group-${C.groupKey}`):e.jsx($c,{row:C,rowIndex:x,visibleColumns:r,isSelected:i.has(x),isFavorite:a.has(C),isReadOnly:c,onToggleSelection:d,onToggleFavorite:f,onView:m,onEdit:g,onDuplicate:y,onDelete:S},`card-${x}`))})}const An=[10,15,25,50,100];function Nc({currentPage:t,pageSize:r,totalRows:n,totalFields:i,onPageChange:a,onPageSizeChange:c}){const l=Math.ceil(n/r);if(n<=Math.min(...An))return null;const d=()=>{t>1&&a(t-1)},f=()=>{t<l&&a(t+1)},h=(t-1)*r+1,m=Math.min(t*r,n);return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data: ",e.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields: ",e.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),e.jsx(o.Select,{value:r,onChange:g=>c(Number(g.target.value)),size:"small",MenuProps:{PaperProps:{sx:{maxHeight:300}},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"}},sx:{minWidth:70,fontSize:"0.8125rem",color:"text.primary","& .MuiSelect-select":{py:.5,px:1.5},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},children:An.map(g=>e.jsx(o.MenuItem,{value:g,sx:{fontSize:"0.8125rem"},children:g},g))})]}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:[h,"–",m," of ",n]}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Page ",t," of ",l]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(o.IconButton,{onClick:d,disabled:t===1,size:"small",title:"Previous page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:e.jsx(j.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(o.IconButton,{onClick:f,disabled:t===l,size:"small",title:"Next page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:e.jsx(j.ChevronRight,{sx:{fontSize:20}})})]})]})]})}function Vc(){return e.jsx(o.Chip,{icon:e.jsx(j.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}function Hc(t,r){if(t==null||t==="")return"—";if(r==="boolean")return t?"True":"False";if(r==="object"||r==="array")try{return JSON.stringify(t,null,2)}catch{return String(t)}return String(t)}function Uc({open:t,onClose:r,row:n,schema:i,reportName:a}){if(!n)return null;const c=i.filter(l=>l.name in n);return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08)"}},children:[e.jsxs(o.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(o.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(j.Visibility,{sx:{fontSize:18,color:"primary.main"}}),e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124"},children:"View Record"})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]}),e.jsx(o.DialogContent,{sx:{p:0,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(o.Box,{children:c.map(l=>{const d=n[l.name],f=Hc(d,l.type),h=f==="—";return e.jsxs(o.Box,{sx:{px:2,py:1.25,borderBottom:"1px solid divider",bgcolor:"#fff",transition:"background-color 0.15s ease","&:hover":{bgcolor:"grey.50"},"&:last-child":{borderBottom:"none"}},children:[e.jsx(o.Typography,{variant:"caption",sx:{color:"#5f6368",fontSize:"0.6875rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.02em",display:"block",mb:.5},children:St(l.name)}),e.jsx(o.Typography,{variant:"body2",sx:{color:h?"#9e9e9e":"#202124",fontStyle:h?"italic":"normal",fontSize:"0.875rem",wordBreak:"break-word",whiteSpace:l.type==="object"||l.type==="array"?"pre-wrap":"normal",fontFamily:l.type==="number"?"monospace":"inherit",fontWeight:400,lineHeight:1.5},children:f})]},l.name)})})}),e.jsx(o.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,bgcolor:"primary.main",color:"#fff",px:2.5,py:.625,minHeight:32,borderRadius:"4px",boxShadow:"none","&:hover":{bgcolor:"primary.dark",boxShadow:"none"}},children:"Close"})})]})}function Gc({open:t,onClose:r,onConfirm:n,rowPreview:i}){return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[e.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:"#fce8e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(j.WarningAmberRounded,{sx:{fontSize:22,color:"#d93025"}})}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),e.jsxs(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:[i?`"${i}"`:"This record"," will be permanently removed."]})]})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{sx:{px:3,pb:2},children:e.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:"#fce8e6",border:"1px solid #f28b82"},children:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#d93025",fontWeight:500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),e.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:e.jsx(j.DeleteForever,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#d93025",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Yc({open:t,onClose:r,onSave:n,row:i,schema:a,reportName:c}){const[l,d]=u.useState({});if(u.useEffect(()=>{t&&i&&d({...i})},[t,i]),!i)return null;const f=a.filter(y=>y.name in i),h=(y,S)=>{d(C=>({...C,[y]:S}))},m=()=>{const y={...l};f.forEach(S=>{const C=l[S.name];if(S.type==="number"){const x=Number(C);y[S.name]=isNaN(x)?i[S.name]:x}else S.type==="boolean"&&(y[S.name]=!!C)}),n(y),r()},g=y=>{const S=l[y.name],C=St(y.name);return y.type==="boolean"?e.jsx(o.FormControlLabel,{control:e.jsx(o.Switch,{checked:!!S,onChange:x=>h(y.name,x.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}}),label:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.primary",fontWeight:500},children:C}),sx:{m:0,bgcolor:"#fff",px:2,py:1,borderRadius:"4px",border:"1px solid #dadce0"}},y.name):e.jsx(o.TextField,{label:C,value:S??"",onChange:x=>h(y.name,x.target.value),type:y.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"outlined",InputLabelProps:y.type==="string"&&String(S).match(/^\d{4}-\d{2}-\d{2}/)?{shrink:!0}:void 0,sx:{"& .MuiOutlinedInput-root":{fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"#ffffff","& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputLabel-root":{fontSize:"0.8125rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiInputBase-input":{color:"text.primary",py:1}}},y.name)};return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08)"}},children:[e.jsxs(o.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(o.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(j.Edit,{sx:{fontSize:18,color:"#ea8600"}}),e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124"},children:"Edit Record"})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]}),e.jsx(o.DialogContent,{sx:{p:2,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(o.Stack,{spacing:1.5,children:f.map(y=>e.jsx(o.Box,{children:g(y)},y.name))})}),e.jsxs(o.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"text.secondary",px:2,py:.625,minHeight:32,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsx(o.Button,{onClick:m,variant:"contained",startIcon:e.jsx(j.Save,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,bgcolor:"primary.main",color:"#fff",px:2.5,py:.625,minHeight:32,borderRadius:"4px",boxShadow:"none","&:hover":{bgcolor:"primary.dark",boxShadow:"none"}},children:"Save"})]})]})}const Jc=160,qc={active:{bg:"#e6f4ea",color:"#137333"},completed:{bg:"#e6f4ea",color:"#137333"},approved:{bg:"#e6f4ea",color:"#137333"},success:{bg:"#e6f4ea",color:"#137333"},done:{bg:"#e6f4ea",color:"#137333"},contract:{bg:"#e8eaf6",color:"#2932e5"},"in progress":{bg:"#e8eaf6",color:"#2932e5"},"in review":{bg:"#e8eaf6",color:"#2932e5"},review:{bg:"#e8eaf6",color:"#2932e5"},pending:{bg:"#e8eaf6",color:"#2932e5"},"on leave":{bg:"#fce8e6",color:"#c5221f"},"on hold":{bg:"#fef7e0",color:"#b06000"},probation:{bg:"#fef7e0",color:"#b06000"},cancelled:{bg:"#fce8e6",color:"#c5221f"},rejected:{bg:"#fce8e6",color:"#c5221f"},blocked:{bg:"#fce8e6",color:"#c5221f"},inactive:{bg:"#f1f3f4",color:"#5f6368"},"not started":{bg:"#f1f3f4",color:"#5f6368"},paused:{bg:"#f1f3f4",color:"#5f6368"}},Kc={low:"#5f6368",medium:"#b06000",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function Xc(t){const r=t.toLowerCase().trim(),n=qc[r]||{bg:"grey.100",color:"grey.600"};return e.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:500,bgcolor:n.bg,color:n.color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function Qc(t){const r=t.toLowerCase().trim(),n=Kc[r];return n?e.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function Zc(t){return e.jsx(o.Box,{component:"span",sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.8125rem",fontWeight:400,letterSpacing:"0.04em"},children:t})}function ed(t,r){const n=t.name.toLowerCase().replace(/[_\s-]/g,""),i=t.name.toLowerCase(),a=r.findIndex(h=>h.name===t.name),c=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(n),l=i.includes("name")||i.includes("task")||i.includes("title")||i.includes("label")||i.includes("subject")||i.includes("description")||i.includes("filename"),d=i.includes("assignee")||i.includes("assigned")||i.includes("owner")||i.includes("author")||i.includes("creator")||i.includes("member")||i.includes("contact")||i.includes("recipient")||i.includes("sender"),f=a===0&&t.type!=="boolean"&&!i.includes("status")&&!i.includes("state");return c||l&&!d||f&&!d}function td(t){return e.jsx(o.Box,{component:"span",sx:{fontWeight:700,color:"text.primary",fontSize:"inherit"},children:t})}function rd(t,r,n=!1){if(r==null||r==="")return e.jsx(o.Box,{component:"span",sx:{color:"grey.400"},children:"—"});const i=String(r),a=t.name.toLowerCase().replace(/[_\s-]/g,""),c=/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase());if(c)return Xc(i);const l=/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase());if(l)return Qc(i);const d=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(a)||/^[A-Z]{2,8}-\d{2,}$/.test(i);return d?Zc(i):n&&!c&&!l&&!d?td(i):t.type==="number"&&typeof r=="number"?r.toLocaleString():typeof r=="boolean"?r?"Yes":"No":typeof r=="object"?JSON.stringify(r):i}function od({schema:t,data:r,sortStack:n=[],filters:i=[],views:a=[],activeViewId:c="",isDirty:l=!1,isExporting:d=!1,columnVisibility:f={},columnOrder:h=[],columnWidths:m={},grouping:g=null,onSort:y,onSortAscending:S,onSortDescending:C,onOpenFilters:x,onOpenSort:E,onOpenFilterForColumn:s,onSelectView:T,onCreateView:I,onManageViews:A,onUpdateCurrentView:v,onSaveAsNewView:W,onToggleDefault:U,onToggleFavorite:w,onRestoreView:O,onPermanentDelete:V,onExport:X,onOpenColumns:p,onUpdateColumnWidth:L,onUpdateColumnOrder:$,onUpdateColumnVisibility:_,onClearFiltersForColumn:F,onResetLayout:oe,onOpenGroup:ue,onToggleGroupCollapse:Ee,onOpenAuditHistory:R,onOpenSharePreset:q,searchQuery:ee,searchHistory:te=[],onAddToSearchHistory:re,onToggleSearchFavourite:ne,onDeleteSearchHistory:Z,selectedRowIds:Q=new Set,onSearchChange:ae,onToggleRowSelection:ce,onToggleAllRows:le,onRangeSelection:je,onClearSelection:G,onExportSelected:Me,currentPage:Ye=1,pageSize:jt=15,totalRowsBeforePagination:tt=r.length,onPageChange:$e,onPageSizeChange:Je,isReadOnly:Ae=!1,userRole:wt,reportName:Yt,onEditRow:pt,onDuplicateRow:rt,onDeleteRow:kt,favoriteRowIndices:Tt=[],resolvedFavoritesSet:ft=new Set,showFavoritesOnly:Fe=!1,onToggleRowFavorite:qe,onBulkSetFavorites:Jt,showDevPanel:Be=!1,onOpenDevConfig:zt,onToggleFavoritesFilter:Ke}){const[ot,qt]=u.useState(null),[xt,Pr]=u.useState(0),[mr,nt]=u.useState(0),[_t,gr]=u.useState(null),[$t,It]=u.useState(null),[Ce,Et]=u.useState(null),[yr,Ve]=u.useState(!1),[P,He]=u.useState(!1),[de,Re]=u.useState(null),[br,Ft]=u.useState(""),[Bt,Lt]=u.useState(!1),[Nt,ht]=u.useState(null),[Kt,Vt]=u.useState(null),[ie,H]=u.useState(null),[it,xe]=u.useState(null),[Le,Xt]=u.useState("list"),[vr,Qt]=u.useState(!1);u.useRef(null);const Zt=u.useMemo(()=>h.length>0?h.map(D=>t.find(Y=>Y.name===D)).filter(D=>D!==void 0):t,[h,t]),Ne=u.useMemo(()=>Zt.filter(D=>f[D.name]!==!1),[Zt,f]),st=u.useMemo(()=>t.filter(D=>f[D.name]===!1).length,[t,f]),er=u.useMemo(()=>t.map(D=>D.name),[t]),mt=u.useMemo(()=>JSON.stringify(h)!==JSON.stringify(er),[h,er]),Sr=u.useCallback((D,Y)=>{D.preventDefault(),D.stopPropagation(),qt(Y),Pr(D.clientX),nt(m[Y]||150)},[m]);u.useEffect(()=>{if(!ot)return;const D=pe=>{const Pe=pe.clientX-xt,se=Math.max(100,mr+Pe);L==null||L(ot,se)},Y=()=>{qt(null)};return document.addEventListener("mousemove",D),document.addEventListener("mouseup",Y),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",Y)}},[ot,xt,mr,L]);const tr=u.useCallback(D=>D==null?"-":typeof D=="object"?JSON.stringify(D):typeof D=="boolean"?D?"true":"false":String(D),[]);u.useCallback(D=>{const Y=n.find(pe=>pe.column===D);return Y?e.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[Y.direction==="asc"?e.jsx(j.ArrowUpward,{sx:{fontSize:14}}):e.jsx(j.ArrowDownward,{sx:{fontSize:14}}),e.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"caption.fontSize",fontWeight:"bold",borderRadius:"50%"},children:Y.priority})]}):null},[n]),u.useCallback(D=>i.some(pe=>pe.column===D)?e.jsx(o.IconButton,{size:"small",onClick:pe=>{pe.stopPropagation(),s==null||s(D)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(j.FilterList,{sx:{fontSize:14}})}):null,[i,s]);const rr=u.useCallback(D=>{y&&y(D)},[y]),or=u.useCallback((D,Y)=>{if(!$)return;const pe=[...h.length>0?h:t.map(se=>se.name)],[Pe]=pe.splice(D,1);pe.splice(Y,0,Pe),$(pe)},[$,h,t]),Cr=u.useCallback(D=>{if(!y)return;const Y=n.find(pe=>pe.column===D);(!Y||Y.direction!=="asc")&&y(D)},[y,n]),gt=u.useCallback(D=>{if(!y)return;const Y=n.find(pe=>pe.column===D);Y?Y.direction==="asc"&&y(D):(y(D),setTimeout(()=>y(D),0))},[y,n]),at=u.useCallback(D=>{if(!y)return;const Y=n.find(pe=>pe.column===D);Y&&(Y.direction==="asc"?(y(D),setTimeout(()=>y(D),0)):Y.direction==="desc"&&y(D))},[y,n]),nr=u.useCallback(D=>{_&&_(D,!1)},[_]),ir=(g==null?void 0:g.enabled)&&r.length>0&&r[0]&&"isGroupHeader"in r[0],sr=u.useMemo(()=>Ne.map(D=>D.name),[Ne]),We=u.useMemo(()=>ee&&ee.trim()?Xn(r,t,ee,sr):r,[r,t,ee,sr]);u.useEffect(()=>{const D=Y=>{!le||!G||Y.target instanceof HTMLInputElement||Y.target instanceof HTMLTextAreaElement||((Y.ctrlKey||Y.metaKey)&&Y.key==="a"&&(Y.preventDefault(),le(!0,We.length)),Y.key==="Escape"&&(Y.preventDefault(),G()))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[le,G,We.length]);const ar=u.useCallback((D,Y)=>{ce&&(Y.shiftKey&&_t!==null?(Y.preventDefault(),je&&je(_t,D)):(ce(D),gr(D)))},[ce,_t,je]),jr=u.useMemo(()=>We.length>0&&Q.size>0&&We.every((D,Y)=>Q.has(Y)),[We,Q]);Q.size>0;const Dt=ce&&le,wr=u.useCallback(D=>{var Pe;const Y=D.groupLevel,pe=Y*24;return e.jsx(o.TableRow,{onClick:()=>Ee==null?void 0:Ee(D.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(o.TableCell,{colSpan:Ne.length+(Dt?1:0),sx:{pl:`${pe+24}px`},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[D.isCollapsed?e.jsx(j.ChevronRight,{sx:{fontSize:16}}):e.jsx(j.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:Vn(Y,((Pe=g==null?void 0:g.levels[Y])==null?void 0:Pe.column)||"",D.groupValue)}),e.jsxs(o.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:se=>N(se.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[D.rowCount," ",D.rowCount===1?"row":"rows"]}),Object.keys(D.aggregates).length>0&&e.jsx(o.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(D.aggregates).map(([se,Ot])=>Nn(Ot)).filter(Boolean).join(" • ")})]})})},D.groupKey)},[Ne,Dt,g,Ee]),lr=u.useCallback((D,Y)=>{const pe=Q.has(Y),Pe=$t===Y;return e.jsxs(o.TableRow,{"data-row-index":Y,onMouseEnter:()=>It(Y),onMouseLeave:()=>It(null),onClick:se=>{!ce||se.target.closest("[data-row-action]")||ar(Y,se)},onContextMenu:se=>{se.preventDefault(),se.stopPropagation(),H({mouseX:se.clientX,mouseY:se.clientY,row:D,rowIndex:Y})},sx:{height:34,cursor:"pointer",bgcolor:pe?se=>N(se.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:pe?se=>N(se.palette.warning.main,.2):"#f8f9fa"},borderBottom:"1px solid",borderColor:"#e0e0e0"},children:[Ne.map((se,Ot)=>e.jsx(o.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,fontSize:"0.8125rem",fontWeight:400,color:"#202124",borderBottom:"none",minWidth:m[se.name]?`${m[se.name]}px`:`${Jc}px`},children:rd(se,D[se.name],ed(se,Ne))},se.name)),e.jsxs(o.TableCell,{"data-row-action":"true",onClick:se=>se.stopPropagation(),sx:{position:"sticky",right:0,width:qe?76:40,minWidth:qe?76:40,maxWidth:qe?76:40,p:0,border:"none",bgcolor:"transparent",opacity:Pe?1:0,transition:"opacity 0.12s ease",zIndex:2,verticalAlign:"middle",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:.25},children:[qe&&e.jsx(o.IconButton,{size:"small",onClick:se=>{se.stopPropagation(),se.preventDefault(),qe(Y)},title:ft.has(D)?"Remove from favorites":"Add to favorites",sx:{color:ft.has(D)?"#fbbc04":"text.secondary","&:hover":{bgcolor:se=>N(se.palette.warning.main,.08),color:"#fbbc04"}},children:ft.has(D)?e.jsx(j.Star,{sx:{fontSize:18}}):e.jsx(j.StarBorder,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:se=>{se.stopPropagation(),se.preventDefault(),H({anchorEl:se.currentTarget,row:D,rowIndex:Y})},sx:{color:"text.secondary","&:hover":{bgcolor:se=>N(se.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(j.MoreVert,{sx:{fontSize:18}})})]})]},Y)},[Q,$t,ar,Ne,m,tr,pt,rt,kt,ce,Et,Ve,H]);return e.jsxs(vt.DndProvider,{backend:zo.HTML5Backend,children:[e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[Dt&&Me&&G&&e.jsx(Ac,{selectedCount:Q.size,selectedRowIds:Q,searchedData:We,resolvedFavoritesSet:ft,onExportSelected:Me,onClearSelection:G,onBulkSetFavorites:Jt}),e.jsxs(o.Box,{sx:{position:"sticky",top:0,zIndex:10,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",px:2,py:0,height:56,display:"flex",alignItems:"center",gap:1},children:[Ae&&e.jsx(Vc,{}),ae&&re&&ne&&Z&&e.jsx(Ic,{value:ee||"",onChange:ae,searchHistory:te,onAddToHistory:re,onToggleFavourite:ne,onDeleteHistory:Z,disabled:Ae}),e.jsx(o.Tooltip,{title:"JSON format guide",children:e.jsx(o.IconButton,{size:"small",onClick:()=>Qt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:D=>N(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(j.InfoOutlined,{sx:{fontSize:20}})})}),Ke&&e.jsx(o.Tooltip,{title:Fe?"Show all data":"Show favorites only",children:e.jsxs(o.IconButton,{onClick:Ke,size:"small",disabled:Ae,sx:{position:"relative",color:Fe?"warning.main":"text.secondary",bgcolor:Fe?D=>N(D.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Fe?D=>N(D.palette.warning.main,.2):D=>N(D.palette.text.primary,.06),color:Fe?"warning.main":"text.primary"},"&.Mui-disabled":{color:"action.disabled"}},children:[Fe?e.jsx(j.Star,{sx:{fontSize:20}}):e.jsx(j.StarBorder,{sx:{fontSize:20}}),Fe&&Tt.length>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"warning.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:Tt.length})]})}),Be&&zt&&e.jsx(o.Tooltip,{title:"Developer configuration",children:e.jsx(o.IconButton,{size:"small",onClick:zt,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:D=>N(D.palette.text.secondary,.3),"&:hover":{bgcolor:D=>N(D.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(j.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(o.Box,{sx:{flexGrow:1}}),T&&I&&A&&v&&a.length>0&&e.jsx(Ec,{views:a||[],activeViewId:c||"",isDirty:l,onSelectView:T,onCreateView:I,onManageViews:A,onToggleDefault:U,onToggleFavorite:w,onRestoreView:O,onPermanentDelete:V,isReadOnly:Ae}),!Ae&&E&&e.jsx(o.Tooltip,{title:"Sort",children:e.jsxs(o.IconButton,{onClick:E,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(j.SwapVert,{sx:{fontSize:20}}),n.length>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Ae&&x&&e.jsx(o.Tooltip,{title:"Filter",children:e.jsxs(o.IconButton,{onClick:x,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(j.FilterList,{sx:{fontSize:20}}),i.length>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:i.length})]})}),!Ae&&p&&e.jsx(o.Tooltip,{title:"Columns",children:e.jsxs(o.IconButton,{onClick:p,size:"small",sx:{position:"relative",color:st>0||mt?"primary.main":"text.secondary",bgcolor:st>0||mt?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:st>0||mt?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:st>0||mt?"primary.main":"text.primary"}},children:[e.jsx(j.ViewColumn,{sx:{fontSize:20}}),st>0&&e.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"#fff",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:st})]})}),e.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(o.Tooltip,{title:"List view",children:e.jsx(o.IconButton,{size:"small",onClick:()=>Xt("list"),sx:{borderRadius:1,color:Le==="list"?"primary.main":"text.secondary",bgcolor:Le==="list"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="list"?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:Le==="list"?"primary.main":"text.primary"}},children:e.jsx(j.TableRows,{sx:{fontSize:20}})})}),e.jsx(o.Tooltip,{title:"Grid view",children:e.jsx(o.IconButton,{size:"small",onClick:()=>Xt("grid"),sx:{borderRadius:1,color:Le==="grid"?"primary.main":"text.secondary",bgcolor:Le==="grid"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="grid"?D=>N(D.palette.primary.main,.2):D=>N(D.palette.text.primary,.06),color:Le==="grid"?"primary.main":"text.primary"}},children:e.jsx(j.GridView,{sx:{fontSize:20}})})}),e.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(o.Tooltip,{title:"Settings",children:e.jsx(o.IconButton,{onClick:D=>xe(D.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:D=>N(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(j.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(o.Popover,{open:!!it,anchorEl:it,onClose:()=>xe(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:200,py:.5,borderRadius:1.5,boxShadow:3}},children:[X&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{X(),xe(null)},disabled:d,sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Ae&&ue&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ue(),xe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),R&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{R(),xe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),q&&e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{q(),xe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Share,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Share Report State"})]})]}),e.jsxs(o.Box,{sx:{position:"relative",overflow:"hidden",flex:1,display:"flex",flexDirection:"column"},children:[Le==="grid"&&e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:D=>N("#d8dee4",.2)},children:e.jsx(Lc,{data:We,visibleColumns:Ne,grouping:g,selectedRowIds:Q,resolvedFavoritesSet:ft,isReadOnly:Ae,isGrouped:!!ir,onToggleRowSelection:ce||(()=>{}),onToggleRowFavorite:qe,onToggleGroupCollapse:Ee,onViewRow:D=>{Et(D),Ve(!0)},onEditRow:(D,Y)=>{ht(D),Vt(Y),Lt(!0)},onDuplicateRow:(D,Y)=>rt==null?void 0:rt(D,Y),onDeleteRow:(D,Y)=>{Re(D);const pe=Object.values(Y).find(Pe=>Pe!=null&&Pe!=="");Ft(pe?String(pe):""),He(!0)}})}),Le==="list"&&e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"auto",position:"relative",bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:D=>D.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:D=>D.palette.mode==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)"}}},children:e.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",width:"100%",minWidth:"100%"},stickyHeader:!0,children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{sx:{height:34,bgcolor:"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0"},children:[Ne.map((D,Y)=>e.jsx(Oc,{column:D,index:Y,sortRule:n.find(pe=>pe.column===D.name),hasFilters:i.some(pe=>pe.column===D.name),isInSortStack:n.some(pe=>pe.column===D.name),width:m[D.name],onColumnClick:rr,onMoveColumn:or,onResizeStart:Sr,onSort:rr,onRemoveSort:at,onSortAscending:Cr,onSortDescending:gt,onOpenFilterForColumn:s||(()=>{}),onClearFiltersForColumn:F||(()=>{}),onHideColumn:nr,onManageColumns:p||(()=>{}),onManageViews:A||(()=>{}),onResetLayout:oe||(()=>{})},D.name)),e.jsx(o.TableCell,{sx:{position:"sticky",top:0,right:0,width:qe?76:40,minWidth:qe?76:40,p:0,border:"none",bgcolor:"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0",zIndex:6}})]})}),e.jsx(o.TableBody,{children:We.length===0?e.jsx(o.TableRow,{children:e.jsx(o.TableCell,{colSpan:Ne.length+(Dt?1:0),align:"center",sx:{py:4},children:e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):ir?We.map((D,Y)=>D.isGroupHeader?wr(D):lr(D,Y)):We.map((D,Y)=>lr(D,Y))})]})}),$e&&Je&&e.jsx(Nc,{currentPage:Ye,pageSize:jt,totalRows:tt,totalFields:t.length,onPageChange:$e,onPageSizeChange:Je}),!($e&&Je)&&e.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:e.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",We.length," ",We.length===1?"row":"rows"]})})]})]}),e.jsxs(o.Popover,{open:!!ie,onClose:()=>H(null),anchorEl:(ie==null?void 0:ie.anchorEl)||null,anchorReference:ie!=null&&ie.anchorEl?"anchorEl":"anchorPosition",anchorPosition:ie&&!ie.anchorEl?{top:ie.mouseY,left:ie.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:ie!=null&&ie.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie&&(Et(ie.row),Ve(!0)),H(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"View"})]}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie&&(ht(ie.row),Vt(ie.rowIndex),Lt(!0)),H(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie&&(rt==null||rt(ie.rowIndex,ie.row)),H(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(j.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsxs(o.MenuItem,{dense:!0,onClick:()=>{if(ie){Re(ie.rowIndex);const D=Object.values(ie.row).find(Y=>Y!=null&&Y!=="");Ft(D?String(D):""),He(!0)}H(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(j.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Uc,{open:yr,onClose:()=>{Ve(!1),Et(null)},row:Ce,schema:t,reportName:Yt}),e.jsx(Yc,{open:Bt,onClose:()=>{Lt(!1),ht(null),Vt(null)},onSave:D=>{Kt!==null&&(pt==null||pt(Kt,D))},row:Nt,schema:t,reportName:Yt}),e.jsx(Gc,{open:P,onClose:()=>{He(!1),Re(null)},onConfirm:()=>{de!==null&&(kt==null||kt(de))},rowPreview:br}),e.jsx(mi,{isOpen:vr,onClose:()=>Qt(!1)})]})}function nd({schema:t,filters:r,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:a,onClearAll:c,onClose:l,focusColumn:d}){const[f,h]=u.useState(""),[m,g]=u.useState(""),[y,S]=u.useState(""),[C,x]=u.useState([]),E=Mr();u.useEffect(()=>{x([...r])},[r]),u.useEffect(()=>{d&&h(d)},[d]);const s=u.useCallback(()=>{h(""),g(""),S("")},[]),T=u.useMemo(()=>t.filter(p=>p.type!=="mixed"&&p.type!=="null"&&p.type!=="array"&&p.type!=="object"),[t]),I=t.find(p=>p.name===f),A=u.useMemo(()=>{const p=I?rn(I.type):[],L=E.filter.allowedOperators;return L.length>0?p.filter($=>L.includes($.value)):p},[I]),v=u.useCallback(()=>!(!f||!m||Nr(m)&&!y.trim()||C.length>=E.filter.maxConditions),[f,m,y,C,E]),W=u.useCallback(()=>{if(!v())return;const p={column:f,operator:m};if(Nr(m)){const $=I==null?void 0:I.type;p.value=$==="number"?Number(y):y}if(C.some($=>$.column===p.column&&$.operator===p.operator&&$.value===p.value)){s();return}x([...C,p]),s()},[v,f,m,I,y,C,s]),U=u.useCallback(p=>{x(C.filter((L,$)=>$!==p))},[C]),w=u.useMemo(()=>C.length!==r.length?!0:JSON.stringify(C)!==JSON.stringify(r),[C,r]),O=u.useCallback(()=>{c(),C.forEach(p=>n(p)),l()},[C,n,c,l]),V=u.useCallback(()=>{x([...r]),s(),l()},[r,s,l]),X=u.useCallback(p=>{var F;const L=t.find(oe=>oe.name===p.column);if(!L)return"";const _=((F=rn(L.type).find(oe=>oe.value===p.operator))==null?void 0:F.label)||p.operator;return Nr(p.operator)?`${p.column} ${_.toLowerCase()} "${p.value}"`:`${p.column} ${_.toLowerCase()}`},[t]);return e.jsx(o.Box,{onClick:V,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:p=>p.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Filter columns"}),e.jsx(o.IconButton,{onClick:V,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:[e.jsxs(o.Box,{sx:{mb:2.5},children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add filter"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(o.Select,{value:f,onChange:p=>{h(p.target.value),g(""),S("")},label:"Column",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:T.map(p=>e.jsxs(o.MenuItem,{value:p.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:L=>N(L.palette.primary.main,.2)}}},children:[St(p.name)," (",p.type,")"]},p.name))})]}),f&&e.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Operator"}),e.jsx(o.Select,{value:m,onChange:p=>{g(p.target.value),S("")},label:"Operator",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:A.map(p=>e.jsx(o.MenuItem,{value:p.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:L=>N(L.palette.primary.main,.2)}}},children:p.label},p.value))})]}),m&&Nr(m)&&e.jsx(o.TextField,{size:"small",fullWidth:!0,type:(I==null?void 0:I.type)==="number"?"number":"text",value:y,onChange:p=>S(p.target.value),label:"Value",placeholder:"Enter value...",sx:{"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1,color:"text.primary"}}})]}),e.jsx(o.Button,{onClick:W,disabled:!v(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add another filter"})]}),C.length>0&&e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Active filters (",C.length,")"]}),e.jsx(o.Button,{onClick:()=>x([]),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:C.map((p,L)=>e.jsx(o.Chip,{label:X(p),onDelete:()=>U(L),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:$=>`1px solid ${N($.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:$=>N($.palette.primary.main,.2),borderColor:"#aecbfa"},"& .MuiChip-label":{px:1.5,color:"primary.main"},"& .MuiChip-deleteIcon":{color:"primary.main",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"primary.dark"}}}},L))})]})]}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:V,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:O,disabled:!w,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"grey.300",color:"grey.500"}},children:"Apply filter"})]})]})})}const Mn="SORT_RULE";function id({rule:t,index:r,onToggleDirection:n,onRemove:i,onMove:a}){const c=u.useRef(null),[{handlerId:l},d]=vt.useDrop({accept:Mn,collect(m){return{handlerId:m.getHandlerId()}},hover(m,g){var T;if(!c.current)return;const y=m.index,S=r;if(y===S)return;const C=(T=c.current)==null?void 0:T.getBoundingClientRect(),x=(C.bottom-C.top)/2,E=g.getClientOffset(),s=((E==null?void 0:E.y)??0)-C.top;y<S&&s<x||y>S&&s>x||(a(y,S),m.index=S)}}),[{isDragging:f},h]=vt.useDrag({type:Mn,item:()=>({index:r}),collect:m=>({isDragging:m.isDragging()})});return h(d(c)),e.jsxs(o.Box,{ref:c,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:f?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)",transform:"translateY(-1px)"}},children:[e.jsx(o.Chip,{label:t.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)","& .MuiChip-label":{px:0}}}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[e.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",fontWeight:400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:t.column}),e.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:e.jsxs(o.Select,{value:t.direction,onChange:m=>n(r,m.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"text.primary",fontWeight:400}},children:[e.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:m=>N(m.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:m=>N(m.palette.primary.main,.2)}}},children:"Descending"})]})}),e.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:"rgba(217, 48, 37, 0.08)",transform:"scale(1.1)"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]})}function sd({schema:t,sortStack:r,onUpdateSortStack:n,onClose:i}){const[a,c]=u.useState(""),[l,d]=u.useState([]);u.useEffect(()=>{d([...r])},[r]);const f=Mr(),h=u.useCallback(()=>!(l.length>=f.sort.maxLevels||!a||l.some(T=>T.column===a)),[l,a]),m=u.useCallback(()=>{if(!h())return;const T=l.length+1,I={column:a,direction:"asc",priority:T};d([...l,I]),c("")},[h,a,l]),g=u.useCallback(T=>{const A=l.filter((v,W)=>W!==T).map((v,W)=>({...v,priority:W+1}));d(A)},[l]),y=u.useCallback((T,I)=>{const A=[...l];A[T]={...A[T],direction:I},d(A)},[l]),S=u.useCallback((T,I)=>{const A=[...l],[v]=A.splice(T,1);A.splice(I,0,v);const W=A.map((U,w)=>({...U,priority:w+1}));d(W)},[l]),C=u.useCallback(()=>{d([])},[]),x=u.useCallback(()=>{n(l),i()},[l,n,i]),E=u.useCallback(()=>{d([...r]),c(""),i()},[r,i]),s=t.filter(T=>!l.some(I=>I.column===T.name));return e.jsx(vt.DndProvider,{backend:zo.HTML5Backend,children:e.jsx(o.Box,{onClick:E,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:T=>T.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),e.jsx(o.IconButton,{onClick:E,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:[e.jsxs(o.Box,{sx:{mb:2.5},children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),e.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=f.sort.maxLevels,children:[e.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),e.jsxs(o.Select,{value:a,onChange:T=>c(T.target.value),label:"Select column...",displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:[e.jsx(o.MenuItem,{value:"",disabled:!0,sx:{display:"none"},children:e.jsx("em",{children:"Select column..."})}),s.map(T=>e.jsx(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:I=>N(I.palette.primary.main,.2)}}},children:St(T.name)},T.name))]})]}),e.jsx(o.Button,{onClick:m,disabled:!h(),sx:{mt:1.5,textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",p:0,justifyContent:"flex-start",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"grey.400"}},children:"+ Add sort column"})]}),l.length>0&&e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",f.sort.maxLevels,")"]}),e.jsx(o.Button,{onClick:C,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((T,I)=>e.jsx(id,{rule:T,index:I,onToggleDirection:y,onRemove:g,onMove:S},`${T.column}-${I}`))})]})]}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:E,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:x,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function ad({views:t,activeViewId:r,onSelectView:n,onCreateView:i,onEditView:a,onDeleteView:c,onRestoreView:l,onPermanentDelete:d,onClose:f}){return e.jsxs(o.Dialog,{open:!0,onClose:f,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Manage Views",e.jsx(o.IconButton,{onClick:f,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.DialogContent,{children:[e.jsx(o.Box,{sx:{mb:2},children:e.jsx(o.Button,{onClick:i,variant:"contained",startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",children:"Create New Report View"})}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:t.map(h=>e.jsx(o.Paper,{sx:{p:2,border:1,borderColor:h.isDeleted?"error.light":r===h.id?"primary.main":"divider",bgcolor:h.isDeleted?m=>N(m.palette.error.main,.12):r===h.id?m=>N(m.palette.primary.main,.12):"background.paper",opacity:h.isDeleted?.75:1,cursor:h.isDeleted?"default":"pointer","&:hover":h.isDeleted?{}:{bgcolor:"action.hover"}},onClick:()=>!h.isDeleted&&n(h.id),elevation:0,children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,textDecoration:h.isDeleted?"line-through":"none",color:h.isDeleted?"text.secondary":"text.primary"},children:h.name}),h.isDeleted&&e.jsx(o.Chip,{label:"Deleted",size:"small",color:"error",sx:{height:20}}),h.isDefault&&e.jsx(o.Chip,{label:"Default",size:"small",color:"primary",sx:{height:20}}),h.isFavorite&&e.jsx(o.Chip,{label:"★ Favorite",size:"small",sx:{height:20}})]}),h.description&&e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:h.description})]}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[!h.isDeleted&&e.jsxs(e.Fragment,{children:[e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),a(h.id)},title:"Edit view",children:e.jsx(j.Edit,{sx:{fontSize:16}})}),e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),c(h.id)},title:"Delete view",sx:{"&:hover":{color:"error.main"}},children:e.jsx(j.Delete,{sx:{fontSize:16}})})]}),h.isDeleted&&l&&e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),l(h.id)},title:"Restore view",sx:{color:"success.main"},children:e.jsx(j.Undo,{sx:{fontSize:16}})}),h.isDeleted&&d&&e.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),d(h.id)},title:"Delete permanently",sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:16}})})]})]})},h.id))})]}),e.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:f,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function Rn({currentSnapshot:t,onSave:r,onClose:n,isEditMode:i=!1,initialName:a="",initialDescription:c="",initialIsDefault:l=!1}){const[d,f]=u.useState(a),[h,m]=u.useState(c),[g,y]=u.useState(l),S=()=>{d.trim()&&(r(d.trim(),h.trim(),g),n())},C=E=>{E.key==="Enter"&&!E.shiftKey?S():E.key==="Escape"&&n()},x=()=>i&&a?`Update ${a} view`:"Create New Report View";return e.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[x(),e.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[e.jsx(o.TextField,{label:"View Name",required:!0,value:d,onChange:E=>f(E.target.value),onKeyDown:C,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small"}),e.jsx(o.TextField,{label:"Description (optional)",value:h,onChange:E=>m(E.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),e.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1},children:"This view will capture:"}),e.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[e.jsxs("li",{children:[t.filters.length," filter",t.filters.length!==1?"s":""]}),e.jsxs("li",{children:["Sorting: ",bs(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:g,onChange:E=>y(E.target.checked),size:"small"}),label:e.jsx(o.Typography,{variant:"body2",children:"Set as default view"})})]})}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:S,disabled:!d.trim(),variant:"contained",startIcon:e.jsx(j.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:i?"Save Changes":"Create Report View"})]})]})}function ld({viewName:t,onConfirm:r,onCancel:n}){return e.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Delete View",e.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[e.jsx(j.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),e.jsxs(o.Box,{children:[e.jsxs(o.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",e.jsxs("strong",{children:['"',t,'"']}),"?"]}),e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(o.Button,{onClick:n,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:.875,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#d93025",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Delete View"})]})]})}const yi=80,bi=600,Wn="COLUMN";function cd({column:t,index:r,isVisible:n,width:i,onToggleVisibility:a,onWidthChange:c,moveColumn:l}){const d=u.useRef(null),[f,h]=u.useState(i.toString());u.useEffect(()=>{h(i.toString())},[i]);const[{handlerId:m},g]=vt.useDrop({accept:Wn,collect(T){return{handlerId:T.getHandlerId()}},hover(T,I){var V;if(!d.current)return;const A=T.index,v=r;if(A===v)return;const W=(V=d.current)==null?void 0:V.getBoundingClientRect(),U=(W.bottom-W.top)/2,w=I.getClientOffset(),O=((w==null?void 0:w.y)??0)-W.top;A<v&&O<U||A>v&&O>U||(l(A,v),T.index=v)}}),[{isDragging:y},S]=vt.useDrag({type:Wn,item:()=>({index:r}),collect:T=>({isDragging:T.isDragging()})});S(g(d));const C=()=>{const T=parseInt(f);if(isNaN(T)){h(i.toString());return}const I=Math.max(yi,Math.min(bi,T));h(I.toString()),c(t.name,I)},x=T=>{(T===""||/^\d+$/.test(T))&&h(T)},E=T=>{T.key==="Enter"&&(T.preventDefault(),C(),T.target.blur())},s=T=>({string:"primary.main",number:"#188038",boolean:"#9334e6",array:"#ea8600",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[T]||"text.secondary";return e.jsxs(o.TableRow,{ref:d,"data-handler-id":m,sx:{opacity:y?.4:1,bgcolor:n?"background.paper":"grey.50",transition:"all 0.2s ease","&:hover":{bgcolor:n?"grey.50":"grey.100"},cursor:"move",height:56,borderBottom:"1px solid divider"},children:[e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(o.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:e.jsx(j.DragIndicator,{sx:{fontSize:20}})}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:St(t.name)})]})}),e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsx(o.Chip,{label:t.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${s(t.type)}15`,color:s(t.type),border:`1px solid ${s(t.type)}30`,"& .MuiChip-label":{px:1}}})}),e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.TextField,{type:"text",value:f,onChange:T=>x(T.target.value),onBlur:C,onKeyDown:E,placeholder:"150",size:"small",sx:{width:80,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"}}}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:"px"})]})}),e.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(o.IconButton,{onClick:()=>a(t.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:n?"primary.dark":"primary.main"}},children:n?e.jsx(j.Visibility,{sx:{fontSize:20}}):e.jsx(j.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?"#e6f4ea":"grey.100",color:n?"#188038":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function dd({schema:t,columnVisibility:r,columnOrder:n,columnWidths:i={},views:a=[],activeViewId:c="",onUpdateColumnVisibility:l,onUpdateColumnOrder:d,onUpdateColumnWidth:f,onResetLayout:h,onSaveToCurrentView:m,onSaveToAllViews:g,onSelectView:y,onClose:S}){const[C,x]=u.useState(!1),[E,s]=u.useState(n),[T,I]=u.useState("all"),[A,v]=u.useState(null);u.useEffect(()=>{s(n)},[n]);const W=(F,oe)=>{const ue=[...E],[Ee]=ue.splice(F,1);ue.splice(oe,0,Ee),s(ue),d(ue)},U=()=>{h(),x(!1)},O=E.map(F=>t.find(oe=>oe.name===F)).filter(F=>F!==void 0).filter(F=>{const oe=r[F.name]??!0;return T==="active"?oe:T==="hidden"?!oe:!0}),V=Object.values(r).filter(F=>F).length,X=t.length,p=a.find(F=>F.id===c),L=a.filter(F=>!F.isDeleted),$=L.length>1,_=u.useMemo(()=>{if(!p)return!1;const F=p.snapshot,oe=JSON.stringify(r)!==JSON.stringify(F.columnVisibility),ue=JSON.stringify(n)!==JSON.stringify(F.columnOrder),Ee=JSON.stringify(i)!==JSON.stringify(F.columnWidths);return oe||ue||Ee},[p,r,n,i]);return e.jsx(vt.DndProvider,{backend:zo.HTML5Backend,children:e.jsx(o.Box,{onClick:S,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:F=>F.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage columns"}),e.jsxs(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5},children:[V," of ",X," columns visible • Drag to reorder"]})]}),L.length>0&&y&&e.jsxs(o.Box,{sx:{ml:2},children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",color:"text.secondary",mb:.75,display:"block",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.1em"},children:"View:"}),e.jsx(o.Button,{onClick:F=>v(F.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(j.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",textTransform:"none",fontSize:"0.875rem",fontWeight:400,color:"text.primary",borderColor:"grey.300",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:e.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(p==null?void 0:p.name)||"Select View"})}),e.jsx(o.Menu,{anchorEl:A,open:!!A,onClose:()=>v(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:"0 2px 6px rgba(60, 64, 67, 0.15)"}},children:L.map(F=>e.jsx(o.MenuItem,{onClick:()=>{y(F.id),v(null)},selected:F.id===c,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:oe=>N(oe.palette.primary.main,.2)}}},children:F.name},F.id))})]}),e.jsx(o.IconButton,{onClick:S,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsxs(o.Tabs,{value:T,onChange:(F,oe)=>I(oe),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:"primary.main",height:3}},children:[e.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),e.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}})]})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{children:[e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Column name"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Type"}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",e.jsx(o.Tooltip,{title:`Column width in pixels (min: ${yi}px, max: ${bi}px)`,arrow:!0,placement:"top",children:e.jsx(j.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),e.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"grey.50",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),e.jsx(o.TableBody,{children:O.length===0?e.jsx(o.TableRow,{children:e.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):O.map((F,oe)=>e.jsx(cd,{column:F,index:oe,isVisible:r[F.name]??!0,width:i[F.name]||150,onToggleVisibility:l,onWidthChange:f||(()=>{}),moveColumn:W},F.name))})]})}),e.jsxs(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:()=>x(!0),disabled:!_,variant:"outlined",startIcon:e.jsx(j.Undo,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",px:2.5,py:.875,minHeight:36,borderRadius:"4px","&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Reset to default"}),e.jsxs(o.Stack,{direction:"row",spacing:1.25,children:[m&&e.jsx(o.Button,{onClick:()=>{m(),S()},disabled:!_,variant:"contained",startIcon:e.jsx(j.Save,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to current view"}),g&&$&&e.jsx(o.Button,{onClick:()=>{g(),S()},disabled:!_||!$,variant:"contained",startIcon:e.jsx(j.GridView,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#188038",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#0d652d",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"grey.400"}},children:"Save to all views"})]})]}),C&&e.jsx(o.Box,{onClick:()=>x(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1400},children:e.jsxs(o.Paper,{onClick:F=>F.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:"12px",bgcolor:"background.paper",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"},children:[e.jsxs(o.Box,{sx:{px:3,py:2.5},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:()=>x(!1),variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,borderRadius:"4px","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:U,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)","&:hover":{bgcolor:"#b3190e",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function ud({schema:t,grouping:r,onApply:n,onClose:i}){var W;const[a,c]=u.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,d]=u.useState(""),[f,h]=u.useState(null),m=u.useMemo(()=>fs(t),[t]),g=u.useMemo(()=>m.filter(U=>!a.levels.some((w,O)=>w.column===U.name&&O!==f)),[m,a.levels,f]),y=Mr(),S=a.levels.length<y.grouping.maxLevels&&g.length>0,C=u.useCallback(()=>{!S||!l||(c({...a,levels:[...a.levels,{column:l}],enabled:!0}),d(""))},[S,l,a]),x=u.useCallback(U=>{const w=a.levels.filter((O,V)=>V!==U);if(w.length===0){n(null),i();return}c({...a,levels:w,enabled:w.length>0})},[a,n,i]),E=u.useCallback(U=>{h(U),d(a.levels[U].column)},[a.levels]),s=u.useCallback(()=>{if(f===null||!l)return;const U=[...a.levels];U[f]={column:l},c({...a,levels:U}),h(null),d("")},[f,l,a]),T=u.useCallback(()=>{h(null),d("")},[]),I=u.useCallback((U,w)=>{const O=w==="up"?U-1:U+1;if(O<0||O>=a.levels.length)return;const V=[...a.levels],[X]=V.splice(U,1);V.splice(O,0,X),c({...a,levels:V})},[a]),A=u.useCallback(()=>{n(null),i()},[n,i]),v=u.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return e.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:U=>U.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),e.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(o.Stack,{spacing:2.5,children:[f===null&&e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),e.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(o.Select,{value:l,onChange:U=>d(U.target.value),disabled:!S,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"grey.50"}},children:[e.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),g.map(U=>e.jsxs(o.MenuItem,{value:U.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:w=>N(w.palette.primary.main,.2)}}},children:[St(U.name)," (",U.type.toUpperCase(),")"]},U.name))]})}),e.jsx(o.Button,{onClick:C,disabled:!S||!l,variant:"outlined",startIcon:e.jsx(j.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",bgcolor:"grey.50"},"&.Mui-disabled":{color:"grey.400",borderColor:"divider"}},children:"Add group level"}),a.levels.length>=y.grouping.maxLevels&&e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),m.length===0&&e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),f!==null&&e.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"}},children:[e.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"text.primary"},children:["Edit Group Level ",f+1]}),e.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(o.Select,{value:l,onChange:U=>d(U.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"grey.300"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[e.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),e.jsxs(o.MenuItem,{value:a.levels[f].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[a.levels[f].column," (",(W=t.find(U=>U.name===a.levels[f].column))==null?void 0:W.type.toUpperCase(),")"]}),g.filter(U=>U.name!==a.levels[f].column).map(U=>e.jsxs(o.MenuItem,{value:U.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[St(U.name)," (",U.type.toUpperCase(),")"]},U.name))]})}),e.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[e.jsx(o.Button,{onClick:s,disabled:!l,variant:"contained",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#ea8600",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"#c96e00",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)"}},children:"Save"}),e.jsx(o.Button,{onClick:T,variant:"outlined",fullWidth:!0,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",borderColor:"grey.300",py:.875,"&:hover":{borderColor:"grey.400",bgcolor:"grey.50"}},children:"Cancel"})]})]}),a.levels.length>0&&f===null&&e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[e.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),e.jsx(o.Button,{onClick:A,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"#b3190e",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(o.Stack,{spacing:1.5,children:a.levels.map((U,w)=>{const O=t.find(V=>V.name===U.column);return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.50",borderColor:"grey.300",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)"}},children:[e.jsx(o.Chip,{label:`L${w+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:"0 1px 2px 0 rgba(25, 103, 210, 0.3)"}}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:U.column}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:O==null?void 0:O.type.toUpperCase()})]}),e.jsxs(o.Stack,{direction:"row",spacing:.5,children:[e.jsx(o.IconButton,{size:"small",onClick:()=>I(w,"up"),disabled:w===0,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(j.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>I(w,"down"),disabled:w===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(j.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>E(w),sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100",color:"primary.main"}},children:e.jsx(j.Edit,{sx:{fontSize:18}})}),e.jsx(o.IconButton,{size:"small",onClick:()=>x(w),sx:{color:"text.secondary","&:hover":{bgcolor:"rgba(217, 48, 37, 0.08)",color:"error.main"}},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]})]},w)})})]})]})}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:i,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:v,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const pd={filters:j.FilterList,sorting:j.UnfoldMore,visibility:j.Visibility,order:j.ViewColumn,widths:j.Straighten,grouping:j.Layers};function fd({changes:t,onClose:r}){const n=i=>({filters:"primary",sorting:"secondary",visibility:"success",order:"warning",widths:"info",grouping:"error"})[i]||"default";return e.jsxs(o.Dialog,{open:!0,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:"12px",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["View Changes Summary",e.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{dividers:!0,children:t.length===0?e.jsx(o.Box,{sx:{textAlign:"center",py:4},children:e.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No changes detected"})}):e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"The following modifications have been made to this view:"}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:t.map((i,a)=>{const c=pd[i.category];return e.jsxs(o.Paper,{elevation:0,sx:{display:"flex",gap:1.5,p:1.5,border:1,borderColor:"divider",borderRadius:1},children:[e.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:1,bgcolor:`${n(i.category)}.lighter`,color:`${n(i.category)}.main`,flexShrink:0},children:e.jsx(c,{sx:{fontSize:16}})}),e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:i.label}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:i.description})]})]},a)})})]})}),e.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end"},children:e.jsx(o.Button,{onClick:r,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})}function xd({viewName:t,isDefaultView:r,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:a,onCancel:c}){const[l,d]=u.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{width:"100%",flexShrink:0,bgcolor:"primary.lighter",borderBottom:f=>`1px solid ${N(f.palette.primary.main,.3)}`,zIndex:10},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:"#3c4043"},children:['Unsaved changes to "',t,'"']}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Button,{onClick:c,variant:"text",size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"#5f6368",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:"rgba(60, 64, 67, 0.08)",color:"#202124"}},children:"Discard"}),e.jsx(o.Button,{onClick:a,variant:"contained",size:"small",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,py:.625,borderRadius:"18px",minHeight:32,boxShadow:"none","&:hover":{boxShadow:"0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px rgba(60, 64, 67, 0.15)"}},children:"Save as new view"})]})]})}),l&&e.jsx(fd,{changes:n,onClose:()=>d(!1)})]})}function hd({onExportAnyway:t,onSaveAndExport:r,onCancel:n}){return e.jsx(o.Box,{sx:{mb:2,mx:3,mt:2},children:e.jsxs(o.Alert,{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}}),action:e.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(j.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[e.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:"You are exporting with unsaved view changes"}),e.jsx(o.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Button,{onClick:r,variant:"contained",color:"primary",startIcon:e.jsx(j.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(o.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(j.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}function md({auditHistory:t,onClose:r}){const[n,i]=u.useState(new Set),a=l=>{i(d=>{const f=new Set(d);return f.has(l)?f.delete(l):f.add(l),f})},c=[...t].sort((l,d)=>new Date(d.timestamp).getTime()-new Date(l.timestamp).getTime());return e.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:l=>l.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Audit history"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[c.length," event",c.length!==1?"s":""," recorded"]})]}),e.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:c.length===0?e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,textAlign:"center"},children:[e.jsx(j.AccessTime,{sx:{fontSize:64,color:"divider",mb:2}}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",mb:.5},children:"No audit events recorded yet"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"grey.400"},children:"Changes to this report will appear here"})]}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:c.map(l=>{const d=n.has(l.id),f=Ms(l.feature);return e.jsxs(o.Paper,{elevation:0,sx:{border:"1px solid divider",borderRadius:"8px",overflow:"hidden",transition:"all 0.2s ease","&:hover":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1)",borderColor:"grey.300"}},children:[e.jsxs(o.Box,{onClick:()=>a(l.id),sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",gap:1.5,cursor:"pointer",bgcolor:"background.paper",transition:"background-color 0.2s ease","&:hover":{bgcolor:"grey.50"}},children:[e.jsx(o.Box,{sx:{flexShrink:0,color:"text.secondary",transition:"transform 0.2s ease",transform:"rotate(0deg)"},children:d?e.jsx(j.KeyboardArrowDown,{sx:{fontSize:20}}):e.jsx(j.ChevronRight,{sx:{fontSize:20}})}),e.jsx(o.Chip,{label:As(l.feature),size:"small",sx:{height:24,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${f}15`,color:f,border:`1px solid ${f}30`,"& .MuiChip-label":{px:1}}}),e.jsx(o.Typography,{variant:"body2",sx:{flex:1,fontWeight:400,fontSize:"0.875rem",color:"text.primary"},children:Os(l.action)}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(j.AccessTime,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:Rs(l.timestamp)})]}),l.user&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(j.Person,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:l.user})]})]}),e.jsx(o.Collapse,{in:d,timeout:200,children:e.jsxs(o.Box,{sx:{px:2.5,pb:2,pt:1.5,borderTop:"1px solid divider",bgcolor:"grey.50"},children:[l.previousState&&e.jsxs(o.Box,{sx:{mb:2},children:[e.jsx(o.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"Previous state"}),e.jsx(o.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"background.paper",border:"1px solid grey.300",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"text.primary",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:3}},children:qo(l.previousState)})]}),l.newState&&e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.6875rem",color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.1em",mb:1,display:"block"},children:"New state"}),e.jsx(o.Box,{component:"pre",sx:{fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Courier New", monospace',bgcolor:"background.paper",border:"1px solid grey.300",borderRadius:"4px",p:1.5,overflow:"auto",maxHeight:200,color:"text.primary",lineHeight:1.6,"&::-webkit-scrollbar":{width:6,height:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:3}},children:qo(l.newState)})]})]})})]},l.id)})})})]})})}function gd({onSave:t,onClose:r}){const[n,i]=u.useState(""),[a,c]=u.useState(""),[l,d]=u.useState(""),[f,h]=u.useState([]),[m,g]=u.useState(""),[y,S]=u.useState(""),C=v=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),x=()=>{const v=l.trim();if(v){if(!C(v)){S("Please enter a valid email address");return}if(f.includes(v)){S("This email is already added");return}h([...f,v]),d(""),S("")}},E=v=>{h(f.filter(W=>W!==v))},s=v=>{v.key==="Enter"&&(v.preventDefault(),x())},T=()=>{if(!n.trim()){g("Preset name is required");return}t(n.trim(),a.trim(),f.length>0?f:void 0)},I=v=>{i(v),m&&g("")},A=v=>{d(v),y&&S("")};return e.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:v=>v.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"background.paper",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),e.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(o.Alert,{severity:"info",icon:e.jsx(j.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:v=>`1px solid ${N(v.palette.primary.main,.3)}`,bgcolor:"primary.lighter","& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),e.jsx(o.TextField,{required:!0,value:n,onChange:v=>I(v.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!m,helperText:m,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),e.jsx(o.TextField,{value:a,onChange:v=>c(v.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[e.jsx(o.TextField,{value:l,onChange:v=>A(v.target.value),onKeyPress:s,placeholder:"Enter email address",error:!!y,helperText:y,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(j.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"grey.300"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}}),e.jsx(o.Button,{onClick:x,variant:"outlined",startIcon:e.jsx(j.Add,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"primary.main",borderColor:"grey.300",px:2,py:1.25,minHeight:40,borderRadius:"4px",flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"grey.50"}},children:"Add"})]}),f.length>0&&e.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:f.map(v=>e.jsx(o.Chip,{label:v,onDelete:()=>E(v),deleteIcon:e.jsx(j.Delete,{sx:{fontSize:16}}),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},v))}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:f.length>0?`An email with the shareable link will be sent to ${f.length} recipient${f.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"grey.50"},children:[e.jsx(o.Button,{onClick:r,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(o.Button,{onClick:T,variant:"contained",startIcon:e.jsx(j.Share,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function yd({presetName:t,shareUrl:r,onCopyLink:n,onOpenPreset:i,onDeletePreset:a,onClose:c}){const[l,d]=u.useState(!1),f=()=>{n(),d(!0),setTimeout(()=>d(!1),2e3)};return e.jsx(o.Box,{onClick:c,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:h=>h.stopPropagation(),elevation:0,sx:{position:"relative",width:580,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Shareable link generated"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5,display:"block"},children:["Preset: ",t]})]}),e.jsx(o.IconButton,{onClick:c,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsxs(o.Alert,{severity:"success",icon:e.jsx(j.Check,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #ceead6",bgcolor:"#e6f4ea","& .MuiAlert-icon":{color:"#188038"},"& .MuiAlert-message":{fontSize:"0.875rem",color:"#3c4043"}},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043",mb:.5},children:"Preset created successfully!"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#5f6368",lineHeight:1.5},children:"Share the link below with anyone who needs access to this report configuration."})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Shareable URL"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[e.jsx(o.TextField,{value:r,size:"small",fullWidth:!0,InputProps:{readOnly:!0},onClick:h=>h.target.select(),sx:{"& .MuiOutlinedInput-root":{fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"#f8f9fa",fontFamily:'"Roboto Mono", "Courier New", monospace',"& fieldset":{borderColor:"#dadce0"},"&:hover fieldset":{borderColor:"#1967d2"},"&.Mui-focused fieldset":{borderColor:"#1967d2",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"#1967d2",cursor:"pointer"}}}),e.jsx(o.Button,{onClick:f,variant:"contained",startIcon:l?e.jsx(j.Check,{sx:{fontSize:18}}):e.jsx(j.ContentCopy,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:l?"#188038":"#1967d2",color:"#ffffff",px:3,py:1.25,minWidth:110,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:l?"#0d652d":"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:l?"Copied!":"Copy"})]})]}),e.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[e.jsx(o.Button,{onClick:i,variant:"outlined",startIcon:e.jsx(j.OpenInNew,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",py:1,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:"Open link"}),e.jsx(o.Button,{onClick:a,variant:"outlined",startIcon:e.jsx(j.Delete,{sx:{fontSize:18}}),fullWidth:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#d93025",borderColor:"#dadce0",py:1,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{borderColor:"#d93025",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete preset"})]})]})}),e.jsx(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:e.jsx(o.Button,{onClick:c,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Done"})})]})})}function bd({presetName:t,onClear:r}){return e.jsx(o.Chip,{icon:e.jsx(j.Link,{sx:{fontSize:14}}),label:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset: ",e.jsx(o.Box,{component:"span",sx:{fontWeight:600},children:t})]}),onDelete:r,deleteIcon:e.jsx(o.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:e.jsx(j.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>N(n.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function vd({presets:t,reportId:r,onOpenPreset:n,onCopyLink:i,onDeletePreset:a,onClose:c}){const[l,d]=u.useState(null),f=(m,g)=>{i(m,g),d(m),setTimeout(()=>d(null),2e3)},h=m=>new Date(m).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx(o.Box,{onClick:c,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:m=>m.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"#5f6368",mt:.5,display:"block"},children:[t.length," saved ",t.length===1?"preset":"presets"]})]}),e.jsx(o.IconButton,{onClick:c,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:t.length===0?e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(j.Share,{sx:{fontSize:48,color:"#dadce0",mb:2}}),e.jsx(o.Typography,{variant:"body1",sx:{fontSize:"0.875rem",color:"#5f6368",textAlign:"center"},children:"No presets created yet"}),e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#80868b",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:t.map(m=>e.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid #e8eaed",borderRadius:"8px",bgcolor:"#ffffff",transition:"all 0.2s ease","&:hover":{borderColor:"#dadce0",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsx(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"#202124",mb:.5},children:m.name}),m.description&&e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#5f6368",lineHeight:1.5},children:m.description})]})}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(o.Chip,{label:`Created ${h(m.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"#5f6368","& .MuiChip-label":{px:1}}}),e.jsx(o.Chip,{label:`By ${m.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"#5f6368","& .MuiChip-label":{px:1}}})]}),e.jsx(o.Divider,{sx:{my:1.5,borderColor:"#f1f3f4"}}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Button,{onClick:()=>n(m.id),variant:"outlined",size:"small",startIcon:e.jsx(j.OpenInNew,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"#1967d2",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#1967d2",bgcolor:"#f8f9fa"}},children:"Open"}),e.jsx(o.Button,{onClick:()=>f(m.id,m.name),variant:"outlined",size:"small",startIcon:l===m.id?e.jsx(j.Check,{sx:{fontSize:16}}):e.jsx(j.ContentCopy,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:l===m.id?"#188038":"#5f6368",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#5f6368",bgcolor:"#f8f9fa"}},children:l===m.id?"Copied!":"Copy link"}),e.jsx(o.Button,{onClick:()=>a(m.id,m.name),variant:"outlined",size:"small",startIcon:e.jsx(j.Delete,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"#d93025",borderColor:"#dadce0",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"#d93025",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete"})]})]},m.id))})}),e.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid #e8eaed",bgcolor:"#f8f9fa",gap:1.25,justifyContent:"flex-end",display:"flex"},children:e.jsx(o.Button,{onClick:c,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:.875,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:"Close"})})]})})}function Sd({totalRows:t,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:a,onExport:c,onClose:l}){const d=Mr(),[f,h]=u.useState(d.export.allowedFormats[0]||"csv"),[m,g]=u.useState("visible"),[y,S]=u.useState("visible"),C=t>5e4,x=m==="visible"?r:t,E=y==="visible"?i:a,s=()=>{c({format:f,scope:m,columnScope:y}),l()},T={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"};return e.jsx(o.Box,{onClick:l,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(o.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:"12px",bgcolor:"#ffffff",outline:"none",boxShadow:"0 8px 16px 4px rgba(60, 64, 67, 0.12), 0 4px 16px 0px rgba(60, 64, 67, 0.08), 0 0 0 1px rgba(60, 64, 67, 0.05)",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid #e8eaed",flexShrink:0},children:[e.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"#202124",letterSpacing:"0",lineHeight:1.5},children:"Export report"}),e.jsx(o.IconButton,{onClick:l,size:"small",sx:{p:.75,color:"#5f6368",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"#202124"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#dadce0",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[C&&e.jsxs(o.Alert,{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"},"& .MuiAlertTitle-root":{fontSize:"0.875rem",fontWeight:500,color:"#3c4043",mb:.5},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"#5f6368"}},children:[e.jsx(o.AlertTitle,{children:"Large dataset warning"}),"This export contains over 50,000 rows. Processing may take a few moments."]}),e.jsxs(o.FormControl,{component:"fieldset",children:[e.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Format"}),e.jsxs(o.RadioGroup,{value:f,onChange:I=>h(I.target.value),children:[d.export.allowedFormats.includes("csv")&&e.jsx(o.FormControlLabel,{value:"csv",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"CSV"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Comma-separated values, compatible with Excel"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),d.export.allowedFormats.includes("excel")&&e.jsx(o.FormControlLabel,{value:"excel",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Excel (.xlsx)"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Native Excel format with formatting support"})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),d.export.allowedFormats.includes("json")&&e.jsx(o.FormControlLabel,{value:"json",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"JSON"}),e.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:"Structured data with metadata and filters"})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(o.FormControl,{component:"fieldset",children:[e.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Rows"}),e.jsxs(o.RadioGroup,{value:m,onChange:I=>g(I.target.value),children:[e.jsx(o.FormControlLabel,{value:"visible",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Visible rows"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",r.toLocaleString()," rows (filtered and searched)"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),e.jsx(o.FormControlLabel,{value:"all",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"All rows"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",t.toLocaleString()," rows (complete original dataset)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(o.FormControl,{component:"fieldset",children:[e.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"#5f6368",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Columns"}),e.jsxs(o.RadioGroup,{value:y,onChange:I=>S(I.target.value),children:[e.jsx(o.FormControlLabel,{value:"visible",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"Visible columns only"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export ",i," visible columns"]})]}),sx:{mb:1.25,alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}}),e.jsx(o.FormControlLabel,{value:"all",control:e.jsx(o.Radio,{size:"small",sx:{color:"#5f6368","&.Mui-checked":{color:"#1967d2"}}}),label:e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:"All columns"}),e.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"#5f6368"},children:["Export all ",a," columns (including hidden)"]})]}),sx:{alignItems:"flex-start",px:1.5,py:1,borderRadius:"8px",transition:"background-color 0.2s ease","&:hover":{bgcolor:"#f8f9fa"}}})]})]}),e.jsxs(o.Box,{sx:{pt:1},children:[e.jsx(o.Divider,{sx:{mb:2,borderColor:"#e8eaed"}}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Format:"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:T[f]})]}),e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Rows to export:"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:x.toLocaleString()})]}),e.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"#5f6368"},children:"Columns to export:"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"#3c4043"},children:E})]})]})]})]})}),e.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid #e8eaed",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[e.jsx(o.Button,{onClick:l,variant:"text",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,color:"#5f6368",px:3,py:1,minHeight:36,borderRadius:"4px",transition:"all 0.2s ease","&:hover":{bgcolor:"#e8eaed",color:"#202124"}},children:"Cancel"}),e.jsxs(o.Button,{onClick:s,variant:"contained",startIcon:e.jsx(j.Download,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"#1967d2",color:"#ffffff",px:3,py:1,minHeight:36,borderRadius:"4px",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15)",transition:"all 0.2s ease","&:hover":{bgcolor:"#1557b0",boxShadow:"0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15)"},"&:active":{boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.3)",transform:"translateY(1px)"}},children:["Download ",T[f]]})]})]})})}function Cd({warning:t,onDismiss:r}){return e.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(o.Alert,{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}}),action:e.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:e.jsx(j.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[e.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),e.jsx(o.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:t.message}),e.jsxs(o.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some ",t.type==="filter"?"filters":t.type==="sort"?"sort levels":"grouping levels"," before adding more."]})]})})}function jd({error:t,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=5e3}){u.useEffect(()=>{if(n){const d=setTimeout(()=>{r()},i);return()=>clearTimeout(d)}},[n,i,r]);const c=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(j.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(j.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(j.InfoOutlined,{sx:{fontSize:20}})}}})(),l=Js(t);return e.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(o.Alert,{severity:c.severity,icon:c.icon,action:e.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${c.severity}.main`},children:e.jsx(j.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${c.severity}.main`,boxShadow:3},children:[e.jsxs(o.AlertTitle,{sx:{fontWeight:600},children:[t.context.charAt(0).toUpperCase()+t.context.slice(1)," Error"]}),e.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:l}),t.details&&process.env.NODE_ENV==="development"&&e.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(t.details,null,2)})]})})}class wd extends u.Component{constructor(r){super(r),this.handleReset=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,n){console.error("[ErrorBoundary] Caught error:",r,n),this.props.onError&&this.props.onError(r,n)}render(){var r,n;return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx(o.Paper,{sx:{bgcolor:i=>N(i.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(j.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:600},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),e.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((r=this.state.error)==null?void 0:r.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&e.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:i=>N(i.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:160},children:(n=this.state.error)==null?void 0:n.stack}),e.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(j.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function zr({children:t,feature:r,onError:n}){return e.jsx(wd,{context:r,onError:(i,a)=>{n&&n(i)},fallback:e.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(j.Warning,{sx:{fontSize:20}}),children:[e.jsxs(o.AlertTitle,{children:[r," temporarily unavailable"]}),"Other features continue to work normally"]}),children:t})}const Pn=[{value:"equals",label:"Equals",group:"Text"},{value:"contains",label:"Contains",group:"Text"},{value:"startsWith",label:"Starts with",group:"Text"},{value:"endsWith",label:"Ends with",group:"Text"},{value:"gt",label:"Greater than (>)",group:"Numeric"},{value:"lt",label:"Less than (<)",group:"Numeric"},{value:"gte",label:"At least (≥)",group:"Numeric"},{value:"lte",label:"At most (≤)",group:"Numeric"},{value:"isTrue",label:"Is true",group:"Boolean"},{value:"isFalse",label:"Is false",group:"Boolean"},{value:"NULL",label:"Is empty (NULL)",group:"Null checks"},{value:"NOT_NULL",label:"Is not empty",group:"Null checks"}],kd=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"}];function Qe({children:t,type:r}){return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"6px",fontSize:"0.6875rem",fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",bgcolor:r==="constraint"?n=>N(n.palette.error.main,.1):n=>N(n.palette.success.main,.1),color:r==="constraint"?"error.dark":"success.dark"},children:r==="constraint"?"Constraint":"Default"}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:t})]})}function Ir({children:t,active:r}){return e.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5},children:t})}function Td({open:t,onClose:r,config:n,onApply:i}){const[a,c]=u.useState(0),[l,d]=u.useState(n),f=()=>d(n),h=()=>d(_e),m=()=>{i(l),r()},g={sort:w=>d(O=>({...O,sort:{...O.sort,...w}})),filter:w=>d(O=>({...O,filter:{...O.filter,...w}})),columns:w=>d(O=>({...O,columns:{...O.columns,...w}})),grouping:w=>d(O=>({...O,grouping:{...O.grouping,...w}})),export:w=>d(O=>({...O,export:{...O.export,...w}}))},y=w=>{const O=l.filter.allowedOperators,V=O.includes(w)?O.filter(X=>X!==w):[...O,w];V.length!==0&&g.filter({allowedOperators:V})},S=w=>{const O=l.export.allowedFormats,V=O.includes(w)?O.filter(X=>X!==w):[...O,w];V.length!==0&&g.export({allowedFormats:V})},C=()=>g.sort({defaultSortStack:[...l.sort.defaultSortStack,{column:"",direction:"asc"}]}),x=w=>g.sort({defaultSortStack:l.sort.defaultSortStack.filter((O,V)=>V!==w)}),E=(w,O,V)=>{const X=[...l.sort.defaultSortStack];X[w]={...X[w],[O]:V},g.sort({defaultSortStack:X})},s=()=>g.filter({defaultFilters:[...l.filter.defaultFilters,{column:"",operator:"equals",value:""}]}),T=w=>g.filter({defaultFilters:l.filter.defaultFilters.filter((O,V)=>V!==w)}),I=(w,O,V)=>{const X=[...l.filter.defaultFilters];X[w]={...X[w],[O]:V},g.filter({defaultFilters:X})},A=()=>{const w=l.grouping.defaultGrouping||[];w.length>=l.grouping.maxLevels||g.grouping({defaultGrouping:[...w,{column:""}]})},v=w=>{const V=(l.grouping.defaultGrouping||[]).filter((X,p)=>p!==w);g.grouping({defaultGrouping:V.length?V:null})},W=(w,O)=>{const V=[...l.grouping.defaultGrouping||[]];V[w]={column:O},g.grouping({defaultGrouping:V})},U=[{label:"Sort",icon:e.jsx(j.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(j.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(j.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(j.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(j.Download,{sx:{fontSize:17}})}];return e.jsxs(o.Dialog,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:f},PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(720px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(60,64,67,0.2), 0 2px 8px rgba(60,64,67,0.12)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o.Box,{sx:{width:28,height:28,borderRadius:"6px",bgcolor:w=>N(w.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(o.Typography,{sx:{fontSize:"1rem"},children:"⚙️"})}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Constraints · Defaults · Ctrl+Shift+D"})]})]}),e.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(o.Tabs,{value:a,onChange:(w,O)=>c(O),variant:"fullWidth",sx:{minHeight:42,"& .MuiTab-root":{minHeight:42,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:U.map((w,O)=>e.jsx(o.Tab,{label:w.label,icon:w.icon,iconPosition:"start"},O))})}),e.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Ir,{active:a===0,children:[e.jsx(Qe,{type:"constraint",children:"Max sort levels"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[e.jsx(o.Slider,{value:l.sort.maxLevels,onChange:(w,O)=>g.sort({maxLevels:O}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on",sx:{flex:1}}),e.jsx(o.Chip,{label:l.sort.maxLevels===_e.sort.maxLevels?"Default":"Custom",size:"small",color:l.sort.maxLevels===_e.sort.maxLevels?"default":"primary",sx:{minWidth:68}})]}),e.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Users can sort by at most ",l.sort.maxLevels," column",l.sort.maxLevels!==1?"s":""," simultaneously."]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default sort on load"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"These sort rules are applied automatically when a report first loads. Use exact column key names."}),l.sort.defaultSortStack.map((w,O)=>e.jsxs(o.Box,{sx:{display:"flex",gap:1,mb:1,alignItems:"center"},children:[e.jsx(o.TextField,{size:"small",label:"Column name",value:w.column,onChange:V=>E(O,"column",V.target.value),sx:{flex:1}}),e.jsxs(o.FormControl,{size:"small",sx:{minWidth:130},children:[e.jsx(o.InputLabel,{children:"Direction"}),e.jsxs(o.Select,{value:w.direction,label:"Direction",onChange:V=>E(O,"direction",V.target.value),children:[e.jsx(o.MenuItem,{value:"asc",children:"Ascending ↑"}),e.jsx(o.MenuItem,{value:"desc",children:"Descending ↓"})]})]}),e.jsx(o.IconButton,{size:"small",onClick:()=>x(O),sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]},O)),l.sort.defaultSortStack.length<l.sort.maxLevels&&e.jsx(o.Button,{startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",onClick:C,sx:{textTransform:"none",fontSize:"0.8125rem",mt:.5},children:"Add default sort level"})]}),e.jsxs(Ir,{active:a===1,children:[e.jsx(Qe,{type:"constraint",children:"Max filter conditions"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:1},children:[e.jsx(o.Slider,{value:l.filter.maxConditions,onChange:(w,O)=>g.filter({maxConditions:O}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on",sx:{flex:1}}),e.jsx(o.Chip,{label:l.filter.maxConditions===_e.filter.maxConditions?"Default":"Custom",size:"small",color:l.filter.maxConditions===_e.filter.maxConditions?"default":"primary",sx:{minWidth:68}})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"constraint",children:"Allowed operators"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(w=>e.jsxs(o.Box,{sx:{mb:1.5},children:[e.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:w}),e.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:Pn.filter(O=>O.group===w).map(O=>e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{size:"small",checked:l.filter.allowedOperators.includes(O.value),onChange:()=>y(O.value)}),label:e.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:O.label}),sx:{mr:1.5}},O.value))})]},w)),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default filters on load"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"These filters are pre-applied when a report first loads. Use exact column key names."}),l.filter.defaultFilters.map((w,O)=>e.jsxs(o.Box,{sx:{display:"flex",gap:1,mb:1,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(o.TextField,{size:"small",label:"Column",value:w.column,onChange:V=>I(O,"column",V.target.value),sx:{flex:1,minWidth:120}}),e.jsxs(o.FormControl,{size:"small",sx:{minWidth:130},children:[e.jsx(o.InputLabel,{children:"Operator"}),e.jsx(o.Select,{value:w.operator,label:"Operator",onChange:V=>I(O,"operator",V.target.value),children:Pn.map(V=>e.jsx(o.MenuItem,{value:V.value,children:V.label},V.value))})]}),e.jsx(o.TextField,{size:"small",label:"Value",value:w.value||"",onChange:V=>I(O,"value",V.target.value),sx:{flex:1,minWidth:100}}),e.jsx(o.IconButton,{size:"small",onClick:()=>T(O),sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]},O)),l.filter.defaultFilters.length<l.filter.maxConditions&&e.jsx(o.Button,{startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",onClick:s,sx:{textTransform:"none",fontSize:"0.8125rem",mt:.5},children:"Add default filter"})]}),e.jsxs(Ir,{active:a===2,children:[e.jsx(Qe,{type:"constraint",children:"Max visible columns"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:.5},children:[e.jsx(o.Slider,{value:l.columns.maxVisible,onChange:(w,O)=>g.columns({maxVisible:O}),min:1,max:50,step:1,valueLabelDisplay:"on",sx:{flex:1}}),e.jsx(o.Chip,{label:l.columns.maxVisible===_e.columns.maxVisible?"Default":"Custom",size:"small",color:l.columns.maxVisible===_e.columns.maxVisible?"default":"primary",sx:{minWidth:68}})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"constraint",children:"Column width range (px)"}),e.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[e.jsx(o.TextField,{label:"Min width",type:"number",size:"small",value:l.columns.minColumnWidth,onChange:w=>g.columns({minColumnWidth:Math.max(40,Math.min(400,Number(w.target.value)))}),inputProps:{min:40,max:400,step:10},sx:{flex:1}}),e.jsx(o.TextField,{label:"Max width",type:"number",size:"small",value:l.columns.maxColumnWidth,onChange:w=>g.columns({maxColumnWidth:Math.max(100,Math.min(2e3,Number(w.target.value)))}),inputProps:{min:100,max:2e3,step:50},sx:{flex:1}})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default hidden columns"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1},children:"Comma-separated exact column key names to hide on first load."}),e.jsx(o.TextField,{size:"small",fullWidth:!0,multiline:!0,rows:2,placeholder:"e.g. id, created_at, internal_notes",value:l.columns.defaultHiddenColumns.join(", "),onChange:w=>g.columns({defaultHiddenColumns:w.target.value.split(",").map(O=>O.trim()).filter(Boolean)})}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default column order"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1},children:"Comma-separated column key names in display order. Omitted columns appear at the end."}),e.jsx(o.TextField,{size:"small",fullWidth:!0,multiline:!0,rows:2,placeholder:"e.g. name, status, assignee, due_date",value:l.columns.defaultColumnOrder.join(", "),onChange:w=>g.columns({defaultColumnOrder:w.target.value.split(",").map(O=>O.trim()).filter(Boolean)})})]}),e.jsxs(Ir,{active:a===3,children:[e.jsx(Qe,{type:"constraint",children:"Max group levels"}),e.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:1},children:[1,2,3].map(w=>e.jsxs(o.Box,{onClick:()=>g.grouping({maxLevels:w}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",borderColor:l.grouping.maxLevels===w?"primary.main":"divider",bgcolor:l.grouping.maxLevels===w?O=>N(O.palette.primary.main,.06):"transparent",textAlign:"center",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light"}},children:[e.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:l.grouping.maxLevels===w?"primary.main":"text.secondary"},children:w}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][w-1]})]},w))}),e.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:l.grouping.allowNested,onChange:w=>g.grouping({allowNested:w.target.checked})}),label:e.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:l.grouping.allowCollapse,onChange:w=>g.grouping({allowCollapse:w.target.checked})}),label:e.jsx(o.Typography,{variant:"body2",children:"Allow collapse/expand"})})]}),e.jsx(o.Divider,{sx:{my:.5}}),e.jsx(Qe,{type:"default",children:"Default grouping on load"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"These group levels are applied automatically on first load. Use exact column key names."}),(l.grouping.defaultGrouping||[]).map((w,O)=>e.jsxs(o.Box,{sx:{display:"flex",gap:1,mb:1,alignItems:"center"},children:[e.jsx(o.Chip,{label:`L${O+1}`,size:"small",color:"primary",sx:{minWidth:36,fontWeight:700}}),e.jsx(o.TextField,{size:"small",label:"Column name",value:w.column,onChange:V=>W(O,V.target.value),sx:{flex:1}}),e.jsx(o.IconButton,{size:"small",onClick:()=>v(O),sx:{color:"error.main"},children:e.jsx(j.Delete,{sx:{fontSize:18}})})]},O)),(l.grouping.defaultGrouping||[]).length<l.grouping.maxLevels&&e.jsx(o.Button,{startIcon:e.jsx(j.Add,{sx:{fontSize:16}}),size:"small",onClick:A,sx:{textTransform:"none",fontSize:"0.8125rem",mt:.5},children:"Add default group level"})]}),e.jsxs(Ir,{active:a===4,children:[e.jsx(Qe,{type:"constraint",children:"Allowed export formats"}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog. At least one must remain checked."}),e.jsx(o.FormGroup,{sx:{gap:1},children:kd.map(w=>e.jsxs(o.Box,{onClick:()=>S(w.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(w.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(w.value)?O=>N(O.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(o.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(w.value),onChange:()=>S(w.value),onClick:O=>O.stopPropagation()}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:w.label}),e.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:w.desc})]})]},w.value))}),e.jsx(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem",mt:1},children:'Export constraints apply to both the Export dialog and the bulk "Export Selected" action bar.'})]})]}),e.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:w=>N(w.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(o.Button,{startIcon:e.jsx(j.RestartAlt,{sx:{fontSize:18}}),onClick:h,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:w=>N(w.palette.text.primary,.06)}},children:"Reset to defaults"}),e.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[e.jsx(o.Button,{onClick:r,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(o.Button,{onClick:m,size:"small",variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}function vi({reportEngine:t}){var Ot,_r;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:a,tableEngine:c,activeView:l,isDirty:d,currentTableState:f,viewChanges:h,showFilterPanel:m,setShowFilterPanel:g,filterFocusColumn:y,handleAddFilter:S,handleUpdateFilter:C,handleRemoveFilter:x,handleClearAllFilters:E,handleOpenFilterForColumn:s,handleCloseFilterPanel:T,handleClearFiltersForColumn:I,showSortPanel:A,setShowSortPanel:v,handleSort:W,handleUpdateSortStack:U,handleSortAscending:w,handleSortDescending:O,showManageViews:V,setShowManageViews:X,showCreateViewModal:p,setShowCreateViewModal:L,showEditViewModal:$,setShowEditViewModal:_,showDeleteConfirmation:F,setShowDeleteConfirmation:oe,editingView:ue,deletingView:Ee,handleSelectView:R,handleCreateView:q,handleUpdateCurrentView:ee,handleSaveColumnConfigToCurrentView:te,handleSaveColumnConfigToAllViews:re,handleSaveAsNewView:ne,handleRevertChanges:Z,handleToggleDefault:Q,handleToggleFavorite:ae,handleSoftDelete:ce,handleRestoreView:le,handlePermanentDelete:je,handleEditView:G,handleSaveEditView:Me,handleConfirmDelete:Ye,showManageColumns:jt,setShowManageColumns:tt,handleUpdateColumnVisibility:$e,handleUpdateColumnOrder:Je,handleUpdateColumnWidth:Ae,handleResetColumnLayout:wt,showGroupPanel:Yt,setShowGroupPanel:pt,handleGroup:rt,handleToggleGroupCollapse:kt,searchQuery:Tt,searchHistory:ft,handleSearchChange:Fe,handleAddToSearchHistory:qe,handleToggleSearchFavourite:Jt,handleDeleteSearchHistory:Be,selectedRowIds:zt,handleToggleRowSelection:Ke,handleToggleAllRows:ot,handleRangeSelection:qt,handleClearSelection:xt,currentPage:Pr,pageSize:mr,paginationEngine:nt,handlePageChange:_t,handlePageSizeChange:gr,isExporting:$t,showExportModal:It,setShowExportModal:Ce,showDirtyExportWarning:Et,handleExport:yr,handleExportWithConfig:Ve,handleExportSelected:P,handleExportAnyway:He,handleSaveAndExport:de,handleCancelExport:Re,showAuditHistory:br,setShowAuditHistory:Ft,showCreatePreset:Bt,setShowCreatePreset:Lt,showShareLink:Nt,setShowShareLink:ht,showManagePresets:Kt,setShowManagePresets:Vt,generatedPreset:ie,activePreset:H,handleOpenSharePreset:it,handleOpenManagePresets:xe,handleCreatePreset:Le,handleCopyPresetLink:Xt,handleOpenPreset:vr,handleDeletePreset:Qt,handleClearActivePreset:Zt,handleOpenPresetById:Ne,handleCopyPresetLinkById:st,handleDeletePresetById:er,isViewerRole:mt,userRole:Sr,featureLimitWarning:tr,setFeatureLimitWarning:rr,reportError:or,setReportError:Cr,handleError:gt,updateReport:at,showSnack:nr,favoriteRowIndices:ir,resolvedFavoritesSet:sr,showFavoritesOnly:We,handleToggleRowFavorite:ar,handleBulkSetFavorites:jr,handleToggleFavoritesFilter:Dt}=t,wr=u.useCallback((ke,Te)=>{if(!(r!=null&&r.uploadedData))return;const At=[...r.uploadedData];At[ke]=Te,at(r.id,{uploadedData:At})},[r,at]),lr=u.useCallback(ke=>{if(!(r!=null&&r.uploadedData))return;const Te=r.uploadedData.filter((At,po)=>po!==ke);at(r.id,{uploadedData:Te})},[r,at]),D=u.useCallback((ke,Te)=>{if(!(r!=null&&r.uploadedData))return;const At=[...r.uploadedData];At.splice(ke+1,0,{...Te}),at(r.id,{uploadedData:At})},[r,at]),Y=Mr(),{handleDevConfigChange:pe}=Kr(),[Pe,se]=u.useState(!1);return u.useEffect(()=>{const ke=Te=>{Te.ctrlKey&&Te.shiftKey&&Te.key==="D"&&(Te.preventDefault(),se(!0))};return document.addEventListener("keydown",ke),()=>document.removeEventListener("keydown",ke)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:[!mt&&d&&l&&e.jsx(xd,{viewName:l.name,isDefaultView:l.isDefault,changes:h,onSaveToCurrentView:l.isDefault?void 0:ee,onSaveAsNewView:ne,onCancel:Z}),e.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",position:"relative"},children:[tr&&e.jsx(Cd,{warning:tr,onDismiss:()=>rr(null)}),or&&e.jsx(jd,{error:or,onDismiss:()=>Cr(null)}),Et&&e.jsx(hd,{onExportAnyway:He,onSaveAndExport:de,onCancel:Re}),e.jsx(od,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:d,isExporting:$t,columnVisibility:r.columnVisibility||(l==null?void 0:l.snapshot.columnVisibility),columnOrder:r.columnOrder||(l==null?void 0:l.snapshot.columnOrder),columnWidths:r.columnWidths||(l==null?void 0:l.snapshot.columnWidths),grouping:r.grouping,onSort:W,onSortAscending:w,onSortDescending:O,onOpenFilters:()=>g(!0),onOpenSort:()=>v(!0),onOpenFilterForColumn:s,onSelectView:R,onCreateView:()=>L(!0),onManageViews:()=>X(!0),onUpdateCurrentView:ee,onSaveAsNewView:ne,onToggleDefault:Q,onToggleFavorite:ae,onRestoreView:le,onPermanentDelete:je,onExport:yr,onOpenColumns:()=>tt(!0),onUpdateColumnWidth:Ae,onUpdateColumnOrder:Je,onUpdateColumnVisibility:$e,onClearFiltersForColumn:I,onResetLayout:wt,onOpenGroup:()=>pt(!0),onToggleGroupCollapse:kt,onOpenAuditHistory:()=>Ft(!0),onOpenSharePreset:it,searchQuery:Tt,searchHistory:ft,onAddToSearchHistory:qe,onToggleSearchFavourite:Jt,onDeleteSearchHistory:Be,selectedRowIds:zt,onSearchChange:Fe,onToggleRowSelection:Ke,onToggleAllRows:ot,onRangeSelection:qt,onClearSelection:xt,onExportSelected:P,currentPage:(nt==null?void 0:nt.currentPage)||Pr,pageSize:(nt==null?void 0:nt.pageSize)||mr,onPageChange:_t,onPageSizeChange:gr,totalRowsBeforePagination:(a==null?void 0:a.searchedRows)||i.length,isReadOnly:mt,userRole:Sr,reportName:r.name,onEditRow:wr,onDeleteRow:lr,onDuplicateRow:D,favoriteRowIndices:ir,resolvedFavoritesSet:sr,showFavoritesOnly:We,onToggleRowFavorite:ar,onBulkSetFavorites:jr,onToggleFavoritesFilter:Dt,showDevPanel:Y.display.showDevPanel,onOpenDevConfig:()=>se(!0)})]}),m&&e.jsx(zr,{feature:"Filters",onError:ke=>{const Te=bt("ui","filters",ke);gt(Te)},children:e.jsx(nd,{schema:r.schema,filters:r.filters??[],onAddFilter:S,onUpdateFilter:C,onRemoveFilter:x,onClearAll:E,onClose:T,focusColumn:y})}),A&&e.jsx(zr,{feature:"Sorting",onError:ke=>{const Te=bt("ui","sorting",ke);gt(Te)},children:e.jsx(sd,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:U,onClose:()=>v(!1)})}),V&&e.jsx(zr,{feature:"Views",onError:ke=>{const Te=bt("ui","views",ke);gt(Te)},children:e.jsx(ad,{views:r.views,activeViewId:r.activeViewId??"",onSelectView:R,onCreateView:()=>{X(!1),L(!0)},onEditView:G,onDeleteView:ce,onRestoreView:le,onPermanentDelete:je,onClose:()=>X(!1)})}),p&&f&&e.jsx(Rn,{currentSnapshot:f,onSave:q,onClose:()=>L(!1)}),$&&ue&&e.jsx(Rn,{currentSnapshot:ue.snapshot,onSave:Me,onClose:()=>{_(!1)},isEditMode:!0,initialName:ue.name,initialDescription:ue.description,initialIsDefault:ue.isDefault}),F&&Ee&&e.jsx(ld,{viewName:Ee.name,onConfirm:Ye,onCancel:()=>{oe(!1)}}),jt&&l&&e.jsx(dd,{schema:r.schema,columnVisibility:r.columnVisibility||l.snapshot.columnVisibility,columnOrder:r.columnOrder||l.snapshot.columnOrder,columnWidths:r.columnWidths||l.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:$e,onUpdateColumnOrder:Je,onUpdateColumnWidth:Ae,onResetLayout:wt,onSelectView:ke=>{R(ke)},onSaveToCurrentView:()=>{te(),tt(!1)},onSaveToAllViews:()=>{re(),tt(!1)},onClose:()=>tt(!1)}),Yt&&e.jsx(zr,{feature:"Grouping",onError:ke=>{const Te=bt("ui","grouping",ke);gt(Te)},children:e.jsx(ud,{schema:r.schema,grouping:r.grouping||null,onApply:rt,onClose:()=>pt(!1)})}),br&&e.jsx(md,{auditHistory:r.auditHistory||[],onClose:()=>Ft(!1)}),Bt&&e.jsx(gd,{onSave:Le,onClose:()=>Lt(!1)}),Nt&&ie&&e.jsx(yd,{presetName:ie.preset.name,shareUrl:ie.url,onCopyLink:Xt,onOpenPreset:vr,onDeletePreset:Qt,onClose:()=>{ht(!1)}}),Kt&&e.jsx(vd,{presets:r.presets||[],reportId:r.id,onOpenPreset:Ne,onCopyLink:st,onDeletePreset:er,onClose:()=>Vt(!1)}),H&&e.jsx(o.Box,{sx:{mt:2},children:e.jsx(bd,{presetName:H.name,onClear:Zt})}),It&&e.jsx(zr,{feature:"Export",onError:ke=>{const Te=bt("ui","export",ke);gt(Te)},children:e.jsx(Sd,{totalRows:(a==null?void 0:a.totalRows)||((Ot=r.uploadedData)==null?void 0:Ot.length)||0,visibleRows:(a==null?void 0:a.searchedRows)||i.length,visibleColumnsCount:((_r=c==null?void 0:c.columnEngine)==null?void 0:_r.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(a==null?void 0:a.isGrouped)||!1,onExport:Ve,onClose:()=>{Ce(!1)}})}),e.jsx(Td,{open:Pe,onClose:()=>se(!1),config:Y,onApply:pe})]})}function Si({open:t,message:r,severity:n,onClose:i}){return e.jsx(o.Snackbar,{open:t,autoHideDuration:4e3,onClose:i,anchorOrigin:{vertical:"top",horizontal:"right"},children:e.jsx(o.Alert,{onClose:i,severity:n,variant:"filled",sx:{width:"100%",boxShadow:3},children:r})})}function Ci(){const t=Kr(),{reports:r,activeReportId:n,activeReport:i,uploadState:a,schema:c,hasSchemaConflicts:l,isModalOpen:d,setIsModalOpen:f,setActiveReportId:h,createReport:m,handleFileUpload:g,handleUploadError:y,handleRetry:S,handleConfirm:C,snack:x,handleSnackClose:E}=t;return e.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(ha,{onCreateReport:()=>f(!0),reports:r,activeReportId:n,onReportClick:h}),e.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:r.length===0?e.jsx(gi,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):i?e.jsx(e.Fragment,{children:i.schemaLocked&&i.schema&&i.uploadedData&&i.views?e.jsx(vi,{reportEngine:t}):e.jsx(o.Box,{sx:{p:3},children:a==="preview"&&i.schema&&i.uploadedData?e.jsx(Tc,{schema:i.schema,onConfirm:C,hasConflicts:l}):i.uploadError?e.jsx(zc,{error:i.uploadError,onRetry:S}):e.jsx(kc,{onFileUpload:g,onError:y,isUploading:a==="uploading"})})}):null}),e.jsx(wc,{isOpen:d,onClose:()=>f(!1),onCreate:m}),e.jsx(Si,{open:x.open,message:x.message,severity:x.severity,onClose:E})]})}function zd(){return e.jsx(Bo,{children:e.jsx(Ci,{})})}function ji(){const t=Kr(),{snack:r,handleSnackClose:n}=t;return e.jsxs(o.Box,{sx:{minHeight:"100vh"},children:[e.jsx(o.Box,{component:"main",children:t.activeReport?e.jsx(vi,{reportEngine:t}):e.jsx(gi,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(Si,{open:r.open,message:r.message,severity:r.severity,onClose:n})]})}function Id({data:t,autoLoad:r=!0,config:n}){return e.jsx(Bo,{data:t,mode:"viewer",autoLoad:r,config:n,children:e.jsx(ji,{})})}exports.URMBuilder=zd;exports.URMBuilderRaw=Ci;exports.URMProvider=Bo;exports.URMViewer=Id;exports.URMViewerRaw=ji;exports.useURMContext=Kr;
|