dts-universal-report-module 1.0.2 → 1.0.3
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 +7360 -6774
- package/dist/index.js +32 -52
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),is=require("xlsx"),j=require("@mui/icons-material"),o=require("@mui/material"),_n=require("react-dom"),ss=require("@emotion/react"),vt=require("react-dnd"),zo=require("react-dnd-html5-backend");function $n(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const Jr=$n(u),Fr=$n(is);function as(t){return t==null?"null":Array.isArray(t)?"array":typeof t=="object"?"object":typeof t=="number"?"number":typeof t=="boolean"?"boolean":typeof t=="string"?"string":"mixed"}function fo(t){if(!Array.isArray(t)||t.length===0)return[];const r=new Set;t.forEach(i=>{typeof i=="object"&&i!==null&&Object.keys(i).forEach(a=>r.add(a))});const n=[];return r.forEach(i=>{const a=new Set;let c=0;t.forEach(h=>{typeof h=="object"&&h!==null&&i in h&&(c++,a.add(as(h[i])))});const l=c===t.length,d=a.size>1&&!a.has("null");let f="mixed";if(a.size===1)f=Array.from(a)[0];else if(a.size===2&&a.has("null")){const h=Array.from(a).filter(m=>m!=="null");h.length===1&&(f=h[0])}n.push({name:i,type:f,required:l,hasConflict:d})}),n}function ls(t){return t.some(r=>r.hasConflict)}function St(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function No(t){return t==null}function cs(t){return(r,n,i)=>{const a=No(r),c=No(n);if(a&&c)return 0;if(a)return 1;if(c)return-1;let l=0;switch(t){case"number":const d=Number(r),f=Number(n);l=d-f;break;case"boolean":l=(r?1:0)-(n?1:0);break;case"string":l=String(r).localeCompare(String(n));break;case"array":case"object":l=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:l=String(r).localeCompare(String(n));break}return i==="asc"?l:-l}}function ds(t,r,n){if(!n||n.length===0)return t;const i=[...n].sort((a,c)=>a.priority-c.priority);return[...t].sort((a,c)=>{for(const l of i){const d=r.find(m=>m.name===l.column);if(!d)continue;const h=cs(d.type)(a[l.column],c[l.column],l.direction);if(h!==0)return h}return 0})}function us(t){return t===null?"asc":t==="asc"?"desc":null}function ps(t){return t==="string"||t==="boolean"}function fs(t){return t.filter(r=>ps(r.type))}function xs(t,r){const n={};return r.forEach(i=>{if(i.type==="number"){const a=t.map(c=>c[i.name]).filter(c=>typeof c=="number");a.length>0&&(n[i.name]=a.reduce((c,l)=>c+l,0))}}),n}function hs(t,r,n){if(!n.enabled||n.levels.length===0)return t;const i=Fn(t,n.levels,r);return Ln(i,n.collapsedGroups||[])}function Fn(t,r,n,i="",a=0){if(a>=r.length)return t;const c=r[a].column,l=new Map;t.forEach(h=>{const m=h[c],g=m==null?"(empty)":String(m);l.has(g)||l.set(g,[]),l.get(g).push(h)});const d=[];return Array.from(l.keys()).sort().forEach(h=>{const m=l.get(h),g=`${c}:${h}`,y=i?`${i}|${g}`:g,S=xs(m,n),C=a<r.length-1?Fn(m,r,n,y,a+1):m,x={key:y,level:a,column:c,value:h,rowCount:m.length,aggregates:S,children:C};d.push(x)}),d}function Ln(t,r,n=[]){for(const i of t)if("key"in i&&"level"in i&&"children"in i){const a=r.includes(i.key);n.push({isGroupHeader:!0,groupKey:i.key,groupLevel:i.level,groupColumn:i.column,groupValue:i.value,rowCount:i.rowCount,aggregates:i.aggregates,isCollapsed:a}),!a&&i.children&&Ln(i.children,r,n)}else n.push(i);return n}function ms(t,r){const n=t.collapsedGroups||[],i=n.includes(r)?n.filter(a=>a!==r):[...n,r];return{...t,collapsedGroups:i}}function Nn(t,r){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function Vn(t,r,n){return`${r}: ${n}`}function Er(t,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...t];const n=r.levels.map(a=>a.column),i=t.filter(a=>!n.includes(a));return[...n,...i]}function Hn(t,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...t];const i=r.levels.map(c=>c.column),a=t.filter(c=>!i.includes(c));if(n){const c=[],l=new Set(i),d=new Set(a);let f=0;for(const h of n)l.has(h)?c.push(h):d.has(h)&&f<a.length?(c.push(a[f]),f++):d.has(h)||c.push(h);for(let h=f;h<a.length;h++)c.includes(a[h])||c.push(a[h]);return c}return[...t]}function xo(t){const r={},n=[],i={};return t.forEach(a=>{r[a.name]=!0,n.push(a.name),i[a.name]=150}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:[],sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function gs(t,r,n,i,a,c,l,d){const f={},h=[],m={};n.forEach(S=>{f[S.name]=!0,h.push(S.name),m[S.name]=150});const y=Hn(a||h,l||null,d||h);return{filters:t||[],sortStack:r||[],columnVisibility:i||f,columnOrder:y,columnWidths:c||m,grouping:l||null}}function ys(t,r){const n=f=>{if(f==null)return f;if(Array.isArray(f))return f.map(h=>n(h));if(typeof f=="object"){const h={};return Object.keys(f).sort().forEach(m=>{h[m]=n(f[m])}),h}return f},i=f=>JSON.stringify(n(f));if(i(t.filters)!==i(r.filters)||i(t.sortStack)!==i(r.sortStack)||i(t.columnVisibility)!==i(r.columnVisibility))return!0;const a=[...t.columnOrder||[]].sort().join(","),c=[...r.columnOrder||[]].sort().join(",");if(a!==c)return!1;const l=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==l){if((t.columnOrder||[]).join(",")!==(r.columnOrder||[]).join(","))return!0}else{const f=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==f)return!0}return i(t.columnWidths)!==i(r.columnWidths)||i(t.grouping)!==i(r.grouping)}function bs(t){return!t||t.length===0?"None":t.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function vs(t,r){var x,E,s;const n=[],i=JSON.stringify(t.filters),a=JSON.stringify(r.filters);if(i!==a){const T=t.filters.length,I=r.filters.length;T>I?n.push({category:"filters",label:"Filters Added",description:`${T-I} new filter${T-I>1?"s":""} added`}):T<I?n.push({category:"filters",label:"Filters Removed",description:`${I-T} filter${I-T>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const c=JSON.stringify(t.sortStack),l=JSON.stringify(r.sortStack);if(c!==l){const T=t.sortStack.length,I=r.sortStack.length;T>I?n.push({category:"sorting",label:"Sorting Added",description:`${T-I} new sort rule${T-I>1?"s":""} added`}):T<I?n.push({category:"sorting",label:"Sorting Removed",description:`${I-T} sort rule${I-T>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const d=JSON.stringify(t.columnVisibility),f=JSON.stringify(r.columnVisibility);if(d!==f){const T=Object.values(t.columnVisibility).filter(A=>A).length,I=Object.values(r.columnVisibility).filter(A=>A).length;T>I?n.push({category:"visibility",label:"Columns Shown",description:`${T-I} column${T-I>1?"s":""} made visible`}):T<I?n.push({category:"visibility",label:"Columns Hidden",description:`${I-T} column${I-T>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const h=JSON.stringify(t.columnOrder),m=JSON.stringify(r.columnOrder);h!==m&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const g=JSON.stringify(t.columnWidths),y=JSON.stringify(r.columnWidths);if(g!==y){const T=Object.keys(t.columnWidths).filter(I=>t.columnWidths[I]!==r.columnWidths[I]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${T} column width${T>1?"s":""} modified`})}const S=JSON.stringify(t.grouping),C=JSON.stringify(r.grouping);if(S!==C){const T=(x=t.grouping)==null?void 0:x.enabled,I=(E=r.grouping)==null?void 0:E.enabled;if(T&&!I){const A=((s=t.grouping)==null?void 0:s.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${A} grouping level${A>1?"s":""} added`})}else!T&&I?n.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):n.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return n}const Un="urm_report_";function Ss(t,r){try{const n=`${Un}${t}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){console.error("Failed to save report state:",n)}}function Cs(t){try{const r=`${Un}${t}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return console.error("Failed to load report state:",r),null}}function qr(t,r,n=0){const i=[];for(const a of t){const c=r.includes(a.key);if(i.push({type:"group",key:a.key,level:n,column:a.column,value:a.value,rowCount:a.rowCount,aggregates:a.aggregates,collapsed:c}),!c&&a.children&&a.children.length>0){const l=a.children[0];if(js(l)){const d=a.children,f=qr(d,r,n+1);i.push(...f)}else{const d=a.children;for(const f of d)i.push({type:"row",parentGroupKey:a.key,level:n+1,data:f})}}}return i}function js(t){return t&&typeof t=="object"&&"key"in t&&"level"in t&&"column"in t&&"value"in t&&"rowCount"in t&&"aggregates"in t&&"children"in t}function Io(t){return t.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function Eo(t,r){const n=new Date,i=n.getFullYear(),a=String(n.getMonth()+1).padStart(2,"0"),c=String(n.getDate()).padStart(2,"0"),l=`${i}-${a}-${c}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${l}.${r}`}function Vo(t,r,n,i,a,c,l){let d,f;c?(d={...c},f=l||r.map(m=>m.name)):a?(d={...a.snapshot.columnVisibility},f=l||[...a.snapshot.columnOrder]):(d={},f=[],r.forEach(m=>{d[m.name]=!0,f.push(m.name)}));const h=Object.entries(d).filter(([m,g])=>!g).map(([m,g])=>m);return{data:t,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:d,columnOrder:f,grouping:(a==null?void 0:a.snapshot.grouping)??null,hiddenColumns:h,viewMeta:a?{id:a.id,name:a.name,isDefault:a.isDefault}:void 0}}function Ho(t,r="export",n){const{data:i,columnOrder:a,grouping:c}=t,l=a.filter(g=>t.columnVisibility[g]);let d;if(c&&c.enabled){const g=qr(i);d=Io(g)}else d=i;const f=l.join(","),h=d.map(g=>l.map(y=>{const S=g[y];if(S==null)return"";const C=String(S);return C.includes(",")||C.includes('"')||C.includes(`
|
|
2
|
-
`)?`"${
|
|
3
|
-
`);Gn(m,Eo(r,"csv"),"text/csv;charset=utf-8;")}function Uo(t,r="export",n){const{data:i,columnOrder:a,grouping:c}=t,l=a.filter(g=>t.columnVisibility[g]);let d;if(c&&c.enabled){const g=qr(i);d=Io(g)}else d=i;const f=[l,...d.map(g=>l.map(y=>g[y]??""))],h=Fr.utils.aoa_to_sheet(f),m=Fr.utils.book_new();Fr.utils.book_append_sheet(m,h,"Data"),Fr.writeFile(m,Eo(r,"xlsx"))}function Go(t,r="export",n){const{data:i,appliedFilters:a,appliedSortStack:c,viewMeta:l,hiddenColumns:d,columnOrder:f,grouping:h}=t;let m;if(h&&h.enabled){const S=qr(i);m=Io(S)}else m=i;const g={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(l==null?void 0:l.name)||"Default View",filters:a.map(S=>({field:S.column,operator:S.operator,value:S.value})),sortStack:c.map(S=>({field:S.column,direction:S.direction,priority:S.priority})),grouping:h||{},hiddenColumns:d,columnOrder:f,exportConfig:n||{scope:"visible"}},data:m},y=JSON.stringify(g,null,2);Gn(y,Eo(r,"json"),"application/json;charset=utf-8;")}function Gn(t,r,n){const i=new Blob([t],{type:n}),a=URL.createObjectURL(i),c=document.createElement("a");c.href=a,c.download=r,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(a)}const Yo=10;function ws(t,r){const n=r.trim();if(!n)return t;const i=t.findIndex(c=>c.query.toLowerCase()===n.toLowerCase());let a;return i!==-1?a=[{...t[i],lastUsed:Date.now()},...t.slice(0,i),...t.slice(i+1)]:a=[{query:n,isFavourite:!1,lastUsed:Date.now()},...t],a.length>Yo&&(a=[...a].sort((l,d)=>l.isFavourite&&!d.isFavourite?-1:!l.isFavourite&&d.isFavourite?1:d.lastUsed-l.lastUsed).slice(0,Yo)),a}function ks(t,r){return t.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function Ts(t,r){return t.filter(n=>n.query!==r)}function zs(t){const r=t.filter(i=>i.isFavourite).sort((i,a)=>a.lastUsed-i.lastUsed),n=t.filter(i=>!i.isFavourite).sort((i,a)=>a.lastUsed-i.lastUsed);return[...r,...n]}const Is={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function Es(t,r){return!t||t.owner===r?"owner":t.editors.includes(r)?"editor":(t.viewers.includes(r),"viewer")}function ct(t,r){return Is[r].includes(t)}function dt(t){return`You do not have permission to ${{view_report:"view this report",edit_columns:"modify columns",edit_filters:"modify filters",edit_sorting:"modify sorting",edit_views:"edit views",create_views:"create views",delete_views:"delete views",delete_report:"delete this report",export_data:"export data"}[t]||"perform this action"}.`}function Bs(t){return t==="viewer"}const Jo=1e3;function Ds(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Yn(t,r,n,i,a,c){return{id:Ds(),user:r,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:a,newState:c}}function Jn(t,r){const n=[r,...t];return n.length>Jo?n.slice(0,Jo):n}function Os(t){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",error_occurred:"Error Occurred"}[t]||t}function As(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function Ms(t){return{filters:"bg-blue-100 text-blue-800 border-blue-200",sorting:"bg-purple-100 text-purple-800 border-purple-200",grouping:"bg-green-100 text-green-800 border-green-200",columns:"bg-orange-100 text-orange-800 border-orange-200",views:"bg-pink-100 text-pink-800 border-pink-200",theme:"bg-gray-100 text-gray-800 border-gray-200",export:"bg-cyan-100 text-cyan-800 border-cyan-200",presets:"bg-indigo-100 text-indigo-800 border-indigo-200",system:"bg-red-100 text-red-800 border-red-200"}[t]||"bg-gray-100 text-gray-800 border-gray-200"}function Rs(t){const r=new Date(t),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4),c=Math.floor(i/36e5),l=Math.floor(i/864e5);return a<1?"Just now":a<60?`${a} minute${a>1?"s":""} ago`:c<24?`${c} hour${c>1?"s":""} ago`:l<7?`${l} day${l>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function qo(t){return t==null?"None":typeof t=="string"||typeof t=="number"||typeof t=="boolean"?String(t):JSON.stringify(t,null,2)}const Ko=100;function Ws(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ps(t){var c;const r=(c=t.views)==null?void 0:c.find(l=>l.id===t.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=t.columnOrder||[],a=Hn(i,t.grouping||null,n);return{filters:t.filters?[...t.filters]:[],sortStack:t.sortStack?[...t.sortStack]:[],columnVisibility:t.columnVisibility?{...t.columnVisibility}:{},columnOrder:a,columnWidths:t.columnWidths?{...t.columnWidths}:{},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}function _s(t,r,n,i){return{id:Ws(),name:t,description:r,createdBy:n,createdAt:Date.now(),config:i}}function $s(t,r){const n=t||[];if(n.length>=Ko)throw new Error(`Maximum of ${Ko} presets reached. Please delete old presets first.`);return[...n,r]}function Xo(t,r){return(t||[]).filter(i=>i.id!==r)}function Qo(t,r){if(t)return t.find(n=>n.id===r)}function ho(t,r){return`${window.location.origin+window.location.pathname}?mode=viewer&reportId=${t}&preset=${r}`}function Zo(t){window.open(t,"_blank","noopener,noreferrer")}function Fs(t,r,n,i){const a=encodeURIComponent(`Shared Report Preset: ${r}`);let c=`I'm sharing a report preset with you:
|
|
4
|
-
|
|
5
|
-
`;c+=`Preset Name: ${r}
|
|
6
|
-
`,i&&(c+=`Description: ${i}
|
|
7
|
-
`),c+=`
|
|
8
|
-
Click the link below to view the report with this configuration:
|
|
9
|
-
${n}
|
|
10
|
-
|
|
11
|
-
`,c+="This link will load the report with pre-configured filters, sorting, and column settings.";const l=encodeURIComponent(c);return`mailto:${t.join(",")}?subject=${a}&body=${l}`}function Ls(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Ns(t){const r=t.columnOrder,n=Er(r,t.grouping);return{filters:t.filters.length>0?[...t.filters]:void 0,sortStack:t.sortStack.length>0?[...t.sortStack]:void 0,columnVisibility:{...t.columnVisibility},columnOrder:n,columnWidths:{...t.columnWidths},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}async function en(t){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(t),!0}catch(r){console.warn("Clipboard API blocked, using fallback method:",r)}try{const r=document.createElement("textarea");r.value=t,r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width="2em",r.style.height="2em",r.style.padding="0",r.style.border="none",r.style.outline="none",r.style.boxShadow="none",r.style.background="transparent",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let n=!1;try{n=document.execCommand("copy")}catch(i){console.error("execCommand copy failed:",i)}return document.body.removeChild(r),n}catch(r){return console.error("Fallback copy method failed:",r),!1}}function Vs(t,r){return{totalRows:t.length,totalColumns:r.length}}const Hs={MAX_CACHE_ENTRIES:3};function Us(t,r){let n=null;return function(...a){const c=()=>{n=null,t(...a)};n&&clearTimeout(n),n=setTimeout(c,r)}}class Lr{constructor(r=Hs.MAX_CACHE_ENTRIES){this.cache=new Map,this.maxEntries=r}get(r){const n=this.cache.get(r);return n?n.value:null}set(r,n){var i;if(this.cache.size>=this.maxEntries&&!this.cache.has(r)){const a=(i=Array.from(this.cache.entries()).sort((c,l)=>c[1].timestamp-l[1].timestamp)[0])==null?void 0:i[0];a&&this.cache.delete(a)}this.cache.set(r,{key:r,value:n,timestamp:Date.now()})}has(r){return this.cache.has(r)}clear(){this.cache.clear()}size(){return this.cache.size}}class Gs{constructor(){this.metrics=new Map}start(r){this.metrics.set(r,performance.now())}end(r){const n=this.metrics.get(r);if(!n)return 0;const i=performance.now()-n;return this.metrics.delete(r),i}measure(r,n){this.start(r);const i=n(),a=this.end(r);return{result:i,duration:a}}async measureAsync(r,n){this.start(r);const i=await n(),a=this.end(r);return{result:i,duration:a}}}function bt(t,r,n,i){const a=n instanceof Error?n.message:n,c={type:t,context:r,message:a,details:i,timestamp:Date.now(),recoverable:Ys(t,r)};return process.env.NODE_ENV==="development"&&console.error("[Report Error]",{type:t,context:r,message:a,details:i}),c}function Ys(t,r){return t==="ui"||t==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:t!=="system"}function Js(t){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[t.context]||"An error occurred";return t.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function qs(t){return{filters:t.filters?[...t.filters]:void 0,sortStack:t.sortStack?[...t.sortStack]:void 0,grouping:t.grouping?{...t.grouping}:void 0,columnVisibility:t.columnVisibility?{...t.columnVisibility}:void 0,columnOrder:t.columnOrder?[...t.columnOrder]:void 0,columnWidths:t.columnWidths?{...t.columnWidths}:void 0,activeViewId:t.activeViewId}}function Ks(t,r,n){n(t.id,{filters:r.filters,sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function Xs(t,r,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(r)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:t==="number"&&["gt","gte","lt","lte","equals"].includes(r)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:t==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function qn(t,r){const n=[],i=[],a=new Set(r.map(c=>c.name));return t.forEach(c=>{a.has(c.column)?n.push(c):i.push(c.column)}),{validRules:n,invalidColumns:i}}function Kn(t,r){if(!t||!t.levels||t.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(c=>c.name)),i=[],a=[];return t.levels.forEach(c=>{n.has(c.column)?i.push(c):a.push(c.column)}),i.length===0?{validGrouping:null,invalidColumns:a}:{validGrouping:{...t,levels:i},invalidColumns:a}}function Qs(t,r){const n=[],i=new Set(r.map(c=>c.name)),a={...t};if(a.filters&&Array.isArray(a.filters)){const c=a.filters.filter(l=>{const d=i.has(l.column);return d||n.push(`Filter for column "${l.column}" ignored (column not found)`),d});a.filters=c.length>0?c:void 0}if(a.sortStack&&Array.isArray(a.sortStack)){const{validRules:c,invalidColumns:l}=qn(a.sortStack,r);l.length>0&&n.push(`Sort rules for columns ignored: ${l.join(", ")}`),a.sortStack=c.length>0?c:void 0}if(a.grouping){const{validGrouping:c,invalidColumns:l}=Kn(a.grouping,r);l.length>0&&n.push(`Grouping for columns ignored: ${l.join(", ")}`),a.grouping=c}if(a.columnVisibility){const c={};Object.entries(a.columnVisibility).forEach(([l,d])=>{i.has(l)?c[l]=d:n.push(`Column visibility for "${l}" ignored (column not found)`)}),a.columnVisibility=Object.keys(c).length>0?c:void 0}if(a.columnOrder&&Array.isArray(a.columnOrder)){const c=a.columnOrder.filter(l=>{const d=i.has(l);return d||n.push(`Column "${l}" in order ignored (column not found)`),d});a.columnOrder=c.length>0?c:void 0}if(a.columnWidths){const c={};Object.entries(a.columnWidths).forEach(([l,d])=>{i.has(l)?c[l]=d:n.push(`Column width for "${l}" ignored (column not found)`)}),a.columnWidths=Object.keys(c).length>0?c:void 0}return{sanitizedConfig:a,warnings:n}}function Zs(t,r){return bt("processing","export",t,{retryAvailable:!!(r!=null&&r.onRetry)})}function tn(t,r,n,i){const a=Yn(t,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Jn(i||[],a)}function ea(t){return t==null}function ta(t,r){const{operator:n,value:i}=r;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(ea(t))return!1;switch(n){case"equals":return String(t)===String(i);case"contains":return String(t).toLowerCase().includes(String(i).toLowerCase());case"startsWith":return String(t).toLowerCase().startsWith(String(i).toLowerCase());case"endsWith":return String(t).toLowerCase().endsWith(String(i).toLowerCase());case"gt":return Number(t)>Number(i);case"lt":return Number(t)<Number(i);case"gte":return Number(t)>=Number(i);case"lte":return Number(t)<=Number(i);case"isTrue":return t===!0;case"isFalse":return t===!1;default:return!0}}function ra(t,r){return!r||r.length===0?t:t.filter(n=>r.every(i=>ta(n[i.column],i)))}function rn(t){switch(t){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Nr(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function oa({data:t,filters:r}){return{filteredData:u.useMemo(()=>!r||r.length===0?t:ra(t,r),[t,r])}}function Xn(t,r,n,i){if(!n||n.trim()==="")return t;const a=n.toLowerCase().trim(),c=r.filter(l=>i.includes(l.name));return t.filter(l=>c.some(d=>{const f=l[d.name];return f==null?!1:String(f).toLowerCase().includes(a)}))}function na({data:t,searchQuery:r,schema:n,visibleColumns:i}){return{searchedData:u.useMemo(()=>!r||r.trim()===""?t:Xn(t,n,r,i),[t,r,n,i])}}function ia({data:t,sortStack:r,schema:n}){return{sortedData:u.useMemo(()=>!r||r.length===0?t:ds(t,n,r),[t,r,n])}}function sa({data:t,grouping:r,schema:n}){const i=u.useMemo(()=>!r||!r.enabled||r.levels.length===0?t:hs(t,n,r),[t,r,n]),a=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:a}}function aa({schema:t,columnVisibility:r,columnOrder:n}){const i=u.useMemo(()=>n.filter(d=>r[d]!==!1),[n,r]),a=u.useMemo(()=>Object.entries(r).filter(([d,f])=>!f).map(([d,f])=>d),[r]),c=u.useMemo(()=>n.map(d=>t.find(h=>h.name===d)||{name:d,type:"string"}),[n,t]),l=u.useMemo(()=>i.map(d=>t.find(h=>h.name===d)||{name:d,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:a,allColumns:c,visibleColumnSchemas:l,hiddenCount:a.length}}function la({views:t,activeViewId:r,currentState:n}){const i=u.useMemo(()=>t.find(h=>h.id===r),[t,r]),a=u.useMemo(()=>i?ys(n,i.snapshot):!1,[i,n]),c=u.useMemo(()=>t.find(h=>h.isDefault),[t]),l=u.useMemo(()=>t.filter(h=>!h.isDefault&&!h.isDeleted),[t]),d=u.useMemo(()=>t.filter(h=>h.isFavorite&&!h.isDeleted),[t]),f=u.useMemo(()=>t.filter(h=>h.isDeleted),[t]);return{activeView:i,isDirty:a,defaultView:c,customViews:l,favoriteViews:d,deletedViews:f,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function ca({data:t,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[a,c]=u.useState(i),l=t.length,d=Math.ceil(l/n),f=u.useMemo(()=>{if(!r)return t;const S=(a-1)*n,C=S+n;return t.slice(S,C)},[t,r,a,n]),h=u.useCallback(S=>{const C=Math.max(1,Math.min(S,d));c(C)},[d]),m=u.useCallback(()=>{a<d&&c(a+1)},[a,d]),g=u.useCallback(()=>{a>1&&c(a-1)},[a]),y=u.useCallback(()=>{c(1)},[]);return{paginatedData:f,currentPage:a,totalPages:d,pageSize:n,totalRows:l,goToPage:h,nextPage:m,prevPage:g,resetPage:y,hasNextPage:a<d,hasPrevPage:a>1}}function da(t){const{rawData:r,schema:n,filters:i,sortStack:a,grouping:c,searchQuery:l,columnVisibility:d,columnOrder:f,columnWidths:h,views:m,activeViewId:g,pagination:y}=t,S=u.useMemo(()=>({filters:i,sortStack:a,grouping:c,columnVisibility:d,columnOrder:f,columnWidths:h}),[i,a,c,d,f,h]),C=la({views:m,activeViewId:g,currentState:S}),x=aa({schema:n,columnVisibility:d,columnOrder:f}),{filteredData:E}=oa({data:r,filters:i}),{sortedData:s}=ia({data:E,sortStack:a,schema:n}),{groupedData:T,isGrouped:I}=sa({data:s,grouping:c,schema:n}),{searchedData:A}=na({data:T,searchQuery:l,schema:n,visibleColumns:x.visibleColumns}),v=ca({data:A,enabled:(y==null?void 0:y.enabled)||!1,pageSize:(y==null?void 0:y.pageSize)||100,initialPage:(y==null?void 0:y.currentPage)||1}),W=y!=null&&y.enabled?v.paginatedData:A,U=u.useMemo(()=>({totalRows:r.length,filteredRows:E.length,sortedRows:s.length,groupedRows:I?T.length:s.length,searchedRows:A.length,visibleRows:W.length,hiddenColumns:x.hiddenCount,activeFilters:i.length,activeSorts:a.length,isGrouped:I}),[r.length,E.length,s.length,T.length,A.length,W.length,x.hiddenCount,i.length,a.length,I]);return{data:W,filteredData:E,sortedData:s,groupedData:T,searchedData:A,viewEngine:C,columnEngine:x,paginationEngine:v,metrics:U,isGrouped:I,isPaginated:(y==null?void 0:y.enabled)||!1}}const Mt="user-demo-001";function ua(t={}){var Po,_o,$o,Fo,Lo;const{mode:r="builder",autoLoad:n=!0,initialData:i,config:a={}}=t,[c,l]=u.useState([]),[d,f]=u.useState(""),[h,m]=u.useState(!1),[g,y]=u.useState(!1),[S,C]=u.useState({message:"",severity:"info",open:!1}),x=(b,k="info")=>{C({message:b,severity:k,open:!0})},E=()=>C(b=>({...b,open:!1})),s=c.find(b=>b.id===d),[T,I]=u.useState("idle"),[A,v]=u.useState(!1),[W,U]=u.useState(!1),[w,O]=u.useState(!1),[V,X]=u.useState(!1),[p,L]=u.useState(!1),[$,_]=u.useState(!1),[F,oe]=u.useState(void 0),[ue,Ee]=u.useState(null),[R,q]=u.useState(null),[ee,te]=u.useState(!1),[re,ne]=u.useState(!1),[Z,Q]=u.useState(null),[ae,ce]=u.useState(!1),[le,je]=u.useState(!1),[G,Me]=u.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Ye,jt]=u.useState(""),[tt,$e]=u.useState(new Set),[Je,Ae]=u.useState(1),[wt,Yt]=u.useState(15),[pt,rt]=u.useState(!1),[kt,Tt]=u.useState(!1),[ft,Fe]=u.useState(!1),[qe,Jt]=u.useState(!1),[Be,zt]=u.useState(null),[Ke,ot]=u.useState(null),[qt,xt]=u.useState(!1),[Pr,mr]=u.useState(null),[nt,_t]=u.useState(null);u.useRef(new Gs),u.useRef(new Lr),u.useRef(new Lr),u.useRef(new Lr),u.useRef(new Lr);const[gr,$t]=u.useState(null),It=u.useRef(null),Ce=u.useMemo(()=>s?Es(s.permissions,Mt):"owner",[s]),Et=Bs(Ce),yr=u.useMemo(()=>!(s!=null&&s.uploadedData)||!(s!=null&&s.schema)?{totalRows:0,totalColumns:0}:Vs(s.uploadedData,s.schema),[s==null?void 0:s.uploadedData,s==null?void 0:s.schema]),Ve=u.useCallback(()=>{s&&(It.current=qs(s))},[s]),P=u.useCallback((b,k)=>{l(z=>z.map(B=>B.id===b?{...B,...k}:B))},[]),He=u.useCallback(b=>{if(!s)return;$t(b);const k=tn(s.id,Mt,b,s.auditHistory||[]);P(s.id,{auditHistory:k}),x(b.message,"error"),b.recoverable&&It.current&&setTimeout(()=>{Ks(s,It.current,P),x("Previous state restored","success")},100)},[s,P]),de=u.useCallback((b,k,z,B)=>{if(!s)return;const J=Yn(s.id,Mt,b,k,z,B),K=s.auditHistory||[],ge=Jn(K,J);setTimeout(()=>{P(s.id,{auditHistory:ge})},0)},[s,P]);u.useEffect(()=>{var b,k,z,B,J;if(s!=null&&s.schemaLocked&&s.schema&&(!s.views||s.views.length===0)){const K=xo(s.schema),ge=(()=>{try{const fe=localStorage.getItem("urm_dev_config");return fe?JSON.parse(fe):null}catch{return null}})();if(ge){const fe=ge;if(Array.isArray((b=fe.sort)==null?void 0:b.defaultSortStack)&&fe.sort.defaultSortStack.length>0){const lt=s.schema.map(Oe=>Oe.name),Xe=fe.sort.defaultSortStack.filter(Oe=>Oe.column&<.includes(Oe.column)).map((Oe,Ht)=>({column:Oe.column,direction:Oe.direction==="desc"?"desc":"asc",priority:Ht+1}));Xe.length>0&&(K.snapshot.sortStack=Xe)}if(Array.isArray((k=fe.filter)==null?void 0:k.defaultFilters)&&fe.filter.defaultFilters.length>0){const lt=s.schema.map(Oe=>Oe.name),Xe=fe.filter.defaultFilters.filter(Oe=>Oe.column&&Oe.operator&<.includes(Oe.column));Xe.length>0&&(K.snapshot.filters=Xe)}if(Array.isArray((z=fe.columns)==null?void 0:z.defaultHiddenColumns)&&fe.columns.defaultHiddenColumns.length>0&&fe.columns.defaultHiddenColumns.forEach(lt=>{lt in K.snapshot.columnVisibility&&(K.snapshot.columnVisibility[lt]=!1)}),Array.isArray((B=fe.columns)==null?void 0:B.defaultColumnOrder)&&fe.columns.defaultColumnOrder.length>0){const lt=s.schema.map(Ht=>Ht.name),Xe=fe.columns.defaultColumnOrder.filter(Ht=>lt.includes(Ht)),Oe=K.snapshot.columnOrder.filter(Ht=>!Xe.includes(Ht));Xe.length>0&&(K.snapshot.columnOrder=[...Xe,...Oe])}if(Array.isArray((J=fe.grouping)==null?void 0:J.defaultGrouping)&&fe.grouping.defaultGrouping.length>0){const lt=s.schema.map(Oe=>Oe.name),Xe=fe.grouping.defaultGrouping.filter(Oe=>Oe.column&<.includes(Oe.column));Xe.length>0&&(K.snapshot.grouping={enabled:!0,levels:Xe,collapsedGroups:[]})}}P(s.id,{views:[K],activeViewId:K.id,filters:K.snapshot.filters,sortStack:K.snapshot.sortStack,columnVisibility:K.snapshot.columnVisibility,columnOrder:K.snapshot.columnOrder,columnWidths:K.snapshot.columnWidths,grouping:K.snapshot.grouping})}},[s==null?void 0:s.schemaLocked,s==null?void 0:s.schema,s==null?void 0:s.id,P]),u.useEffect(()=>{if(i&&n&&!g&&c.length===0){const b={id:`auto-report-${Date.now()}`,name:r==="viewer"?"Data View":"Imported Data",description:"Auto-generated from external data",schemaLocked:!0,uploadedData:i,schema:fo(i),permissions:{owner:Mt,editors:[],viewers:[]}};l([b]),f(b.id),y(!0),I("confirmed")}},[i,n,g,c.length,r]);const Re=(Po=s==null?void 0:s.views)==null?void 0:Po.find(b=>b.id===s.activeViewId),br=u.useMemo(()=>s!=null&&s.uploadedData?!s.showFavoritesOnly||!s.favoriteRowIndices||s.favoriteRowIndices.length===0?s.uploadedData:s.uploadedData.filter((b,k)=>s.favoriteRowIndices.includes(k)):[],[s==null?void 0:s.uploadedData,s==null?void 0:s.showFavoritesOnly,s==null?void 0:s.favoriteRowIndices]),Ft=u.useMemo(()=>{var k;if(!(s!=null&&s.uploadedData)||!((k=s==null?void 0:s.favoriteRowIndices)!=null&&k.length))return new Set;const b=new Set;return s.favoriteRowIndices.forEach(z=>{const B=s.uploadedData[z];B!==void 0&&b.add(B)}),b},[s==null?void 0:s.uploadedData,s==null?void 0:s.showFavoritesOnly,s==null?void 0:s.favoriteRowIndices]),Bt=da({rawData:br,schema:(s==null?void 0:s.schema)||[],filters:(s==null?void 0:s.filters)||[],sortStack:(s==null?void 0:s.sortStack)||[],grouping:(s==null?void 0:s.grouping)||null,searchQuery:Ye||"",columnVisibility:(s==null?void 0:s.columnVisibility)||(Re==null?void 0:Re.snapshot.columnVisibility)||{},columnOrder:(s==null?void 0:s.columnOrder)||(Re==null?void 0:Re.snapshot.columnOrder)||[],columnWidths:(s==null?void 0:s.columnWidths)||(Re==null?void 0:Re.snapshot.columnWidths)||{},views:(s==null?void 0:s.views)||[],activeViewId:(s==null?void 0:s.activeViewId)||"",pagination:{enabled:!0,pageSize:wt,currentPage:Je}}),{data:Lt=[],searchedData:Nt=[],groupedData:ht=[],metrics:Kt={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Vt=!1,paginationEngine:ie}=Bt||{},H=((_o=Bt.viewEngine)==null?void 0:_o.activeView)||Re,it=(($o=Bt.viewEngine)==null?void 0:$o.isDirty)||!1;u.useEffect(()=>{if(!(!H||!s)&&!s.columnOrder){const b=H.snapshot.columnOrder,k=Er(b,H.snapshot.grouping);P(s.id,{columnOrder:k})}},[s==null?void 0:s.activeViewId]);const xe=u.useMemo(()=>!(s!=null&&s.schema)||!H?null:gs(s.filters||[],s.sortStack||[],s.schema,s.columnVisibility,s.columnOrder,s.columnWidths,s.grouping,H.snapshot.columnOrder),[s==null?void 0:s.filters,s==null?void 0:s.sortStack,s==null?void 0:s.schema,s==null?void 0:s.columnVisibility,s==null?void 0:s.columnOrder,s==null?void 0:s.columnWidths,s==null?void 0:s.grouping,H]),Le=u.useMemo(()=>!H||!xe||!it?[]:vs(xe,H.snapshot),[H,xe,it]),Xt=u.useCallback((b,k,z)=>{const B={id:`report-${Date.now()}`,name:b,description:k,schemaLocked:!1,permissions:{owner:Mt,editors:[],viewers:[]}};if(z&&Array.isArray(z)&&z.length>0){const J=fo(z),K=xo(J);B.uploadedData=z,B.schema=J,B.schemaLocked=!0,B.views=[K],B.activeViewId=K.id,B.sortStack=K.snapshot.sortStack,B.filters=K.snapshot.filters,B.columnVisibility=K.snapshot.columnVisibility,B.columnOrder=K.snapshot.columnOrder,B.columnWidths=K.snapshot.columnWidths,B.grouping=K.snapshot.grouping}l(J=>[...J,B]),f(B.id),m(!1),I("confirmed")},[]),vr=u.useCallback(b=>{s&&(I("uploading"),setTimeout(()=>{const k=fo(b);P(s.id,{uploadedData:b,schema:k,uploadError:void 0}),I("preview")},500))},[s,P]),Qt=u.useCallback(b=>{s&&(P(s.id,{uploadError:b}),I("idle"))},[s,P]),Zt=u.useCallback(()=>{s&&(P(s.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),I("idle"))},[s,P]),Ne=u.useCallback(()=>{s&&(P(s.id,{schemaLocked:!0}),I("confirmed"))},[s,P]),st=u.useCallback(b=>{if(!s)return;if(!ct("edit_sorting",Ce)){x(dt("edit_sorting"),"error");return}const k=s.sortStack??[],z=k.find(B=>B.column===b);if(z){const B=us(z.direction);if(B===null){const J=k.filter(K=>K.column!==b).map((K,ge)=>({...K,priority:ge+1}));P(s.id,{sortStack:J.length>0?J:void 0})}else{const J=k.map(K=>K.column===b?{...K,direction:B}:K);P(s.id,{sortStack:J})}}else{if(k.length>=3)return;const B={column:b,direction:"asc",priority:k.length+1};P(s.id,{sortStack:[...k,B]})}},[s,Ce,P]),er=u.useCallback(b=>{if(s)if(s.schema){const{validRules:k,invalidColumns:z}=qn(b,s.schema);z.length>0&&x(`Removed invalid sort columns: ${z.join(", ")}`),Ve();try{P(s.id,{sortStack:k.length>0?k:void 0})}catch(B){const J=bt("processing","sorting",B);He(J)}}else P(s.id,{sortStack:b.length>0?b:void 0})},[s,P,Ve,He]),mt=u.useCallback(b=>{if(!s)return;const k=s.sortStack??[],z=k.find(B=>B.column===b);if(!(z&&z.direction==="asc"))if(z){const B=k.map(J=>J.column===b?{...J,direction:"asc"}:J);P(s.id,{sortStack:B})}else{if(k.length>=3)return;const B={column:b,direction:"asc",priority:k.length+1};P(s.id,{sortStack:[...k,B]})}},[s,P]),Sr=u.useCallback(b=>{if(!s)return;const k=s.sortStack??[],z=k.find(B=>B.column===b);if(!(z&&z.direction==="desc"))if(z){const B=k.map(J=>J.column===b?{...J,direction:"desc"}:J);P(s.id,{sortStack:B})}else{if(k.length>=3)return;const B={column:b,direction:"desc",priority:k.length+1};P(s.id,{sortStack:[...k,B]})}},[s,P]),tr=u.useCallback(b=>{var z;if(!s)return;if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}const k=(z=s.schema)==null?void 0:z.find(B=>B.name===b.column);if(k&&b.value!==void 0){const B=Xs(k.type,b.operator,b.value);if(!B.isValid){x(B.errorMessage||"Invalid filter value","error");return}}Ve();try{const B=s.filters??[];de("filters","filter_added",B,[...B,b]),P(s.id,{filters:[...B,b]})}catch(B){const J=bt("processing","filters",B);He(J)}},[s,Ce,P,Ve,He,de]),rr=u.useCallback((b,k)=>{if(!s)return;if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}const z=s.filters??[],B=[...z];de("filters","filter_updated",z[b],k),B[b]=k,P(s.id,{filters:B})},[s,Ce,P,de]),or=u.useCallback(b=>{if(!s)return;if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}const k=s.filters??[],z=k.filter((B,J)=>J!==b);de("filters","filter_removed",k[b],null),P(s.id,{filters:z.length>0?z:void 0})},[s,Ce,P,de]),Cr=u.useCallback(()=>{if(!s)return;if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}const b=s.filters??[];de("filters","filter_cleared",b,null),P(s.id,{filters:void 0})},[s,Ce,P,de]),gt=u.useCallback(b=>{var J;if(!s)return;const k=(J=s.views)==null?void 0:J.find(K=>K.id===b);if(!k)return;const z=k.snapshot.columnOrder,B=Er(z,k.snapshot.grouping);P(s.id,{filters:k.snapshot.filters.length>0?[...k.snapshot.filters]:void 0,sortStack:k.snapshot.sortStack.length>0?[...k.snapshot.sortStack]:void 0,columnVisibility:{...k.snapshot.columnVisibility},columnOrder:B,columnWidths:{...k.snapshot.columnWidths},grouping:k.snapshot.grouping,activeViewId:b}),$e(new Set),O(!1)},[s,P]),at=u.useCallback((b,k,z)=>{if(!(s!=null&&s.schema)||!xe)return;const B={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:b,description:k||void 0,isDefault:z,isFavorite:!1,isDeleted:!1,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...xe}},J=s.views??[],K=z?J.map(ge=>({...ge,isDefault:!1})):J;P(s.id,{views:[...K,B],activeViewId:B.id}),x(`"${b}" view created`,"success")},[s,xe,P]),nr=u.useCallback(()=>{var k;if(!H||!xe||H.isDefault||!s)return;const b=(k=s.views)==null?void 0:k.map(z=>z.id===H.id?{...z,snapshot:{...xe}}:z);P(s.id,{views:b}),x(`"${H.name}" view updated`,"success")},[H,xe,s,P]),ir=u.useCallback(()=>{var k;if(!H||!xe||!s)return;const b=(k=s.views)==null?void 0:k.map(z=>z.id===H.id?{...z,snapshot:{...z.snapshot,columnVisibility:xe.columnVisibility,columnOrder:xe.columnOrder,columnWidths:xe.columnWidths},updatedAt:Date.now()}:z);P(s.id,{views:b}),x(`Column configuration saved to "${H.name}"`,"success")},[H,xe,s,P]),sr=u.useCallback(()=>{var B,J;if(!xe||!s||!H)return;const b={...H,snapshot:{...H.snapshot,columnVisibility:xe.columnVisibility,columnOrder:xe.columnOrder,columnWidths:xe.columnWidths},updatedAt:Date.now()},k=(B=s.views)==null?void 0:B.map(K=>K.id===H.id?b:{...K,snapshot:{...K.snapshot,columnVisibility:xe.columnVisibility,columnOrder:xe.columnOrder,columnWidths:xe.columnWidths},updatedAt:Date.now()});P(s.id,{views:k});const z=(((J=s.views)==null?void 0:J.length)||0)-1;x(`Column configuration saved to current view and ${z} other view${z===1?"":"s"}`,"success")},[xe,s,H,P]),We=u.useCallback(()=>{X(!0)},[]),ar=u.useCallback(()=>{if(!H||!s)return;const b=H.snapshot.columnOrder,k=Er(b,H.snapshot.grouping);P(s.id,{filters:H.snapshot.filters.length>0?[...H.snapshot.filters]:void 0,sortStack:H.snapshot.sortStack.length>0?[...H.snapshot.sortStack]:void 0,columnVisibility:{...H.snapshot.columnVisibility},columnOrder:k,columnWidths:{...H.snapshot.columnWidths},grouping:H.snapshot.grouping}),x("Changes reverted to last saved state","success")},[H,s,P]),jr=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.map(B=>({...B,isDefault:B.id===b}));P(s.id,{views:k});const z=s.views.find(B=>B.id===b);z&&x(`"${z.name}" set as default view`,"success")},[s,P]),Dt=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.map(B=>B.id===b?{...B,isFavorite:!B.isFavorite,updatedAt:Date.now()}:B);P(s.id,{views:k});const z=s.views.find(B=>B.id===b);z&&!z.isFavorite?x(`"${z.name}" added to favorites`,"success"):z&&x(`"${z.name}" removed from favorites`,"info")},[s,P]),wr=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.map(K=>K.id===b?{...K,isDeleted:!0,updatedAt:Date.now()}:K),z=s.activeViewId===b,B=k.find(K=>K.isDefault&&!K.isDeleted);P(s.id,{views:k,activeViewId:z&&B?B.id:s.activeViewId,filters:z&&B?B.snapshot.filters.length>0?B.snapshot.filters:void 0:s.filters,sortStack:z&&B?B.snapshot.sortStack.length>0?B.snapshot.sortStack:void 0:s.sortStack});const J=s.views.find(K=>K.id===b);J&&x(`"${J.name}" moved to Recently Deleted`,"info")},[s,P]),lr=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.map(B=>B.id===b?{...B,isDeleted:!1,updatedAt:Date.now()}:B);P(s.id,{views:k});const z=s.views.find(B=>B.id===b);z&&x(`"${z.name}" restored`,"success")},[s,P]),D=u.useCallback(b=>{if(!(s!=null&&s.views))return;const k=s.views.find(fe=>fe.id===b),z=s.views.filter(fe=>!fe.isDeleted||fe.id===b);if((k==null?void 0:k.isDefault)&&z.filter(fe=>fe.isDefault).length===1){x("Cannot delete the last default view","error");return}const J=s.views.filter(fe=>fe.id!==b),K=s.activeViewId===b,ge=J.find(fe=>fe.isDefault&&!fe.isDeleted);P(s.id,{views:J,activeViewId:K&&ge?ge.id:s.activeViewId,filters:K&&ge?ge.snapshot.filters.length>0?ge.snapshot.filters:void 0:s.filters,sortStack:K&&ge?ge.snapshot.sortStack.length>0?ge.snapshot.sortStack:void 0:s.sortStack}),k&&x(`"${k.name}" permanently deleted`,"success")},[s,P]),Y=u.useCallback(b=>{Ee(b),L(!0),O(!1)},[]),pe=u.useCallback((b,k)=>{if(!ue||!(s!=null&&s.views))return;const z=s.views.map(B=>B.id===ue?{...B,name:b,description:k||void 0}:B);P(s.id,{views:z}),Ee(null)},[ue,s,P]),Pe=u.useCallback(b=>{q(b),_(!0),O(!1)},[]),se=u.useCallback(()=>{if(!R||!(s!=null&&s.views))return;const b=s.views.filter(B=>B.id!==R),k=s.activeViewId===R,z=b.find(B=>B.isDefault);P(s.id,{views:b,activeViewId:k&&z?z.id:s.activeViewId,filters:k&&z?z.snapshot.filters.length>0?z.snapshot.filters:void 0:s.filters,sortStack:k&&z?z.snapshot.sortStack.length>0?z.snapshot.sortStack:void 0:s.sortStack}),q(null),_(!1)},[R,s,P]);u.useEffect(()=>{ie!=null&&ie.resetPage?ie.resetPage():Ae(1)},[s==null?void 0:s.filters,Ye,s==null?void 0:s.activeViewId]),u.useEffect(()=>{ie&&ie.currentPage!==Je&&Ae(ie.currentPage)},[ie==null?void 0:ie.currentPage]);const Ot=u.useCallback(b=>{ie!=null&&ie.goToPage&&ie.goToPage(b),Ae(b)},[ie]),_r=u.useCallback(b=>{const k=(Je-1)*wt,z=Math.floor(k/b)+1;Yt(b),Ae(z)},[Je,wt]),ke=u.useCallback((b,k)=>{if(!s)return;if(!ct("edit_columns",Ce)){x(dt("edit_columns"),"error");return}const B={...s.columnVisibility||(H==null?void 0:H.snapshot.columnVisibility)||{},[b]:k};P(s.id,{columnVisibility:B})},[s,H,Ce,P]),Te=u.useCallback(b=>{if(s){if(!ct("edit_columns",Ce)){x(dt("edit_columns"),"error");return}P(s.id,{columnOrder:b})}},[s,Ce,P]),At=u.useCallback((b,k)=>{if(!s)return;if(!ct("edit_columns",Ce)){x(dt("edit_columns"),"error");return}const B={...s.columnWidths||(H==null?void 0:H.snapshot.columnWidths)||{},[b]:k};P(s.id,{columnWidths:B})},[s,H,Ce,P]),po=u.useCallback(b=>{if(!s)return;const z=(s.filters??[]).filter(B=>B.column!==b);P(s.id,{filters:z.length>0?z:void 0})},[s,P]),wi=u.useCallback(()=>{if(!H||!(s!=null&&s.schema))return;const b={},k=[],z={};s.schema.forEach(B=>{b[B.name]=!0,k.push(B.name),z[B.name]=150}),P(s.id,{columnVisibility:b,columnOrder:k,columnWidths:z,filters:void 0,sortStack:void 0}),x("Reset to default layout - all filters and sorts cleared","success")},[H,s,P]),Wo=u.useCallback(Us(b=>{jt(b)},300),[]),ki=u.useCallback(b=>{Wo(b)},[Wo]),Ti=u.useCallback(b=>{if(!b.trim()||!s)return;const k=s.searchHistory||[],z=ws(k,b);P(s.id,{searchHistory:z})},[s,P]),zi=u.useCallback(b=>{if(!s)return;const k=s.searchHistory||[],z=ks(k,b);P(s.id,{searchHistory:z})},[s,P]),Ii=u.useCallback(b=>{if(!s)return;const k=s.searchHistory||[],z=Ts(k,b);P(s.id,{searchHistory:z})},[s,P]),Ei=u.useCallback(b=>{$e(k=>{const z=new Set(k);return z.has(b)?z.delete(b):z.add(b),z})},[]),Bi=u.useCallback((b,k)=>{if(b){const z=new Set;for(let B=0;B<k;B++)z.add(B);$e(z)}else $e(new Set)},[]),Di=u.useCallback((b,k)=>{$e(z=>{const B=new Set(z),J=Math.min(b,k),K=Math.max(b,k);for(let ge=J;ge<=K;ge++)B.add(ge);return B})},[]),Oi=u.useCallback(()=>{$e(new Set)},[]),Ai=u.useCallback(b=>{if(!s)return;const k=s.favoriteRowIndices||[],B=k.includes(b)?k.filter(J=>J!==b):[...k,b];P(s.id,{favoriteRowIndices:B})},[s,P]),Mi=u.useCallback((b,k)=>{if(!s)return;const z=s.favoriteRowIndices||[],B=k?[...z,...b.filter(J=>!z.includes(J))]:z.filter(J=>!b.includes(J));P(s.id,{favoriteRowIndices:B})},[s,P]),Ri=u.useCallback(()=>{if(!s)return;const b=s.favoriteRowIndices||[],k=!s.showFavoritesOnly;if(k&&b.length===0){x("No rows marked as favorite","warning");return}P(s.id,{showFavoritesOnly:k}),$e(new Set),x(k?`Showing ${b.length} favorite row${b.length===1?"":"s"}`:"Showing all data","info")},[s,P]),Wi=u.useCallback(b=>{if(s){if(!ct("edit_columns",Ce)){x(dt("edit_columns"),"error");return}if(b&&s.schema){const{validGrouping:k,invalidColumns:z}=Kn(b,s.schema);z.length>0&&x(`Removed invalid grouping columns: ${z.join(", ")}`,"warning"),Ve();try{const B=s.grouping;k===null?de("grouping","group_cleared",B,null):B?de("grouping","group_reordered",B,k):de("grouping","group_level_added",null,k);const J=(H==null?void 0:H.snapshot.columnOrder)||s.columnOrder||[],K=Er(J,k);P(s.id,{grouping:k,columnOrder:K}),JSON.stringify(K)!==JSON.stringify(s.columnOrder)&&de("columns","column_reordered",s.columnOrder,K),je(!1)}catch(B){const J=bt("processing","grouping",B);He(J)}}else{const k=s.grouping;de("grouping","group_cleared",k,null);const z=(H==null?void 0:H.snapshot.columnOrder)||s.columnOrder||[];P(s.id,{grouping:b,columnOrder:[...z]}),JSON.stringify(z)!==JSON.stringify(s.columnOrder)&&de("columns","column_reordered",s.columnOrder,z),je(!1)}}},[s,H,Ce,P,Ve,He,de]),Pi=u.useCallback(b=>{if(!s)return;const k=s.grouping;if(!k)return;const z=ms(k,b);P(s.id,{grouping:z})},[s,P]),_i=u.useCallback(()=>{xt(!0)},[]),cr=u.useCallback(b=>{s!=null&&s.schema&&(te(!0),setTimeout(()=>{try{let k;b.scope==="visible"?k=Nt:k=s.uploadedData||[];let z;b.columnScope==="all"?(z={},s.schema.forEach(fe=>{z[fe.name]=!0})):z=s.columnVisibility||(H==null?void 0:H.snapshot.columnVisibility)||{};const B=s.columnOrder||(H==null?void 0:H.snapshot.columnOrder),J=Vo(k,s.schema,s.filters??[],s.sortStack??[],H,z,B),K=s.name;let ge;switch(b.format){case"csv":Ho(J,K,b),ge="export_csv";break;case"excel":Uo(J,K,b),ge="export_excel";break;case"json":Go(J,K,b),ge="export_json";break}de("export",ge,null,{format:b.format,scope:b.scope,columnScope:b.columnScope,rowCount:k.length,viewName:(H==null?void 0:H.name)||"Default View"}),x(`Export completed successfully (${b.format.toUpperCase()})`,"success")}catch(k){const z=Zs(k,{onRetry:()=>cr(b)});x(`Export failed: ${z.message}`,{action:{label:"Retry",onClick:()=>cr(b)}});const B=tn(s.id,Mt,z,s.auditHistory||[]);P(s.id,{auditHistory:B}),console.error("Export error:",k)}finally{te(!1)}},500))},[s,H,Nt,P,de]),$i=u.useCallback(b=>{if(s!=null&&s.schema){if(it&&H&&!H.isDefault){Q(b.format),ne(!0),xt(!1);return}cr(b),xt(!1)}},[s,H,it,cr]),$r=u.useCallback(b=>{cr({format:b,scope:"visible",columnScope:"visible"})},[cr]),Fi=u.useCallback(()=>{Z&&$r(Z),ne(!1),Q(null)},[Z,$r]),Li=u.useCallback(()=>{nr(),Z&&$r(Z),ne(!1),Q(null)},[nr,Z,$r]),Ni=u.useCallback(()=>{ne(!1),Q(null)},[]),Vi=u.useCallback(b=>{!(s!=null&&s.schema)||tt.size===0||(te(!0),setTimeout(()=>{try{const k=Array.from(tt).sort((J,K)=>J-K).map(J=>ht[J]).filter(J=>J!==void 0),z=Vo(k,s.schema,s.filters??[],s.sortStack??[],H),B=`${s.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(b){case"csv":Ho(z,B);break;case"excel":Uo(z,B);break;case"json":Go(z,B);break}x(`Exported ${k.length} selected rows`,"info")}catch(k){x("Export failed. Please try again.","error"),console.error("Export error:",k)}finally{te(!1)}},500))},[s,H,tt,ht]),Hi=u.useCallback(()=>{if(!ct("edit_filters",Ce)){x(dt("edit_filters"),"error");return}Tt(!0)},[Ce]),Ui=u.useCallback((b,k,z)=>{if(s)try{const B=Ps(s),J=_s(b,k,Mt,B),K=$s(s.presets,J);P(s.id,{presets:K});const ge=ho(s.id,J.id);if(de("presets","preset_created",null,{presetId:J.id,name:J.name}),z&&z.length>0){const fe=Fs(z,b,ge,k);window.location.href=fe,x(`Preset created! Opening email client to share with ${z.length} recipient${z.length>1?"s":""}...`,"success")}zt({preset:J,url:ge}),Tt(!1),Fe(!0),x(`Preset "${b}" created successfully`,"success")}catch(B){x(B instanceof Error?B.message:"Failed to create preset","error")}},[s,P,de]),Gi=u.useCallback(async()=>{if(!Be)return;await en(Be.url)?(de("presets","preset_link_copied",null,{presetId:Be.preset.id}),x("Link copied to clipboard","success")):x("Failed to copy link","error")},[Be,de]),Yi=u.useCallback(()=>{Be&&(Zo(Be.url),de("presets","preset_link_opened",null,{presetId:Be.preset.id}),x("Opening preset in new tab...","info"))},[Be,de]),Ji=u.useCallback(()=>{if(!Be||!s)return;const b=Be.preset.id,k=Be.preset.name,z=Xo(s.presets,b);P(s.id,{presets:z}),de("presets","preset_deleted",{presetId:b,name:k},null),Ke===b&&ot(null),Fe(!1),zt(null),x(`Preset "${k}" deleted`,"success")},[Be,s,Ke,P,de]),qi=u.useCallback(()=>{ot(null),x("Exited preset view","info")},[]),Ki=u.useCallback(()=>{Jt(!0)},[]),Xi=u.useCallback(b=>{if(!s)return;const k=ho(s.id,b);Zo(k),de("presets","preset_link_opened",null,{presetId:b}),x("Opening preset in new tab...","info")},[s,de]),Qi=u.useCallback(async(b,k)=>{if(!s)return;const z=ho(s.id,b);await en(z)?(de("presets","preset_link_copied",null,{presetId:b}),x(`Link for "${k}" copied to clipboard`,"success")):x("Failed to copy link. Please try the manual copy method.","error")},[s,de]),Zi=u.useCallback((b,k)=>{if(!s)return;const z=Xo(s.presets,b);P(s.id,{presets:z}),de("presets","preset_deleted",{presetId:b,name:k},null),Ke===b&&ot(null),(Be==null?void 0:Be.preset.id)===b&&(Fe(!1),zt(null)),x(`Preset "${k}" deleted`,"success")},[s,Ke,Be,P,de]);u.useEffect(()=>{if(!s)return;const b=Ls();if(b&&s.presets&&s.schemaLocked&&s.schema){const k=Qo(s.presets,b);if(k){const{sanitizedConfig:z,warnings:B}=Qs(k.config,s.schema);B.length>0&&B.forEach(K=>x(K,"warning"));const J=Ns(z);P(s.id,J),ot(b),de("presets","preset_applied",null,{presetId:k.id,name:k.name}),x(`Loaded preset: ${k.name}`,"info")}else x("Preset not found","info")}},[s==null?void 0:s.schemaLocked]);const es=Ke?Qo(s==null?void 0:s.presets,Ke):void 0;u.useEffect(()=>{s!=null&&s.views&&s.views.length>0&&s.activeViewId&&Ss(s.id,{views:s.views,activeViewId:s.activeViewId})},[s==null?void 0:s.views,s==null?void 0:s.activeViewId,s==null?void 0:s.id]),u.useEffect(()=>{if(s!=null&&s.schemaLocked&&s.schema&&(!s.views||s.views.length===0)){const b=Cs(s.id);if(b&&b.views.length>0){const k=b.views.find(z=>z.id===b.activeViewId);if(k)P(s.id,{views:b.views,activeViewId:b.activeViewId,filters:k.snapshot.filters.length>0?k.snapshot.filters:void 0,sortStack:k.snapshot.sortStack.length>0?k.snapshot.sortStack:void 0});else{const z=b.views.find(B=>B.isDefault)||xo(s.schema);P(s.id,{views:b.views,activeViewId:z.id,filters:z.snapshot.filters.length>0?z.snapshot.filters:void 0,sortStack:z.snapshot.sortStack.length>0?z.snapshot.sortStack:void 0})}}}},[s==null?void 0:s.schemaLocked,s==null?void 0:s.schema,s==null?void 0:s.id]);const ts=u.useCallback(b=>{oe(b),v(!0)},[]),rs=u.useCallback(()=>{v(!1),oe(void 0)},[]),os=(Fo=s==null?void 0:s.views)==null?void 0:Fo.find(b=>b.id===ue),ns=(Lo=s==null?void 0:s.views)==null?void 0:Lo.find(b=>b.id===R);return{reports:c,activeReport:s,activeReportId:d,setActiveReportId:f,isModalOpen:h,setIsModalOpen:m,createReport:Xt,updateReport:P,uploadState:T,handleFileUpload:vr,handleUploadError:Qt,handleRetry:Zt,handleConfirm:Ne,paginatedData:Lt,processedData:Nt,displayData:ht,tableMetrics:Kt,isGrouped:Vt,tableEngine:Bt,activeView:H,isDirty:it,currentTableState:xe,viewChanges:Le,filters:s==null?void 0:s.filters,showFilterPanel:A,setShowFilterPanel:v,filterFocusColumn:F,handleAddFilter:tr,handleUpdateFilter:rr,handleRemoveFilter:or,handleClearAllFilters:Cr,handleOpenFilterForColumn:ts,handleCloseFilterPanel:rs,handleClearFiltersForColumn:po,sortStack:s==null?void 0:s.sortStack,showSortPanel:W,setShowSortPanel:U,handleSort:st,handleUpdateSortStack:er,handleSortAscending:mt,handleSortDescending:Sr,views:s==null?void 0:s.views,showManageViews:w,setShowManageViews:O,showCreateViewModal:V,setShowCreateViewModal:X,showEditViewModal:p,setShowEditViewModal:L,showDeleteConfirmation:$,setShowDeleteConfirmation:_,editingView:os,deletingView:ns,editingViewId:ue,deletingViewId:R,handleSelectView:gt,handleCreateView:at,handleUpdateCurrentView:nr,handleSaveColumnConfigToCurrentView:ir,handleSaveColumnConfigToAllViews:sr,handleSaveAsNewView:We,handleRevertChanges:ar,handleToggleDefault:jr,handleToggleFavorite:Dt,handleSoftDelete:wr,handleRestoreView:lr,handlePermanentDelete:D,handleEditView:Y,handleSaveEditView:pe,handleDeleteView:Pe,handleConfirmDelete:se,showManageColumns:ae,setShowManageColumns:ce,columnVisibility:s==null?void 0:s.columnVisibility,columnOrder:s==null?void 0:s.columnOrder,columnWidths:s==null?void 0:s.columnWidths,handleUpdateColumnVisibility:ke,handleUpdateColumnOrder:Te,handleUpdateColumnWidth:At,handleResetColumnLayout:wi,showGroupPanel:le,setShowGroupPanel:je,grouping:s==null?void 0:s.grouping,groupingState:G,handleGroup:Wi,handleToggleGroupCollapse:Pi,searchQuery:Ye,searchHistory:zs((s==null?void 0:s.searchHistory)||[]),handleSearchChange:ki,handleAddToSearchHistory:Ti,handleToggleSearchFavourite:zi,handleDeleteSearchHistory:Ii,selectedRowIds:tt,handleToggleRowSelection:Ei,handleToggleAllRows:Bi,handleRangeSelection:Di,handleClearSelection:Oi,favoriteRowIndices:(s==null?void 0:s.favoriteRowIndices)||[],resolvedFavoritesSet:Ft,showFavoritesOnly:(s==null?void 0:s.showFavoritesOnly)||!1,handleToggleRowFavorite:Ai,handleBulkSetFavorites:Mi,handleToggleFavoritesFilter:Ri,currentPage:Je,pageSize:wt,paginationEngine:ie,handlePageChange:Ot,handlePageSizeChange:_r,isExporting:ee,showExportModal:qt,setShowExportModal:xt,showDirtyExportWarning:re,handleExport:_i,handleExportWithConfig:$i,handleExportSelected:Vi,handleExportAnyway:Fi,handleSaveAndExport:Li,handleCancelExport:Ni,showAuditHistory:pt,setShowAuditHistory:rt,auditHistory:s==null?void 0:s.auditHistory,showCreatePreset:kt,setShowCreatePreset:Tt,showShareLink:ft,setShowShareLink:Fe,showManagePresets:qe,setShowManagePresets:Jt,generatedPreset:Be,activePreset:es,activePresetId:Ke,handleOpenSharePreset:Hi,handleOpenManagePresets:Ki,handleCreatePreset:Ui,handleCopyPresetLink:Gi,handleOpenPreset:Yi,handleDeletePreset:Ji,handleClearActivePreset:qi,handleOpenPresetById:Xi,handleCopyPresetLinkById:Qi,handleDeletePresetById:Zi,userRole:Ce,isViewerRole:Et,currentUserId:Mt,featureLimitWarning:nt,setFeatureLimitWarning:_t,datasetMeta:yr,reportError:gr,setReportError:$t,handleError:He,schema:s==null?void 0:s.schema,hasSchemaConflicts:s!=null&&s.schema?ls(s.schema):!1,snack:S,handleSnackClose:E,showSnack:x}}const _e={sort:{maxLevels:5,defaultSortStack:[]},filter:{maxConditions:10,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"],defaultFilters:[]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800,defaultHiddenColumns:[],defaultColumnOrder:[],defaultColumnWidths:{}},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0,defaultGrouping:null},export:{allowedFormats:["csv","excel","json"]},display:{showDevPanel:!1}},Qn="urm_dev_config";function pa(){try{const t=localStorage.getItem(Qn);if(!t)return _e;const r=JSON.parse(t);return{sort:{..._e.sort,...r.sort},filter:{..._e.filter,...r.filter},columns:{..._e.columns,...r.columns},grouping:{..._e.grouping,...r.grouping},export:{..._e.export,...r.export},display:{..._e.display,...r.display}}}catch{return _e}}function fa(t){try{localStorage.setItem(Qn,JSON.stringify(t))}catch{}}function xa(t,r,n){return!n||!r?t:{sort:{...t.sort,...r.sort},filter:{...t.filter,...r.filter},columns:{...t.columns,...r.columns},grouping:{...t.grouping,...r.grouping},export:{...t.export,...r.export},display:{...t.display,...r.display}}}const Zn=u.createContext(_e);function Mr(){return u.useContext(Zn)}const ei=u.createContext(void 0);function Bo(t){const{children:r,initialData:n,data:i,mode:a="builder",autoLoad:c=!0,config:l,devConfig:d,showDevPanel:f=!1}=t,m=ua({mode:a,autoLoad:c,initialData:i||n,config:l}),[g,y]=u.useState(()=>pa()),S=(()=>{const s=xa(g,d,!!d);return{...s,display:{...s.display,showDevPanel:f||s.display.showDevPanel}}})(),C=u.useCallback(E=>{y(E),fa(E)},[]),x={...m,activeDevConfig:S,handleDevConfigChange:C};return e.jsx(Zn.Provider,{value:S,children:e.jsx(ei.Provider,{value:x,children:r})})}function Kr(){const t=u.useContext(ei);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function ha({onCreateReport:t,reports:r=[],activeReportId:n,onReportClick:i}){const a=r.find(c=>c.id===n);return e.jsx(o.Box,{component:"header",sx:{position:"sticky",top:0,zIndex:50,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},children:e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[e.jsxs(o.Breadcrumbs,{separator:e.jsx(j.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[e.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:500,fontSize:"1.375rem",color:"text.primary",letterSpacing:"-0.01em",cursor:r.length>0&&a?"pointer":"default","&:hover":r.length>0&&a?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),a&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(a.id),children:a.name}),e.jsx(o.Tooltip,{title:a.description||"No description",arrow:!0,placement:"bottom",children:e.jsx(j.InfoOutlined,{sx:{fontSize:18,color:"#5f6368",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),e.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:e.jsx(o.Button,{variant:"contained",startIcon:e.jsx(j.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,textTransform:"none",fontWeight:500,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Gt(t,...r){const n=new URL(`https://mui.com/production-error/?code=${t}`);return r.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${t}; visit ${n} for the full message.`}const ma="$$material";function ga(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Vr={exports:{}},Hr={exports:{}},he={};/** @license React v16.13.1
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),ns=require("xlsx"),T=require("@mui/icons-material"),r=require("@mui/material"),Pn=require("react-dom"),is=require("@emotion/react"),bt=require("react-dnd"),Mo=require("react-dnd-html5-backend");function $n(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(o,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return o.default=t,Object.freeze(o)}const oo=$n(p),Lr=$n(ns);function ss(t){return t==null?"null":Array.isArray(t)?"array":typeof t=="object"?"object":typeof t=="number"?"number":typeof t=="boolean"?"boolean":typeof t=="string"?"string":"mixed"}function _n(t,o="",n=0){if(n>2)return{[o]:t};const i={};for(const s of Object.keys(t)){const l=o?`${o}.${s}`:s,c=t[s];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,_n(c,l,n+1)):i[l]=c}return i}function Kr(t){return t.map(o=>typeof o!="object"||o===null||Array.isArray(o)?o:_n(o))}function Ir(t){if(!Array.isArray(t)||t.length===0)return[];const o=Kr(t),n=new Set;o.forEach(s=>{typeof s=="object"&&s!==null&&Object.keys(s).forEach(l=>n.add(l))});const i=[];return n.forEach(s=>{const l=new Set;let c=0;o.forEach(g=>{typeof g=="object"&&g!==null&&s in g&&(c++,l.add(ss(g[s])))});const d=c===o.length,u=l.size>1&&!l.has("null");let f="mixed";if(l.size===1)f=Array.from(l)[0];else if(l.size===2&&l.has("null")){const g=Array.from(l).filter(h=>h!=="null");g.length===1&&(f=g[0])}i.push({name:s,type:f,required:d,hasConflict:u})}),i}function as(t){return t.some(o=>o.hasConflict)}function vt(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function Jo(t){return t==null}function ls(t){return(o,n,i)=>{const s=Jo(o),l=Jo(n);if(s&&l)return 0;if(s)return 1;if(l)return-1;let c=0;switch(t){case"number":const d=Number(o),u=Number(n);c=d-u;break;case"boolean":c=(o?1:0)-(n?1:0);break;case"string":c=String(o).localeCompare(String(n));break;case"array":case"object":c=JSON.stringify(o).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:c=String(o).localeCompare(String(n));break}return i==="asc"?c:-c}}function cs(t,o,n){if(!n||n.length===0)return t;const i=[...n].sort((s,l)=>s.priority-l.priority);return[...t].sort((s,l)=>{for(const c of i){const d=o.find(g=>g.name===c.column);if(!d)continue;const f=ls(d.type)(s[c.column],l[c.column],c.direction);if(f!==0)return f}return 0})}function ds(t){return t===null?"asc":t==="asc"?"desc":null}function us(t){return t==="string"||t==="boolean"}function ps(t){return t.filter(o=>us(o.type))}function xs(t,o){const n={};return o.forEach(i=>{if(i.type==="number"){const s=t.map(l=>l[i.name]).filter(l=>typeof l=="number");s.length>0&&(n[i.name]=s.reduce((l,c)=>l+c,0))}}),n}function fs(t,o,n){if(!n.enabled||n.levels.length===0)return t;const i=Nn(t,n.levels,o);return Fn(i,n.collapsedGroups||[])}function Nn(t,o,n,i="",s=0){if(s>=o.length)return t;const l=o[s].column,c=new Map;t.forEach(f=>{const g=f[l],h=g==null?"(empty)":String(g);c.has(h)||c.set(h,[]),c.get(h).push(f)});const d=[];return Array.from(c.keys()).sort().forEach(f=>{const g=c.get(f),h=`${l}:${f}`,y=i?`${i}|${h}`:h,w=xs(g,n),k=s<o.length-1?Nn(g,o,n,y,s+1):g,m={key:y,level:s,column:l,value:f,rowCount:g.length,aggregates:w,children:k};d.push(m)}),d}function Fn(t,o,n=[]){for(const i of t)if("key"in i&&"level"in i&&"children"in i){const s=o.includes(i.key);n.push({isGroupHeader:!0,groupKey:i.key,groupLevel:i.level,groupColumn:i.column,groupValue:i.value,rowCount:i.rowCount,aggregates:i.aggregates,isCollapsed:s}),!s&&i.children&&Fn(i.children,o,n)}else n.push(i);return n}function hs(t,o){const n=t.collapsedGroups||[],i=n.includes(o)?n.filter(s=>s!==o):[...n,o];return{...t,collapsedGroups:i}}function Vn(t,o){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function Ln(t,o,n){return`${o}: ${n}`}function Ar(t,o){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const n=o.levels.map(s=>s.column),i=t.filter(s=>!n.includes(s));return[...n,...i]}function Hn(t,o,n){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const i=o.levels.map(l=>l.column),s=t.filter(l=>!i.includes(l));if(n){const l=[],c=new Set(i),d=new Set(s);let u=0;for(const f of n)c.has(f)?l.push(f):d.has(f)&&u<s.length?(l.push(s[u]),u++):d.has(f)||l.push(f);for(let f=u;f<s.length;f++)l.includes(s[f])||l.push(s[f]);return l}return[...t]}function Co(t){const o={},n=[],i={};return t.forEach(s=>{o[s.name]=!0,n.push(s.name),i[s.name]=150}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:[],sortStack:[],columnVisibility:o,columnOrder:n,columnWidths:i,grouping:null}}}function ms(t,o,n,i,s,l,c,d){const u={},f=[],g={};n.forEach(w=>{u[w.name]=!0,f.push(w.name),g[w.name]=150});const y=Hn(s||f,c||null,d||f);return{filters:t||[],sortStack:o||[],columnVisibility:i||u,columnOrder:y,columnWidths:l||g,grouping:c||null}}function gs(t,o){const n=u=>{if(u==null)return u;if(Array.isArray(u))return u.map(f=>n(f));if(typeof u=="object"){const f={};return Object.keys(u).sort().forEach(g=>{f[g]=n(u[g])}),f}return u},i=u=>JSON.stringify(n(u));if(i(t.filters)!==i(o.filters)||i(t.sortStack)!==i(o.sortStack)||i(t.columnVisibility)!==i(o.columnVisibility))return!0;const s=[...t.columnOrder||[]].sort().join(","),l=[...o.columnOrder||[]].sort().join(",");if(s!==l)return!1;const c=[...o.columnOrder||[]].sort().join(",");if((o.columnOrder||[]).join(",")!==c){if((t.columnOrder||[]).join(",")!==(o.columnOrder||[]).join(","))return!0}else{const u=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==u)return!0}return i(t.columnWidths)!==i(o.columnWidths)||i(t.grouping)!==i(o.grouping)}function ys(t){return!t||t.length===0?"None":t.sort((o,n)=>o.priority-n.priority).map(o=>`${o.column} ${o.direction==="asc"?"↑":"↓"}`).join(", ")}function bs(t,o){var m,v,j;const n=[],i=JSON.stringify(t.filters),s=JSON.stringify(o.filters);if(i!==s){const b=t.filters.length,S=o.filters.length;b>S?n.push({category:"filters",label:"Filters Added",description:`${b-S} new filter${b-S>1?"s":""} added`}):b<S?n.push({category:"filters",label:"Filters Removed",description:`${S-b} filter${S-b>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const l=JSON.stringify(t.sortStack),c=JSON.stringify(o.sortStack);if(l!==c){const b=t.sortStack.length,S=o.sortStack.length;b>S?n.push({category:"sorting",label:"Sorting Added",description:`${b-S} new sort rule${b-S>1?"s":""} added`}):b<S?n.push({category:"sorting",label:"Sorting Removed",description:`${S-b} sort rule${S-b>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const d=JSON.stringify(t.columnVisibility),u=JSON.stringify(o.columnVisibility);if(d!==u){const b=Object.values(t.columnVisibility).filter(a=>a).length,S=Object.values(o.columnVisibility).filter(a=>a).length;b>S?n.push({category:"visibility",label:"Columns Shown",description:`${b-S} column${b-S>1?"s":""} made visible`}):b<S?n.push({category:"visibility",label:"Columns Hidden",description:`${S-b} column${S-b>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const f=JSON.stringify(t.columnOrder),g=JSON.stringify(o.columnOrder);f!==g&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const h=JSON.stringify(t.columnWidths),y=JSON.stringify(o.columnWidths);if(h!==y){const b=Object.keys(t.columnWidths).filter(S=>t.columnWidths[S]!==o.columnWidths[S]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${b} column width${b>1?"s":""} modified`})}const w=JSON.stringify(t.grouping),k=JSON.stringify(o.grouping);if(w!==k){const b=(m=t.grouping)==null?void 0:m.enabled,S=(v=o.grouping)==null?void 0:v.enabled;if(b&&!S){const a=((j=t.grouping)==null?void 0:j.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${a} grouping level${a>1?"s":""} added`})}else!b&&S?n.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):n.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return n}const Un="urm_report_";function vs(t,o){try{const n=`${Un}${t}`;localStorage.setItem(n,JSON.stringify(o))}catch(n){console.error("Failed to save report state:",n)}}function Ss(t){try{const o=`${Un}${t}`,n=localStorage.getItem(o);return n?JSON.parse(n):null}catch(o){return console.error("Failed to load report state:",o),null}}function no(t,o,n=0){const i=[];for(const s of t){const l=o.includes(s.key);if(i.push({type:"group",key:s.key,level:n,column:s.column,value:s.value,rowCount:s.rowCount,aggregates:s.aggregates,collapsed:l}),!l&&s.children&&s.children.length>0){const c=s.children[0];if(Cs(c)){const d=s.children,u=no(d,o,n+1);i.push(...u)}else{const d=s.children;for(const u of d)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function Cs(t){return t&&typeof t=="object"&&"key"in t&&"level"in t&&"column"in t&&"value"in t&&"rowCount"in t&&"aggregates"in t&&"children"in t}function Wo(t){return t.filter(o=>o.type==="row").map(o=>o.type==="row"?o.data:null).filter(o=>o!==null)}function Ro(t,o){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),l=String(n.getDate()).padStart(2,"0"),c=`${i}-${s}-${l}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${o}`}function Qr(t,o,n,i,s,l,c){let d,u;l?(d={...l},u=c||o.map(g=>g.name)):s?(d={...s.snapshot.columnVisibility},u=c||[...s.snapshot.columnOrder]):(d={},u=[],o.forEach(g=>{d[g.name]=!0,u.push(g.name)}));const f=Object.entries(d).filter(([g,h])=>!h).map(([g,h])=>g);return{data:t,schema:o,appliedFilters:n,appliedSortStack:i,columnVisibility:d,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:f,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function Zr(t,o="export",n){const{data:i,columnOrder:s,grouping:l}=t,c=s.filter(h=>t.columnVisibility[h]);let d;if(l&&l.enabled){const h=no(i);d=Wo(h)}else d=i;const u=c.join(","),f=d.map(h=>c.map(y=>{const w=h[y];if(w==null)return"";const k=String(w);return k.includes(",")||k.includes('"')||k.includes(`
|
|
2
|
+
`)?`"${k.replace(/"/g,'""')}"`:k}).join(",")),g=[u,...f].join(`
|
|
3
|
+
`);Gn(g,Ro(o,"csv"),"text/csv;charset=utf-8;")}function eo(t,o="export",n){const{data:i,columnOrder:s,grouping:l}=t,c=s.filter(h=>t.columnVisibility[h]);let d;if(l&&l.enabled){const h=no(i);d=Wo(h)}else d=i;const u=[c,...d.map(h=>c.map(y=>h[y]??""))],f=Lr.utils.aoa_to_sheet(u),g=Lr.utils.book_new();Lr.utils.book_append_sheet(g,f,"Data"),Lr.writeFile(g,Ro(o,"xlsx"))}function to(t,o="export",n){const{data:i,appliedFilters:s,appliedSortStack:l,viewMeta:c,hiddenColumns:d,columnOrder:u,grouping:f}=t;let g;if(f&&f.enabled){const w=no(i);g=Wo(w)}else g=i;const h={meta:{exportedAt:new Date().toISOString(),reportName:o,view:(c==null?void 0:c.name)||"Default View",filters:s.map(w=>({field:w.column,operator:w.operator,value:w.value})),sortStack:l.map(w=>({field:w.column,direction:w.direction,priority:w.priority})),grouping:f||{},hiddenColumns:d,columnOrder:u,exportConfig:n||{scope:"visible"}},data:g},y=JSON.stringify(h,null,2);Gn(y,Ro(o,"json"),"application/json;charset=utf-8;")}function Gn(t,o,n){const i=new Blob([t],{type:n}),s=URL.createObjectURL(i),l=document.createElement("a");l.href=s,l.download=o,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)}const Ko=10;function js(t,o){const n=o.trim();if(!n)return t;const i=t.findIndex(l=>l.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...t[i],lastUsed:Date.now()},...t.slice(0,i),...t.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...t],s.length>Ko&&(s=[...s].sort((c,d)=>c.isFavourite&&!d.isFavourite?-1:!c.isFavourite&&d.isFavourite?1:d.lastUsed-c.lastUsed).slice(0,Ko)),s}function ws(t,o){return t.map(n=>n.query===o?{...n,isFavourite:!n.isFavourite}:n)}function ks(t,o){return t.filter(n=>n.query!==o)}function Ts(t){const o=t.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),n=t.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...o,...n]}const zs={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function Is(t,o){return!t||t.owner===o?"owner":t.editors.includes(o)?"editor":(t.viewers.includes(o),"viewer")}function ft(t,o){return zs[o].includes(t)}function ht(t){return`You do not have permission to ${{view_report:"view this report",edit_columns:"modify columns",edit_filters:"modify filters",edit_sorting:"modify sorting",edit_views:"edit views",create_views:"create views",delete_views:"delete views",delete_report:"delete this report",export_data:"export data"}[t]||"perform this action"}.`}function Es(t){return t==="viewer"}const Xo=1e3;function Bs(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Yn(t,o,n,i,s,l){return{id:Bs(),user:o,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:l}}function qn(t,o){const n=[o,...t];return n.length>Xo?n.slice(0,Xo):n}function Ds(t){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",error_occurred:"Error Occurred"}[t]||t}function Os(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function As(t){return{filters:"bg-blue-100 text-blue-800 border-blue-200",sorting:"bg-purple-100 text-purple-800 border-purple-200",grouping:"bg-green-100 text-green-800 border-green-200",columns:"bg-orange-100 text-orange-800 border-orange-200",views:"bg-pink-100 text-pink-800 border-pink-200",theme:"bg-gray-100 text-gray-800 border-gray-200",export:"bg-cyan-100 text-cyan-800 border-cyan-200",presets:"bg-indigo-100 text-indigo-800 border-indigo-200",system:"bg-red-100 text-red-800 border-red-200"}[t]||"bg-gray-100 text-gray-800 border-gray-200"}function Ms(t){const o=new Date(t),i=new Date().getTime()-o.getTime(),s=Math.floor(i/6e4),l=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:l<24?`${l} hour${l>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Qo(t){return t==null?"None":typeof t=="string"||typeof t=="number"||typeof t=="boolean"?String(t):JSON.stringify(t,null,2)}const Zo=100;function Ws(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Rs(t){var l;const o=(l=t.views)==null?void 0:l.find(c=>c.id===t.activeViewId),n=o==null?void 0:o.snapshot.columnOrder,i=t.columnOrder||[],s=Hn(i,t.grouping||null,n);return{filters:t.filters?[...t.filters]:[],sortStack:t.sortStack?[...t.sortStack]:[],columnVisibility:t.columnVisibility?{...t.columnVisibility}:{},columnOrder:s,columnWidths:t.columnWidths?{...t.columnWidths}:{},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}function Ps(t,o,n,i){return{id:Ws(),name:t,description:o,createdBy:n,createdAt:Date.now(),config:i}}function $s(t,o){const n=t||[];if(n.length>=Zo)throw new Error(`Maximum of ${Zo} presets reached. Please delete old presets first.`);return[...n,o]}function _s(t,o){return(t||[]).filter(i=>i.id!==o)}function en(t,o){if(t)return t.find(n=>n.id===o)}function Ns(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Fs(t){const o=t.columnOrder,n=Ar(o,t.grouping);return{filters:t.filters.length>0?[...t.filters]:void 0,sortStack:t.sortStack.length>0?[...t.sortStack]:void 0,columnVisibility:{...t.columnVisibility},columnOrder:n,columnWidths:{...t.columnWidths},grouping:t.grouping?{...t.grouping}:null,activeViewId:t.activeViewId}}function Vs(t,o){return{totalRows:t.length,totalColumns:o.length}}const Ls={MAX_CACHE_ENTRIES:3};function Hs(t,o){let n=null;return function(...s){const l=()=>{n=null,t(...s)};n&&clearTimeout(n),n=setTimeout(l,o)}}class Hr{constructor(o=Ls.MAX_CACHE_ENTRIES){this.cache=new Map,this.maxEntries=o}get(o){const n=this.cache.get(o);return n?n.value:null}set(o,n){var i;if(this.cache.size>=this.maxEntries&&!this.cache.has(o)){const s=(i=Array.from(this.cache.entries()).sort((l,c)=>l[1].timestamp-c[1].timestamp)[0])==null?void 0:i[0];s&&this.cache.delete(s)}this.cache.set(o,{key:o,value:n,timestamp:Date.now()})}has(o){return this.cache.has(o)}clear(){this.cache.clear()}size(){return this.cache.size}}class Us{constructor(){this.metrics=new Map}start(o){this.metrics.set(o,performance.now())}end(o){const n=this.metrics.get(o);if(!n)return 0;const i=performance.now()-n;return this.metrics.delete(o),i}measure(o,n){this.start(o);const i=n(),s=this.end(o);return{result:i,duration:s}}async measureAsync(o,n){this.start(o);const i=await n(),s=this.end(o);return{result:i,duration:s}}}function yt(t,o,n,i){const s=n instanceof Error?n.message:n,l={type:t,context:o,message:s,details:i,timestamp:Date.now(),recoverable:Gs(t,o)};return process.env.NODE_ENV==="development"&&console.error("[Report Error]",{type:t,context:o,message:s,details:i}),l}function Gs(t,o){return t==="ui"||t==="processing"&&["filters","sorting","grouping","columns"].includes(o)?!0:t!=="system"}function Ys(t){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[t.context]||"An error occurred";return t.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function qs(t){return{filters:t.filters?[...t.filters]:void 0,sortStack:t.sortStack?[...t.sortStack]:void 0,grouping:t.grouping?{...t.grouping}:void 0,columnVisibility:t.columnVisibility?{...t.columnVisibility}:void 0,columnOrder:t.columnOrder?[...t.columnOrder]:void 0,columnWidths:t.columnWidths?{...t.columnWidths}:void 0,activeViewId:t.activeViewId}}function Js(t,o,n){n(t.id,{filters:o.filters,sortStack:o.sortStack,grouping:o.grouping,columnVisibility:o.columnVisibility,columnOrder:o.columnOrder,columnWidths:o.columnWidths,activeViewId:o.activeViewId})}function Ks(t,o,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(o)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:t==="number"&&["gt","gte","lt","lte","equals"].includes(o)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:t==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function Jn(t,o){const n=[],i=[],s=new Set(o.map(l=>l.name));return t.forEach(l=>{s.has(l.column)?n.push(l):i.push(l.column)}),{validRules:n,invalidColumns:i}}function Kn(t,o){if(!t||!t.levels||t.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(o.map(l=>l.name)),i=[],s=[];return t.levels.forEach(l=>{n.has(l.column)?i.push(l):s.push(l.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...t,levels:i},invalidColumns:s}}function Xs(t,o){const n=[],i=new Set(o.map(l=>l.name)),s={...t};if(s.filters&&Array.isArray(s.filters)){const l=s.filters.filter(c=>{const d=i.has(c.column);return d||n.push(`Filter for column "${c.column}" ignored (column not found)`),d});s.filters=l.length>0?l:void 0}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:l,invalidColumns:c}=Jn(s.sortStack,o);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),s.sortStack=l.length>0?l:void 0}if(s.grouping){const{validGrouping:l,invalidColumns:c}=Kn(s.grouping,o);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),s.grouping=l}if(s.columnVisibility){const l={};Object.entries(s.columnVisibility).forEach(([c,d])=>{i.has(c)?l[c]=d:n.push(`Column visibility for "${c}" ignored (column not found)`)}),s.columnVisibility=Object.keys(l).length>0?l:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const l=s.columnOrder.filter(c=>{const d=i.has(c);return d||n.push(`Column "${c}" in order ignored (column not found)`),d});s.columnOrder=l.length>0?l:void 0}if(s.columnWidths){const l={};Object.entries(s.columnWidths).forEach(([c,d])=>{i.has(c)?l[c]=d:n.push(`Column width for "${c}" ignored (column not found)`)}),s.columnWidths=Object.keys(l).length>0?l:void 0}return{sanitizedConfig:s,warnings:n}}function Qs(t,o){return yt("processing","export",t,{retryAvailable:!!(o!=null&&o.onRetry)})}function tn(t,o,n,i){const s=Yn(t,o,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return qn(i||[],s)}function Zs(t){return t==null}function ea(t,o){const{operator:n,value:i}=o;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(Zs(t))return!1;switch(n){case"equals":return String(t)===String(i);case"contains":return String(t).toLowerCase().includes(String(i).toLowerCase());case"startsWith":return String(t).toLowerCase().startsWith(String(i).toLowerCase());case"endsWith":return String(t).toLowerCase().endsWith(String(i).toLowerCase());case"gt":return Number(t)>Number(i);case"lt":return Number(t)<Number(i);case"gte":return Number(t)>=Number(i);case"lte":return Number(t)<=Number(i);case"isTrue":return t===!0;case"isFalse":return t===!1;default:return!0}}function ta(t,o){return!o||o.length===0?t:t.filter(n=>o.every(i=>ea(n[i.column],i)))}function rn(t){switch(t){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Ur(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function ra({data:t,filters:o}){return{filteredData:p.useMemo(()=>!o||o.length===0?t:ta(t,o),[t,o])}}function Xn(t,o,n,i){if(!n||n.trim()==="")return t;const s=n.toLowerCase().trim(),l=o.filter(c=>i.includes(c.name));return t.filter(c=>l.some(d=>{const u=c[d.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function oa({data:t,searchQuery:o,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!o||o.trim()===""?t:Xn(t,n,o,i),[t,o,n,i])}}function na({data:t,sortStack:o,schema:n}){return{sortedData:p.useMemo(()=>!o||o.length===0?t:cs(t,n,o),[t,o,n])}}function ia({data:t,grouping:o,schema:n}){const i=p.useMemo(()=>!o||!o.enabled||o.levels.length===0?t:fs(t,n,o),[t,o,n]),s=(o==null?void 0:o.enabled)&&((o==null?void 0:o.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function sa({schema:t,columnVisibility:o,columnOrder:n}){const i=p.useMemo(()=>n.filter(d=>o[d]!==!1),[n,o]),s=p.useMemo(()=>Object.entries(o).filter(([d,u])=>!u).map(([d,u])=>d),[o]),l=p.useMemo(()=>n.map(d=>t.find(f=>f.name===d)||{name:d,type:"string"}),[n,t]),c=p.useMemo(()=>i.map(d=>t.find(f=>f.name===d)||{name:d,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:s,allColumns:l,visibleColumnSchemas:c,hiddenCount:s.length}}function aa({views:t,activeViewId:o,currentState:n}){const i=p.useMemo(()=>t.find(f=>f.id===o),[t,o]),s=p.useMemo(()=>i?gs(n,i.snapshot):!1,[i,n]),l=p.useMemo(()=>t.find(f=>f.isDefault),[t]),c=p.useMemo(()=>t.filter(f=>!f.isDefault&&!f.isDeleted),[t]),d=p.useMemo(()=>t.filter(f=>f.isFavorite&&!f.isDeleted),[t]),u=p.useMemo(()=>t.filter(f=>f.isDeleted),[t]);return{activeView:i,isDirty:s,defaultView:l,customViews:c,favoriteViews:d,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function la({data:t,enabled:o=!1,pageSize:n=100,initialPage:i=1}){const[s,l]=p.useState(i),c=t.length,d=Math.ceil(c/n),u=p.useMemo(()=>{if(!o)return t;const w=(s-1)*n,k=w+n;return t.slice(w,k)},[t,o,s,n]),f=p.useCallback(w=>{const k=Math.max(1,Math.min(w,d));l(k)},[d]),g=p.useCallback(()=>{s<d&&l(s+1)},[s,d]),h=p.useCallback(()=>{s>1&&l(s-1)},[s]),y=p.useCallback(()=>{l(1)},[]);return{paginatedData:u,currentPage:s,totalPages:d,pageSize:n,totalRows:c,goToPage:f,nextPage:g,prevPage:h,resetPage:y,hasNextPage:s<d,hasPrevPage:s>1}}function ca(t){const{rawData:o,schema:n,filters:i,sortStack:s,grouping:l,searchQuery:c,columnVisibility:d,columnOrder:u,columnWidths:f,views:g,activeViewId:h,pagination:y}=t,w=p.useMemo(()=>({filters:i,sortStack:s,grouping:l,columnVisibility:d,columnOrder:u,columnWidths:f}),[i,s,l,d,u,f]),k=aa({views:g,activeViewId:h,currentState:w}),m=sa({schema:n,columnVisibility:d,columnOrder:u}),{filteredData:v}=ra({data:o,filters:i}),{sortedData:j}=na({data:v,sortStack:s,schema:n}),{groupedData:b,isGrouped:S}=ia({data:j,grouping:l,schema:n}),{searchedData:a}=oa({data:b,searchQuery:c,schema:n,visibleColumns:m.visibleColumns}),I=la({data:a,enabled:(y==null?void 0:y.enabled)||!1,pageSize:(y==null?void 0:y.pageSize)||100,initialPage:(y==null?void 0:y.currentPage)||1}),O=y!=null&&y.enabled?I.paginatedData:a,H=p.useMemo(()=>({totalRows:o.length,filteredRows:v.length,sortedRows:j.length,groupedRows:S?b.length:j.length,searchedRows:a.length,visibleRows:O.length,hiddenColumns:m.hiddenCount,activeFilters:i.length,activeSorts:s.length,isGrouped:S}),[o.length,v.length,j.length,b.length,a.length,O.length,m.hiddenCount,i.length,s.length,S]);return{data:O,filteredData:v,sortedData:j,groupedData:b,searchedData:a,viewEngine:k,columnEngine:m,paginationEngine:I,metrics:H,isGrouped:S,isPaginated:(y==null?void 0:y.enabled)||!1}}const mt="user-demo-001";function da(t={}){var Ho,Uo,Go,Yo,qo;const{mode:o="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:l,sharedReportId:c,config:d={}}=t,[u,f]=p.useState([]),[g,h]=p.useState(""),[y,w]=p.useState(!1),[k,m]=p.useState(!1),[v,j]=p.useState({message:"",severity:"info",open:!1}),b=(C,z="info")=>{j({message:C,severity:z,open:!0})},S=()=>j(C=>({...C,open:!1})),a=u.find(C=>C.id===g),[I,O]=p.useState("idle"),[H,N]=p.useState(!1),[Q,ee]=p.useState(!1),[oe,x]=p.useState(!1),[F,$]=p.useState(!1),[_,V]=p.useState(!1),[ie,ce]=p.useState(!1),[Te,M]=p.useState(void 0),[Y,Z]=p.useState(null),[re,ne]=p.useState(null),[R,X]=p.useState(!1),[te,ae]=p.useState(!1),[se,le]=p.useState(null),[we,G]=p.useState(!1),[De,He]=p.useState(!1),[Ct,At]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[et,jt]=p.useState(""),[Oe,Ke]=p.useState(new Set),[tt,Ue]=p.useState(1),[$e,wt]=p.useState(15),[Yt,dt]=p.useState(!1),[Xe,Ne]=p.useState(!1),[fr,qt]=p.useState(!1),[rt,kt]=p.useState(null),[Mt,ut]=p.useState(!1),[hr,Fr]=p.useState(null),[Jt,ot]=p.useState(null);p.useRef(new Us),p.useRef(new Hr),p.useRef(new Hr),p.useRef(new Hr),p.useRef(new Hr);const[Wt,Kt]=p.useState(null),Tt=p.useRef(null),Ce=p.useMemo(()=>a?Is(a.permissions,mt):"owner",[a]),mr=Es(Ce),zt=p.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:Vs(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),nt=p.useCallback(()=>{a&&(Tt.current=qs(a))},[a]),P=p.useCallback((C,z)=>{f(B=>B.map(E=>E.id===C?{...E,...z}:E))},[]),Qe=p.useCallback(C=>{if(!a)return;Kt(C);const z=tn(a.id,mt,C,a.auditHistory||[]);P(a.id,{auditHistory:z}),b(C.message,"error"),C.recoverable&&Tt.current&&setTimeout(()=>{Js(a,Tt.current,P),b("Previous state restored","success")},100)},[a,P]),ge=p.useCallback((C,z,B,E)=>{if(!a)return;const K=Yn(a.id,mt,C,z,B,E),U=a.auditHistory||[],pe=qn(U,K);setTimeout(()=>{P(a.id,{auditHistory:pe})},0)},[a,P]);p.useEffect(()=>{var C,z,B,E,K;if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const U=Co(a.schema),pe=(()=>{try{const ue=localStorage.getItem("urm_dev_config");return ue?JSON.parse(ue):null}catch{return null}})();if(pe){const ue=pe;if(Array.isArray((C=ue.sort)==null?void 0:C.defaultSortStack)&&ue.sort.defaultSortStack.length>0){const lt=a.schema.map(Be=>Be.name),Ye=ue.sort.defaultSortStack.filter(Be=>Be.column&<.includes(Be.column)).map((Be,Ft)=>({column:Be.column,direction:Be.direction==="desc"?"desc":"asc",priority:Ft+1}));Ye.length>0&&(U.snapshot.sortStack=Ye)}if(Array.isArray((z=ue.filter)==null?void 0:z.defaultFilters)&&ue.filter.defaultFilters.length>0){const lt=a.schema.map(Be=>Be.name),Ye=ue.filter.defaultFilters.filter(Be=>Be.column&&Be.operator&<.includes(Be.column));Ye.length>0&&(U.snapshot.filters=Ye)}if(Array.isArray((B=ue.columns)==null?void 0:B.defaultHiddenColumns)&&ue.columns.defaultHiddenColumns.length>0&&ue.columns.defaultHiddenColumns.forEach(lt=>{lt in U.snapshot.columnVisibility&&(U.snapshot.columnVisibility[lt]=!1)}),Array.isArray((E=ue.columns)==null?void 0:E.defaultColumnOrder)&&ue.columns.defaultColumnOrder.length>0){const lt=a.schema.map(Ft=>Ft.name),Ye=ue.columns.defaultColumnOrder.filter(Ft=>lt.includes(Ft)),Be=U.snapshot.columnOrder.filter(Ft=>!Ye.includes(Ft));Ye.length>0&&(U.snapshot.columnOrder=[...Ye,...Be])}if(Array.isArray((K=ue.grouping)==null?void 0:K.defaultGrouping)&&ue.grouping.defaultGrouping.length>0){const lt=a.schema.map(Be=>Be.name),Ye=ue.grouping.defaultGrouping.filter(Be=>Be.column&<.includes(Be.column));Ye.length>0&&(U.snapshot.grouping={enabled:!0,levels:Ye,collapsedGroups:[]})}}P(a.id,{views:[U],activeViewId:U.id,filters:U.snapshot.filters,sortStack:U.snapshot.sortStack,columnVisibility:U.snapshot.columnVisibility,columnOrder:U.snapshot.columnOrder,columnWidths:U.snapshot.columnWidths,grouping:U.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,P]),p.useEffect(()=>{if(i&&n&&!k&&u.length===0){const C=Kr(i),z={id:`auto-report-${Date.now()}`,name:l||(o==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:C,schema:Ir(C),permissions:{owner:mt,editors:[],viewers:[]}};f([z]),h(z.id),m(!0),O("confirmed")}},[i,n,k,u.length,o,l]),p.useEffect(()=>{if(!s||k)return;let C=!1,z=null;const B=async()=>{try{O("uploading");let E;if(s.type==="api"){const U=await fetch(s.url,{headers:s.headers||{}});if(!U.ok)throw new Error(`HTTP ${U.status}: ${U.statusText}`);E=await U.json()}else E=await s.fetch();if(C)return;if(!Array.isArray(E))throw new Error("Data source must return an array of objects");const K=Ir(E);if(k)f(U=>U.map(pe=>pe.id===g?{...pe,uploadedData:E}:pe)),O("confirmed");else{const U={id:`auto-report-${Date.now()}`,name:l||(o==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:Kr(E),schema:Ir(Kr(E)),permissions:{owner:mt,editors:[],viewers:[]}};f([U]),h(U.id),m(!0),O("confirmed")}}catch(E){C||(O("error"),a&&P(a.id,{uploadError:(E==null?void 0:E.message)||"Failed to load data from source"}))}};return B(),s.refreshInterval&&s.refreshInterval>0&&(z=setInterval(B,s.refreshInterval)),()=>{C=!0,z&&clearInterval(z)}},[s,l,o]);const Re=(Ho=a==null?void 0:a.views)==null?void 0:Ho.find(C=>C.id===a.activeViewId),Rt=p.useMemo(()=>a!=null&&a.uploadedData?!a.showFavoritesOnly||!a.favoriteRowIndices||a.favoriteRowIndices.length===0?a.uploadedData:a.uploadedData.filter((C,z)=>a.favoriteRowIndices.includes(z)):[],[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),gr=p.useMemo(()=>{var z;if(!(a!=null&&a.uploadedData)||!((z=a==null?void 0:a.favoriteRowIndices)!=null&&z.length))return new Set;const C=new Set;return a.favoriteRowIndices.forEach(B=>{const E=a.uploadedData[B];E!==void 0&&C.add(E)}),C},[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),it=ca({rawData:Rt,schema:(a==null?void 0:a.schema)||[],filters:(a==null?void 0:a.filters)||[],sortStack:(a==null?void 0:a.sortStack)||[],grouping:(a==null?void 0:a.grouping)||null,searchQuery:et||"",columnVisibility:(a==null?void 0:a.columnVisibility)||(Re==null?void 0:Re.snapshot.columnVisibility)||{},columnOrder:(a==null?void 0:a.columnOrder)||(Re==null?void 0:Re.snapshot.columnOrder)||[],columnWidths:(a==null?void 0:a.columnWidths)||(Re==null?void 0:Re.snapshot.columnWidths)||{},views:(a==null?void 0:a.views)||[],activeViewId:(a==null?void 0:a.activeViewId)||"",pagination:{enabled:!0,pageSize:$e,currentPage:tt}}),{data:yr=[],searchedData:pt=[],groupedData:Pt=[],metrics:$t={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:br=!1,paginationEngine:ke}=it||{},L=((Uo=it.viewEngine)==null?void 0:Uo.activeView)||Re,Me=((Go=it.viewEngine)==null?void 0:Go.isDirty)||!1;p.useEffect(()=>{if(!(!L||!a)&&!a.columnOrder){const C=L.snapshot.columnOrder,z=Ar(C,L.snapshot.grouping);P(a.id,{columnOrder:z})}},[a==null?void 0:a.activeViewId]);const Se=p.useMemo(()=>!(a!=null&&a.schema)||!L?null:ms(a.filters||[],a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,L.snapshot.columnOrder),[a==null?void 0:a.filters,a==null?void 0:a.sortStack,a==null?void 0:a.schema,a==null?void 0:a.columnVisibility,a==null?void 0:a.columnOrder,a==null?void 0:a.columnWidths,a==null?void 0:a.grouping,L]),xt=p.useMemo(()=>!L||!Se||!Me?[]:bs(Se,L.snapshot),[L,Se,Me]),_e=p.useCallback((C,z,B)=>{const E={id:`report-${Date.now()}`,name:C,description:z,schemaLocked:!1,permissions:{owner:mt,editors:[],viewers:[]}};if(B&&Array.isArray(B)&&B.length>0){const K=Ir(B),U=Co(K);E.uploadedData=B,E.schema=K,E.schemaLocked=!0,E.views=[U],E.activeViewId=U.id,E.sortStack=U.snapshot.sortStack,E.filters=U.snapshot.filters,E.columnVisibility=U.snapshot.columnVisibility,E.columnOrder=U.snapshot.columnOrder,E.columnWidths=U.snapshot.columnWidths,E.grouping=U.snapshot.grouping}f(K=>[...K,E]),h(E.id),w(!1),O("confirmed")},[]),Xt=p.useCallback(C=>{a&&(O("uploading"),setTimeout(()=>{const z=Ir(C);P(a.id,{uploadedData:C,schema:z,uploadError:void 0}),O("preview")},500))},[a,P]),vr=p.useCallback(C=>{a&&(P(a.id,{uploadError:C}),O("idle"))},[a,P]),Qt=p.useCallback(()=>{a&&(P(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),O("idle"))},[a,P]),Zt=p.useCallback(()=>{a&&(P(a.id,{schemaLocked:!0}),O("confirmed"))},[a,P]),Sr=p.useCallback(C=>{if(!a)return;if(!ft("edit_sorting",Ce)){b(ht("edit_sorting"),"error");return}const z=a.sortStack??[],B=z.find(E=>E.column===C);if(B){const E=ds(B.direction);if(E===null){const K=z.filter(U=>U.column!==C).map((U,pe)=>({...U,priority:pe+1}));P(a.id,{sortStack:K.length>0?K:void 0})}else{const K=z.map(U=>U.column===C?{...U,direction:E}:U);P(a.id,{sortStack:K})}}else{if(z.length>=3)return;const E={column:C,direction:"asc",priority:z.length+1};P(a.id,{sortStack:[...z,E]})}},[a,Ce,P]),er=p.useCallback(C=>{if(a)if(a.schema){const{validRules:z,invalidColumns:B}=Jn(C,a.schema);B.length>0&&b(`Removed invalid sort columns: ${B.join(", ")}`),nt();try{P(a.id,{sortStack:z.length>0?z:void 0})}catch(E){const K=yt("processing","sorting",E);Qe(K)}}else P(a.id,{sortStack:C.length>0?C:void 0})},[a,P,nt,Qe]),tr=p.useCallback(C=>{if(!a)return;const z=a.sortStack??[],B=z.find(E=>E.column===C);if(!(B&&B.direction==="asc"))if(B){const E=z.map(K=>K.column===C?{...K,direction:"asc"}:K);P(a.id,{sortStack:E})}else{if(z.length>=3)return;const E={column:C,direction:"asc",priority:z.length+1};P(a.id,{sortStack:[...z,E]})}},[a,P]),Pe=p.useCallback(C=>{if(!a)return;const z=a.sortStack??[],B=z.find(E=>E.column===C);if(!(B&&B.direction==="desc"))if(B){const E=z.map(K=>K.column===C?{...K,direction:"desc"}:K);P(a.id,{sortStack:E})}else{if(z.length>=3)return;const E={column:C,direction:"desc",priority:z.length+1};P(a.id,{sortStack:[...z,E]})}},[a,P]),st=p.useCallback(C=>{var B;if(!a)return;if(!ft("edit_filters",Ce)){b(ht("edit_filters"),"error");return}const z=(B=a.schema)==null?void 0:B.find(E=>E.name===C.column);if(z&&C.value!==void 0){const E=Ks(z.type,C.operator,C.value);if(!E.isValid){b(E.errorMessage||"Invalid filter value","error");return}}nt();try{const E=a.filters??[];ge("filters","filter_added",E,[...E,C]),P(a.id,{filters:[...E,C]})}catch(E){const K=yt("processing","filters",E);Qe(K)}},[a,Ce,P,nt,Qe,ge]),at=p.useCallback((C,z)=>{if(!a)return;if(!ft("edit_filters",Ce)){b(ht("edit_filters"),"error");return}const B=a.filters??[],E=[...B];ge("filters","filter_updated",B[C],z),E[C]=z,P(a.id,{filters:E})},[a,Ce,P,ge]),Fe=p.useCallback(C=>{if(!a)return;if(!ft("edit_filters",Ce)){b(ht("edit_filters"),"error");return}const z=a.filters??[],B=z.filter((E,K)=>K!==C);ge("filters","filter_removed",z[C],null),P(a.id,{filters:B.length>0?B:void 0})},[a,Ce,P,ge]),rr=p.useCallback(()=>{if(!a)return;if(!ft("edit_filters",Ce)){b(ht("edit_filters"),"error");return}const C=a.filters??[];ge("filters","filter_cleared",C,null),P(a.id,{filters:void 0})},[a,Ce,P,ge]),Cr=p.useCallback(C=>{var K;if(!a)return;const z=(K=a.views)==null?void 0:K.find(U=>U.id===C);if(!z)return;const B=z.snapshot.columnOrder,E=Ar(B,z.snapshot.grouping);P(a.id,{filters:z.snapshot.filters.length>0?[...z.snapshot.filters]:void 0,sortStack:z.snapshot.sortStack.length>0?[...z.snapshot.sortStack]:void 0,columnVisibility:{...z.snapshot.columnVisibility},columnOrder:E,columnWidths:{...z.snapshot.columnWidths},grouping:z.snapshot.grouping,activeViewId:C}),Ke(new Set),x(!1)},[a,P]),or=p.useCallback((C,z,B)=>{if(!(a!=null&&a.schema)||!Se)return;const E={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:C,description:z||void 0,isDefault:B,isFavorite:!1,isDeleted:!1,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Se}},K=a.views??[],U=B?K.map(pe=>({...pe,isDefault:!1})):K;P(a.id,{views:[...U,E],activeViewId:E.id}),b(`"${C}" view created`,"success")},[a,Se,P]),_t=p.useCallback(()=>{var z;if(!L||!Se||L.isDefault||!a)return;const C=(z=a.views)==null?void 0:z.map(B=>B.id===L.id?{...B,snapshot:{...Se}}:B);P(a.id,{views:C}),b(`"${L.name}" view updated`,"success")},[L,Se,a,P]),jr=p.useCallback(()=>{var z;if(!L||!Se||!a)return;const C=(z=a.views)==null?void 0:z.map(B=>B.id===L.id?{...B,snapshot:{...B.snapshot,columnVisibility:Se.columnVisibility,columnOrder:Se.columnOrder,columnWidths:Se.columnWidths},updatedAt:Date.now()}:B);P(a.id,{views:C}),b(`Column configuration saved to "${L.name}"`,"success")},[L,Se,a,P]),wr=p.useCallback(()=>{var E,K;if(!Se||!a||!L)return;const C={...L,snapshot:{...L.snapshot,columnVisibility:Se.columnVisibility,columnOrder:Se.columnOrder,columnWidths:Se.columnWidths},updatedAt:Date.now()},z=(E=a.views)==null?void 0:E.map(U=>U.id===L.id?C:{...U,snapshot:{...U.snapshot,columnVisibility:Se.columnVisibility,columnOrder:Se.columnOrder,columnWidths:Se.columnWidths},updatedAt:Date.now()});P(a.id,{views:z});const B=(((K=a.views)==null?void 0:K.length)||0)-1;b(`Column configuration saved to current view and ${B} other view${B===1?"":"s"}`,"success")},[Se,a,L,P]),kr=p.useCallback(()=>{$(!0)},[]),Tr=p.useCallback(()=>{if(!L||!a)return;const C=L.snapshot.columnOrder,z=Ar(C,L.snapshot.grouping);P(a.id,{filters:L.snapshot.filters.length>0?[...L.snapshot.filters]:void 0,sortStack:L.snapshot.sortStack.length>0?[...L.snapshot.sortStack]:void 0,columnVisibility:{...L.snapshot.columnVisibility},columnOrder:z,columnWidths:{...L.snapshot.columnWidths},grouping:L.snapshot.grouping}),b("Changes reverted to last saved state","success")},[L,a,P]),Nt=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.map(E=>({...E,isDefault:E.id===C}));P(a.id,{views:z});const B=a.views.find(E=>E.id===C);B&&b(`"${B.name}" set as default view`,"success")},[a,P]),nr=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.map(E=>E.id===C?{...E,isFavorite:!E.isFavorite,updatedAt:Date.now()}:E);P(a.id,{views:z});const B=a.views.find(E=>E.id===C);B&&!B.isFavorite?b(`"${B.name}" added to favorites`,"success"):B&&b(`"${B.name}" removed from favorites`,"info")},[a,P]),We=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.map(U=>U.id===C?{...U,isDeleted:!0,updatedAt:Date.now()}:U),B=a.activeViewId===C,E=z.find(U=>U.isDefault&&!U.isDeleted);P(a.id,{views:z,activeViewId:B&&E?E.id:a.activeViewId,filters:B&&E?E.snapshot.filters.length>0?E.snapshot.filters:void 0:a.filters,sortStack:B&&E?E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0:a.sortStack});const K=a.views.find(U=>U.id===C);K&&b(`"${K.name}" moved to Recently Deleted`,"info")},[a,P]),ir=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.map(E=>E.id===C?{...E,isDeleted:!1,updatedAt:Date.now()}:E);P(a.id,{views:z});const B=a.views.find(E=>E.id===C);B&&b(`"${B.name}" restored`,"success")},[a,P]),sr=p.useCallback(C=>{if(!(a!=null&&a.views))return;const z=a.views.find(ue=>ue.id===C),B=a.views.filter(ue=>!ue.isDeleted||ue.id===C);if((z==null?void 0:z.isDefault)&&B.filter(ue=>ue.isDefault).length===1){b("Cannot delete the last default view","error");return}const K=a.views.filter(ue=>ue.id!==C),U=a.activeViewId===C,pe=K.find(ue=>ue.isDefault&&!ue.isDeleted);P(a.id,{views:K,activeViewId:U&&pe?pe.id:a.activeViewId,filters:U&&pe?pe.snapshot.filters.length>0?pe.snapshot.filters:void 0:a.filters,sortStack:U&&pe?pe.snapshot.sortStack.length>0?pe.snapshot.sortStack:void 0:a.sortStack}),z&&b(`"${z.name}" permanently deleted`,"success")},[a,P]),It=p.useCallback(C=>{Z(C),V(!0),x(!1)},[]),zr=p.useCallback((C,z)=>{if(!Y||!(a!=null&&a.views))return;const B=a.views.map(E=>E.id===Y?{...E,name:C,description:z||void 0}:E);P(a.id,{views:B}),Z(null)},[Y,a,P]),Et=p.useCallback(C=>{ne(C),ce(!0),x(!1)},[]),D=p.useCallback(()=>{if(!re||!(a!=null&&a.views))return;const C=a.views.filter(E=>E.id!==re),z=a.activeViewId===re,B=C.find(E=>E.isDefault);P(a.id,{views:C,activeViewId:z&&B?B.id:a.activeViewId,filters:z&&B?B.snapshot.filters.length>0?B.snapshot.filters:void 0:a.filters,sortStack:z&&B?B.snapshot.sortStack.length>0?B.snapshot.sortStack:void 0:a.sortStack}),ne(null),ce(!1)},[re,a,P]);p.useEffect(()=>{ke!=null&&ke.resetPage?ke.resetPage():Ue(1)},[a==null?void 0:a.filters,et,a==null?void 0:a.activeViewId]),p.useEffect(()=>{ke&&ke.currentPage!==tt&&Ue(ke.currentPage)},[ke==null?void 0:ke.currentPage]);const q=p.useCallback(C=>{ke!=null&&ke.goToPage&&ke.goToPage(C),Ue(C)},[ke]),de=p.useCallback(C=>{const z=(tt-1)*$e,B=Math.floor(z/C)+1;wt(C),Ue(B)},[tt,$e]),Ae=p.useCallback((C,z)=>{if(!a)return;if(!ft("edit_columns",Ce)){b(ht("edit_columns"),"error");return}const E={...a.columnVisibility||(L==null?void 0:L.snapshot.columnVisibility)||{},[C]:z};P(a.id,{columnVisibility:E})},[a,L,Ce,P]),J=p.useCallback(C=>{if(a){if(!ft("edit_columns",Ce)){b(ht("edit_columns"),"error");return}P(a.id,{columnOrder:C})}},[a,Ce,P]),ye=p.useCallback((C,z)=>{if(!a)return;if(!ft("edit_columns",Ce)){b(ht("edit_columns"),"error");return}const E={...a.columnWidths||(L==null?void 0:L.snapshot.columnWidths)||{},[C]:z};P(a.id,{columnWidths:E})},[a,L,Ce,P]),Ge=p.useCallback(C=>{if(!a)return;const B=(a.filters??[]).filter(E=>E.column!==C);P(a.id,{filters:B.length>0?B:void 0})},[a,P]),So=p.useCallback(()=>{if(!L||!(a!=null&&a.schema))return;const C={},z=[],B={};a.schema.forEach(E=>{C[E.name]=!0,z.push(E.name),B[E.name]=150}),P(a.id,{columnVisibility:C,columnOrder:z,columnWidths:B,filters:void 0,sortStack:void 0}),b("Reset to default layout - all filters and sorts cleared","success")},[L,a,P]),Lo=p.useCallback(Hs(C=>{jt(C)},300),[]),Bi=p.useCallback(C=>{Lo(C)},[Lo]),Di=p.useCallback(C=>{if(!C.trim()||!a)return;const z=a.searchHistory||[],B=js(z,C);P(a.id,{searchHistory:B})},[a,P]),Oi=p.useCallback(C=>{if(!a)return;const z=a.searchHistory||[],B=ws(z,C);P(a.id,{searchHistory:B})},[a,P]),Ai=p.useCallback(C=>{if(!a)return;const z=a.searchHistory||[],B=ks(z,C);P(a.id,{searchHistory:B})},[a,P]),Mi=p.useCallback(C=>{Ke(z=>{const B=new Set(z);return B.has(C)?B.delete(C):B.add(C),B})},[]),Wi=p.useCallback((C,z)=>{if(C){const B=new Set;for(let E=0;E<z;E++)B.add(E);Ke(B)}else Ke(new Set)},[]),Ri=p.useCallback((C,z)=>{Ke(B=>{const E=new Set(B),K=Math.min(C,z),U=Math.max(C,z);for(let pe=K;pe<=U;pe++)E.add(pe);return E})},[]),Pi=p.useCallback(()=>{Ke(new Set)},[]),$i=p.useCallback(C=>{if(!a)return;const z=a.favoriteRowIndices||[],E=z.includes(C)?z.filter(K=>K!==C):[...z,C];P(a.id,{favoriteRowIndices:E})},[a,P]),_i=p.useCallback((C,z)=>{if(!a)return;const B=a.favoriteRowIndices||[],E=z?[...B,...C.filter(K=>!B.includes(K))]:B.filter(K=>!C.includes(K));P(a.id,{favoriteRowIndices:E})},[a,P]),Ni=p.useCallback(()=>{if(!a)return;const C=a.favoriteRowIndices||[],z=!a.showFavoritesOnly;if(z&&C.length===0){b("No rows marked as favorite","warning");return}P(a.id,{showFavoritesOnly:z}),Ke(new Set),b(z?`Showing ${C.length} favorite row${C.length===1?"":"s"}`:"Showing all data","info")},[a,P]),Fi=p.useCallback(C=>{if(a){if(!ft("edit_columns",Ce)){b(ht("edit_columns"),"error");return}if(C&&a.schema){const{validGrouping:z,invalidColumns:B}=Kn(C,a.schema);B.length>0&&b(`Removed invalid grouping columns: ${B.join(", ")}`,"warning"),nt();try{const E=a.grouping;z===null?ge("grouping","group_cleared",E,null):E?ge("grouping","group_reordered",E,z):ge("grouping","group_level_added",null,z);const K=(L==null?void 0:L.snapshot.columnOrder)||a.columnOrder||[],U=Ar(K,z);P(a.id,{grouping:z,columnOrder:U}),JSON.stringify(U)!==JSON.stringify(a.columnOrder)&&ge("columns","column_reordered",a.columnOrder,U),He(!1)}catch(E){const K=yt("processing","grouping",E);Qe(K)}}else{const z=a.grouping;ge("grouping","group_cleared",z,null);const B=(L==null?void 0:L.snapshot.columnOrder)||a.columnOrder||[];P(a.id,{grouping:C,columnOrder:[...B]}),JSON.stringify(B)!==JSON.stringify(a.columnOrder)&&ge("columns","column_reordered",a.columnOrder,B),He(!1)}}},[a,L,Ce,P,nt,Qe,ge]),Vi=p.useCallback(C=>{if(!a)return;const z=a.grouping;if(!z)return;const B=hs(z,C);P(a.id,{grouping:B})},[a,P]),Li=p.useCallback(()=>{ut(!0)},[]),ar=p.useCallback(C=>{a!=null&&a.schema&&(X(!0),setTimeout(()=>{try{let z;C.scope==="visible"?z=pt:z=a.uploadedData||[];let B;C.columnScope==="all"?(B={},a.schema.forEach(ue=>{B[ue.name]=!0})):B=a.columnVisibility||(L==null?void 0:L.snapshot.columnVisibility)||{};const E=a.columnOrder||(L==null?void 0:L.snapshot.columnOrder),K=Qr(z,a.schema,a.filters??[],a.sortStack??[],L,B,E),U=a.name;let pe;switch(C.format){case"csv":Zr(K,U,C),pe="export_csv";break;case"excel":eo(K,U,C),pe="export_excel";break;case"json":to(K,U,C),pe="export_json";break}ge("export",pe,null,{format:C.format,scope:C.scope,columnScope:C.columnScope,rowCount:z.length,viewName:(L==null?void 0:L.name)||"Default View"}),b(`Export completed successfully (${C.format.toUpperCase()})`,"success")}catch(z){const B=Qs(z,{onRetry:()=>ar(C)});b(`Export failed: ${B.message}`,{action:{label:"Retry",onClick:()=>ar(C)}});const E=tn(a.id,mt,B,a.auditHistory||[]);P(a.id,{auditHistory:E}),console.error("Export error:",z)}finally{X(!1)}},500))},[a,L,pt,P,ge]),Hi=p.useCallback(C=>{if(a!=null&&a.schema){if(Me&&L&&!L.isDefault){le(C.format),ae(!0),ut(!1);return}ar(C),ut(!1)}},[a,L,Me,ar]),Vr=p.useCallback(C=>{ar({format:C,scope:"visible",columnScope:"visible"})},[ar]),Ui=p.useCallback(()=>{se&&Vr(se),ae(!1),le(null)},[se,Vr]),Gi=p.useCallback(()=>{_t(),se&&Vr(se),ae(!1),le(null)},[_t,se,Vr]),Yi=p.useCallback(()=>{ae(!1),le(null)},[]),qi=p.useCallback(C=>{!(a!=null&&a.schema)||Oe.size===0||(X(!0),setTimeout(()=>{try{const z=Array.from(Oe).sort((K,U)=>K-U).map(K=>Pt[K]).filter(K=>K!==void 0),B=Qr(z,a.schema,a.filters??[],a.sortStack??[],L),E=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(C){case"csv":Zr(B,E);break;case"excel":eo(B,E);break;case"json":to(B,E);break}b(`Exported ${z.length} selected rows`,"info")}catch(z){b("Export failed. Please try again.","error"),console.error("Export error:",z)}finally{X(!1)}},500))},[a,L,Oe,Pt]),Ji=p.useCallback((C,z)=>{if(a)try{const B=Rs(a),E=Ps(C,z,mt,B),K=$s(a.presets,E);P(a.id,{presets:K}),ge("presets","preset_created",null,{presetId:E.id,name:E.name}),Ne(!1),b(`Preset "${C}" saved successfully`,"success")}catch(B){b(B instanceof Error?B.message:"Failed to create preset","error")}},[a,P,ge]),Ki=p.useCallback(()=>{kt(null),b("Exited preset view","info")},[]),Xi=p.useCallback(()=>{qt(!0)},[]),Qi=p.useCallback((C,z)=>{if(!a)return;const B=_s(a.presets,C);P(a.id,{presets:B}),ge("presets","preset_deleted",{presetId:C,name:z},null),rt===C&&kt(null),b(`Preset "${z}" deleted`,"success")},[a,rt,P,ge]);p.useEffect(()=>{if(!c||u.length===0)return;const C=u.find(z=>z.id===c);C&&C.id!==g&&h(C.id)},[c,u,g]),p.useEffect(()=>{if(!a)return;const C=Ns();if(C&&a.presets&&a.schemaLocked&&a.schema){const z=en(a.presets,C);if(z){const{sanitizedConfig:B,warnings:E}=Xs(z.config,a.schema);E.length>0&&E.forEach(U=>b(U,"warning"));const K=Fs(B);P(a.id,K),kt(C),ge("presets","preset_applied",null,{presetId:z.id,name:z.name}),b(`Loaded preset: ${z.name}`,"info")}else b("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const Zi=rt?en(a==null?void 0:a.presets,rt):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&vs(a.id,{views:a.views,activeViewId:a.activeViewId})},[a==null?void 0:a.views,a==null?void 0:a.activeViewId,a==null?void 0:a.id]),p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const C=Ss(a.id);if(C&&C.views.length>0){const z=C.views.find(B=>B.id===C.activeViewId);if(z)P(a.id,{views:C.views,activeViewId:C.activeViewId,filters:z.snapshot.filters.length>0?z.snapshot.filters:void 0,sortStack:z.snapshot.sortStack.length>0?z.snapshot.sortStack:void 0});else{const B=C.views.find(E=>E.isDefault)||Co(a.schema);P(a.id,{views:C.views,activeViewId:B.id,filters:B.snapshot.filters.length>0?B.snapshot.filters:void 0,sortStack:B.snapshot.sortStack.length>0?B.snapshot.sortStack:void 0})}}}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id]);const es=p.useCallback(C=>{M(C),N(!0)},[]),ts=p.useCallback(()=>{N(!1),M(void 0)},[]),rs=(Yo=a==null?void 0:a.views)==null?void 0:Yo.find(C=>C.id===Y),os=(qo=a==null?void 0:a.views)==null?void 0:qo.find(C=>C.id===re);return{reports:u,activeReport:a,activeReportId:g,setActiveReportId:h,isModalOpen:y,setIsModalOpen:w,createReport:_e,updateReport:P,uploadState:I,handleFileUpload:Xt,handleUploadError:vr,handleRetry:Qt,handleConfirm:Zt,paginatedData:yr,processedData:pt,displayData:Pt,tableMetrics:$t,isGrouped:br,tableEngine:it,activeView:L,isDirty:Me,currentTableState:Se,viewChanges:xt,filters:a==null?void 0:a.filters,showFilterPanel:H,setShowFilterPanel:N,filterFocusColumn:Te,handleAddFilter:st,handleUpdateFilter:at,handleRemoveFilter:Fe,handleClearAllFilters:rr,handleOpenFilterForColumn:es,handleCloseFilterPanel:ts,handleClearFiltersForColumn:Ge,sortStack:a==null?void 0:a.sortStack,showSortPanel:Q,setShowSortPanel:ee,handleSort:Sr,handleUpdateSortStack:er,handleSortAscending:tr,handleSortDescending:Pe,views:a==null?void 0:a.views,showManageViews:oe,setShowManageViews:x,showCreateViewModal:F,setShowCreateViewModal:$,showEditViewModal:_,setShowEditViewModal:V,showDeleteConfirmation:ie,setShowDeleteConfirmation:ce,editingView:rs,deletingView:os,editingViewId:Y,deletingViewId:re,handleSelectView:Cr,handleCreateView:or,handleUpdateCurrentView:_t,handleSaveColumnConfigToCurrentView:jr,handleSaveColumnConfigToAllViews:wr,handleSaveAsNewView:kr,handleRevertChanges:Tr,handleToggleDefault:Nt,handleToggleFavorite:nr,handleSoftDelete:We,handleRestoreView:ir,handlePermanentDelete:sr,handleEditView:It,handleSaveEditView:zr,handleDeleteView:Et,handleConfirmDelete:D,showManageColumns:we,setShowManageColumns:G,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:Ae,handleUpdateColumnOrder:J,handleUpdateColumnWidth:ye,handleResetColumnLayout:So,showGroupPanel:De,setShowGroupPanel:He,grouping:a==null?void 0:a.grouping,groupingState:Ct,handleGroup:Fi,handleToggleGroupCollapse:Vi,searchQuery:et,searchHistory:Ts((a==null?void 0:a.searchHistory)||[]),handleSearchChange:Bi,handleAddToSearchHistory:Di,handleToggleSearchFavourite:Oi,handleDeleteSearchHistory:Ai,selectedRowIds:Oe,handleToggleRowSelection:Mi,handleToggleAllRows:Wi,handleRangeSelection:Ri,handleClearSelection:Pi,favoriteRowIndices:(a==null?void 0:a.favoriteRowIndices)||[],resolvedFavoritesSet:gr,showFavoritesOnly:(a==null?void 0:a.showFavoritesOnly)||!1,handleToggleRowFavorite:$i,handleBulkSetFavorites:_i,handleToggleFavoritesFilter:Ni,currentPage:tt,pageSize:$e,paginationEngine:ke,handlePageChange:q,handlePageSizeChange:de,isExporting:R,showExportModal:Mt,setShowExportModal:ut,showDirtyExportWarning:te,handleExport:Li,handleExportWithConfig:Hi,handleExportSelected:qi,handleExportAnyway:Ui,handleSaveAndExport:Gi,handleCancelExport:Yi,showAuditHistory:Yt,setShowAuditHistory:dt,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:Xe,setShowCreatePreset:Ne,showManagePresets:fr,setShowManagePresets:qt,activePreset:Zi,activePresetId:rt,handleOpenManagePresets:Xi,handleCreatePreset:Ji,handleClearActivePreset:Ki,handleDeletePresetById:Qi,userRole:Ce,isViewerRole:mr,currentUserId:mt,featureLimitWarning:Jt,setFeatureLimitWarning:ot,datasetMeta:zt,reportError:Wt,setReportError:Kt,handleError:Qe,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?as(a.schema):!1,snack:v,handleSnackClose:S,showSnack:b}}const Ze={sort:{maxLevels:5},filter:{maxConditions:10,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0},export:{allowedFormats:["csv","excel","json"]},display:{showDevPanel:!1}},Qn="urm_dev_config";function ua(){try{const t=localStorage.getItem(Qn);if(!t)return Ze;const o=JSON.parse(t);return{sort:{...Ze.sort,...o.sort},filter:{...Ze.filter,...o.filter},columns:{...Ze.columns,...o.columns},grouping:{...Ze.grouping,...o.grouping},export:{...Ze.export,...o.export},display:{...Ze.display,...o.display}}}catch{return Ze}}function pa(t){try{localStorage.setItem(Qn,JSON.stringify(t))}catch{}}function xa(t,o,n){return!n||!o?t:{sort:{...t.sort,...o.sort},filter:{...t.filter,...o.filter},columns:{...t.columns,...o.columns},grouping:{...t.grouping,...o.grouping},export:{...t.export,...o.export},display:{...t.display,...o.display}}}const Zn=p.createContext(Ze);function $r(){return p.useContext(Zn)}const ei=p.createContext(void 0);function Po(t){const{children:o,initialData:n,data:i,reportName:s,dataSource:l,mode:c="builder",autoLoad:d=!0,config:u,devConfig:f,showDevPanel:g=!1,sharedReportId:h}=t,w=da({mode:c,autoLoad:d,initialData:i||n,dataSource:l,reportName:s,sharedReportId:h,config:u}),[k,m]=p.useState(()=>ua()),v=(()=>{const a=xa(k,f,!!f);return{...a,display:{...a.display,showDevPanel:g||a.display.showDevPanel}}})(),j=p.useCallback(S=>{m(S),pa(S)},[]),b={...w,activeDevConfig:v,handleDevConfigChange:j};return e.jsx(Zn.Provider,{value:v,children:e.jsx(ei.Provider,{value:b,children:o})})}function io(){const t=p.useContext(ei);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function fa({onCreateReport:t,reports:o=[],activeReportId:n,onReportClick:i}){const s=o.find(l=>l.id===n);return e.jsx(r.Box,{component:"header",sx:{position:"sticky",top:0,zIndex:50,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[e.jsxs(r.Breadcrumbs,{separator:e.jsx(T.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"h6",component:"h1",sx:{fontWeight:500,fontSize:"1.375rem",color:"text.primary",letterSpacing:"-0.01em",cursor:o.length>0&&s?"pointer":"default","&:hover":o.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{o.length>0},children:"Reports"}),s&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),e.jsx(r.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:e.jsx(T.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:e.jsx(r.Button,{variant:"contained",startIcon:e.jsx(T.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,textTransform:"none",fontWeight:500,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Ht(t,...o){const n=new URL(`https://mui.com/production-error/?code=${t}`);return o.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${t}; visit ${n} for the full message.`}const ha="$$material";function ma(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Gr={exports:{}},Yr={exports:{}},xe={};/** @license React v16.13.1
|
|
12
4
|
* react-is.production.min.js
|
|
13
5
|
*
|
|
14
6
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
15
7
|
*
|
|
16
8
|
* This source code is licensed under the MIT license found in the
|
|
17
9
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var on;function
|
|
10
|
+
*/var on;function ga(){if(on)return xe;on=1;var t=typeof Symbol=="function"&&Symbol.for,o=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,s=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,c=t?Symbol.for("react.provider"):60109,d=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,g=t?Symbol.for("react.forward_ref"):60112,h=t?Symbol.for("react.suspense"):60113,y=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,k=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,v=t?Symbol.for("react.fundamental"):60117,j=t?Symbol.for("react.responder"):60118,b=t?Symbol.for("react.scope"):60119;function S(I){if(typeof I=="object"&&I!==null){var O=I.$$typeof;switch(O){case o:switch(I=I.type,I){case u:case f:case i:case l:case s:case h:return I;default:switch(I=I&&I.$$typeof,I){case d:case g:case k:case w:case c:return I;default:return O}}case n:return O}}}function a(I){return S(I)===f}return xe.AsyncMode=u,xe.ConcurrentMode=f,xe.ContextConsumer=d,xe.ContextProvider=c,xe.Element=o,xe.ForwardRef=g,xe.Fragment=i,xe.Lazy=k,xe.Memo=w,xe.Portal=n,xe.Profiler=l,xe.StrictMode=s,xe.Suspense=h,xe.isAsyncMode=function(I){return a(I)||S(I)===u},xe.isConcurrentMode=a,xe.isContextConsumer=function(I){return S(I)===d},xe.isContextProvider=function(I){return S(I)===c},xe.isElement=function(I){return typeof I=="object"&&I!==null&&I.$$typeof===o},xe.isForwardRef=function(I){return S(I)===g},xe.isFragment=function(I){return S(I)===i},xe.isLazy=function(I){return S(I)===k},xe.isMemo=function(I){return S(I)===w},xe.isPortal=function(I){return S(I)===n},xe.isProfiler=function(I){return S(I)===l},xe.isStrictMode=function(I){return S(I)===s},xe.isSuspense=function(I){return S(I)===h},xe.isValidElementType=function(I){return typeof I=="string"||typeof I=="function"||I===i||I===f||I===l||I===s||I===h||I===y||typeof I=="object"&&I!==null&&(I.$$typeof===k||I.$$typeof===w||I.$$typeof===c||I.$$typeof===d||I.$$typeof===g||I.$$typeof===v||I.$$typeof===j||I.$$typeof===b||I.$$typeof===m)},xe.typeOf=S,xe}var fe={};/** @license React v16.13.1
|
|
19
11
|
* react-is.development.js
|
|
20
12
|
*
|
|
21
13
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
14
|
*
|
|
23
15
|
* This source code is licensed under the MIT license found in the
|
|
24
16
|
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var nn;function
|
|
17
|
+
*/var nn;function ya(){return nn||(nn=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,o=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,s=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,c=t?Symbol.for("react.provider"):60109,d=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,g=t?Symbol.for("react.forward_ref"):60112,h=t?Symbol.for("react.suspense"):60113,y=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,k=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,v=t?Symbol.for("react.fundamental"):60117,j=t?Symbol.for("react.responder"):60118,b=t?Symbol.for("react.scope"):60119;function S(G){return typeof G=="string"||typeof G=="function"||G===i||G===f||G===l||G===s||G===h||G===y||typeof G=="object"&&G!==null&&(G.$$typeof===k||G.$$typeof===w||G.$$typeof===c||G.$$typeof===d||G.$$typeof===g||G.$$typeof===v||G.$$typeof===j||G.$$typeof===b||G.$$typeof===m)}function a(G){if(typeof G=="object"&&G!==null){var De=G.$$typeof;switch(De){case o:var He=G.type;switch(He){case u:case f:case i:case l:case s:case h:return He;default:var Ct=He&&He.$$typeof;switch(Ct){case d:case g:case k:case w:case c:return Ct;default:return De}}case n:return De}}}var I=u,O=f,H=d,N=c,Q=o,ee=g,oe=i,x=k,F=w,$=n,_=l,V=s,ie=h,ce=!1;function Te(G){return ce||(ce=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),M(G)||a(G)===u}function M(G){return a(G)===f}function Y(G){return a(G)===d}function Z(G){return a(G)===c}function re(G){return typeof G=="object"&&G!==null&&G.$$typeof===o}function ne(G){return a(G)===g}function R(G){return a(G)===i}function X(G){return a(G)===k}function te(G){return a(G)===w}function ae(G){return a(G)===n}function se(G){return a(G)===l}function le(G){return a(G)===s}function we(G){return a(G)===h}fe.AsyncMode=I,fe.ConcurrentMode=O,fe.ContextConsumer=H,fe.ContextProvider=N,fe.Element=Q,fe.ForwardRef=ee,fe.Fragment=oe,fe.Lazy=x,fe.Memo=F,fe.Portal=$,fe.Profiler=_,fe.StrictMode=V,fe.Suspense=ie,fe.isAsyncMode=Te,fe.isConcurrentMode=M,fe.isContextConsumer=Y,fe.isContextProvider=Z,fe.isElement=re,fe.isForwardRef=ne,fe.isFragment=R,fe.isLazy=X,fe.isMemo=te,fe.isPortal=ae,fe.isProfiler=se,fe.isStrictMode=le,fe.isSuspense=we,fe.isValidElementType=S,fe.typeOf=a})()),fe}var sn;function ti(){return sn||(sn=1,process.env.NODE_ENV==="production"?Yr.exports=ga():Yr.exports=ya()),Yr.exports}/*
|
|
26
18
|
object-assign
|
|
27
19
|
(c) Sindre Sorhus
|
|
28
20
|
@license MIT
|
|
29
|
-
*/var
|
|
30
|
-
Valid keys: `+JSON.stringify(Object.keys(
|
|
21
|
+
*/var jo,an;function ba(){if(an)return jo;an=1;var t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function s(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var c={},d=0;d<10;d++)c["_"+String.fromCharCode(d)]=d;var u=Object.getOwnPropertyNames(c).map(function(g){return c[g]});if(u.join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(g){f[g]=g}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return jo=s()?Object.assign:function(l,c){for(var d,u=i(l),f,g=1;g<arguments.length;g++){d=Object(arguments[g]);for(var h in d)o.call(d,h)&&(u[h]=d[h]);if(t){f=t(d);for(var y=0;y<f.length;y++)n.call(d,f[y])&&(u[f[y]]=d[f[y]])}}return u},jo}var wo,ln;function $o(){if(ln)return wo;ln=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return wo=t,wo}var ko,cn;function ri(){return cn||(cn=1,ko=Function.call.bind(Object.prototype.hasOwnProperty)),ko}var To,dn;function va(){if(dn)return To;dn=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var o=$o(),n={},i=ri();t=function(l){var c="Warning: "+l;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(l,c,d,u,f){if(process.env.NODE_ENV!=="production"){for(var g in l)if(i(l,g)){var h;try{if(typeof l[g]!="function"){var y=Error((u||"React class")+": "+d+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw y.name="Invariant Violation",y}h=l[g](c,g,u,d,null,o)}catch(k){h=k}if(h&&!(h instanceof Error)&&t((u||"React class")+": type specification of "+d+" `"+g+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof h+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),h instanceof Error&&!(h.message in n)){n[h.message]=!0;var w=f?f():"";t("Failed "+d+" type: "+h.message+(w??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},To=s,To}var zo,un;function Sa(){if(un)return zo;un=1;var t=ti(),o=ba(),n=$o(),i=ri(),s=va(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(d){var u="Warning: "+d;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return zo=function(d,u){var f=typeof Symbol=="function"&&Symbol.iterator,g="@@iterator";function h(M){var Y=M&&(f&&M[f]||M[g]);if(typeof Y=="function")return Y}var y="<<anonymous>>",w={array:j("array"),bigint:j("bigint"),bool:j("boolean"),func:j("function"),number:j("number"),object:j("object"),string:j("string"),symbol:j("symbol"),any:b(),arrayOf:S,element:a(),elementType:I(),instanceOf:O,node:ee(),objectOf:N,oneOf:H,oneOfType:Q,shape:x,exact:F};function k(M,Y){return M===Y?M!==0||1/M===1/Y:M!==M&&Y!==Y}function m(M,Y){this.message=M,this.data=Y&&typeof Y=="object"?Y:{},this.stack=""}m.prototype=Error.prototype;function v(M){if(process.env.NODE_ENV!=="production")var Y={},Z=0;function re(R,X,te,ae,se,le,we){if(ae=ae||y,le=le||te,we!==n){if(u){var G=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw G.name="Invariant Violation",G}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var De=ae+":"+te;!Y[De]&&Z<3&&(l("You are manually calling a React.PropTypes validation function for the `"+le+"` prop on `"+ae+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),Y[De]=!0,Z++)}}return X[te]==null?R?X[te]===null?new m("The "+se+" `"+le+"` is marked as required "+("in `"+ae+"`, but its value is `null`.")):new m("The "+se+" `"+le+"` is marked as required in "+("`"+ae+"`, but its value is `undefined`.")):null:M(X,te,ae,se,le)}var ne=re.bind(null,!1);return ne.isRequired=re.bind(null,!0),ne}function j(M){function Y(Z,re,ne,R,X,te){var ae=Z[re],se=V(ae);if(se!==M){var le=ie(ae);return new m("Invalid "+R+" `"+X+"` of type "+("`"+le+"` supplied to `"+ne+"`, expected ")+("`"+M+"`."),{expectedType:M})}return null}return v(Y)}function b(){return v(c)}function S(M){function Y(Z,re,ne,R,X){if(typeof M!="function")return new m("Property `"+X+"` of component `"+ne+"` has invalid PropType notation inside arrayOf.");var te=Z[re];if(!Array.isArray(te)){var ae=V(te);return new m("Invalid "+R+" `"+X+"` of type "+("`"+ae+"` supplied to `"+ne+"`, expected an array."))}for(var se=0;se<te.length;se++){var le=M(te,se,ne,R,X+"["+se+"]",n);if(le instanceof Error)return le}return null}return v(Y)}function a(){function M(Y,Z,re,ne,R){var X=Y[Z];if(!d(X)){var te=V(X);return new m("Invalid "+ne+" `"+R+"` of type "+("`"+te+"` supplied to `"+re+"`, expected a single ReactElement."))}return null}return v(M)}function I(){function M(Y,Z,re,ne,R){var X=Y[Z];if(!t.isValidElementType(X)){var te=V(X);return new m("Invalid "+ne+" `"+R+"` of type "+("`"+te+"` supplied to `"+re+"`, expected a single ReactElement type."))}return null}return v(M)}function O(M){function Y(Z,re,ne,R,X){if(!(Z[re]instanceof M)){var te=M.name||y,ae=Te(Z[re]);return new m("Invalid "+R+" `"+X+"` of type "+("`"+ae+"` supplied to `"+ne+"`, expected ")+("instance of `"+te+"`."))}return null}return v(Y)}function H(M){if(!Array.isArray(M))return process.env.NODE_ENV!=="production"&&(arguments.length>1?l("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):l("Invalid argument supplied to oneOf, expected an array.")),c;function Y(Z,re,ne,R,X){for(var te=Z[re],ae=0;ae<M.length;ae++)if(k(te,M[ae]))return null;var se=JSON.stringify(M,function(we,G){var De=ie(G);return De==="symbol"?String(G):G});return new m("Invalid "+R+" `"+X+"` of value `"+String(te)+"` "+("supplied to `"+ne+"`, expected one of "+se+"."))}return v(Y)}function N(M){function Y(Z,re,ne,R,X){if(typeof M!="function")return new m("Property `"+X+"` of component `"+ne+"` has invalid PropType notation inside objectOf.");var te=Z[re],ae=V(te);if(ae!=="object")return new m("Invalid "+R+" `"+X+"` of type "+("`"+ae+"` supplied to `"+ne+"`, expected an object."));for(var se in te)if(i(te,se)){var le=M(te,se,ne,R,X+"."+se,n);if(le instanceof Error)return le}return null}return v(Y)}function Q(M){if(!Array.isArray(M))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var Y=0;Y<M.length;Y++){var Z=M[Y];if(typeof Z!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ce(Z)+" at index "+Y+"."),c}function re(ne,R,X,te,ae){for(var se=[],le=0;le<M.length;le++){var we=M[le],G=we(ne,R,X,te,ae,n);if(G==null)return null;G.data&&i(G.data,"expectedType")&&se.push(G.data.expectedType)}var De=se.length>0?", expected one of type ["+se.join(", ")+"]":"";return new m("Invalid "+te+" `"+ae+"` supplied to "+("`"+X+"`"+De+"."))}return v(re)}function ee(){function M(Y,Z,re,ne,R){return $(Y[Z])?null:new m("Invalid "+ne+" `"+R+"` supplied to "+("`"+re+"`, expected a ReactNode."))}return v(M)}function oe(M,Y,Z,re,ne){return new m((M||"React class")+": "+Y+" type `"+Z+"."+re+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+ne+"`.")}function x(M){function Y(Z,re,ne,R,X){var te=Z[re],ae=V(te);if(ae!=="object")return new m("Invalid "+R+" `"+X+"` of type `"+ae+"` "+("supplied to `"+ne+"`, expected `object`."));for(var se in M){var le=M[se];if(typeof le!="function")return oe(ne,R,X,se,ie(le));var we=le(te,se,ne,R,X+"."+se,n);if(we)return we}return null}return v(Y)}function F(M){function Y(Z,re,ne,R,X){var te=Z[re],ae=V(te);if(ae!=="object")return new m("Invalid "+R+" `"+X+"` of type `"+ae+"` "+("supplied to `"+ne+"`, expected `object`."));var se=o({},Z[re],M);for(var le in se){var we=M[le];if(i(M,le)&&typeof we!="function")return oe(ne,R,X,le,ie(we));if(!we)return new m("Invalid "+R+" `"+X+"` key `"+le+"` supplied to `"+ne+"`.\nBad object: "+JSON.stringify(Z[re],null," ")+`
|
|
22
|
+
Valid keys: `+JSON.stringify(Object.keys(M),null," "));var G=we(te,le,ne,R,X+"."+le,n);if(G)return G}return null}return v(Y)}function $(M){switch(typeof M){case"number":case"string":case"undefined":return!0;case"boolean":return!M;case"object":if(Array.isArray(M))return M.every($);if(M===null||d(M))return!0;var Y=h(M);if(Y){var Z=Y.call(M),re;if(Y!==M.entries){for(;!(re=Z.next()).done;)if(!$(re.value))return!1}else for(;!(re=Z.next()).done;){var ne=re.value;if(ne&&!$(ne[1]))return!1}}else return!1;return!0;default:return!1}}function _(M,Y){return M==="symbol"?!0:Y?Y["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&Y instanceof Symbol:!1}function V(M){var Y=typeof M;return Array.isArray(M)?"array":M instanceof RegExp?"object":_(Y,M)?"symbol":Y}function ie(M){if(typeof M>"u"||M===null)return""+M;var Y=V(M);if(Y==="object"){if(M instanceof Date)return"date";if(M instanceof RegExp)return"regexp"}return Y}function ce(M){var Y=ie(M);switch(Y){case"array":case"object":return"an "+Y;case"boolean":case"date":case"regexp":return"a "+Y;default:return Y}}function Te(M){return!M.constructor||!M.constructor.name?y:M.constructor.name}return w.checkPropTypes=s,w.resetWarningCache=s.resetWarningCache,w.PropTypes=w,w},zo}var Io,pn;function Ca(){if(pn)return Io;pn=1;var t=$o();function o(){}function n(){}return n.resetWarningCache=o,Io=function(){function i(c,d,u,f,g,h){if(h!==t){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}}i.isRequired=i;function s(){return i}var l={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:o};return l.PropTypes=l,l},Io}var xn;function ja(){if(xn)return Gr.exports;if(xn=1,process.env.NODE_ENV!=="production"){var t=ti(),o=!0;Gr.exports=Sa()(t.isElement,o)}else Gr.exports=Ca()();return Gr.exports}var wa=ja();const Er=ma(wa);var qr={exports:{}},be={};/**
|
|
31
23
|
* @license React
|
|
32
24
|
* react-is.production.js
|
|
33
25
|
*
|
|
@@ -35,7 +27,7 @@ Valid keys: `+JSON.stringify(Object.keys(R),null," "));var G=je(Q,le,re,ne,Z+".
|
|
|
35
27
|
*
|
|
36
28
|
* This source code is licensed under the MIT license found in the
|
|
37
29
|
* LICENSE file in the root directory of this source tree.
|
|
38
|
-
*/var
|
|
30
|
+
*/var fn;function ka(){if(fn)return be;fn=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),y=Symbol.for("react.view_transition"),w=Symbol.for("react.client.reference");function k(m){if(typeof m=="object"&&m!==null){var v=m.$$typeof;switch(v){case t:switch(m=m.type,m){case n:case s:case i:case u:case f:case y:return m;default:switch(m=m&&m.$$typeof,m){case c:case d:case h:case g:return m;case l:return m;default:return v}}case o:return v}}}return be.ContextConsumer=l,be.ContextProvider=c,be.Element=t,be.ForwardRef=d,be.Fragment=n,be.Lazy=h,be.Memo=g,be.Portal=o,be.Profiler=s,be.StrictMode=i,be.Suspense=u,be.SuspenseList=f,be.isContextConsumer=function(m){return k(m)===l},be.isContextProvider=function(m){return k(m)===c},be.isElement=function(m){return typeof m=="object"&&m!==null&&m.$$typeof===t},be.isForwardRef=function(m){return k(m)===d},be.isFragment=function(m){return k(m)===n},be.isLazy=function(m){return k(m)===h},be.isMemo=function(m){return k(m)===g},be.isPortal=function(m){return k(m)===o},be.isProfiler=function(m){return k(m)===s},be.isStrictMode=function(m){return k(m)===i},be.isSuspense=function(m){return k(m)===u},be.isSuspenseList=function(m){return k(m)===f},be.isValidElementType=function(m){return typeof m=="string"||typeof m=="function"||m===n||m===s||m===i||m===u||m===f||typeof m=="object"&&m!==null&&(m.$$typeof===h||m.$$typeof===g||m.$$typeof===c||m.$$typeof===l||m.$$typeof===d||m.$$typeof===w||m.getModuleId!==void 0)},be.typeOf=k,be}var ve={};/**
|
|
39
31
|
* @license React
|
|
40
32
|
* react-is.development.js
|
|
41
33
|
*
|
|
@@ -43,16 +35,16 @@ Valid keys: `+JSON.stringify(Object.keys(R),null," "));var G=je(Q,le,re,ne,Z+".
|
|
|
43
35
|
*
|
|
44
36
|
* This source code is licensed under the MIT license found in the
|
|
45
37
|
* LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/var hn;function
|
|
47
|
-
For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,
|
|
48
|
-
`)):console.error([`MUI: The \`theme.${
|
|
49
|
-
`)));const d=
|
|
50
|
-
`)),()=>{})}function Oo(t){return Rr(t,"spacing",8,"spacing")}function Wr(t,r){return typeof r=="string"||r==null?r:t(r)}function Na(t,r){return n=>t.reduce((i,a)=>(i[a]=Wr(r,n),i),{})}function Va(t,r,n,i){if(!r.includes(n))return null;const a=Fa(n),c=Na(a,i),l=t[n];return Ct(t,l,c)}function si(t,r){const n=Oo(t.theme);return Object.keys(t).map(i=>Va(t,r,i,n)).reduce(Or,{})}function ze(t){return si(t,Zr)}ze.propTypes=process.env.NODE_ENV!=="production"?Zr.reduce((t,r)=>(t[r]=Pt,t),{}):{};ze.filterProps=Zr;function Ie(t){return si(t,eo)}Ie.propTypes=process.env.NODE_ENV!=="production"?eo.reduce((t,r)=>(t[r]=Pt,t),{}):{};Ie.filterProps=eo;process.env.NODE_ENV!=="production"&&La.reduce((t,r)=>(t[r]=Pt,t),{});function ai(t=8,r=Oo({spacing:t})){if(t.mui)return t;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(c=>{const l=r(c);return typeof l=="number"?`${l}px`:l}).join(" "));return n.mui=!0,n}function to(...t){const r=t.reduce((i,a)=>(a.filterProps.forEach(c=>{i[c]=a}),i),{}),n=i=>Object.keys(i).reduce((a,c)=>r[c]?Or(a,r[c](i)):a,{});return n.propTypes=process.env.NODE_ENV!=="production"?t.reduce((i,a)=>Object.assign(i,a.propTypes),{}):{},n.filterProps=t.reduce((i,a)=>i.concat(a.filterProps),[]),n}function Ze(t){return typeof t!="number"?t:`${t}px solid`}function et(t,r){return De({prop:t,themeKey:"borders",transform:r})}const Ha=et("border",Ze),Ua=et("borderTop",Ze),Ga=et("borderRight",Ze),Ya=et("borderBottom",Ze),Ja=et("borderLeft",Ze),qa=et("borderColor"),Ka=et("borderTopColor"),Xa=et("borderRightColor"),Qa=et("borderBottomColor"),Za=et("borderLeftColor"),el=et("outline",Ze),tl=et("outlineColor"),ro=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const r=Rr(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Wr(r,i)});return Ct(t,t.borderRadius,n)}return null};ro.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Pt}:{};ro.filterProps=["borderRadius"];to(Ha,Ua,Ga,Ya,Ja,qa,Ka,Xa,Qa,Za,ro,el,tl);const oo=t=>{if(t.gap!==void 0&&t.gap!==null){const r=Rr(t.theme,"spacing",8,"gap"),n=i=>({gap:Wr(r,i)});return Ct(t,t.gap,n)}return null};oo.propTypes=process.env.NODE_ENV!=="production"?{gap:Pt}:{};oo.filterProps=["gap"];const no=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const r=Rr(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Wr(r,i)});return Ct(t,t.columnGap,n)}return null};no.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Pt}:{};no.filterProps=["columnGap"];const io=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const r=Rr(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Wr(r,i)});return Ct(t,t.rowGap,n)}return null};io.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Pt}:{};io.filterProps=["rowGap"];const rl=De({prop:"gridColumn"}),ol=De({prop:"gridRow"}),nl=De({prop:"gridAutoFlow"}),il=De({prop:"gridAutoColumns"}),sl=De({prop:"gridAutoRows"}),al=De({prop:"gridTemplateColumns"}),ll=De({prop:"gridTemplateRows"}),cl=De({prop:"gridTemplateAreas"}),dl=De({prop:"gridArea"});to(oo,no,io,rl,ol,nl,il,sl,al,ll,cl,dl);function hr(t,r){return r==="grey"?r:t}const ul=De({prop:"color",themeKey:"palette",transform:hr}),pl=De({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:hr}),fl=De({prop:"backgroundColor",themeKey:"palette",transform:hr});to(ul,pl,fl);function Ue(t){return t<=1&&t!==0?`${t*100}%`:t}const xl=De({prop:"width",transform:Ue}),Ao=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const r=n=>{var a,c,l,d,f;const i=((l=(c=(a=t.theme)==null?void 0:a.breakpoints)==null?void 0:c.values)==null?void 0:l[n])||Xr[n];return i?((f=(d=t.theme)==null?void 0:d.breakpoints)==null?void 0:f.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Ue(n)}};return Ct(t,t.maxWidth,r)}return null};Ao.filterProps=["maxWidth"];const hl=De({prop:"minWidth",transform:Ue}),ml=De({prop:"height",transform:Ue}),gl=De({prop:"maxHeight",transform:Ue}),yl=De({prop:"minHeight",transform:Ue});De({prop:"size",cssProperty:"width",transform:Ue});De({prop:"size",cssProperty:"height",transform:Ue});const bl=De({prop:"boxSizing"});to(xl,Ao,hl,ml,gl,yl,bl);const so={border:{themeKey:"borders",transform:Ze},borderTop:{themeKey:"borders",transform:Ze},borderRight:{themeKey:"borders",transform:Ze},borderBottom:{themeKey:"borders",transform:Ze},borderLeft:{themeKey:"borders",transform:Ze},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:Ze},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:ro},color:{themeKey:"palette",transform:hr},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:hr},backgroundColor:{themeKey:"palette",transform:hr},p:{style:Ie},pt:{style:Ie},pr:{style:Ie},pb:{style:Ie},pl:{style:Ie},px:{style:Ie},py:{style:Ie},padding:{style:Ie},paddingTop:{style:Ie},paddingRight:{style:Ie},paddingBottom:{style:Ie},paddingLeft:{style:Ie},paddingX:{style:Ie},paddingY:{style:Ie},paddingInline:{style:Ie},paddingInlineStart:{style:Ie},paddingInlineEnd:{style:Ie},paddingBlock:{style:Ie},paddingBlockStart:{style:Ie},paddingBlockEnd:{style:Ie},m:{style:ze},mt:{style:ze},mr:{style:ze},mb:{style:ze},ml:{style:ze},mx:{style:ze},my:{style:ze},margin:{style:ze},marginTop:{style:ze},marginRight:{style:ze},marginBottom:{style:ze},marginLeft:{style:ze},marginX:{style:ze},marginY:{style:ze},marginInline:{style:ze},marginInlineStart:{style:ze},marginInlineEnd:{style:ze},marginBlock:{style:ze},marginBlockStart:{style:ze},marginBlockEnd:{style:ze},displayPrint:{cssProperty:!1,transform:t=>({"@media print":{display:t}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:oo},rowGap:{style:io},columnGap:{style:no},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Ue},maxWidth:{style:Ao},minWidth:{transform:Ue},height:{transform:Ue},maxHeight:{transform:Ue},minHeight:{transform:Ue},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function vl(...t){const r=t.reduce((i,a)=>i.concat(Object.keys(a)),[]),n=new Set(r);return t.every(i=>n.size===Object.keys(i).length)}function Sl(t,r){return typeof t=="function"?t(r):t}function Cl(){function t(n,i,a,c){const l={[n]:i,theme:a},d=c[n];if(!d)return{[n]:i};const{cssProperty:f=n,themeKey:h,transform:m,style:g}=d;if(i==null)return null;if(h==="typography"&&i==="inherit")return{[n]:i};const y=Qr(a,h)||{};return g?g(l):Ct(l,i,C=>{let x=Yr(y,m,C);return C===x&&typeof C=="string"&&(x=Yr(y,m,`${n}${C==="default"?"":ii(C)}`,C)),f===!1?x:{[f]:x}})}function r(n){const{sx:i,theme:a={},nested:c}=n||{};if(!i)return null;const l=a.unstable_sxConfig??so;function d(f){let h=f;if(typeof f=="function")h=f(a);else if(typeof f!="object")return f;if(!h)return null;const m=Wa(a.breakpoints),g=Object.keys(m);let y=m;return Object.keys(h).forEach(S=>{const C=Sl(h[S],a);if(C!=null)if(typeof C=="object")if(l[S])y=Or(y,t(S,C,a,l));else{const x=Ct({theme:a},C,E=>({[S]:E}));vl(x,C)?y[S]=r({sx:C,theme:a,nested:!0}):y=Or(y,x)}else y=Or(y,t(S,C,a,l))}),!c&&a.modularCssLayers?{"@layer sx":gn(a,bn(g,y))}:gn(a,bn(g,y))}return Array.isArray(i)?i.map(d):d(i)}return r}const ao=Cl();ao.filterProps=["sx"];function jl(t,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[t])||typeof n.getColorSchemeSelector!="function")return{};let a=n.getColorSchemeSelector(t);return a==="&"?r:((a.includes("data-")||a.includes("."))&&(a=`*:where(${a.replace(/\s*&$/,"")}) &`),{[a]:r})}return n.palette.mode===t?r:{}}function li(t={},...r){const{breakpoints:n={},palette:i={},spacing:a,shape:c={},...l}=t,d=Ba(n),f=ai(a);let h=Ge({breakpoints:d,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:f,shape:{...Ma,...c}},l);return h=Aa(h),h.applyStyles=jl,h=r.reduce((m,g)=>Ge(m,g),h),h.unstable_sxConfig={...so,...l==null?void 0:l.unstable_sxConfig},h.unstable_sx=function(g){return ao({sx:g,theme:this})},h}function wl(t){return Object.keys(t).length===0}function kl(t=null){const r=Jr.useContext(ss.ThemeContext);return!r||wl(r)?t:r}const Tl=li();function zl(t=Tl){return kl(t)}const Sn=t=>t,Il=()=>{let t=Sn;return{configure(r){t=r},generate(r){return t(r)},reset(){t=Sn}}},El=Il(),Bl={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function Dl(t,r,n="Mui"){const i=Bl[r];return i?`${n}-${i}`:`${El.generate(t)}-${r}`}function Ol(t,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(t,n))}function Mo(t,r=0,n=1){return process.env.NODE_ENV!=="production"&&(t<r||t>n)&&console.error(`MUI: The value provided ${t} is out of range [${r}, ${n}].`),Ol(t,r,n)}function Al(t){t=t.slice(1);const r=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let n=t.match(r);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&t.length!==t.trim().length&&console.error(`MUI: The color: "${t}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,a)=>a<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Wt(t){if(t.type)return t;if(t.charAt(0)==="#")return Wt(Al(t));const r=t.indexOf("("),n=t.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${t}\` color.
|
|
51
|
-
The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:
|
|
52
|
-
The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:
|
|
53
|
-
`))}return
|
|
54
|
-
The color object needs to have a \`main\` property or a \`${
|
|
55
|
-
\`color.main\` should be a string, but \`${JSON.stringify(
|
|
38
|
+
*/var hn;function Ta(){return hn||(hn=1,process.env.NODE_ENV!=="production"&&(function(){function t(m){if(typeof m=="object"&&m!==null){var v=m.$$typeof;switch(v){case o:switch(m=m.type,m){case i:case l:case s:case f:case g:case w:return m;default:switch(m=m&&m.$$typeof,m){case d:case u:case y:case h:return m;case c:return m;default:return v}}case n:return v}}}var o=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),w=Symbol.for("react.view_transition"),k=Symbol.for("react.client.reference");ve.ContextConsumer=c,ve.ContextProvider=d,ve.Element=o,ve.ForwardRef=u,ve.Fragment=i,ve.Lazy=y,ve.Memo=h,ve.Portal=n,ve.Profiler=l,ve.StrictMode=s,ve.Suspense=f,ve.SuspenseList=g,ve.isContextConsumer=function(m){return t(m)===c},ve.isContextProvider=function(m){return t(m)===d},ve.isElement=function(m){return typeof m=="object"&&m!==null&&m.$$typeof===o},ve.isForwardRef=function(m){return t(m)===u},ve.isFragment=function(m){return t(m)===i},ve.isLazy=function(m){return t(m)===y},ve.isMemo=function(m){return t(m)===h},ve.isPortal=function(m){return t(m)===n},ve.isProfiler=function(m){return t(m)===l},ve.isStrictMode=function(m){return t(m)===s},ve.isSuspense=function(m){return t(m)===f},ve.isSuspenseList=function(m){return t(m)===g},ve.isValidElementType=function(m){return typeof m=="string"||typeof m=="function"||m===i||m===l||m===s||m===f||m===g||typeof m=="object"&&m!==null&&(m.$$typeof===y||m.$$typeof===h||m.$$typeof===d||m.$$typeof===c||m.$$typeof===u||m.$$typeof===k||m.getModuleId!==void 0)},ve.typeOf=t})()),ve}var mn;function za(){return mn||(mn=1,process.env.NODE_ENV==="production"?qr.exports=ka():qr.exports=Ta()),qr.exports}var oi=za();function Bt(t){if(typeof t!="object"||t===null)return!1;const o=Object.getPrototypeOf(t);return(o===null||o===Object.prototype||Object.getPrototypeOf(o)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function ni(t){if(oo.isValidElement(t)||oi.isValidElementType(t)||!Bt(t))return t;const o={};return Object.keys(t).forEach(n=>{o[n]=ni(t[n])}),o}function Le(t,o,n={clone:!0}){const i=n.clone?{...t}:t;return Bt(t)&&Bt(o)&&Object.keys(o).forEach(s=>{oo.isValidElement(o[s])||oi.isValidElementType(o[s])?i[s]=o[s]:Bt(o[s])&&Object.prototype.hasOwnProperty.call(t,s)&&Bt(t[s])?i[s]=Le(t[s],o[s],n):n.clone?i[s]=Bt(o[s])?ni(o[s]):o[s]:i[s]=o[s]}),i}const Ia=t=>{const o=Object.keys(t).map(n=>({key:n,val:t[n]}))||[];return o.sort((n,i)=>n.val-i.val),o.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function Ea(t){const{values:o={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=t,l=Ia(o),c=Object.keys(l);function d(y){return`@media (min-width:${typeof o[y]=="number"?o[y]:y}${n})`}function u(y){return`@media (max-width:${(typeof o[y]=="number"?o[y]:y)-i/100}${n})`}function f(y,w){const k=c.indexOf(w);return`@media (min-width:${typeof o[y]=="number"?o[y]:y}${n}) and (max-width:${(k!==-1&&typeof o[c[k]]=="number"?o[c[k]]:w)-i/100}${n})`}function g(y){return c.indexOf(y)+1<c.length?f(y,c[c.indexOf(y)+1]):d(y)}function h(y){const w=c.indexOf(y);return w===0?d(c[1]):w===c.length-1?u(c[w]):f(y,c[c.indexOf(y)+1]).replace("@media","@media not all and")}return{keys:c,values:l,up:d,down:u,between:f,only:g,not:h,unit:n,...s}}function gn(t,o){if(!t.containerQueries)return o;const n=Object.keys(o).filter(i=>i.startsWith("@container")).sort((i,s)=>{var c,d;const l=/min-width:\s*([0-9.]+)/;return+(((c=i.match(l))==null?void 0:c[1])||0)-+(((d=s.match(l))==null?void 0:d[1])||0)});return n.length?n.reduce((i,s)=>{const l=o[s];return delete i[s],i[s]=l,i},{...o}):o}function Ba(t,o){return o==="@"||o.startsWith("@")&&(t.some(n=>o.startsWith(`@${n}`))||!!o.match(/^@\d/))}function Da(t,o){const n=o.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${o})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
|
|
39
|
+
For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,l=Number.isNaN(+i)?i||0:+i;return t.containerQueries(s).up(l)}function Oa(t){const o=(l,c)=>l.replace("@media",c?`@container ${c}`:"@container");function n(l,c){l.up=(...d)=>o(t.breakpoints.up(...d),c),l.down=(...d)=>o(t.breakpoints.down(...d),c),l.between=(...d)=>o(t.breakpoints.between(...d),c),l.only=(...d)=>o(t.breakpoints.only(...d),c),l.not=(...d)=>{const u=o(t.breakpoints.not(...d),c);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=l=>(n(i,l),i);return n(s),{...t,containerQueries:s}}const Aa={borderRadius:4},Ot=process.env.NODE_ENV!=="production"?Er.oneOfType([Er.number,Er.string,Er.object,Er.array]):{};function Rr(t,o){return o?Le(t,o,{clone:!1}):t}const so={xs:0,sm:600,md:900,lg:1200,xl:1536},yn={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${so[t]}px)`},Ma={containerQueries:t=>({up:o=>{let n=typeof o=="number"?o:so[o]||o;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function St(t,o,n){const i=t.theme||{};if(Array.isArray(o)){const l=i.breakpoints||yn;return o.reduce((c,d,u)=>(c[l.up(l.keys[u])]=n(o[u]),c),{})}if(typeof o=="object"){const l=i.breakpoints||yn;return Object.keys(o).reduce((c,d)=>{if(Ba(l.keys,d)){const u=Da(i.containerQueries?i:Ma,d);u&&(c[u]=n(o[d],d))}else if(Object.keys(l.values||so).includes(d)){const u=l.up(d);c[u]=n(o[d],d)}else{const u=d;c[u]=o[u]}return c},{})}return n(o)}function Wa(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,s)=>{const l=t.up(s);return i[l]={},i},{}))||{}}function bn(t,o){return t.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},o)}function ii(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Ht(7));return t.charAt(0).toUpperCase()+t.slice(1)}function ao(t,o,n=!0){if(!o||typeof o!="string")return null;if(t&&t.vars&&n){const i=`vars.${o}`.split(".").reduce((s,l)=>s&&s[l]?s[l]:null,t);if(i!=null)return i}return o.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,t)}function ro(t,o,n,i=n){let s;return typeof t=="function"?s=t(n):Array.isArray(t)?s=t[n]||i:s=ao(t,n)||i,o&&(s=o(s,i,t)),s}function Ee(t){const{prop:o,cssProperty:n=t.prop,themeKey:i,transform:s}=t,l=c=>{if(c[o]==null)return null;const d=c[o],u=c.theme,f=ao(u,i)||{};return St(c,d,h=>{let y=ro(f,s,h);return h===y&&typeof h=="string"&&(y=ro(f,s,`${o}${h==="default"?"":ii(h)}`,h)),n===!1?y:{[n]:y}})};return l.propTypes=process.env.NODE_ENV!=="production"?{[o]:Ot}:{},l.filterProps=[o],l}function Ra(t){const o={};return n=>(o[n]===void 0&&(o[n]=t(n)),o[n])}const Pa={m:"margin",p:"padding"},$a={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},vn={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},_a=Ra(t=>{if(t.length>2)if(vn[t])t=vn[t];else return[t];const[o,n]=t.split(""),i=Pa[o],s=$a[n]||"";return Array.isArray(s)?s.map(l=>i+l):[i+s]}),lo=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],co=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],Na=[...lo,...co];function _r(t,o,n,i){const s=ao(t,o,!0)??n;return typeof s=="number"||typeof s=="string"?l=>typeof l=="string"?l:(process.env.NODE_ENV!=="production"&&typeof l!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${l}.`),typeof s=="string"?s.startsWith("var(")&&l===0?0:s.startsWith("var(")&&l===1?s:`calc(${l} * ${s})`:s*l):Array.isArray(s)?l=>{if(typeof l=="string")return l;const c=Math.abs(l);process.env.NODE_ENV!=="production"&&(Number.isInteger(c)?c>s.length-1&&console.error([`MUI: The value provided (${c}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${c} > ${s.length-1}, you need to add the missing values.`].join(`
|
|
40
|
+
`)):console.error([`MUI: The \`theme.${o}\` array type cannot be combined with non integer values.You should either use an integer value that can be used as index, or define the \`theme.${o}\` as a number.`].join(`
|
|
41
|
+
`)));const d=s[c];return l>=0?d:typeof d=="number"?-d:typeof d=="string"&&d.startsWith("var(")?`calc(-1 * ${d})`:`-${d}`}:typeof s=="function"?s:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${o}\` value (${s}) is invalid.`,"It should be a number, an array or a function."].join(`
|
|
42
|
+
`)),()=>{})}function _o(t){return _r(t,"spacing",8,"spacing")}function Nr(t,o){return typeof o=="string"||o==null?o:t(o)}function Fa(t,o){return n=>t.reduce((i,s)=>(i[s]=Nr(o,n),i),{})}function Va(t,o,n,i){if(!o.includes(n))return null;const s=_a(n),l=Fa(s,i),c=t[n];return St(t,c,l)}function si(t,o){const n=_o(t.theme);return Object.keys(t).map(i=>Va(t,o,i,n)).reduce(Rr,{})}function ze(t){return si(t,lo)}ze.propTypes=process.env.NODE_ENV!=="production"?lo.reduce((t,o)=>(t[o]=Ot,t),{}):{};ze.filterProps=lo;function Ie(t){return si(t,co)}Ie.propTypes=process.env.NODE_ENV!=="production"?co.reduce((t,o)=>(t[o]=Ot,t),{}):{};Ie.filterProps=co;process.env.NODE_ENV!=="production"&&Na.reduce((t,o)=>(t[o]=Ot,t),{});function ai(t=8,o=_o({spacing:t})){if(t.mui)return t;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(l=>{const c=o(l);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function uo(...t){const o=t.reduce((i,s)=>(s.filterProps.forEach(l=>{i[l]=s}),i),{}),n=i=>Object.keys(i).reduce((s,l)=>o[l]?Rr(s,o[l](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?t.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=t.reduce((i,s)=>i.concat(s.filterProps),[]),n}function qe(t){return typeof t!="number"?t:`${t}px solid`}function Je(t,o){return Ee({prop:t,themeKey:"borders",transform:o})}const La=Je("border",qe),Ha=Je("borderTop",qe),Ua=Je("borderRight",qe),Ga=Je("borderBottom",qe),Ya=Je("borderLeft",qe),qa=Je("borderColor"),Ja=Je("borderTopColor"),Ka=Je("borderRightColor"),Xa=Je("borderBottomColor"),Qa=Je("borderLeftColor"),Za=Je("outline",qe),el=Je("outlineColor"),po=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const o=_r(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Nr(o,i)});return St(t,t.borderRadius,n)}return null};po.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Ot}:{};po.filterProps=["borderRadius"];uo(La,Ha,Ua,Ga,Ya,qa,Ja,Ka,Xa,Qa,po,Za,el);const xo=t=>{if(t.gap!==void 0&&t.gap!==null){const o=_r(t.theme,"spacing",8,"gap"),n=i=>({gap:Nr(o,i)});return St(t,t.gap,n)}return null};xo.propTypes=process.env.NODE_ENV!=="production"?{gap:Ot}:{};xo.filterProps=["gap"];const fo=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const o=_r(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Nr(o,i)});return St(t,t.columnGap,n)}return null};fo.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Ot}:{};fo.filterProps=["columnGap"];const ho=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const o=_r(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Nr(o,i)});return St(t,t.rowGap,n)}return null};ho.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Ot}:{};ho.filterProps=["rowGap"];const tl=Ee({prop:"gridColumn"}),rl=Ee({prop:"gridRow"}),ol=Ee({prop:"gridAutoFlow"}),nl=Ee({prop:"gridAutoColumns"}),il=Ee({prop:"gridAutoRows"}),sl=Ee({prop:"gridTemplateColumns"}),al=Ee({prop:"gridTemplateRows"}),ll=Ee({prop:"gridTemplateAreas"}),cl=Ee({prop:"gridArea"});uo(xo,fo,ho,tl,rl,ol,nl,il,sl,al,ll,cl);function xr(t,o){return o==="grey"?o:t}const dl=Ee({prop:"color",themeKey:"palette",transform:xr}),ul=Ee({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:xr}),pl=Ee({prop:"backgroundColor",themeKey:"palette",transform:xr});uo(dl,ul,pl);function Ve(t){return t<=1&&t!==0?`${t*100}%`:t}const xl=Ee({prop:"width",transform:Ve}),No=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const o=n=>{var s,l,c,d,u;const i=((c=(l=(s=t.theme)==null?void 0:s.breakpoints)==null?void 0:l.values)==null?void 0:c[n])||so[n];return i?((u=(d=t.theme)==null?void 0:d.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Ve(n)}};return St(t,t.maxWidth,o)}return null};No.filterProps=["maxWidth"];const fl=Ee({prop:"minWidth",transform:Ve}),hl=Ee({prop:"height",transform:Ve}),ml=Ee({prop:"maxHeight",transform:Ve}),gl=Ee({prop:"minHeight",transform:Ve});Ee({prop:"size",cssProperty:"width",transform:Ve});Ee({prop:"size",cssProperty:"height",transform:Ve});const yl=Ee({prop:"boxSizing"});uo(xl,No,fl,hl,ml,gl,yl);const mo={border:{themeKey:"borders",transform:qe},borderTop:{themeKey:"borders",transform:qe},borderRight:{themeKey:"borders",transform:qe},borderBottom:{themeKey:"borders",transform:qe},borderLeft:{themeKey:"borders",transform:qe},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:qe},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:po},color:{themeKey:"palette",transform:xr},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:xr},backgroundColor:{themeKey:"palette",transform:xr},p:{style:Ie},pt:{style:Ie},pr:{style:Ie},pb:{style:Ie},pl:{style:Ie},px:{style:Ie},py:{style:Ie},padding:{style:Ie},paddingTop:{style:Ie},paddingRight:{style:Ie},paddingBottom:{style:Ie},paddingLeft:{style:Ie},paddingX:{style:Ie},paddingY:{style:Ie},paddingInline:{style:Ie},paddingInlineStart:{style:Ie},paddingInlineEnd:{style:Ie},paddingBlock:{style:Ie},paddingBlockStart:{style:Ie},paddingBlockEnd:{style:Ie},m:{style:ze},mt:{style:ze},mr:{style:ze},mb:{style:ze},ml:{style:ze},mx:{style:ze},my:{style:ze},margin:{style:ze},marginTop:{style:ze},marginRight:{style:ze},marginBottom:{style:ze},marginLeft:{style:ze},marginX:{style:ze},marginY:{style:ze},marginInline:{style:ze},marginInlineStart:{style:ze},marginInlineEnd:{style:ze},marginBlock:{style:ze},marginBlockStart:{style:ze},marginBlockEnd:{style:ze},displayPrint:{cssProperty:!1,transform:t=>({"@media print":{display:t}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:xo},rowGap:{style:ho},columnGap:{style:fo},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Ve},maxWidth:{style:No},minWidth:{transform:Ve},height:{transform:Ve},maxHeight:{transform:Ve},minHeight:{transform:Ve},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function bl(...t){const o=t.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(o);return t.every(i=>n.size===Object.keys(i).length)}function vl(t,o){return typeof t=="function"?t(o):t}function Sl(){function t(n,i,s,l){const c={[n]:i,theme:s},d=l[n];if(!d)return{[n]:i};const{cssProperty:u=n,themeKey:f,transform:g,style:h}=d;if(i==null)return null;if(f==="typography"&&i==="inherit")return{[n]:i};const y=ao(s,f)||{};return h?h(c):St(c,i,k=>{let m=ro(y,g,k);return k===m&&typeof k=="string"&&(m=ro(y,g,`${n}${k==="default"?"":ii(k)}`,k)),u===!1?m:{[u]:m}})}function o(n){const{sx:i,theme:s={},nested:l}=n||{};if(!i)return null;const c=s.unstable_sxConfig??mo;function d(u){let f=u;if(typeof u=="function")f=u(s);else if(typeof u!="object")return u;if(!f)return null;const g=Wa(s.breakpoints),h=Object.keys(g);let y=g;return Object.keys(f).forEach(w=>{const k=vl(f[w],s);if(k!=null)if(typeof k=="object")if(c[w])y=Rr(y,t(w,k,s,c));else{const m=St({theme:s},k,v=>({[w]:v}));bl(m,k)?y[w]=o({sx:k,theme:s,nested:!0}):y=Rr(y,m)}else y=Rr(y,t(w,k,s,c))}),!l&&s.modularCssLayers?{"@layer sx":gn(s,bn(h,y))}:gn(s,bn(h,y))}return Array.isArray(i)?i.map(d):d(i)}return o}const go=Sl();go.filterProps=["sx"];function Cl(t,o){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[t])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(t);return s==="&"?o:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:o})}return n.palette.mode===t?o:{}}function li(t={},...o){const{breakpoints:n={},palette:i={},spacing:s,shape:l={},...c}=t,d=Ea(n),u=ai(s);let f=Le({breakpoints:d,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...Aa,...l}},c);return f=Oa(f),f.applyStyles=Cl,f=o.reduce((g,h)=>Le(g,h),f),f.unstable_sxConfig={...mo,...c==null?void 0:c.unstable_sxConfig},f.unstable_sx=function(h){return go({sx:h,theme:this})},f}function jl(t){return Object.keys(t).length===0}function wl(t=null){const o=oo.useContext(is.ThemeContext);return!o||jl(o)?t:o}const kl=li();function Tl(t=kl){return wl(t)}const Sn=t=>t,zl=()=>{let t=Sn;return{configure(o){t=o},generate(o){return t(o)},reset(){t=Sn}}},Il=zl(),El={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function Bl(t,o,n="Mui"){const i=El[o];return i?`${n}-${i}`:`${Il.generate(t)}-${o}`}function Dl(t,o=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(o,Math.min(t,n))}function Fo(t,o=0,n=1){return process.env.NODE_ENV!=="production"&&(t<o||t>n)&&console.error(`MUI: The value provided ${t} is out of range [${o}, ${n}].`),Dl(t,o,n)}function Ol(t){t=t.slice(1);const o=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let n=t.match(o);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&t.length!==t.trim().length&&console.error(`MUI: The color: "${t}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Dt(t){if(t.type)return t;if(t.charAt(0)==="#")return Dt(Ol(t));const o=t.indexOf("("),n=t.substring(0,o);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${t}\` color.
|
|
43
|
+
The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Ht(9,t));let i=t.substring(o+1,t.length-1),s;if(n==="color"){if(i=i.split(" "),s=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),!["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].includes(s))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${s}\` color space.
|
|
44
|
+
The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Ht(10,s))}else i=i.split(",");return i=i.map(l=>parseFloat(l)),{type:n,values:i,colorSpace:s}}const Al=t=>{const o=Dt(t);return o.values.slice(0,3).map((n,i)=>o.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Mr=(t,o)=>{try{return Al(t)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),t}};function yo(t){const{type:o,colorSpace:n}=t;let{values:i}=t;return o.includes("rgb")?i=i.map((s,l)=>l<3?parseInt(s,10):s):o.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),o.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${o}(${i})`}function ci(t){t=Dt(t);const{values:o}=t,n=o[0],i=o[1]/100,s=o[2]/100,l=i*Math.min(s,1-s),c=(f,g=(f+n/30)%12)=>s-l*Math.max(Math.min(g-3,9-g,1),-1);let d="rgb";const u=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return t.type==="hsla"&&(d+="a",u.push(o[3])),yo({type:d,values:u})}function Do(t){t=Dt(t);let o=t.type==="hsl"||t.type==="hsla"?Dt(ci(t)).values:t.values;return o=o.map(n=>(t.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*o[0]+.7152*o[1]+.0722*o[2]).toFixed(3))}function Cn(t,o){const n=Do(t),i=Do(o);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function W(t,o){return t=Dt(t),o=Fo(o),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${o}`:t.values[3]=o,yo(t)}function Vt(t,o,n){try{return W(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function bo(t,o){if(t=Dt(t),o=Fo(o),t.type.includes("hsl"))t.values[2]*=1-o;else if(t.type.includes("rgb")||t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]*=1-o;return yo(t)}function he(t,o,n){try{return bo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function vo(t,o){if(t=Dt(t),o=Fo(o),t.type.includes("hsl"))t.values[2]+=(100-t.values[2])*o;else if(t.type.includes("rgb"))for(let n=0;n<3;n+=1)t.values[n]+=(255-t.values[n])*o;else if(t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]+=(1-t.values[n])*o;return yo(t)}function me(t,o,n){try{return vo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Ml(t,o=.15){return Do(t)>.5?bo(t,o):vo(t,o)}function Jr(t,o,n){try{return Ml(t,o)}catch{return t}}function Wl(t=""){function o(...i){if(!i.length)return"";const s=i[0];return typeof s=="string"&&!s.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${t?`${t}-`:""}${s}${o(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${t?`${t}-`:""}${i}${o(...s)})`}const jn=(t,o,n,i=[])=>{let s=t;o.forEach((l,c)=>{c===o.length-1?Array.isArray(s)?s[Number(l)]=n:s&&typeof s=="object"&&(s[l]=n):s&&typeof s=="object"&&(s[l]||(s[l]=i.includes(l)?[]:{}),s=s[l])})},Rl=(t,o,n)=>{function i(s,l=[],c=[]){Object.entries(s).forEach(([d,u])=>{(!n||n&&!n([...l,d]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...l,d],Array.isArray(u)?[...c,d]:c):o([...l,d],u,c))})}i(t)},Pl=(t,o)=>typeof o=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>t.includes(i))||t[t.length-1].toLowerCase().includes("opacity")?o:`${o}px`:o;function Eo(t,o){const{prefix:n,shouldSkipGeneratingVar:i}=o||{},s={},l={},c={};return Rl(t,(d,u,f)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(d,u))){const g=`--${n?`${n}-`:""}${d.join("-")}`,h=Pl(d,u);Object.assign(s,{[g]:h}),jn(l,d,`var(${g})`,f),jn(c,d,`var(${g}, ${h})`,f)}},d=>d[0]==="vars"),{css:s,vars:l,varsWithDefaults:c}}function $l(t,o={}){const{getSelector:n=j,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:l}=o,{colorSchemes:c={},components:d,defaultColorScheme:u="light",...f}=t,{vars:g,css:h,varsWithDefaults:y}=Eo(f,o);let w=y;const k={},{[u]:m,...v}=c;if(Object.entries(v||{}).forEach(([a,I])=>{const{vars:O,css:H,varsWithDefaults:N}=Eo(I,o);w=Le(w,N),k[a]={css:H,vars:O}}),m){const{css:a,vars:I,varsWithDefaults:O}=Eo(m,o);w=Le(w,O),k[u]={css:a,vars:I}}function j(a,I){var H,N;let O=s;if(s==="class"&&(O=".%s"),s==="data"&&(O="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(O=`[${s}="%s"]`),a){if(O==="media")return t.defaultColorScheme===a?":root":{[`@media (prefers-color-scheme: ${((N=(H=c[a])==null?void 0:H.palette)==null?void 0:N.mode)||a})`]:{":root":I}};if(O)return t.defaultColorScheme===a?`:root, ${O.replace("%s",String(a))}`:O.replace("%s",String(a))}return":root"}return{vars:w,generateThemeVars:()=>{let a={...g};return Object.entries(k).forEach(([,{vars:I}])=>{a=Le(a,I)}),a},generateStyleSheets:()=>{var Q,ee;const a=[],I=t.defaultColorScheme||"light";function O(oe,x){Object.keys(x).length&&a.push(typeof oe=="string"?{[oe]:{...x}}:oe)}O(n(void 0,{...h}),h);const{[I]:H,...N}=k;if(H){const{css:oe}=H,x=(ee=(Q=c[I])==null?void 0:Q.palette)==null?void 0:ee.mode,F=!i&&x?{colorScheme:x,...oe}:{...oe};O(n(I,{...F}),F)}return Object.entries(N).forEach(([oe,{css:x}])=>{var _,V;const F=(V=(_=c[oe])==null?void 0:_.palette)==null?void 0:V.mode,$=!i&&F?{colorScheme:F,...x}:{...x};O(n(oe,{...$}),$)}),l&&a.push({":root":{"--__l-threshold":"0.7","--__l":"clamp(0, (l / var(--__l-threshold) - 1) * -infinity, 1)","--__a":"clamp(0.87, (l / var(--__l-threshold) - 1) * -infinity, 1)"}}),a}}}function _l(t){return function(n){return t==="media"?(process.env.NODE_ENV!=="production"&&n!=="light"&&n!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${n}'.`),`@media (prefers-color-scheme: ${n})`):t?t.startsWith("data-")&&!t.includes("%s")?`[${t}="${n}"] &`:t==="class"?`.${n} &`:t==="data"?`[data-${n}] &`:`${t.replace("%s",n)} &`:"&"}}const Pr={black:"#000",white:"#fff"},Nl={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},lr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},cr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Br={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},dr={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},ur={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},pr={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function di(){return{text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:Pr.white,default:Pr.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}}}const ui=di();function pi(){return{text:{primary:Pr.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",icon:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:"#121212",default:"#121212"},action:{active:Pr.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}}}const Oo=pi();function wn(t,o,n,i){const s=i.light||i,l=i.dark||i*1.5;t[o]||(t.hasOwnProperty(n)?t[o]=t[n]:o==="light"?t.light=vo(t.main,s):o==="dark"&&(t.dark=bo(t.main,l)))}function kn(t,o,n,i,s){const l=s.light||s,c=s.dark||s*1.5;o[n]||(o.hasOwnProperty(i)?o[n]=o[i]:n==="light"?o.light=`color-mix(in ${t}, ${o.main}, #fff ${(l*100).toFixed(0)}%)`:n==="dark"&&(o.dark=`color-mix(in ${t}, ${o.main}, #000 ${(c*100).toFixed(0)}%)`))}function Fl(t="light"){return t==="dark"?{main:dr[200],light:dr[50],dark:dr[400]}:{main:dr[700],light:dr[400],dark:dr[800]}}function Vl(t="light"){return t==="dark"?{main:lr[200],light:lr[50],dark:lr[400]}:{main:lr[500],light:lr[300],dark:lr[700]}}function Ll(t="light"){return t==="dark"?{main:cr[500],light:cr[300],dark:cr[700]}:{main:cr[700],light:cr[400],dark:cr[800]}}function Hl(t="light"){return t==="dark"?{main:ur[400],light:ur[300],dark:ur[700]}:{main:ur[700],light:ur[500],dark:ur[900]}}function Ul(t="light"){return t==="dark"?{main:pr[400],light:pr[300],dark:pr[700]}:{main:pr[800],light:pr[500],dark:pr[900]}}function Gl(t="light"){return t==="dark"?{main:Br[400],light:Br[300],dark:Br[700]}:{main:"#ed6c02",light:Br[500],dark:Br[900]}}function Yl(t){return`oklch(from ${t} var(--__l) 0 h / var(--__a))`}function Vo(t){const{mode:o="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...l}=t,c=t.primary||Fl(o),d=t.secondary||Vl(o),u=t.error||Ll(o),f=t.info||Hl(o),g=t.success||Ul(o),h=t.warning||Gl(o);function y(v){if(s)return Yl(v);const j=Cn(v,Oo.text.primary)>=n?Oo.text.primary:ui.text.primary;if(process.env.NODE_ENV!=="production"){const b=Cn(v,j);b<3&&console.error([`MUI: The contrast ratio of ${b}:1 for ${j} on ${v}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
|
|
45
|
+
`))}return j}const w=({color:v,name:j,mainShade:b=500,lightShade:S=300,darkShade:a=700})=>{if(v={...v},!v.main&&v[b]&&(v.main=v[b]),!v.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${j?` (${j})`:""} provided to augmentColor(color) is invalid.
|
|
46
|
+
The color object needs to have a \`main\` property or a \`${b}\` property.`:Ht(11,j?` (${j})`:"",b));if(typeof v.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${j?` (${j})`:""} provided to augmentColor(color) is invalid.
|
|
47
|
+
\`color.main\` should be a string, but \`${JSON.stringify(v.main)}\` was provided instead.
|
|
56
48
|
|
|
57
49
|
Did you intend to use one of the following approaches?
|
|
58
50
|
|
|
@@ -64,17 +56,17 @@ const theme1 = createTheme({ palette: {
|
|
|
64
56
|
|
|
65
57
|
const theme2 = createTheme({ palette: {
|
|
66
58
|
primary: { main: green[500] },
|
|
67
|
-
} });`:
|
|
68
|
-
`)),Object.keys(
|
|
59
|
+
} });`:Ht(12,j?` (${j})`:"",JSON.stringify(v.main)));return s?(kn(s,v,"light",S,i),kn(s,v,"dark",a,i)):(wn(v,"light",S,i),wn(v,"dark",a,i)),v.contrastText||(v.contrastText=y(v.main)),v};let k;return o==="light"?k=di():o==="dark"&&(k=pi()),process.env.NODE_ENV!=="production"&&(k||console.error(`MUI: The palette mode \`${o}\` is not supported.`)),Le({common:{...Pr},mode:o,primary:w({color:c,name:"primary"}),secondary:w({color:d,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:w({color:u,name:"error"}),warning:w({color:h,name:"warning"}),info:w({color:f,name:"info"}),success:w({color:g,name:"success"}),grey:Nl,contrastThreshold:n,getContrastText:y,augmentColor:w,tonalOffset:i,...k},l)}function ql(t){const o={};return Object.entries(t).forEach(i=>{const[s,l]=i;typeof l=="object"&&(o[s]=`${l.fontStyle?`${l.fontStyle} `:""}${l.fontVariant?`${l.fontVariant} `:""}${l.fontWeight?`${l.fontWeight} `:""}${l.fontStretch?`${l.fontStretch} `:""}${l.fontSize||""}${l.lineHeight?`/${l.lineHeight} `:""}${l.fontFamily||""}`)}),o}function Jl(t,o){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...o}}function Kl(t){return Math.round(t*1e5)/1e5}const Tn={textTransform:"uppercase"},zn='"Roboto", "Helvetica", "Arial", sans-serif';function Xl(t,o){const{fontFamily:n=zn,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:l=400,fontWeightMedium:c=500,fontWeightBold:d=700,htmlFontSize:u=16,allVariants:f,pxToRem:g,...h}=typeof o=="function"?o(t):o;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const y=i/14,w=g||(v=>`${v/u*y}rem`),k=(v,j,b,S,a)=>({fontFamily:n,fontWeight:v,fontSize:w(j),lineHeight:b,...n===zn?{letterSpacing:`${Kl(S/j)}em`}:{},...a,...f}),m={h1:k(s,96,1.167,-1.5),h2:k(s,60,1.2,-.5),h3:k(l,48,1.167,0),h4:k(l,34,1.235,.25),h5:k(l,24,1.334,0),h6:k(c,20,1.6,.15),subtitle1:k(l,16,1.75,.15),subtitle2:k(c,14,1.57,.1),body1:k(l,16,1.5,.15),body2:k(l,14,1.43,.15),button:k(c,14,1.75,.4,Tn),caption:k(l,12,1.66,.4),overline:k(l,12,2.66,1,Tn),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Le({htmlFontSize:u,pxToRem:w,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:l,fontWeightMedium:c,fontWeightBold:d,...m},h,{clone:!1})}const Ql=.2,Zl=.14,ec=.12;function je(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${Ql})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${Zl})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${ec})`].join(",")}const tc=["none",je(0,2,1,-1,0,1,1,0,0,1,3,0),je(0,3,1,-2,0,2,2,0,0,1,5,0),je(0,3,3,-2,0,3,4,0,0,1,8,0),je(0,2,4,-1,0,4,5,0,0,1,10,0),je(0,3,5,-1,0,5,8,0,0,1,14,0),je(0,3,5,-1,0,6,10,0,0,1,18,0),je(0,4,5,-2,0,7,10,1,0,2,16,1),je(0,5,5,-3,0,8,10,1,0,3,14,2),je(0,5,6,-3,0,9,12,1,0,3,16,2),je(0,6,6,-3,0,10,14,1,0,4,18,3),je(0,6,7,-4,0,11,15,1,0,4,20,3),je(0,7,8,-4,0,12,17,2,0,5,22,4),je(0,7,8,-4,0,13,19,2,0,5,24,4),je(0,7,9,-4,0,14,21,2,0,5,26,4),je(0,8,9,-5,0,15,22,2,0,6,28,5),je(0,8,10,-5,0,16,24,2,0,6,30,5),je(0,8,11,-5,0,17,26,2,0,6,32,5),je(0,9,11,-5,0,18,28,2,0,7,34,6),je(0,9,12,-6,0,19,29,2,0,7,36,6),je(0,10,13,-6,0,20,31,3,0,8,38,7),je(0,10,13,-6,0,21,33,3,0,8,40,7),je(0,10,14,-6,0,22,35,3,0,8,42,7),je(0,11,14,-7,0,23,36,3,0,9,44,8),je(0,11,15,-7,0,24,38,3,0,9,46,8)],rc={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},oc={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function In(t){return`${Math.round(t)}ms`}function nc(t){if(!t)return 0;const o=t/36;return Math.min(Math.round((4+15*o**.25+o/5)*10),3e3)}function ic(t){const o={...rc,...t.easing},n={...oc,...t.duration};return{getAutoHeightDuration:nc,create:(s=["all"],l={})=>{const{duration:c=n.standard,easing:d=o.easeInOut,delay:u=0,...f}=l;if(process.env.NODE_ENV!=="production"){const g=y=>typeof y=="string",h=y=>!Number.isNaN(parseFloat(y));!g(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!h(c)&&!g(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),g(d)||console.error('MUI: Argument "easing" must be a string.'),!h(u)&&!g(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof l!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
|
|
60
|
+
`)),Object.keys(f).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(f).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(g=>`${g} ${typeof c=="string"?c:In(c)} ${d} ${typeof u=="string"?u:In(u)}`).join(",")},...t,easing:o,duration:n}}const sc={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function ac(t){return Bt(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function xi(t={}){const o={...t};function n(i){const s=Object.entries(i);for(let l=0;l<s.length;l++){const[c,d]=s[l];!ac(d)||c.startsWith("unstable_")?delete i[c]:Bt(d)&&(i[c]={...d},n(i[c]))}}return n(o),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
|
|
69
61
|
|
|
70
|
-
const theme = ${JSON.stringify(
|
|
62
|
+
const theme = ${JSON.stringify(o,null,2)};
|
|
71
63
|
|
|
72
64
|
theme.breakpoints = createBreakpoints(theme.breakpoints || {});
|
|
73
65
|
theme.transitions = createTransitions(theme.transitions || {});
|
|
74
66
|
|
|
75
|
-
export default theme;`}function En(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const
|
|
76
|
-
`))}
|
|
77
|
-
To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function yc(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const ut=t=>{try{return t()}catch{}},bc=(t="mui")=>Wl(t);function jo(t,r,n,i,a){if(!n)return;n=n===!0?{}:n;const c=a==="dark"?"dark":"light";if(!i){r[a]=fc({...n,palette:{mode:c,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:l,...d}=To({...i,palette:{mode:c,...n==null?void 0:n.palette},colorSpace:t});return r[a]={...n,palette:l,opacity:{...xi(c),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||hi(c)},d}function vc(t={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:a=!1,cssVarPrefix:c="mui",nativeColor:l=!1,shouldSkipGeneratingVar:d=xc,colorSchemeSelector:f=n.light&&n.dark?"media":void 0,rootSelector:h=":root",...m}=t,g=Object.keys(n)[0],y=i||(n.light&&g!=="light"?"light":g),S=bc(c),{[y]:C,light:x,dark:E,...s}=n,T={...s};let I=C;if((y==="dark"&&!("dark"in n)||y==="light"&&!("light"in n))&&(I=!0),!I)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${y}\` option is either missing or invalid.`:Gt(21,y));let A;l&&(A="oklch");const v=jo(A,T,I,m,y);x&&!T.light&&jo(A,T,x,void 0,"light"),E&&!T.dark&&jo(A,T,E,void 0,"dark");let W={defaultColorScheme:y,...v,cssVarPrefix:c,colorSchemeSelector:f,rootSelector:h,getCssVar:S,colorSchemes:T,font:{...ql(v.typography),...v.font},spacing:yc(m.spacing)};Object.keys(W.colorSchemes).forEach(X=>{const p=W.colorSchemes[X].palette,L=_=>{const F=_.split("-"),oe=F[1],ue=F[2];return S(_,p[oe][ue])};p.mode==="light"&&(M(p.common,"background","#fff"),M(p.common,"onBackground","#000")),p.mode==="dark"&&(M(p.common,"background","#000"),M(p.common,"onBackground","#fff"));function $(_,F,oe){if(A){let ue;return _===Ut&&(ue=`transparent ${((1-oe)*100).toFixed(0)}%`),_===ye&&(ue=`#000 ${(oe*100).toFixed(0)}%`),_===be&&(ue=`#fff ${(oe*100).toFixed(0)}%`),`color-mix(in ${A}, ${F}, ${ue})`}return _(F,oe)}if(gc(p,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),p.mode==="light"){M(p.Alert,"errorColor",$(ye,p.error.light,.6)),M(p.Alert,"infoColor",$(ye,p.info.light,.6)),M(p.Alert,"successColor",$(ye,p.success.light,.6)),M(p.Alert,"warningColor",$(ye,p.warning.light,.6)),M(p.Alert,"errorFilledBg",L("palette-error-main")),M(p.Alert,"infoFilledBg",L("palette-info-main")),M(p.Alert,"successFilledBg",L("palette-success-main")),M(p.Alert,"warningFilledBg",L("palette-warning-main")),M(p.Alert,"errorFilledColor",ut(()=>p.getContrastText(p.error.main))),M(p.Alert,"infoFilledColor",ut(()=>p.getContrastText(p.info.main))),M(p.Alert,"successFilledColor",ut(()=>p.getContrastText(p.success.main))),M(p.Alert,"warningFilledColor",ut(()=>p.getContrastText(p.warning.main))),M(p.Alert,"errorStandardBg",$(be,p.error.light,.9)),M(p.Alert,"infoStandardBg",$(be,p.info.light,.9)),M(p.Alert,"successStandardBg",$(be,p.success.light,.9)),M(p.Alert,"warningStandardBg",$(be,p.warning.light,.9)),M(p.Alert,"errorIconColor",L("palette-error-main")),M(p.Alert,"infoIconColor",L("palette-info-main")),M(p.Alert,"successIconColor",L("palette-success-main")),M(p.Alert,"warningIconColor",L("palette-warning-main")),M(p.AppBar,"defaultBg",L("palette-grey-100")),M(p.Avatar,"defaultBg",L("palette-grey-400")),M(p.Button,"inheritContainedBg",L("palette-grey-300")),M(p.Button,"inheritContainedHoverBg",L("palette-grey-A100")),M(p.Chip,"defaultBorder",L("palette-grey-400")),M(p.Chip,"defaultAvatarColor",L("palette-grey-700")),M(p.Chip,"defaultIconColor",L("palette-grey-700")),M(p.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),M(p.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),M(p.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),M(p.LinearProgress,"primaryBg",$(be,p.primary.main,.62)),M(p.LinearProgress,"secondaryBg",$(be,p.secondary.main,.62)),M(p.LinearProgress,"errorBg",$(be,p.error.main,.62)),M(p.LinearProgress,"infoBg",$(be,p.info.main,.62)),M(p.LinearProgress,"successBg",$(be,p.success.main,.62)),M(p.LinearProgress,"warningBg",$(be,p.warning.main,.62)),M(p.Skeleton,"bg",A?$(Ut,p.text.primary,.11):`rgba(${L("palette-text-primaryChannel")} / 0.11)`),M(p.Slider,"primaryTrack",$(be,p.primary.main,.62)),M(p.Slider,"secondaryTrack",$(be,p.secondary.main,.62)),M(p.Slider,"errorTrack",$(be,p.error.main,.62)),M(p.Slider,"infoTrack",$(be,p.info.main,.62)),M(p.Slider,"successTrack",$(be,p.success.main,.62)),M(p.Slider,"warningTrack",$(be,p.warning.main,.62));const _=A?$(ye,p.background.default,.6825):Gr(p.background.default,.8);M(p.SnackbarContent,"bg",_),M(p.SnackbarContent,"color",ut(()=>A?ko.text.primary:p.getContrastText(_))),M(p.SpeedDialAction,"fabHoverBg",Gr(p.background.paper,.15)),M(p.StepConnector,"border",L("palette-grey-400")),M(p.StepContent,"border",L("palette-grey-400")),M(p.Switch,"defaultColor",L("palette-common-white")),M(p.Switch,"defaultDisabledColor",L("palette-grey-100")),M(p.Switch,"primaryDisabledColor",$(be,p.primary.main,.62)),M(p.Switch,"secondaryDisabledColor",$(be,p.secondary.main,.62)),M(p.Switch,"errorDisabledColor",$(be,p.error.main,.62)),M(p.Switch,"infoDisabledColor",$(be,p.info.main,.62)),M(p.Switch,"successDisabledColor",$(be,p.success.main,.62)),M(p.Switch,"warningDisabledColor",$(be,p.warning.main,.62)),M(p.TableCell,"border",$(be,$(Ut,p.divider,1),.88)),M(p.Tooltip,"bg",$(Ut,p.grey[700],.92))}if(p.mode==="dark"){M(p.Alert,"errorColor",$(be,p.error.light,.6)),M(p.Alert,"infoColor",$(be,p.info.light,.6)),M(p.Alert,"successColor",$(be,p.success.light,.6)),M(p.Alert,"warningColor",$(be,p.warning.light,.6)),M(p.Alert,"errorFilledBg",L("palette-error-dark")),M(p.Alert,"infoFilledBg",L("palette-info-dark")),M(p.Alert,"successFilledBg",L("palette-success-dark")),M(p.Alert,"warningFilledBg",L("palette-warning-dark")),M(p.Alert,"errorFilledColor",ut(()=>p.getContrastText(p.error.dark))),M(p.Alert,"infoFilledColor",ut(()=>p.getContrastText(p.info.dark))),M(p.Alert,"successFilledColor",ut(()=>p.getContrastText(p.success.dark))),M(p.Alert,"warningFilledColor",ut(()=>p.getContrastText(p.warning.dark))),M(p.Alert,"errorStandardBg",$(ye,p.error.light,.9)),M(p.Alert,"infoStandardBg",$(ye,p.info.light,.9)),M(p.Alert,"successStandardBg",$(ye,p.success.light,.9)),M(p.Alert,"warningStandardBg",$(ye,p.warning.light,.9)),M(p.Alert,"errorIconColor",L("palette-error-main")),M(p.Alert,"infoIconColor",L("palette-info-main")),M(p.Alert,"successIconColor",L("palette-success-main")),M(p.Alert,"warningIconColor",L("palette-warning-main")),M(p.AppBar,"defaultBg",L("palette-grey-900")),M(p.AppBar,"darkBg",L("palette-background-paper")),M(p.AppBar,"darkColor",L("palette-text-primary")),M(p.Avatar,"defaultBg",L("palette-grey-600")),M(p.Button,"inheritContainedBg",L("palette-grey-800")),M(p.Button,"inheritContainedHoverBg",L("palette-grey-700")),M(p.Chip,"defaultBorder",L("palette-grey-700")),M(p.Chip,"defaultAvatarColor",L("palette-grey-300")),M(p.Chip,"defaultIconColor",L("palette-grey-300")),M(p.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),M(p.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),M(p.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),M(p.LinearProgress,"primaryBg",$(ye,p.primary.main,.5)),M(p.LinearProgress,"secondaryBg",$(ye,p.secondary.main,.5)),M(p.LinearProgress,"errorBg",$(ye,p.error.main,.5)),M(p.LinearProgress,"infoBg",$(ye,p.info.main,.5)),M(p.LinearProgress,"successBg",$(ye,p.success.main,.5)),M(p.LinearProgress,"warningBg",$(ye,p.warning.main,.5)),M(p.Skeleton,"bg",A?$(Ut,p.text.primary,.13):`rgba(${L("palette-text-primaryChannel")} / 0.13)`),M(p.Slider,"primaryTrack",$(ye,p.primary.main,.5)),M(p.Slider,"secondaryTrack",$(ye,p.secondary.main,.5)),M(p.Slider,"errorTrack",$(ye,p.error.main,.5)),M(p.Slider,"infoTrack",$(ye,p.info.main,.5)),M(p.Slider,"successTrack",$(ye,p.success.main,.5)),M(p.Slider,"warningTrack",$(ye,p.warning.main,.5));const _=A?$(be,p.background.default,.985):Gr(p.background.default,.98);M(p.SnackbarContent,"bg",_),M(p.SnackbarContent,"color",ut(()=>A?ui.text.primary:p.getContrastText(_))),M(p.SpeedDialAction,"fabHoverBg",Gr(p.background.paper,.15)),M(p.StepConnector,"border",L("palette-grey-600")),M(p.StepContent,"border",L("palette-grey-600")),M(p.Switch,"defaultColor",L("palette-grey-300")),M(p.Switch,"defaultDisabledColor",L("palette-grey-600")),M(p.Switch,"primaryDisabledColor",$(ye,p.primary.main,.55)),M(p.Switch,"secondaryDisabledColor",$(ye,p.secondary.main,.55)),M(p.Switch,"errorDisabledColor",$(ye,p.error.main,.55)),M(p.Switch,"infoDisabledColor",$(ye,p.info.main,.55)),M(p.Switch,"successDisabledColor",$(ye,p.success.main,.55)),M(p.Switch,"warningDisabledColor",$(ye,p.warning.main,.55)),M(p.TableCell,"border",$(ye,$(Ut,p.divider,1),.68)),M(p.Tooltip,"bg",$(Ut,p.grey[700],.92))}yt(p.background,"default"),yt(p.background,"paper"),yt(p.common,"background"),yt(p.common,"onBackground"),yt(p,"divider"),Object.keys(p).forEach(_=>{const F=p[_];_!=="tonalOffset"&&F&&typeof F=="object"&&(F.main&&M(p[_],"mainChannel",Br(Dr(F.main))),F.light&&M(p[_],"lightChannel",Br(Dr(F.light))),F.dark&&M(p[_],"darkChannel",Br(Dr(F.dark))),F.contrastText&&M(p[_],"contrastTextChannel",Br(Dr(F.contrastText))),_==="text"&&(yt(p[_],"primary"),yt(p[_],"secondary")),_==="action"&&(F.active&&yt(p[_],"active"),F.selected&&yt(p[_],"selected")))})}),W=r.reduce((X,p)=>Ge(X,p),W);const U={prefix:c,disableCssColorScheme:a,shouldSkipGeneratingVar:d,getSelector:mc(W),enableContrastVars:l},{vars:w,generateThemeVars:O,generateStyleSheets:V}=$l(W,U);return W.vars=w,Object.entries(W.colorSchemes[W.defaultColorScheme]).forEach(([X,p])=>{W[X]=p}),W.generateThemeVars=O,W.generateStyleSheets=V,W.generateSpacing=function(){return ai(m.spacing,Oo(this))},W.getColorSchemeSelector=Fl(f),W.spacing=W.generateSpacing(),W.shouldSkipGeneratingVar=d,W.unstable_sxConfig={...so,...m==null?void 0:m.unstable_sxConfig},W.unstable_sx=function(p){return ao({sx:p,theme:this})},W.toRuntimeSource=fi,W}function Bn(t,r,n){t.colorSchemes&&n&&(t.colorSchemes[r]={...n!==!0&&n,palette:Ro({...n===!0?{}:n.palette,mode:r})})}function Sc(t={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:a=n?void 0:{light:!0},defaultColorScheme:c=n==null?void 0:n.mode,...l}=t,d=c||"light",f=a==null?void 0:a[d],h={...a,...n?{[d]:{...typeof f!="boolean"&&f,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return To(t,...r);let m=n;"palette"in t||h[d]&&(h[d]!==!0?m=h[d].palette:d==="dark"&&(m={mode:"dark"}));const g=To({...t,palette:m},...r);return g.defaultColorScheme=d,g.colorSchemes=h,g.palette.mode==="light"&&(g.colorSchemes.light={...h.light!==!0&&h.light,palette:g.palette},Bn(g,"dark",h.dark)),g.palette.mode==="dark"&&(g.colorSchemes.dark={...h.dark!==!0&&h.dark,palette:g.palette},Bn(g,"light",h.light)),g}return!n&&!("light"in h)&&d==="light"&&(h.light=!0),vc({...l,colorSchemes:h,defaultColorScheme:d,...typeof i!="boolean"&&i},...r)}const Cc=Sc();function jc(){const t=zl(Cc);return process.env.NODE_ENV!=="production"&&Jr.useDebugValue(t),t[ma]||t}function wc({isOpen:t,onClose:r,onCreate:n}){const[i,a]=u.useState(""),[c,l]=u.useState(""),[d,f]=u.useState(null),[h,m]=u.useState(null),[g,y]=u.useState(!1),[S,C]=u.useState(""),x=u.useRef(null),E=async v=>{if(C(""),!v.name.endsWith(".json")){C("Please upload a JSON file");return}try{const W=await v.text(),U=JSON.parse(W);if(!Array.isArray(U)){C("JSON must be an array of objects");return}f(v),m(U)}catch{C("Invalid JSON format")}},s=v=>{v.preventDefault();const W=v.dataTransfer.files[0];W&&E(W)},T=()=>{i.trim()&&h&&(n(i.trim(),c.trim(),h),I())},I=()=>{a(""),l(""),f(null),m(null),C(""),r()},A=!i.trim()||!h;return e.jsxs(e.Fragment,{children:[e.jsxs(o.Dialog,{open:t,onClose:I,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",width:480,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), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:500,fontSize:"1.125rem",color:"text.primary",letterSpacing:"-0.01em",borderBottom:"1px solid",borderColor:"divider"},children:["Create new report",e.jsx(o.IconButton,{onClick:I,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(j.Close,{sx:{fontSize:18}})})]}),e.jsx(o.DialogContent,{sx:{px:3,pt:2,pb:2},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(o.TextField,{label:"Report name",required:!0,fullWidth:!0,value:i,onChange:v=>a(v.target.value),placeholder:"Enter report name",autoFocus:!0,sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsx(o.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:c,onChange:v=>l(v.target.value),placeholder:"Add details about this report",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsxs(o.Box,{children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),e.jsx(o.IconButton,{size:"small",onClick:()=>y(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Info,{sx:{fontSize:16}})})]}),e.jsxs(o.Box,{onDrop:s,onDragOver:v=>v.preventDefault(),onClick:()=>{var v;return(v=x.current)==null?void 0:v.click()},sx:{position:"relative",border:"1.5px",borderStyle:h?"solid":"dashed",borderColor:h?"success.main":S?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:h?v=>N(v.palette.success.main,.04):S?v=>N(v.palette.error.main,.04):v=>N(v.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:h?v=>N(v.palette.success.main,.08):S?v=>N(v.palette.error.main,.08):v=>N(v.palette.primary.main,.08),borderColor:h?"success.dark":S?"error.dark":"primary.dark"}},children:[e.jsx("input",{ref:x,type:"file",accept:".json",style:{display:"none"},onChange:v=>{var W;return((W=v.target.files)==null?void 0:W[0])&&E(v.target.files[0])}}),h?e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[e.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:v=>N(v.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(j.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:d==null?void 0:d.name}),e.jsx(o.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):e.jsxs(o.Box,{children:[e.jsx(o.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:v=>N(v.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(j.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),e.jsx(o.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),e.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),S&&e.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:v=>N(v.palette.error.main,.08),border:1,borderColor:v=>N(v.palette.error.main,.2)},children:e.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:S})})]})]})]})]})}),e.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1},children:[e.jsx(o.Button,{onClick:I,variant:"text",sx:{textTransform:"none",color:"primary.main",fontWeight:500,fontSize:"0.875rem",borderRadius:"4px",px:2,py:.625,minWidth:64,"&:hover":{bgcolor:v=>N(v.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(o.Button,{onClick:T,disabled:A,variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2},"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),e.jsxs(o.Dialog,{open:g,onClose:()=>y(!1),maxWidth:"sm",PaperProps:{sx:{borderRadius:3,width:560,maxHeight:"80vh",boxShadow:8}},children:[e.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em"},children:["JSON format guide",e.jsx(o.IconButton,{onClick:()=>y(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(j.Close,{sx:{fontSize:20}})})]}),e.jsx(o.DialogContent,{sx:{px:3,py:2},children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),e.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),e.jsxs(o.Box,{children:[e.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),e.jsx(o.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
|
|
67
|
+
export default theme;`}function En(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const lc=t=>{if(!Number.isNaN(+t))return+t;const o=t.match(/\d*\.?\d+/g);if(!o)return 0;let n=0;for(let i=0;i<o.length;i+=1)n+=+o[i];return n};function cc(t){Object.assign(t,{alpha(o,n){const i=this||t;return i.colorSpace?`oklch(from ${o} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${o.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:W(o,lc(n))},lighten(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #fff ${En(n)})`:vo(o,n)},darken(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #000 ${En(n)})`:bo(o,n)}})}function Ao(t={},...o){const{breakpoints:n,mixins:i={},spacing:s,palette:l={},transitions:c={},typography:d={},shape:u,colorSpace:f,...g}=t;if(t.vars&&t.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":Ht(20));const h=Vo({...l,colorSpace:f}),y=li(t);let w=Le(y,{mixins:Jl(y.breakpoints,i),palette:h,shadows:tc.slice(),typography:Xl(h,d),transitions:ic(c),zIndex:{...sc}});if(w=Le(w,g),w=o.reduce((k,m)=>Le(k,m),w),process.env.NODE_ENV!=="production"){const k=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],m=(v,j)=>{let b;for(b in v){const S=v[b];if(k.includes(b)&&Object.keys(S).length>0){if(process.env.NODE_ENV!=="production"){const a=Bl("",b);console.error([`MUI: The \`${j}\` component increases the CSS specificity of the \`${b}\` internal state.`,"You can not override it like this: ",JSON.stringify(v,null,2),"",`Instead, you need to use the '&.${a}' syntax:`,JSON.stringify({root:{[`&.${a}`]:S}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
|
|
68
|
+
`))}v[b]={}}}};Object.keys(w.components).forEach(v=>{const j=w.components[v].styleOverrides;j&&v.startsWith("Mui")&&m(j,v)})}return w.unstable_sxConfig={...mo,...g==null?void 0:g.unstable_sxConfig},w.unstable_sx=function(m){return go({sx:m,theme:this})},w.toRuntimeSource=xi,cc(w),w}function dc(t){let o;return t<1?o=5.11916*t**2:o=4.5*Math.log(t+1)+2,Math.round(o*10)/1e3}const uc=[...Array(25)].map((t,o)=>{if(o===0)return"none";const n=dc(o);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function fi(t){return{inputPlaceholder:t==="dark"?.5:.42,inputUnderline:t==="dark"?.7:.42,switchTrackDisabled:t==="dark"?.2:.12,switchTrack:t==="dark"?.3:.38}}function hi(t){return t==="dark"?uc:[]}function pc(t){const{palette:o={mode:"light"},opacity:n,overlays:i,colorSpace:s,...l}=t,c=Vo({...o,colorSpace:s});return{palette:c,opacity:{...fi(c.mode),...n},overlays:i||hi(c.mode),...l}}function xc(t){var o;return!!t[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!t[0].match(/sxConfig$/)||t[0]==="palette"&&!!((o=t[1])!=null&&o.match(/(mode|contrastThreshold|tonalOffset)/))}const fc=t=>[...[...Array(25)].map((o,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],hc=t=>(o,n)=>{const i=t.rootSelector||":root",s=t.colorSchemeSelector;let l=s;if(s==="class"&&(l=".%s"),s==="data"&&(l="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(l=`[${s}="%s"]`),t.defaultColorScheme===o){if(o==="dark"){const c={};return fc(t.cssVarPrefix).forEach(d=>{c[d]=n[d],delete n[d]}),l==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:c}}:l?{[l.replace("%s",o)]:c,[`${i}, ${l.replace("%s",o)}`]:n}:{[i]:{...n,...c}}}if(l&&l!=="media")return`${i}, ${l.replace("%s",String(o))}`}else if(o){if(l==="media")return{[`@media (prefers-color-scheme: ${String(o)})`]:{[i]:n}};if(l)return l.replace("%s",String(o))}return i};function mc(t,o){o.forEach(n=>{t[n]||(t[n]={})})}function A(t,o,n){!t[o]&&n&&(t[o]=n)}function Wr(t){return typeof t!="string"||!t.startsWith("hsl")?t:ci(t)}function gt(t,o){`${o}Channel`in t||(t[`${o}Channel`]=Mr(Wr(t[o]),`MUI: Can't create \`palette.${o}Channel\` because \`palette.${o}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
|
|
69
|
+
To suppress this warning, you need to explicitly provide the \`palette.${o}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function gc(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const ct=t=>{try{return t()}catch{}},yc=(t="mui")=>Wl(t);function Bo(t,o,n,i,s){if(!n)return;n=n===!0?{}:n;const l=s==="dark"?"dark":"light";if(!i){o[s]=pc({...n,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:c,...d}=Ao({...i,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:t});return o[s]={...n,palette:c,opacity:{...fi(l),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||hi(l)},d}function bc(t={},...o){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:l="mui",nativeColor:c=!1,shouldSkipGeneratingVar:d=xc,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:f=":root",...g}=t,h=Object.keys(n)[0],y=i||(n.light&&h!=="light"?"light":h),w=yc(l),{[y]:k,light:m,dark:v,...j}=n,b={...j};let S=k;if((y==="dark"&&!("dark"in n)||y==="light"&&!("light"in n))&&(S=!0),!S)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${y}\` option is either missing or invalid.`:Ht(21,y));let a;c&&(a="oklch");const I=Bo(a,b,S,g,y);m&&!b.light&&Bo(a,b,m,void 0,"light"),v&&!b.dark&&Bo(a,b,v,void 0,"dark");let O={defaultColorScheme:y,...I,cssVarPrefix:l,colorSchemeSelector:u,rootSelector:f,getCssVar:w,colorSchemes:b,font:{...ql(I.typography),...I.font},spacing:gc(g.spacing)};Object.keys(O.colorSchemes).forEach(oe=>{const x=O.colorSchemes[oe].palette,F=_=>{const V=_.split("-"),ie=V[1],ce=V[2];return w(_,x[ie][ce])};x.mode==="light"&&(A(x.common,"background","#fff"),A(x.common,"onBackground","#000")),x.mode==="dark"&&(A(x.common,"background","#000"),A(x.common,"onBackground","#fff"));function $(_,V,ie){if(a){let ce;return _===Vt&&(ce=`transparent ${((1-ie)*100).toFixed(0)}%`),_===he&&(ce=`#000 ${(ie*100).toFixed(0)}%`),_===me&&(ce=`#fff ${(ie*100).toFixed(0)}%`),`color-mix(in ${a}, ${V}, ${ce})`}return _(V,ie)}if(mc(x,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),x.mode==="light"){A(x.Alert,"errorColor",$(he,x.error.light,.6)),A(x.Alert,"infoColor",$(he,x.info.light,.6)),A(x.Alert,"successColor",$(he,x.success.light,.6)),A(x.Alert,"warningColor",$(he,x.warning.light,.6)),A(x.Alert,"errorFilledBg",F("palette-error-main")),A(x.Alert,"infoFilledBg",F("palette-info-main")),A(x.Alert,"successFilledBg",F("palette-success-main")),A(x.Alert,"warningFilledBg",F("palette-warning-main")),A(x.Alert,"errorFilledColor",ct(()=>x.getContrastText(x.error.main))),A(x.Alert,"infoFilledColor",ct(()=>x.getContrastText(x.info.main))),A(x.Alert,"successFilledColor",ct(()=>x.getContrastText(x.success.main))),A(x.Alert,"warningFilledColor",ct(()=>x.getContrastText(x.warning.main))),A(x.Alert,"errorStandardBg",$(me,x.error.light,.9)),A(x.Alert,"infoStandardBg",$(me,x.info.light,.9)),A(x.Alert,"successStandardBg",$(me,x.success.light,.9)),A(x.Alert,"warningStandardBg",$(me,x.warning.light,.9)),A(x.Alert,"errorIconColor",F("palette-error-main")),A(x.Alert,"infoIconColor",F("palette-info-main")),A(x.Alert,"successIconColor",F("palette-success-main")),A(x.Alert,"warningIconColor",F("palette-warning-main")),A(x.AppBar,"defaultBg",F("palette-grey-100")),A(x.Avatar,"defaultBg",F("palette-grey-400")),A(x.Button,"inheritContainedBg",F("palette-grey-300")),A(x.Button,"inheritContainedHoverBg",F("palette-grey-A100")),A(x.Chip,"defaultBorder",F("palette-grey-400")),A(x.Chip,"defaultAvatarColor",F("palette-grey-700")),A(x.Chip,"defaultIconColor",F("palette-grey-700")),A(x.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),A(x.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),A(x.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),A(x.LinearProgress,"primaryBg",$(me,x.primary.main,.62)),A(x.LinearProgress,"secondaryBg",$(me,x.secondary.main,.62)),A(x.LinearProgress,"errorBg",$(me,x.error.main,.62)),A(x.LinearProgress,"infoBg",$(me,x.info.main,.62)),A(x.LinearProgress,"successBg",$(me,x.success.main,.62)),A(x.LinearProgress,"warningBg",$(me,x.warning.main,.62)),A(x.Skeleton,"bg",a?$(Vt,x.text.primary,.11):`rgba(${F("palette-text-primaryChannel")} / 0.11)`),A(x.Slider,"primaryTrack",$(me,x.primary.main,.62)),A(x.Slider,"secondaryTrack",$(me,x.secondary.main,.62)),A(x.Slider,"errorTrack",$(me,x.error.main,.62)),A(x.Slider,"infoTrack",$(me,x.info.main,.62)),A(x.Slider,"successTrack",$(me,x.success.main,.62)),A(x.Slider,"warningTrack",$(me,x.warning.main,.62));const _=a?$(he,x.background.default,.6825):Jr(x.background.default,.8);A(x.SnackbarContent,"bg",_),A(x.SnackbarContent,"color",ct(()=>a?Oo.text.primary:x.getContrastText(_))),A(x.SpeedDialAction,"fabHoverBg",Jr(x.background.paper,.15)),A(x.StepConnector,"border",F("palette-grey-400")),A(x.StepContent,"border",F("palette-grey-400")),A(x.Switch,"defaultColor",F("palette-common-white")),A(x.Switch,"defaultDisabledColor",F("palette-grey-100")),A(x.Switch,"primaryDisabledColor",$(me,x.primary.main,.62)),A(x.Switch,"secondaryDisabledColor",$(me,x.secondary.main,.62)),A(x.Switch,"errorDisabledColor",$(me,x.error.main,.62)),A(x.Switch,"infoDisabledColor",$(me,x.info.main,.62)),A(x.Switch,"successDisabledColor",$(me,x.success.main,.62)),A(x.Switch,"warningDisabledColor",$(me,x.warning.main,.62)),A(x.TableCell,"border",$(me,$(Vt,x.divider,1),.88)),A(x.Tooltip,"bg",$(Vt,x.grey[700],.92))}if(x.mode==="dark"){A(x.Alert,"errorColor",$(me,x.error.light,.6)),A(x.Alert,"infoColor",$(me,x.info.light,.6)),A(x.Alert,"successColor",$(me,x.success.light,.6)),A(x.Alert,"warningColor",$(me,x.warning.light,.6)),A(x.Alert,"errorFilledBg",F("palette-error-dark")),A(x.Alert,"infoFilledBg",F("palette-info-dark")),A(x.Alert,"successFilledBg",F("palette-success-dark")),A(x.Alert,"warningFilledBg",F("palette-warning-dark")),A(x.Alert,"errorFilledColor",ct(()=>x.getContrastText(x.error.dark))),A(x.Alert,"infoFilledColor",ct(()=>x.getContrastText(x.info.dark))),A(x.Alert,"successFilledColor",ct(()=>x.getContrastText(x.success.dark))),A(x.Alert,"warningFilledColor",ct(()=>x.getContrastText(x.warning.dark))),A(x.Alert,"errorStandardBg",$(he,x.error.light,.9)),A(x.Alert,"infoStandardBg",$(he,x.info.light,.9)),A(x.Alert,"successStandardBg",$(he,x.success.light,.9)),A(x.Alert,"warningStandardBg",$(he,x.warning.light,.9)),A(x.Alert,"errorIconColor",F("palette-error-main")),A(x.Alert,"infoIconColor",F("palette-info-main")),A(x.Alert,"successIconColor",F("palette-success-main")),A(x.Alert,"warningIconColor",F("palette-warning-main")),A(x.AppBar,"defaultBg",F("palette-grey-900")),A(x.AppBar,"darkBg",F("palette-background-paper")),A(x.AppBar,"darkColor",F("palette-text-primary")),A(x.Avatar,"defaultBg",F("palette-grey-600")),A(x.Button,"inheritContainedBg",F("palette-grey-800")),A(x.Button,"inheritContainedHoverBg",F("palette-grey-700")),A(x.Chip,"defaultBorder",F("palette-grey-700")),A(x.Chip,"defaultAvatarColor",F("palette-grey-300")),A(x.Chip,"defaultIconColor",F("palette-grey-300")),A(x.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),A(x.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),A(x.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),A(x.LinearProgress,"primaryBg",$(he,x.primary.main,.5)),A(x.LinearProgress,"secondaryBg",$(he,x.secondary.main,.5)),A(x.LinearProgress,"errorBg",$(he,x.error.main,.5)),A(x.LinearProgress,"infoBg",$(he,x.info.main,.5)),A(x.LinearProgress,"successBg",$(he,x.success.main,.5)),A(x.LinearProgress,"warningBg",$(he,x.warning.main,.5)),A(x.Skeleton,"bg",a?$(Vt,x.text.primary,.13):`rgba(${F("palette-text-primaryChannel")} / 0.13)`),A(x.Slider,"primaryTrack",$(he,x.primary.main,.5)),A(x.Slider,"secondaryTrack",$(he,x.secondary.main,.5)),A(x.Slider,"errorTrack",$(he,x.error.main,.5)),A(x.Slider,"infoTrack",$(he,x.info.main,.5)),A(x.Slider,"successTrack",$(he,x.success.main,.5)),A(x.Slider,"warningTrack",$(he,x.warning.main,.5));const _=a?$(me,x.background.default,.985):Jr(x.background.default,.98);A(x.SnackbarContent,"bg",_),A(x.SnackbarContent,"color",ct(()=>a?ui.text.primary:x.getContrastText(_))),A(x.SpeedDialAction,"fabHoverBg",Jr(x.background.paper,.15)),A(x.StepConnector,"border",F("palette-grey-600")),A(x.StepContent,"border",F("palette-grey-600")),A(x.Switch,"defaultColor",F("palette-grey-300")),A(x.Switch,"defaultDisabledColor",F("palette-grey-600")),A(x.Switch,"primaryDisabledColor",$(he,x.primary.main,.55)),A(x.Switch,"secondaryDisabledColor",$(he,x.secondary.main,.55)),A(x.Switch,"errorDisabledColor",$(he,x.error.main,.55)),A(x.Switch,"infoDisabledColor",$(he,x.info.main,.55)),A(x.Switch,"successDisabledColor",$(he,x.success.main,.55)),A(x.Switch,"warningDisabledColor",$(he,x.warning.main,.55)),A(x.TableCell,"border",$(he,$(Vt,x.divider,1),.68)),A(x.Tooltip,"bg",$(Vt,x.grey[700],.92))}gt(x.background,"default"),gt(x.background,"paper"),gt(x.common,"background"),gt(x.common,"onBackground"),gt(x,"divider"),Object.keys(x).forEach(_=>{const V=x[_];_!=="tonalOffset"&&V&&typeof V=="object"&&(V.main&&A(x[_],"mainChannel",Mr(Wr(V.main))),V.light&&A(x[_],"lightChannel",Mr(Wr(V.light))),V.dark&&A(x[_],"darkChannel",Mr(Wr(V.dark))),V.contrastText&&A(x[_],"contrastTextChannel",Mr(Wr(V.contrastText))),_==="text"&&(gt(x[_],"primary"),gt(x[_],"secondary")),_==="action"&&(V.active&>(x[_],"active"),V.selected&>(x[_],"selected")))})}),O=o.reduce((oe,x)=>Le(oe,x),O);const H={prefix:l,disableCssColorScheme:s,shouldSkipGeneratingVar:d,getSelector:hc(O),enableContrastVars:c},{vars:N,generateThemeVars:Q,generateStyleSheets:ee}=$l(O,H);return O.vars=N,Object.entries(O.colorSchemes[O.defaultColorScheme]).forEach(([oe,x])=>{O[oe]=x}),O.generateThemeVars=Q,O.generateStyleSheets=ee,O.generateSpacing=function(){return ai(g.spacing,_o(this))},O.getColorSchemeSelector=_l(u),O.spacing=O.generateSpacing(),O.shouldSkipGeneratingVar=d,O.unstable_sxConfig={...mo,...g==null?void 0:g.unstable_sxConfig},O.unstable_sx=function(x){return go({sx:x,theme:this})},O.toRuntimeSource=xi,O}function Bn(t,o,n){t.colorSchemes&&n&&(t.colorSchemes[o]={...n!==!0&&n,palette:Vo({...n===!0?{}:n.palette,mode:o})})}function vc(t={},...o){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:l=n==null?void 0:n.mode,...c}=t,d=l||"light",u=s==null?void 0:s[d],f={...s,...n?{[d]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return Ao(t,...o);let g=n;"palette"in t||f[d]&&(f[d]!==!0?g=f[d].palette:d==="dark"&&(g={mode:"dark"}));const h=Ao({...t,palette:g},...o);return h.defaultColorScheme=d,h.colorSchemes=f,h.palette.mode==="light"&&(h.colorSchemes.light={...f.light!==!0&&f.light,palette:h.palette},Bn(h,"dark",f.dark)),h.palette.mode==="dark"&&(h.colorSchemes.dark={...f.dark!==!0&&f.dark,palette:h.palette},Bn(h,"light",f.light)),h}return!n&&!("light"in f)&&d==="light"&&(f.light=!0),bc({...c,colorSchemes:f,defaultColorScheme:d,...typeof i!="boolean"&&i},...o)}const Sc=vc();function Cc(){const t=Tl(Sc);return process.env.NODE_ENV!=="production"&&oo.useDebugValue(t),t[ha]||t}async function jc(t,o,n){const i={"Content-Type":"application/json"};o&&(i.Authorization=`Bearer ${o}`);const s=await fetch(t,{headers:i});if(!s.ok)throw new Error(`API error ${s.status}: ${s.statusText}`);const l=await s.json();let c;if(Array.isArray(l))c=l;else if(n&&l[n]&&Array.isArray(l[n]))c=l[n];else{const u=["data","results","items","records"].find(f=>l[f]&&Array.isArray(l[f]));if(u)c=l[u];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:c,source:t,fetchedAt:new Date().toISOString()}}function wc({isOpen:t,onClose:o,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[l,c]=p.useState(""),[d,u]=p.useState(""),[f,g]=p.useState(null),[h,y]=p.useState(null),[w,k]=p.useState(!1),[m,v]=p.useState(""),j=p.useRef(null),[b,S]=p.useState("json"),[a,I]=p.useState(""),[O,H]=p.useState(""),[N,Q]=p.useState(""),[ee,oe]=p.useState("idle"),[x,F]=p.useState(""),[$,_]=p.useState(null),[V,ie]=p.useState(0),ce=async R=>{if(v(""),!R.name.endsWith(".json")){v("Please upload a JSON file");return}try{const X=await R.text(),te=JSON.parse(X);if(!Array.isArray(te)){v("JSON must be an array of objects");return}g(R),y(te)}catch{v("Invalid JSON format")}},Te=R=>{R.preventDefault();const X=R.dataTransfer.files[0];X&&ce(X)},M=async()=>{if(a.trim()){oe("loading"),F("");try{const R=await jc(a.trim(),O.trim()||void 0,N.trim()||void 0);_(R.data),ie(R.data.length),oe("ready")}catch(R){F((R==null?void 0:R.message)||"Connection failed"),oe("error")}}},Y=()=>{const R=b==="api"?$:i||h;l.trim()&&R&&(n(l.trim(),d.trim(),R),Z())},Z=()=>{c(""),u(""),g(null),y(null),v(""),S("json"),I(""),H(""),Q(""),oe("idle"),F(""),_(null),ie(0),o()},re=i||h,ne=!l.trim()||b==="json"&&!re||b==="api"&&ee!=="ready";return e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:Z,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",width:480,maxHeight:"min(720px, calc(100vh - 120px))",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), 0 0 0 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:500,fontSize:"1.125rem",color:"text.primary",letterSpacing:"-0.01em",borderBottom:"1px solid",borderColor:"divider"},children:["Create new report",e.jsx(r.IconButton,{onClick:Z,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(T.Close,{sx:{fontSize:18}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pt:2,pb:2,overflowY:"auto"},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[e.jsx(r.TextField,{label:"Report name",required:!0,fullWidth:!0,value:l,onChange:R=>c(R.target.value),placeholder:"Enter report name",autoFocus:!0,sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsx(r.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:d,onChange:R=>u(R.target.value),placeholder:"Add details about this report",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsxs(r.Tabs,{value:b==="json"?0:1,onChange:(R,X)=>{S(X===0?"json":"api"),oe("idle"),F("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40},children:[e.jsx(r.Tab,{label:"Upload JSON",icon:e.jsx(T.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}}),e.jsx(r.Tab,{label:"Connect API",icon:e.jsx(T.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),b==="json"&&e.jsx(r.Box,{children:i?e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:R=>W(R.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:R=>W(R.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(T.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),e.jsx(r.IconButton,{size:"small",onClick:()=>k(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(T.Info,{sx:{fontSize:16}})})]}),e.jsxs(r.Box,{onDrop:Te,onDragOver:R=>R.preventDefault(),onClick:()=>{var R;return(R=j.current)==null?void 0:R.click()},sx:{position:"relative",border:"1.5px",borderStyle:h?"solid":"dashed",borderColor:h?"success.main":m?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:h?R=>W(R.palette.success.main,.04):m?R=>W(R.palette.error.main,.04):R=>W(R.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:h?R=>W(R.palette.success.main,.08):m?R=>W(R.palette.error.main,.08):R=>W(R.palette.primary.main,.08),borderColor:h?"success.dark":m?"error.dark":"primary.dark"}},children:[e.jsx("input",{ref:j,type:"file",accept:".json",style:{display:"none"},onChange:R=>{var X;return((X=R.target.files)==null?void 0:X[0])&&ce(R.target.files[0])}}),h?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[e.jsx(r.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:R=>W(R.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(T.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:f==null?void 0:f.name}),e.jsx(r.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):e.jsxs(r.Box,{children:[e.jsx(r.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:R=>W(R.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(T.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),m&&e.jsx(r.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:R=>W(R.palette.error.main,.08),border:1,borderColor:R=>W(R.palette.error.main,.2)},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:m})})]})]})]})}),b==="api"&&e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(r.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:a,onChange:R=>{I(R.target.value),oe("idle")},placeholder:"http://localhost:8000/api/reports/sales-pipeline/data/flat",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsx(r.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:O,onChange:R=>H(R.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",children:e.jsx(T.Lock,{sx:{fontSize:16,color:"text.secondary"}})})},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),e.jsx(r.TextField,{label:"Response data path (optional)",fullWidth:!0,size:"small",value:N,onChange:R=>Q(R.target.value),placeholder:"data (leave blank if API returns a plain array)",helperText:'If your API returns { "data": [...] }, enter: data',sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:0}}}),e.jsx(r.Button,{variant:"outlined",fullWidth:!0,disabled:!a.trim()||ee==="loading",onClick:M,startIcon:ee==="loading"?e.jsx(r.CircularProgress,{size:16,color:"inherit"}):e.jsx(T.Api,{}),sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:R=>W(R.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:ee==="loading"?"Connecting...":"Test Connection & Load Data"}),ee==="ready"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:R=>W(R.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(T.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),e.jsxs(r.Box,{children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[V.toLocaleString()," records loaded — ready to create"]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:a})]})]}),ee==="error"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:R=>W(R.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(T.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:x})]})]})]})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[e.jsx(r.Button,{onClick:Z,variant:"text",sx:{textTransform:"none",color:"primary.main",fontWeight:500,fontSize:"0.875rem",borderRadius:"4px",px:2,py:.625,minWidth:64,"&:hover":{bgcolor:R=>W(R.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(r.Button,{onClick:Y,disabled:ne,variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2},"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),e.jsxs(r.Dialog,{open:w,onClose:()=>k(!1),maxWidth:"sm",PaperProps:{sx:{borderRadius:3,width:560,maxHeight:"80vh",boxShadow:8}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em"},children:["JSON format guide",e.jsx(r.IconButton,{onClick:()=>k(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,py:2},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),e.jsx(r.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),e.jsx(r.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
|
|
78
70
|
{
|
|
79
71
|
"id": 1,
|
|
80
72
|
"customerName": "John Smith",
|
|
@@ -83,26 +75,8 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
|
|
|
83
75
|
"orderCount": 8,
|
|
84
76
|
"memberSince": "2024-01-15",
|
|
85
77
|
"status": "active"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"id": 2,
|
|
89
|
-
"customerName": "Sarah Johnson",
|
|
90
|
-
"email": "sarah@example.com",
|
|
91
|
-
"totalSpent": 3420.00,
|
|
92
|
-
"orderCount": 15,
|
|
93
|
-
"memberSince": "2023-11-20",
|
|
94
|
-
"status": "active"
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"id": 3,
|
|
98
|
-
"customerName": "Mike Davis",
|
|
99
|
-
"email": "mike@example.com",
|
|
100
|
-
"totalSpent": 890.25,
|
|
101
|
-
"orderCount": 5,
|
|
102
|
-
"memberSince": "2024-03-10",
|
|
103
|
-
"status": "inactive"
|
|
104
78
|
}
|
|
105
|
-
]`})]}),e.jsxs(
|
|
79
|
+
]`})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),e.jsx(r.DialogActions,{sx:{px:3,py:2},children:e.jsx(r.Button,{onClick:()=>k(!1),variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"4px",px:2.5,py:.625,minWidth:64,"&:hover":{bgcolor:"primary.dark",boxShadow:2}},children:"Got it"})})]})]})}function mi({isOpen:t,onClose:o}){return t?e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(640px, 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)",display:"flex",flexDirection:"column"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["JSON Format Guide",e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary"},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",e.jsx("strong",{children:"array of objects"}),". Each object represents a single row in your report, and the keys of each object become the column names."]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),e.jsx(r.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:e.jsx(r.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
|
|
106
80
|
{
|
|
107
81
|
"Active Sessions": 33,
|
|
108
82
|
"Active State": true,
|
|
@@ -112,4 +86,10 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
|
|
|
112
86
|
"Region": "Europe",
|
|
113
87
|
"Subscription Type": "Basic"
|
|
114
88
|
}
|
|
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;
|
|
89
|
+
]`})})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Number:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g., ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),", ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Boolean:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g., ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),", ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"String:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g., ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),", ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,minWidth:80},children:"Date:"}),e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g., ",e.jsx(r.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),e.jsxs(r.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(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",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:"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:"Got it"})})]}):null}function kc({onFileUpload:t,onError:o,isUploading:n}){const[i,s]=p.useState(!1),[l,c]=p.useState(""),[d,u]=p.useState(!1),f=p.useRef(null),g=async j=>{if(!j.name.endsWith(".json")){o("Please upload a valid JSON file");return}c(j.name);try{const b=await j.text(),S=JSON.parse(b);if(!Array.isArray(S)){o("JSON must be an array of objects");return}if(S.length===0){o("JSON array is empty");return}t(S)}catch{o("Invalid JSON format. Please check your file and try again.")}finally{c("")}},h=j=>{j.preventDefault(),s(!0)},y=j=>{j.preventDefault(),s(!1)},w=j=>{j.preventDefault(),s(!1);const b=j.dataTransfer.files[0];b&&g(b)},k=()=>{var j;(j=f.current)==null||j.click()},m=j=>{var S;const b=(S=j.target.files)==null?void 0:S[0];b&&g(b)},v=j=>{j.stopPropagation(),u(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{onDragOver:h,onDragLeave:y,onDrop:w,onClick:k,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?j=>W(j.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(r.Box,{component:"input",ref:f,type:"file",accept:".json",onChange:m,sx:{display:"none"}}),n?e.jsxs(e.Fragment,{children:[e.jsx(r.CircularProgress,{size:32,sx:{mb:2}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:.5},children:"Uploading..."}),l&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:l})]}):e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:j=>W(j.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(T.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(r.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),e.jsx(r.IconButton,{onClick:v,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(T.InfoOutlined,{sx:{fontSize:16}})})]}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),e.jsx(r.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:()=>u(!1)})]})}function Tc({schema:t,onConfirm:o,hasConflicts:n}){return e.jsxs(r.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[e.jsxs(r.Box,{sx:{mb:2},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontWeight:600,mb:.5},children:"Schema Preview"}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&e.jsxs(r.Alert,{severity:"warning",sx:{mb:2},children:[e.jsx(r.AlertTitle,{sx:{fontWeight:600},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),e.jsx(r.TableContainer,{sx:{mb:3},children:e.jsxs(r.Table,{children:[e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{bgcolor:"action.hover"},children:[e.jsx(r.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),e.jsx(r.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),e.jsx(r.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),e.jsx(r.TableBody,{children:t.map(i=>e.jsxs(r.TableRow,{sx:{bgcolor:i.hasConflict?s=>W(s.palette.warning.main,.12):"transparent"},children:[e.jsxs(r.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&e.jsx(r.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),e.jsx(r.TableCell,{children:e.jsx(r.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),e.jsx(r.TableCell,{children:e.jsx(r.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(T.Lock,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),e.jsx(r.Button,{variant:"contained",onClick:o,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function zc({error:t,onRetry:o}){return e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>W(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>W(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(T.ErrorOutline,{color:"error",sx:{fontSize:32}})}),e.jsx(r.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:600,mb:1},children:"Upload Failed"}),e.jsx(r.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:t}),e.jsx(r.Button,{variant:"contained",color:"error",startIcon:e.jsx(T.Upload,{sx:{fontSize:16}}),onClick:o,sx:{fontWeight:500},children:"Try Again"})]})}function gi({title:t,description:o,showIcon:n=!0}){return e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&e.jsx(r.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>W(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(T.Description,{sx:{fontSize:36,color:"primary.main"}})}),e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:500,mb:1,color:"text.primary",fontSize:"1.125rem"},children:t}),e.jsx(r.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:"0.875rem",lineHeight:1.5},children:o})]})}function Ic({value:t,onChange:o,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:l,disabled:c}){const[d,u]=p.useState(!1),[f,g]=p.useState(!1),[h,y]=p.useState(-1),w=p.useRef(null),k=p.useRef(null);p.useEffect(()=>{function N(Q){w.current&&!w.current.contains(Q.target)&&(u(!1),g(!1))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const m=p.useCallback(()=>{g(!0),y(-1),n.length>0&&u(!0)},[n.length]),v=p.useCallback(N=>{o(N),y(-1)},[o]),j=p.useCallback(N=>{var Q;o(N),i(N),u(!1),(Q=k.current)==null||Q.blur()},[o,i]),b=p.useCallback(N=>{y(-1),j(N)},[j]),S=p.useCallback(N=>{var Q;N.key==="Enter"?h>=0&&h<n.length?(N.preventDefault(),b(n[h].query)):t.trim()&&j(t.trim()):N.key==="Escape"?(u(!1),y(-1),(Q=k.current)==null||Q.blur()):N.key==="ArrowDown"?(N.preventDefault(),n.length>0&&(d||u(!0),y(ee=>ee<n.length-1?ee+1:ee))):N.key==="ArrowUp"&&(N.preventDefault(),y(ee=>ee>0?ee-1:-1))},[h,n,t,d,b,j]),a=p.useCallback(()=>{var N;o(""),(N=k.current)==null||N.focus()},[o]),I=p.useMemo(()=>n.filter(N=>N.isFavourite),[n]),O=p.useMemo(()=>n.filter(N=>!N.isFavourite),[n]),H=d&&n.length>0;return e.jsxs(r.Box,{sx:{position:"relative",width:240},ref:w,children:[e.jsx(r.TextField,{inputRef:k,size:"small",fullWidth:!0,value:t,onChange:N=>v(N.target.value),onFocus:m,onKeyDown:S,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"common.white",height:"36px","& fieldset":{borderColor:"divider",transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:"divider"},"&.Mui-focused":{bgcolor:"common.white"},"&.Mui-focused fieldset":{borderColor:"#2932e5",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px"}},InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",sx:{ml:.5},children:e.jsx(T.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:t?e.jsx(r.InputAdornment,{position:"end",children:e.jsx(r.IconButton,{size:"small",onClick:a,edge:"end",sx:{mr:-.5},children:e.jsx(T.Close,{sx:{fontSize:16}})})}):null}}),H&&e.jsxs(r.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[I.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[e.jsx(r.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),I.map((N,Q)=>e.jsx(Dn,{entry:N,isSelected:h===Q,onClick:()=>b(N.query),onToggleFavourite:()=>s(N.query),onDelete:()=>l(N.query)},`fav-${N.query}`))]}),O.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[I.length>0&&e.jsx(r.Divider,{}),e.jsx(r.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),O.map((N,Q)=>{const ee=I.length+Q;return e.jsx(Dn,{entry:N,isSelected:h===ee,onClick:()=>b(N.query),onToggleFavourite:()=>s(N.query),onDelete:()=>l(N.query)},`recent-${N.query}`)})]})]})]})}const Dn=p.memo(function({entry:o,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:l}){const c=p.useCallback(u=>{u.stopPropagation(),s()},[s]),d=p.useCallback(u=>{u.stopPropagation(),l()},[l]);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>W(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>W(u.palette.primary.main,.12):"action.hover"}},children:[e.jsx(r.Box,{sx:{flex:1,minWidth:0},onClick:i,children:e.jsx(r.Typography,{variant:"body2",noWrap:!0,children:o.query})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[e.jsx(r.IconButton,{size:"small",onClick:c,title:o.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:o.isFavourite?e.jsx(T.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(T.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(r.IconButton,{size:"small",onClick:d,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(T.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function Ec({views:t,activeViewId:o,isDirty:n,onSelectView:i,onCreateView:s,onManageViews:l,onToggleDefault:c,onToggleFavorite:d,onRestoreView:u,onPermanentDelete:f,isReadOnly:g}){const h=Cc(),[y,w]=p.useState(!1),[k,m]=p.useState(!1),[v,j]=p.useState({top:0,left:0}),b=p.useRef(null),S=p.useRef(null),a=t.find(_=>_.id===o),I=a==null?void 0:a.isDefault,O=t.filter(_=>_.isDefault&&!_.isDeleted),H=t.filter(_=>!_.isDefault&&!_.isDeleted).sort((_,V)=>(V.updatedAt||0)-(_.updatedAt||0)),N=t.filter(_=>_.isFavorite&&!_.isDeleted).sort((_,V)=>(V.updatedAt||0)-(_.updatedAt||0)),Q=t.filter(_=>_.isDeleted);p.useEffect(()=>{if(y&&S.current){const _=S.current.getBoundingClientRect();j({top:_.bottom+window.scrollY+8,left:_.right+window.scrollX-320})}},[y]),p.useEffect(()=>{const _=V=>{b.current&&!b.current.contains(V.target)&&S.current&&!S.current.contains(V.target)&&w(!1)};return y&&document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[y]);const ee=_=>{i(_),w(!1)},oe=(_,V=!1)=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:o===_.id?h.palette.primary.light+"20":"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:o===_.id?h.palette.primary.light+"20":h.palette.grey[50]}},children:[e.jsxs(r.Button,{onClick:()=>ee(_.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:[o===_.id&&e.jsx(T.Check,{sx:{fontSize:16,flexShrink:0}}),o!==_.id&&e.jsx(r.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(r.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:o===_.id?h.palette.primary.dark:h.palette.text.primary,fontWeight:o===_.id?500:400},children:_.name}),V&&e.jsx(r.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:h.palette.text.secondary,backgroundColor:h.palette.grey[100],px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[d&&e.jsx(r.IconButton,{onClick:ie=>{ie.stopPropagation(),d(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.grey[200]}},title:_.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(T.Star,{sx:{fontSize:16}})}),c&&!_.isDefault&&e.jsx(r.IconButton,{onClick:ie=>{ie.stopPropagation(),c(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.grey[200]}},title:"Set as default",children:e.jsx(T.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},_.id),x=_=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:h.palette.grey[50]},children:[e.jsx(r.Typography,{sx:{color:h.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:_.name}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[u&&e.jsx(r.IconButton,{onClick:V=>{V.stopPropagation(),u(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.grey[200]}},title:"Restore view",children:e.jsx(T.Undo,{sx:{fontSize:16,color:"success.main"}})}),f&&e.jsx(r.IconButton,{onClick:V=>{V.stopPropagation(),f(_.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.grey[200]}},title:"Delete permanently",children:e.jsx(T.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},_.id),F=n||!I,$=n;return e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsxs(r.IconButton,{ref:S,onClick:()=>w(!y),size:"small",sx:{position:"relative",color:F?"warning.main":"text.secondary",bgcolor:F?W(h.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:F?W(h.palette.warning.main,.2):W(h.palette.text.primary,.06),color:F?"warning.dark":"text.primary"}},title:`View: ${(a==null?void 0:a.name)||"Default View"}`,children:[e.jsx(T.Visibility,{sx:{fontSize:20}}),$&&e.jsx(r.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&&Pn.createPortal(e.jsxs(r.Box,{ref:b,sx:{position:"fixed",width:"320px",backgroundColor:h.palette.background.paper,border:`1px solid ${h.palette.divider}`,borderRadius:1,boxShadow:h.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:v.top,left:v.left},children:[O.length>0&&e.jsxs(r.Box,{sx:{py:.5},children:[e.jsx(r.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Default Views"}),O.map(_=>oe(_,!0))]}),N.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(T.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),N.map(_=>oe(_))]})]}),H.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsx(r.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom Views"}),H.map(_=>oe(_))]})]}),Q.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Button,{onClick:()=>m(!k),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.grey[50]}},children:[e.jsxs(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",Q.length,")"]}),e.jsx(T.ChevronRight,{sx:{fontSize:16}})]}),k&&e.jsx(r.Box,{sx:{backgroundColor:h.palette.grey[50]},children:Q.map(_=>x(_))})]})]}),e.jsx(r.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),e.jsxs(r.Button,{onClick:()=>{s(),w(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:h.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.grey[50]}},children:[e.jsx(T.Add,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(r.Button,{onClick:()=>{l(),w(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:h.palette.text.primary,textTransform:"none",justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.grey[50]}},children:[e.jsx(T.Settings,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body)]})}function Bc({columnName:t,columnType:o="string",currentSort:n,hasFilters:i,isInSortStack:s,position:l,onSort:c,onRemoveSort:d,onSortAscending:u,onSortDescending:f,onFilter:g,onClearFilter:h,onHideColumn:y,onManageColumns:w,onManageViews:k,onResetLayout:m,onClose:v}){const j=p.useRef(null);p.useEffect(()=>{const S=I=>{j.current&&!j.current.contains(I.target)&&v()},a=I=>{I.key==="Escape"&&v()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",a)}},[v]);const b=()=>n?n.direction==="asc"?o==="number"?"(0→9)":o==="boolean"?"(False→True)":"(A→Z)":o==="number"?"(9→0)":o==="boolean"?"(True→False)":"(Z→A)":"";return Pn.createPortal(e.jsxs(r.Paper,{ref:j,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:100,minWidth:240},elevation:3,children:[e.jsxs(r.Box,{sx:{px:2,py:1},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:"Sorting"}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.IconButton,{size:"small",onClick:()=>{u?u(t):(n==null?void 0:n.direction)!=="asc"&&(c(t),(n==null?void 0:n.direction)==="desc"&&setTimeout(()=>c(t),0))},title:"Sort Ascending",sx:{p:.75},children:e.jsx(T.ArrowUpward,{color:(n==null?void 0:n.direction)==="asc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>{f?f(t):n?n.direction==="asc"&&c(t):(c(t),setTimeout(()=>c(t),0))},title:"Sort Descending",sx:{p:.75},children:e.jsx(T.ArrowDownward,{color:(n==null?void 0:n.direction)==="desc"?"primary":void 0,sx:{fontSize:16}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>d(t),title:"Clear sorting",disabled:!n,sx:{p:.75,"&:hover":{color:"error.main"}},children:e.jsx(T.Close,{sx:{fontSize:16}})})]})]}),n&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:b()}),e.jsx(r.Chip,{label:`Level ${n.priority}`,size:"small",color:"primary",sx:{height:20,fontSize:"caption.fontSize"}})]})]}),e.jsx(r.Divider,{}),e.jsxs(r.MenuList,{dense:!0,children:[e.jsxs(r.MenuItem,{onClick:()=>{g(t),v()},children:[e.jsx(T.FilterList,{sx:{fontSize:16,mr:1}}),"Filter this column",i&&e.jsx(r.Chip,{label:"Active",size:"small",color:"primary",sx:{ml:"auto",height:20,fontSize:"caption.fontSize"}})]}),i&&e.jsxs(r.MenuItem,{onClick:()=>{h(t),v()},sx:{color:"warning.main"},children:[e.jsx(T.FilterListOff,{sx:{fontSize:16,mr:1}}),"Clear Filters"]})]}),e.jsx(r.Divider,{}),e.jsx(r.MenuList,{dense:!0,children:e.jsxs(r.MenuItem,{onClick:()=>{y(t),v()},children:[e.jsx(T.VisibilityOff,{sx:{fontSize:16,mr:1}}),"Hide column"]})}),e.jsx(r.Divider,{}),e.jsxs(r.MenuList,{dense:!0,children:[e.jsxs(r.MenuItem,{onClick:()=>{w(),v()},children:[e.jsx(T.Settings,{sx:{fontSize:16,mr:1}}),"Column Settings"]}),e.jsxs(r.MenuItem,{onClick:()=>{k(),v()},children:[e.jsx(T.Description,{sx:{fontSize:16,mr:1}}),"View Setup"]}),e.jsxs(r.MenuItem,{onClick:()=>{m(),v()},children:[e.jsx(T.Undo,{sx:{fontSize:16,mr:1}}),"Reset to Default Layout"]})]})]}),document.body)}const Dc=150,On="COLUMN_HEADER",Oc=p.memo(function({column:o,index:n,sortRule:i,hasFilters:s,isInSortStack:l,width:c,onColumnClick:d,onMoveColumn:u,onResizeStart:f,onSort:g,onRemoveSort:h,onSortAscending:y,onSortDescending:w,onOpenFilterForColumn:k,onClearFiltersForColumn:m,onHideColumn:v,onManageColumns:j,onManageViews:b,onResetLayout:S}){const a=p.useRef(null),[I,O]=p.useState(!1),[H,N]=p.useState({x:0,y:0}),[{handlerId:Q,isOver:ee},oe]=bt.useDrop({accept:On,collect(M){return{handlerId:M.getHandlerId(),isOver:M.isOver()}},hover(M,Y){var ae;if(!a.current)return;const Z=M.index,re=n;if(Z===re)return;const ne=(ae=a.current)==null?void 0:ae.getBoundingClientRect(),R=(ne.right-ne.left)/2,X=Y.getClientOffset(),te=((X==null?void 0:X.x)??0)-ne.left;Z<re&&te<R||Z>re&&te>R||(u(Z,re),M.index=re)}}),[{isDragging:x},F]=bt.useDrag({type:On,item:()=>({index:n,columnName:o.name}),collect:M=>({isDragging:M.isDragging()})});F(oe(a));const $=p.useCallback(M=>{M.preventDefault(),M.stopPropagation(),N({x:M.clientX,y:M.clientY}),O(!0)},[]),_=p.useCallback(()=>{O(!1)},[]),V=p.useCallback(()=>{d(o.name)},[d,o.name]),ie=p.useCallback(M=>{M.stopPropagation(),k(o.name)},[k,o.name]),ce=p.useCallback(()=>i?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25,color:"primary.main"},children:[i.direction==="asc"?e.jsx(T.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(T.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),e.jsx(r.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]),Te=p.useCallback(()=>s?e.jsx(r.Box,{onClick:ie,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,[s,ie]);return e.jsxs(e.Fragment,{children:[e.jsxs(r.TableCell,{ref:a,"data-handler-id":Q,"data-column-index":n,onClick:V,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:x?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:ee?M=>W(M.palette.primary.main,.08):"#f5f5f5",borderBottom:"1px solid",borderColor:"#e0e0e0",py:0,px:2,height:34,"&:hover":{bgcolor:"divider",color:"primary.dark"},width:c?`${c}px`:`${Dc}px`},children:[e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center"},children:[vt(o.name),ce(),Te()]}),e.jsx(r.Box,{sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:10,"&:hover":{bgcolor:"primary.light"}},onMouseDown:M=>{M.stopPropagation(),f(M,o.name)},onClick:M=>M.stopPropagation()}),ee&&e.jsx(r.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),I&&e.jsx(Bc,{columnName:o.name,columnType:o.type,currentSort:i,hasFilters:s,isInSortStack:l,position:H,onSort:g,onRemoveSort:h,onSortAscending:y,onSortDescending:w,onFilter:k,onClearFilter:m,onHideColumn:v,onManageColumns:j,onManageViews:b,onResetLayout:S,onClose:_})]})});function Ac({selectedCount:t,selectedRowIds:o,searchedData:n,resolvedFavoritesSet:i,onExportSelected:s,onClearSelection:l,onBulkSetFavorites:c}){const[d,u]=p.useState(null),f=p.useMemo(()=>Array.from(o),[o]),g=p.useMemo(()=>f.filter(j=>{const b=n[j];return b!==void 0&&i.has(b)}),[f,n,i]),h=p.useMemo(()=>f.filter(j=>{const b=n[j];return b!==void 0&&!i.has(b)}),[f,n,i]),y=g.length>0,w=h.length>0;if(t===0)return null;const k=()=>{c&&c(f,!0)},m=()=>{c&&c(f,!1)},v=j=>{s(j),u(null)};return e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:j=>W(j.palette.primary.main,.08),borderBottom:j=>`1px solid ${W(j.palette.primary.main,.25)}`,zIndex:10},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"primary.main"},children:[t," ",t===1?"row":"rows"," selected"]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Button,{onClick:l,startIcon:e.jsx(T.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:j=>W(j.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(r.Button,{onClick:j=>u(j.currentTarget),startIcon:e.jsx(T.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:j=>W(j.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:j=>W(j.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(r.Menu,{anchorEl:d,open:!!d,onClose:()=>u(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:180,borderRadius:1.5}},children:[e.jsx(r.MenuItem,{dense:!0,onClick:()=>v("csv"),sx:{py:1,px:2},children:"Export as CSV"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>v("excel"),sx:{py:1,px:2},children:"Export as Excel"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>v("json"),sx:{py:1,px:2},children:"Export as JSON"})]}),c&&w&&e.jsx(r.Button,{onClick:k,startIcon:e.jsx(T.StarBorder,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",borderColor:j=>W(j.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:j=>W(j.palette.warning.main,.06)}},children:"Add to Favorites"}),c&&y&&e.jsx(r.Button,{onClick:m,startIcon:e.jsx(T.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:j=>W(j.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:j=>W(j.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:"text.secondary"},"not started":{bg:"#f1f3f4",color:"text.secondary"},paused:{bg:"#f1f3f4",color:"text.secondary"}},Wc={low:"text.secondary",medium:"#e65100",high:"#e8710a",critical:"#c5221f",urgent:"#c5221f"};function Rc(t){const o=t.toLowerCase().trim(),n=Mc[o]||{bg:"#f1f3f4",color:"text.secondary"};return e.jsx(r.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,o){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.8125rem"},children:"—"});const n=String(o),i=t.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Rc(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=Wc[n.toLowerCase().trim()];return s?e.jsx(r.Box,{component:"span",sx:{color:s,fontWeight:600,fontSize:"0.8125rem"},children:n}):e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}return typeof o=="boolean"?e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:o?"Yes":"No"}):typeof o=="object"?e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:JSON.stringify(o)}):e.jsx(r.Box,{component:"span",sx:{fontSize:"0.8125rem"},children:n})}function $c(t){const o=t.find(s=>{const l=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(l)})||t[0]||null,n=t.find(s=>{const l=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(l)&&s!==o})||null,i=t.filter(s=>s!==o&&s!==n).slice(0,4);return{primaryCol:o,idCol:n,bodyColumns:i}}function _c({row:t,rowIndex:o,visibleColumns:n,isSelected:i,isFavorite:s,isReadOnly:l,onToggleSelection:c,onToggleFavorite:d,onView:u,onEdit:f,onDuplicate:g,onDelete:h}){const[y,w]=p.useState(null),[k,m]=p.useState(!1),{primaryCol:v,idCol:j,bodyColumns:b}=p.useMemo(()=>$c(n),[n]),S=v?t[v.name]:null,a=j?t[j.name]:null,I=k||i||s||!!y;return e.jsxs(r.Box,{onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),onClick:()=>c(o),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":O=>W(O.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?O=>`0 0 0 3px ${W(O.palette.primary.main,.15)}, 0 2px 8px ${W(O.palette.common.black,.08)}`:k?"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:k&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:O=>W(O.palette.primary.main,.03)}},children:[e.jsx(r.Box,{sx:{px:2,pt:2,pb:1.5},children:e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,fontSize:"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:S!=null&&S!==""?String(S):e.jsx(r.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})}),e.jsx(r.Box,{sx:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}),e.jsxs(r.Box,{sx:{px:2,py:1.5,flex:1,display:"flex",flexDirection:"column",gap:1},children:[b.map(O=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minHeight:22},children:[e.jsx(r.Typography,{sx:{color:"text.secondary",fontWeight:500,fontSize:"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",minWidth:68,flexShrink:0,lineHeight:1},children:vt(O.name)}),e.jsx(r.Box,{sx:{flex:1,lineHeight:1},children:Pc(O,t[O.name])})]},O.name)),b.length===0&&e.jsx(r.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic"},children:"No additional fields visible"})]}),e.jsxs(r.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:O=>W(O.palette.action.hover,.1),minHeight:40},children:[e.jsx(r.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(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:I?1:0,transition:"opacity 0.15s ease"},onClick:O=>O.stopPropagation(),children:[d&&e.jsx(r.Tooltip,{title:s?"Remove from favorites":"Add to favorites",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:O=>{O.stopPropagation(),d(o)},sx:{width:28,height:28,color:s?"#fbbc04":"action.disabled","&:hover":{bgcolor:O=>W(O.palette.warning.main,.1),color:"#fbbc04"}},children:s?e.jsx(T.Star,{sx:{fontSize:17}}):e.jsx(T.StarBorder,{sx:{fontSize:17}})})}),e.jsx(r.Tooltip,{title:"More actions",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:O=>{O.stopPropagation(),w(O.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:O=>W(O.palette.text.primary,.08)}},children:e.jsx(T.MoreVert,{sx:{fontSize:17}})})})]})]}),e.jsxs(r.Popover,{open:!!y,anchorEl:y,onClose:()=>w(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:O=>O.stopPropagation(),children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{u(t),w(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(T.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),!l&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{f(t,o),w(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(T.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),!l&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{g(o,t),w(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(T.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),!l&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{h(o,t),w(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(T.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Nc({row:t,grouping:o,onToggleCollapse:n}){var i;return e.jsxs(r.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:s=>W(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(T.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(T.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Ln(t.groupLevel,((i=o==null?void 0:o.levels[t.groupLevel])==null?void 0:i.column)||"",t.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>W(s.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(r.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(t.aggregates).map(([s,l])=>Vn(l)).filter(Boolean).join(" • ")})]})}function Fc({data:t,visibleColumns:o,grouping:n,selectedRowIds:i,resolvedFavoritesSet:s,isReadOnly:l,isGrouped:c,onToggleRowSelection:d,onToggleRowFavorite:u,onToggleGroupCollapse:f,onViewRow:g,onEditRow:h,onDuplicateRow:y,onDeleteRow:w}){return t.length===0?e.jsx(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):e.jsx(r.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(272px, 1fr))",gap:1.5,alignContent:"start"},children:t.map((k,m)=>c&&k.isGroupHeader?e.jsx(Nc,{row:k,grouping:n,onToggleCollapse:f||(()=>{})},`group-${k.groupKey}`):e.jsx(_c,{row:k,rowIndex:m,visibleColumns:o,isSelected:i.has(m),isFavorite:s.has(k),isReadOnly:l,onToggleSelection:d,onToggleFavorite:u,onView:g,onEdit:h,onDuplicate:y,onDelete:w},`card-${m}`))})}const An=[10,15,25,50,100];function Vc({currentPage:t,pageSize:o,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:l}){const c=Math.ceil(n/o);if(n<=Math.min(...An))return null;const d=()=>{t>1&&s(t-1)},u=()=>{t<c&&s(t+1)},f=(t-1)*o+1,g=Math.min(t*o,n);return e.jsxs(r.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(r.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data: ",e.jsx(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields: ",e.jsx(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),e.jsx(r.Select,{value:o,onChange:h=>l(Number(h.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(h=>e.jsx(r.MenuItem,{value:h,sx:{fontSize:"0.8125rem"},children:h},h))})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:[f,"–",g," of ",n]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Page ",t," of ",c]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.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(T.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:u,disabled:t===c,size:"small",title:"Next page",sx:{p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}},children:e.jsx(T.ChevronRight,{sx:{fontSize:20}})})]})]})]})}function Lc(){return e.jsx(r.Chip,{icon:e.jsx(T.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const yi="urm_hint_seen_";function Hc(t){try{return localStorage.getItem(yi+t)==="true"}catch{return!1}}function Uc(t){try{localStorage.setItem(yi+t,"true")}catch{}}function Gc(t,o){if(t==null||t==="")return"—";if(o==="boolean")return t?"True":"False";if(o==="object"||o==="array")try{return JSON.stringify(t,null,2)}catch{return String(t)}return String(t)}function Yc({open:t,onClose:o,row:n,schema:i,reportName:s}){if(!n)return null;const l=i.filter(c=>c.name in n);return e.jsxs(r.Dialog,{open:t,onClose:o,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(r.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(r.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(T.Visibility,{sx:{fontSize:18,color:"primary.main"}}),e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"text.primary"},children:"View Record"})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(T.Close,{sx:{fontSize:18}})})]}),e.jsx(r.DialogContent,{sx:{p:0,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(r.Box,{children:l.map(c=>{const d=n[c.name],u=Gc(d,c.type),f=u==="—";return e.jsxs(r.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(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.6875rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.02em",display:"block",mb:.5},children:vt(c.name)}),e.jsx(r.Typography,{variant:"body2",sx:{color:f?"#9e9e9e":"text.primary",fontStyle:f?"italic":"normal",fontSize:"0.875rem",wordBreak:"break-word",whiteSpace:c.type==="object"||c.type==="array"?"pre-wrap":"normal",fontFamily:c.type==="number"?"monospace":"inherit",fontWeight:400,lineHeight:1.5},children:u})]},c.name)})})}),e.jsx(r.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,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 qc({open:t,onClose:o,onConfirm:n,rowPreview:i}){return e.jsxs(r.Dialog,{open:t,onClose:o,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(r.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs(r.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[e.jsx(r.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:"#fce8e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(T.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:[i?`"${i}"`:"This record"," will be permanently removed."]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"text.primary"}},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pb:2},children:e.jsx(r.Box,{sx:{p:2,borderRadius:"8px",bgcolor:"#fce8e6",border:"1px solid #f28b82"},children:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"error.main",fontWeight:500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,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(r.Button,{onClick:()=>{n(),o()},variant:"contained",startIcon:e.jsx(T.DeleteForever,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"error.main",color:"common.white",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 Jc({open:t,onClose:o,onSave:n,row:i,schema:s,reportName:l}){const[c,d]=p.useState({});if(p.useEffect(()=>{t&&i&&d({...i})},[t,i]),!i)return null;const u=s.filter(y=>y.name in i),f=(y,w)=>{d(k=>({...k,[y]:w}))},g=()=>{const y={...c};u.forEach(w=>{const k=c[w.name];if(w.type==="number"){const m=Number(k);y[w.name]=isNaN(m)?i[w.name]:m}else w.type==="boolean"&&(y[w.name]=!!k)}),n(y),o()},h=y=>{const w=c[y.name],k=vt(y.name);return y.type==="boolean"?e.jsx(r.FormControlLabel,{control:e.jsx(r.Switch,{checked:!!w,onChange:m=>f(y.name,m.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.primary",fontWeight:500},children:k}),sx:{m:0,bgcolor:"#fff",px:2,py:1,borderRadius:"4px",border:"1px solid divider"}},y.name):e.jsx(r.TextField,{label:k,value:w??"",onChange:m=>f(y.name,m.target.value),type:y.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"outlined",InputLabelProps:y.type==="string"&&String(w).match(/^\d{4}-\d{2}-\d{2}/)?{shrink:!0}:void 0,sx:{"& .MuiOutlinedInput-root":{fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"common.white","& fieldset":{borderColor:"divider"},"&: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(r.Dialog,{open:t,onClose:o,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(r.Box,{sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid divider",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(r.Stack,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(T.Edit,{sx:{fontSize:18,color:"#ea8600"}}),e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"text.primary"},children:"Edit Record"})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{p:.5,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(T.Close,{sx:{fontSize:18}})})]}),e.jsx(r.DialogContent,{sx:{p:2,bgcolor:"grey.50",overflowY:"auto",flex:1},children:e.jsx(r.Stack,{spacing:1.5,children:u.map(y=>e.jsx(r.Box,{children:h(y)},y.name))})}),e.jsxs(r.DialogActions,{sx:{px:2,py:1.25,borderTop:"1px solid divider",bgcolor:"#fff",gap:1,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,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(r.Button,{onClick:g,variant:"contained",startIcon:e.jsx(T.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 Kc=160,Xc={active:{bg:"success.lighter",color:"success.dark"},completed:{bg:"success.lighter",color:"success.dark"},approved:{bg:"success.lighter",color:"success.dark"},success:{bg:"success.lighter",color:"success.dark"},done:{bg:"success.lighter",color:"success.dark"},contract:{bg:"primary.lighter",color:"primary.main"},"in progress":{bg:"primary.lighter",color:"primary.main"},"in review":{bg:"primary.lighter",color:"primary.main"},review:{bg:"primary.lighter",color:"primary.main"},pending:{bg:"primary.lighter",color:"primary.main"},"on leave":{bg:"error.lighter",color:"error.dark"},"on hold":{bg:"warning.lighter",color:"warning.dark"},probation:{bg:"warning.lighter",color:"warning.dark"},cancelled:{bg:"error.lighter",color:"error.dark"},rejected:{bg:"error.lighter",color:"error.dark"},blocked:{bg:"error.lighter",color:"error.dark"},inactive:{bg:"action.selected",color:"text.secondary"},"not started":{bg:"action.selected",color:"text.secondary"},paused:{bg:"action.selected",color:"text.secondary"}},Qc={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Zc(t){const o=t.toLowerCase().trim(),n=Xc[o]||{bg:"grey.100",color:"grey.600"};return e.jsx(r.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 ed(t){const o=t.toLowerCase().trim(),n=Qc[o];return n?e.jsx(r.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function td(t){return e.jsx(r.Box,{component:"span",sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.8125rem",fontWeight:400,letterSpacing:"0.04em"},children:t})}function rd(t,o){const n=t.name.toLowerCase().replace(/[_\s-]/g,""),i=t.name.toLowerCase(),s=o.findIndex(f=>f.name===t.name),l=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(n),c=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"),u=s===0&&t.type!=="boolean"&&!i.includes("status")&&!i.includes("state");return l||c&&!d||u&&!d}function od(t){return e.jsx(r.Box,{component:"span",sx:{fontWeight:700,color:"text.primary",fontSize:"inherit"},children:t})}function nd(t,o,n=!1){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"grey.400"},children:"—"});const i=String(o),s=t.name.toLowerCase().replace(/[_\s-]/g,""),l=/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase());if(l)return Zc(i);const c=/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase());if(c)return ed(i);const d=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(s)||/^[A-Z]{2,8}-\d{2,}$/.test(i);if(d)return td(i);if(n&&!l&&!c&&!d)return od(i);if(t.type==="number"&&typeof o=="number")return o.toLocaleString();if(typeof o=="boolean")return o?"Yes":"No";if(Array.isArray(o)){if(o.length===0)return e.jsx(r.Box,{component:"span",sx:{color:"grey.400"},children:"[ ]"});const u=o.slice(0,3).map(f=>typeof f=="object"?JSON.stringify(f):String(f)).join(", ");return e.jsxs(r.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[u,o.length>3?` +${o.length-3} more`:""]})}if(typeof o=="object"){const u=JSON.stringify(o);return e.jsx(r.Box,{component:"span",title:u,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:u.length>40?u.slice(0,40)+"…":u})}return i}function id({schema:t,data:o,sortStack:n=[],filters:i=[],views:s=[],activeViewId:l="",isDirty:c=!1,isExporting:d=!1,columnVisibility:u={},columnOrder:f=[],columnWidths:g={},grouping:h=null,onSort:y,onSortAscending:w,onSortDescending:k,onOpenFilters:m,onOpenSort:v,onOpenFilterForColumn:j,onSelectView:b,onCreateView:S,onManageViews:a,onUpdateCurrentView:I,onSaveAsNewView:O,onToggleDefault:H,onToggleFavorite:N,onRestoreView:Q,onPermanentDelete:ee,onExport:oe,onOpenColumns:x,onUpdateColumnWidth:F,onUpdateColumnOrder:$,onUpdateColumnVisibility:_,onClearFiltersForColumn:V,onResetLayout:ie,onOpenGroup:ce,onToggleGroupCollapse:Te,onOpenAuditHistory:M,onOpenScheduledReports:Y,searchQuery:Z,searchHistory:re=[],onAddToSearchHistory:ne,onToggleSearchFavourite:R,onDeleteSearchHistory:X,selectedRowIds:te=new Set,onSearchChange:ae,onToggleRowSelection:se,onToggleAllRows:le,onRangeSelection:we,onClearSelection:G,onExportSelected:De,currentPage:He=1,pageSize:Ct=15,totalRowsBeforePagination:At=o.length,onPageChange:et,onPageSizeChange:jt,isReadOnly:Oe=!1,userRole:Ke,reportName:tt,onEditRow:Ue,onDuplicateRow:$e,onDeleteRow:wt,favoriteRowIndices:Yt=[],resolvedFavoritesSet:dt=new Set,showFavoritesOnly:Xe=!1,onToggleRowFavorite:Ne,onBulkSetFavorites:fr,showDevPanel:qt=!1,onOpenDevConfig:rt,onToggleFavoritesFilter:kt}){const[Mt,ut]=p.useState(null),[hr,Fr]=p.useState(0),[Jt,ot]=p.useState(0),[Wt,Kt]=p.useState(null),[Tt,Ce]=p.useState(null),[mr,zt]=p.useState(null),[nt,P]=p.useState(!1),[Qe,ge]=p.useState(!1),[Re,Rt]=p.useState(null),[gr,it]=p.useState(""),[yr,pt]=p.useState(!1),[Pt,$t]=p.useState(null),[br,ke]=p.useState(null),[L,Me]=p.useState(null),[Se,xt]=p.useState(null),[_e,Xt]=p.useState("list"),[vr,Qt]=p.useState(!1),[Zt,Sr]=p.useState(()=>!Hc("toolbar_search"));p.useRef(null);const er=p.useCallback(()=>{Uc("toolbar_search"),Sr(!1)},[]),tr=p.useMemo(()=>f.length>0?f.map(D=>t.find(q=>q.name===D)).filter(D=>D!==void 0):t,[f,t]),Pe=p.useMemo(()=>tr.filter(D=>u[D.name]!==!1),[tr,u]),st=p.useMemo(()=>t.filter(D=>u[D.name]===!1).length,[t,u]),at=p.useMemo(()=>t.map(D=>D.name),[t]),Fe=p.useMemo(()=>JSON.stringify(f)!==JSON.stringify(at),[f,at]),rr=p.useCallback((D,q)=>{D.preventDefault(),D.stopPropagation(),ut(q),Fr(D.clientX),ot(g[q]||150)},[g]);p.useEffect(()=>{if(!Mt)return;const D=de=>{const Ae=de.clientX-hr,J=Math.max(100,Jt+Ae);F==null||F(Mt,J)},q=()=>{ut(null)};return document.addEventListener("mousemove",D),document.addEventListener("mouseup",q),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",q)}},[Mt,hr,Jt,F]);const Cr=p.useCallback(D=>D==null?"-":typeof D=="object"?JSON.stringify(D):typeof D=="boolean"?D?"true":"false":String(D),[]);p.useCallback(D=>{const q=n.find(de=>de.column===D);return q?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[q.direction==="asc"?e.jsx(T.ArrowUpward,{sx:{fontSize:14}}):e.jsx(T.ArrowDownward,{sx:{fontSize:14}}),e.jsx(r.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:q.priority})]}):null},[n]),p.useCallback(D=>i.some(de=>de.column===D)?e.jsx(r.IconButton,{size:"small",onClick:de=>{de.stopPropagation(),j==null||j(D)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(T.FilterList,{sx:{fontSize:14}})}):null,[i,j]);const or=p.useCallback(D=>{y&&y(D)},[y]),_t=p.useCallback((D,q)=>{if(!$)return;const de=[...f.length>0?f:t.map(J=>J.name)],[Ae]=de.splice(D,1);de.splice(q,0,Ae),$(de)},[$,f,t]),jr=p.useCallback(D=>{if(!y)return;const q=n.find(de=>de.column===D);(!q||q.direction!=="asc")&&y(D)},[y,n]),wr=p.useCallback(D=>{if(!y)return;const q=n.find(de=>de.column===D);q?q.direction==="asc"&&y(D):(y(D),setTimeout(()=>y(D),0))},[y,n]),kr=p.useCallback(D=>{if(!y)return;const q=n.find(de=>de.column===D);q&&(q.direction==="asc"?(y(D),setTimeout(()=>y(D),0)):q.direction==="desc"&&y(D))},[y,n]),Tr=p.useCallback(D=>{_&&_(D,!1)},[_]),Nt=(h==null?void 0:h.enabled)&&o.length>0&&o[0]&&"isGroupHeader"in o[0],nr=p.useMemo(()=>Pe.map(D=>D.name),[Pe]),We=p.useMemo(()=>Z&&Z.trim()?Xn(o,t,Z,nr):o,[o,t,Z,nr]);p.useEffect(()=>{const D=q=>{!le||!G||q.target instanceof HTMLInputElement||q.target instanceof HTMLTextAreaElement||((q.ctrlKey||q.metaKey)&&q.key==="a"&&(q.preventDefault(),le(!0,We.length)),q.key==="Escape"&&(q.preventDefault(),G()))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[le,G,We.length]);const ir=p.useCallback((D,q)=>{se&&(q.shiftKey&&Wt!==null?(q.preventDefault(),we&&we(Wt,D)):(se(D),Kt(D)))},[se,Wt,we]),sr=p.useMemo(()=>We.length>0&&te.size>0&&We.every((D,q)=>te.has(q)),[We,te]);te.size>0;const It=se&&le,zr=p.useCallback(D=>{var Ae;const q=D.groupLevel,de=q*24;return e.jsx(r.TableRow,{onClick:()=>Te==null?void 0:Te(D.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(r.TableCell,{colSpan:Pe.length+(It?1:0),sx:{pl:`${de+24}px`},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[D.isCollapsed?e.jsx(T.ChevronRight,{sx:{fontSize:16}}):e.jsx(T.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:Ln(q,((Ae=h==null?void 0:h.levels[q])==null?void 0:Ae.column)||"",D.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:J=>W(J.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(r.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(D.aggregates).map(([J,ye])=>Vn(ye)).filter(Boolean).join(" • ")})]})})},D.groupKey)},[Pe,It,h,Te]),Et=p.useCallback((D,q)=>{const de=te.has(q),Ae=Tt===q;return e.jsxs(r.TableRow,{"data-row-index":q,onMouseEnter:()=>Ce(q),onMouseLeave:()=>Ce(null),onClick:J=>{!se||J.target.closest("[data-row-action]")||ir(q,J)},onContextMenu:J=>{J.preventDefault(),J.stopPropagation(),Me({mouseX:J.clientX,mouseY:J.clientY,row:D,rowIndex:q})},sx:{height:34,cursor:"pointer",bgcolor:de?J=>W(J.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:de?J=>W(J.palette.warning.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[Pe.map((J,ye)=>e.jsx(r.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"none",minWidth:g[J.name]?`${g[J.name]}px`:`${Kc}px`},children:nd(J,D[J.name],rd(J,Pe))},J.name)),e.jsxs(r.TableCell,{"data-row-action":"true",onClick:J=>J.stopPropagation(),sx:{position:"sticky",right:0,width:Ne?76:40,minWidth:Ne?76:40,maxWidth:Ne?76:40,p:0,border:"none",bgcolor:"transparent",opacity:Ae?1:0,transition:"opacity 0.12s ease",zIndex:2,verticalAlign:"middle",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:.25},children:[Ne&&e.jsx(r.IconButton,{size:"small",onClick:J=>{J.stopPropagation(),J.preventDefault(),Ne(q)},title:dt.has(D)?"Remove from favorites":"Add to favorites",sx:{color:dt.has(D)?"warning.main":"text.secondary","&:hover":{bgcolor:J=>W(J.palette.warning.main,.08),color:"warning.main"}},children:dt.has(D)?e.jsx(T.Star,{sx:{fontSize:18}}):e.jsx(T.StarBorder,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:J=>{J.stopPropagation(),J.preventDefault(),Me({anchorEl:J.currentTarget,row:D,rowIndex:q})},sx:{color:"text.secondary","&:hover":{bgcolor:J=>W(J.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(T.MoreVert,{sx:{fontSize:18}})})]})]},q)},[te,Tt,ir,Pe,g,Cr,Ue,$e,wt,se,zt,P,Me]);return e.jsxs(bt.DndProvider,{backend:Mo.HTML5Backend,children:[e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[It&&De&&G&&e.jsx(Ac,{selectedCount:te.size,selectedRowIds:te,searchedData:We,resolvedFavoritesSet:dt,onExportSelected:De,onClearSelection:G,onBulkSetFavorites:fr}),e.jsxs(r.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:[Oe&&e.jsx(Lc,{}),ae&&ne&&R&&X&&e.jsx(r.Tooltip,{open:Zt,title:e.jsxs(r.Box,{sx:{p:.5},children:[e.jsx(r.Typography,{variant:"caption",sx:{display:"block",fontWeight:500,mb:.25},children:"💡 Search tip"}),e.jsx(r.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:er},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:e.jsx(r.Box,{component:"span",children:e.jsx(Ic,{value:Z||"",onChange:ae,searchHistory:re,onAddToHistory:ne,onToggleFavourite:R,onDeleteHistory:X,disabled:Oe})})}),e.jsx(r.Tooltip,{title:"JSON format guide",children:e.jsx(r.IconButton,{size:"small",onClick:()=>Qt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:D=>W(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(T.InfoOutlined,{sx:{fontSize:20}})})}),kt&&e.jsx(r.Tooltip,{title:Xe?"Show all data":"Show favorites only",children:e.jsxs(r.IconButton,{onClick:kt,size:"small",disabled:Oe,sx:{position:"relative",color:Xe?"warning.main":"text.secondary",bgcolor:Xe?D=>W(D.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Xe?D=>W(D.palette.warning.main,.2):D=>W(D.palette.text.primary,.06),color:Xe?"warning.main":"text.primary"},"&.Mui-disabled":{color:"action.disabled"}},children:[Xe?e.jsx(T.Star,{sx:{fontSize:20}}):e.jsx(T.StarBorder,{sx:{fontSize:20}}),Xe&&Yt.length>0&&e.jsx(r.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"warning.main",color:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:Yt.length})]})}),qt&&rt&&e.jsx(r.Tooltip,{title:"Developer configuration",children:e.jsx(r.IconButton,{size:"small",onClick:rt,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:D=>W(D.palette.text.secondary,.3),"&:hover":{bgcolor:D=>W(D.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(T.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(r.Box,{sx:{flexGrow:1}}),b&&S&&a&&I&&s.length>0&&e.jsx(Ec,{views:s||[],activeViewId:l||"",isDirty:c,onSelectView:b,onCreateView:S,onManageViews:a,onToggleDefault:H,onToggleFavorite:N,onRestoreView:Q,onPermanentDelete:ee,isReadOnly:Oe}),!Oe&&v&&e.jsx(r.Tooltip,{title:"Sort",children:e.jsxs(r.IconButton,{onClick:v,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=>W(D.palette.primary.main,.2):D=>W(D.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(T.SwapVert,{sx:{fontSize:20}}),n.length>0&&e.jsx(r.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Oe&&m&&e.jsx(r.Tooltip,{title:"Filter",children:e.jsxs(r.IconButton,{onClick:m,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=>W(D.palette.primary.main,.2):D=>W(D.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(T.FilterList,{sx:{fontSize:20}}),i.length>0&&e.jsx(r.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:i.length})]})}),!Oe&&x&&e.jsx(r.Tooltip,{title:"Columns",children:e.jsxs(r.IconButton,{onClick:x,size:"small",sx:{position:"relative",color:st>0||Fe?"primary.main":"text.secondary",bgcolor:st>0||Fe?"primary.lighter":"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:st>0||Fe?D=>W(D.palette.primary.main,.2):D=>W(D.palette.text.primary,.06),color:st>0||Fe?"primary.main":"text.primary"}},children:[e.jsx(T.ViewColumn,{sx:{fontSize:20}}),st>0&&e.jsx(r.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"common.white",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:st})]})}),e.jsx(r.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(r.Tooltip,{title:"List view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>Xt("list"),sx:{borderRadius:1,color:_e==="list"?"primary.main":"text.secondary",bgcolor:_e==="list"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:_e==="list"?D=>W(D.palette.primary.main,.2):D=>W(D.palette.text.primary,.06),color:_e==="list"?"primary.main":"text.primary"}},children:e.jsx(T.TableRows,{sx:{fontSize:20}})})}),e.jsx(r.Tooltip,{title:"Grid view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>Xt("grid"),sx:{borderRadius:1,color:_e==="grid"?"primary.main":"text.secondary",bgcolor:_e==="grid"?"primary.lighter":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:_e==="grid"?D=>W(D.palette.primary.main,.2):D=>W(D.palette.text.primary,.06),color:_e==="grid"?"primary.main":"text.primary"}},children:e.jsx(T.GridView,{sx:{fontSize:20}})})}),e.jsx(r.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),e.jsx(r.Tooltip,{title:"Settings",children:e.jsx(r.IconButton,{onClick:D=>xt(D.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:D=>W(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(T.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(r.Popover,{open:!!Se,anchorEl:Se,onClose:()=>xt(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:[oe&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{oe(),xt(null)},disabled:d,sx:{py:1,px:2,gap:1.5},children:[e.jsx(T.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Export"})]}),!Oe&&ce&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{ce(),xt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(T.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Grouping"})]}),M&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{M(),xt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(T.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Audit History"})]}),Y&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{Y(),xt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(T.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Scheduled Reports"})]})]}),e.jsxs(r.Box,{sx:{position:"relative",overflow:"hidden",flex:1,display:"flex",flexDirection:"column"},children:[_e==="grid"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:e.jsx(Fc,{data:We,visibleColumns:Pe,grouping:h,selectedRowIds:te,resolvedFavoritesSet:dt,isReadOnly:Oe,isGrouped:!!Nt,onToggleRowSelection:se||(()=>{}),onToggleRowFavorite:Ne,onToggleGroupCollapse:Te,onViewRow:D=>{zt(D),P(!0)},onEditRow:(D,q)=>{$t(D),ke(q),pt(!0)},onDuplicateRow:(D,q)=>$e==null?void 0:$e(D,q),onDeleteRow:(D,q)=>{Rt(D);const de=Object.values(q).find(Ae=>Ae!=null&&Ae!=="");it(de?String(de):""),ge(!0)}})}),_e==="list"&&e.jsx(r.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(r.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",width:"100%",minWidth:"100%"},stickyHeader:!0,children:[e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[Pe.map((D,q)=>e.jsx(Oc,{column:D,index:q,sortRule:n.find(de=>de.column===D.name),hasFilters:i.some(de=>de.column===D.name),isInSortStack:n.some(de=>de.column===D.name),width:g[D.name],onColumnClick:or,onMoveColumn:_t,onResizeStart:rr,onSort:or,onRemoveSort:kr,onSortAscending:jr,onSortDescending:wr,onOpenFilterForColumn:j||(()=>{}),onClearFiltersForColumn:V||(()=>{}),onHideColumn:Tr,onManageColumns:x||(()=>{}),onManageViews:a||(()=>{}),onResetLayout:ie||(()=>{})},D.name)),e.jsx(r.TableCell,{sx:{position:"sticky",top:0,right:0,width:Ne?76:40,minWidth:Ne?76:40,p:0,border:"none",bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider",zIndex:6}})]})}),e.jsx(r.TableBody,{children:We.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:Pe.length+(It?1:0),align:"center",sx:{py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Nt?We.map((D,q)=>D.isGroupHeader?zr(D):Et(D,q)):We.map((D,q)=>Et(D,q))})]})}),et&&jt&&e.jsx(Vc,{currentPage:He,pageSize:Ct,totalRows:At,totalFields:t.length,onPageChange:et,onPageSizeChange:jt}),!(et&&jt)&&e.jsx(r.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:e.jsxs(r.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",We.length," ",We.length===1?"row":"rows"]})})]})]}),e.jsxs(r.Popover,{open:!!L,onClose:()=>Me(null),anchorEl:(L==null?void 0:L.anchorEl)||null,anchorReference:L!=null&&L.anchorEl?"anchorEl":"anchorPosition",anchorPosition:L&&!L.anchorEl?{top:L.mouseY,left:L.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:L!=null&&L.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{L&&(zt(L.row),P(!0)),Me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(T.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{L&&($t(L.row),ke(L.rowIndex),pt(!0)),Me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(T.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{L&&($e==null||$e(L.rowIndex,L.row)),Me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(T.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),e.jsx(r.Divider,{sx:{my:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{if(L){Rt(L.rowIndex);const D=Object.values(L.row).find(q=>q!=null&&q!=="");it(D?String(D):""),ge(!0)}Me(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(T.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Yc,{open:nt,onClose:()=>{P(!1),zt(null)},row:mr,schema:t,reportName:tt}),e.jsx(Jc,{open:yr,onClose:()=>{pt(!1),$t(null),ke(null)},onSave:D=>{br!==null&&(Ue==null||Ue(br,D))},row:Pt,schema:t,reportName:tt}),e.jsx(qc,{open:Qe,onClose:()=>{ge(!1),Rt(null)},onConfirm:()=>{Re!==null&&(wt==null||wt(Re))},rowPreview:gr}),e.jsx(mi,{isOpen:vr,onClose:()=>Qt(!1)})]})}function Ut({content:t,isDev:o=!1}){const[n,i]=p.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(r.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${t.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>W(s.palette.primary.main,.08)}},children:e.jsx(T.InfoOutlined,{sx:{fontSize:15}})}),e.jsxs(r.Popover,{open:!!n,anchorEl:n,onClose:()=>i(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{width:280,borderRadius:"10px",boxShadow:4,p:0,overflow:"hidden"}},children:[e.jsx(r.Box,{sx:{px:2,py:1.5,bgcolor:s=>W(s.palette.primary.main,.06)},children:e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"primary.main",fontSize:"0.875rem"},children:t.title})}),e.jsx(r.Divider,{}),e.jsxs(r.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.6},children:t.description}),t.tips&&t.tips.length>0&&e.jsx(r.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:t.tips.map((s,l)=>e.jsx(r.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},l))}),o&&t.devNote&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5}}),e.jsxs(r.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>W(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>W(s.palette.warning.main,.2)},children:[e.jsx(r.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:500,display:"block",mb:.25},children:"Dev note"}),e.jsx(r.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.5},children:t.devNote})]})]})]})]})]})}const Gt={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}};function sd({schema:t,filters:o,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:s,onClearAll:l,onClose:c,focusColumn:d}){const[u,f]=p.useState(""),[g,h]=p.useState(""),[y,w]=p.useState(""),[k,m]=p.useState([]),v=$r();p.useEffect(()=>{m([...o])},[o]),p.useEffect(()=>{d&&f(d)},[d]);const j=p.useCallback(()=>{f(""),h(""),w("")},[]),b=p.useMemo(()=>t.filter(x=>x.type!=="mixed"&&x.type!=="null"&&x.type!=="array"&&x.type!=="object"),[t]),S=t.find(x=>x.name===u),a=p.useMemo(()=>{const x=S?rn(S.type):[],F=v.filter.allowedOperators;return F.length>0?x.filter($=>F.includes($.value)):x},[S]),I=p.useCallback(()=>!(!u||!g||Ur(g)&&!y.trim()||k.length>=v.filter.maxConditions),[u,g,y,k,v]),O=p.useCallback(()=>{if(!I())return;const x={column:u,operator:g};if(Ur(g)){const $=S==null?void 0:S.type;x.value=$==="number"?Number(y):y}if(k.some($=>$.column===x.column&&$.operator===x.operator&&$.value===x.value)){j();return}m([...k,x]),j()},[I,u,g,S,y,k,j]),H=p.useCallback(x=>{m(k.filter((F,$)=>$!==x))},[k]),N=p.useMemo(()=>k.length!==o.length?!0:JSON.stringify(k)!==JSON.stringify(o),[k,o]),Q=p.useCallback(()=>{l(),k.forEach(x=>n(x)),c()},[k,n,l,c]),ee=p.useCallback(()=>{m([...o]),j(),c()},[o,j,c]),oe=p.useCallback(x=>{var V;const F=t.find(ie=>ie.name===x.column);if(!F)return"";const _=((V=rn(F.type).find(ie=>ie.value===x.operator))==null?void 0:V.label)||x.operator;return Ur(x.operator)?`${x.column} ${_.toLowerCase()} "${x.value}"`:`${x.column} ${_.toLowerCase()}`},[t]);return e.jsx(r.Box,{onClick:ee,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(r.Paper,{onClick:x=>x.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(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Filter columns"}),e.jsx(Ut,{content:Gt.filter,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:ee,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:[e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsx(r.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(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(r.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(r.Select,{value:u,onChange:x=>{f(x.target.value),h(""),w("")},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:b.map(x=>e.jsxs(r.MenuItem,{value:x.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:F=>W(F.palette.primary.main,.2)}}},children:[vt(x.name)," (",x.type,")"]},x.name))})]}),u&&e.jsxs(r.FormControl,{size:"small",fullWidth:!0,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Operator"}),e.jsx(r.Select,{value:g,onChange:x=>{h(x.target.value),w("")},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(x=>e.jsx(r.MenuItem,{value:x.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:F=>W(F.palette.primary.main,.2)}}},children:x.label},x.value))})]}),g&&Ur(g)&&e.jsx(r.TextField,{size:"small",fullWidth:!0,type:(S==null?void 0:S.type)==="number"?"number":"text",value:y,onChange:x=>w(x.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(r.Button,{onClick:O,disabled:!I(),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"})]}),k.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Active filters (",k.length,")"]}),e.jsx(r.Button,{onClick:()=>m([]),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(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:k.map((x,F)=>e.jsx(r.Chip,{label:oe(x),onDelete:()=>H(F),sx:{bgcolor:"primary.lighter",color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:$=>`1px solid ${W($.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:$=>W($.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"}}}},F))})]})]}),e.jsxs(r.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(r.Button,{onClick:ee,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(r.Button,{onClick:Q,disabled:!N,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 ad({rule:t,index:o,onToggleDirection:n,onRemove:i,onMove:s}){const l=p.useRef(null),[{handlerId:c},d]=bt.useDrop({accept:Mn,collect(g){return{handlerId:g.getHandlerId()}},hover(g,h){var b;if(!l.current)return;const y=g.index,w=o;if(y===w)return;const k=(b=l.current)==null?void 0:b.getBoundingClientRect(),m=(k.bottom-k.top)/2,v=h.getClientOffset(),j=((v==null?void 0:v.y)??0)-k.top;y<w&&j<m||y>w&&j>m||(s(y,w),g.index=w)}}),[{isDragging:u},f]=bt.useDrag({type:Mn,item:()=>({index:o}),collect:g=>({isDragging:g.isDragging()})});return f(d(l)),e.jsxs(r.Box,{ref:l,"data-handler-id":c,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.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(r.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(r.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(r.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(r.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),e.jsx(r.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),e.jsx(r.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(r.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:e.jsxs(r.Select,{value:t.direction,onChange:g=>n(o,g.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(r.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:g=>W(g.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(r.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:g=>W(g.palette.primary.main,.2)}}},children:"Descending"})]})}),e.jsx(r.IconButton,{onClick:()=>i(o),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(T.Close,{sx:{fontSize:18}})})]})}function ld({schema:t,sortStack:o,onUpdateSortStack:n,onClose:i}){const[s,l]=p.useState(""),[c,d]=p.useState([]);p.useEffect(()=>{d([...o])},[o]);const u=$r(),f=p.useCallback(()=>!(c.length>=u.sort.maxLevels||!s||c.some(b=>b.column===s)),[c,s]),g=p.useCallback(()=>{if(!f())return;const b=c.length+1,S={column:s,direction:"asc",priority:b};d([...c,S]),l("")},[f,s,c]),h=p.useCallback(b=>{const a=c.filter((I,O)=>O!==b).map((I,O)=>({...I,priority:O+1}));d(a)},[c]),y=p.useCallback((b,S)=>{const a=[...c];a[b]={...a[b],direction:S},d(a)},[c]),w=p.useCallback((b,S)=>{const a=[...c],[I]=a.splice(b,1);a.splice(S,0,I);const O=a.map((H,N)=>({...H,priority:N+1}));d(O)},[c]),k=p.useCallback(()=>{d([])},[]),m=p.useCallback(()=>{n(c),i()},[c,n,i]),v=p.useCallback(()=>{d([...o]),l(""),i()},[o,i]),j=t.filter(b=>!c.some(S=>S.column===b.name));return e.jsx(bt.DndProvider,{backend:Mo.HTML5Backend,children:e.jsx(r.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(r.Paper,{onClick:b=>b.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(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),e.jsx(Ut,{content:Gt.sort,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.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(T.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.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(r.Box,{sx:{mb:2.5},children:[e.jsx(r.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(r.FormControl,{size:"small",fullWidth:!0,disabled:c.length>=u.sort.maxLevels,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),e.jsxs(r.Select,{value:s,onChange:b=>l(b.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(r.MenuItem,{value:"",disabled:!0,sx:{display:"none"},children:e.jsx("em",{children:"Select column..."})}),j.map(b=>e.jsx(r.MenuItem,{value:b.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:S=>W(S.palette.primary.main,.2)}}},children:vt(b.name)},b.name))]})]}),e.jsx(r.Button,{onClick:g,disabled:!f(),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"})]}),c.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[e.jsxs(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",c.length,"/",u.sort.maxLevels,")"]}),e.jsx(r.Button,{onClick:k,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(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:c.map((b,S)=>e.jsx(ad,{rule:b,index:S,onToggleDirection:y,onRemove:h,onMove:w},`${b.column}-${S}`))})]})]}),e.jsxs(r.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(r.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(r.Button,{onClick:m,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 cd({views:t,activeViewId:o,onSelectView:n,onCreateView:i,onEditView:s,onDeleteView:l,onRestoreView:c,onPermanentDelete:d,onClose:u}){return e.jsxs(r.Dialog,{open:!0,onClose:u,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(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Manage Views",e.jsx(r.IconButton,{onClick:u,size:"small",sx:{color:"text.secondary"},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.DialogContent,{children:[e.jsx(r.Box,{sx:{mb:2},children:e.jsx(r.Button,{onClick:i,variant:"contained",startIcon:e.jsx(T.Add,{sx:{fontSize:16}}),size:"small",children:"Create New Report View"})}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:t.map(f=>e.jsx(r.Paper,{sx:{p:2,border:1,borderColor:f.isDeleted?"error.light":o===f.id?"primary.main":"divider",bgcolor:f.isDeleted?g=>W(g.palette.error.main,.12):o===f.id?g=>W(g.palette.primary.main,.12):"background.paper",opacity:f.isDeleted?.75:1,cursor:f.isDeleted?"default":"pointer","&:hover":f.isDeleted?{}:{bgcolor:"action.hover"}},onClick:()=>!f.isDeleted&&n(f.id),elevation:0,children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsxs(r.Box,{sx:{flex:1},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,textDecoration:f.isDeleted?"line-through":"none",color:f.isDeleted?"text.secondary":"text.primary"},children:f.name}),f.isDeleted&&e.jsx(r.Chip,{label:"Deleted",size:"small",color:"error",sx:{height:20}}),f.isDefault&&e.jsx(r.Chip,{label:"Default",size:"small",color:"primary",sx:{height:20}}),f.isFavorite&&e.jsx(r.Chip,{label:"★ Favorite",size:"small",sx:{height:20}})]}),f.description&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:f.description})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[!f.isDeleted&&e.jsxs(e.Fragment,{children:[e.jsx(r.IconButton,{size:"small",onClick:g=>{g.stopPropagation(),s(f.id)},title:"Edit view",children:e.jsx(T.Edit,{sx:{fontSize:16}})}),e.jsx(r.IconButton,{size:"small",onClick:g=>{g.stopPropagation(),l(f.id)},title:"Delete view",sx:{"&:hover":{color:"error.main"}},children:e.jsx(T.Delete,{sx:{fontSize:16}})})]}),f.isDeleted&&c&&e.jsx(r.IconButton,{size:"small",onClick:g=>{g.stopPropagation(),c(f.id)},title:"Restore view",sx:{color:"success.main"},children:e.jsx(T.Undo,{sx:{fontSize:16}})}),f.isDeleted&&d&&e.jsx(r.IconButton,{size:"small",onClick:g=>{g.stopPropagation(),d(f.id)},title:"Delete permanently",sx:{color:"error.main"},children:e.jsx(T.Delete,{sx:{fontSize:16}})})]})]})},f.id))})]}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:u,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 Wn({currentSnapshot:t,onSave:o,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:l="",initialIsDefault:c=!1}){const[d,u]=p.useState(s),[f,g]=p.useState(l),[h,y]=p.useState(c),w=()=>{d.trim()&&(o(d.trim(),f.trim(),h),n())},k=v=>{v.key==="Enter"&&!v.shiftKey?w():v.key==="Escape"&&n()},m=()=>i&&s?`Update ${s} view`:"Create New Report View";return e.jsxs(r.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(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[m(),e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[e.jsx(r.TextField,{label:"View Name",required:!0,value:d,onChange:v=>u(v.target.value),onKeyDown:k,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small"}),e.jsx(r.TextField,{label:"Description (optional)",value:f,onChange:v=>g(v.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),e.jsxs(r.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:1},children:"This view will capture:"}),e.jsxs(r.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: ",ys(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:h,onChange:v=>y(v.target.checked),size:"small"}),label:e.jsx(r.Typography,{variant:"body2",children:"Set as default view"})})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"grey.50",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.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(r.Button,{onClick:w,disabled:!d.trim(),variant:"contained",startIcon:e.jsx(T.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 dd({viewName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.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(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Delete View",e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[e.jsx(T.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),e.jsxs(r.Box,{children:[e.jsxs(r.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",e.jsxs("strong",{children:['"',t,'"']}),"?"]}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.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:"action.selected",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",disableElevation:!0,sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,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":{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 bi=80,vi=600,Rn="COLUMN";function ud({column:t,index:o,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:l,moveColumn:c}){const d=p.useRef(null),[u,f]=p.useState(i.toString());p.useEffect(()=>{f(i.toString())},[i]);const[{handlerId:g},h]=bt.useDrop({accept:Rn,collect(b){return{handlerId:b.getHandlerId()}},hover(b,S){var ee;if(!d.current)return;const a=b.index,I=o;if(a===I)return;const O=(ee=d.current)==null?void 0:ee.getBoundingClientRect(),H=(O.bottom-O.top)/2,N=S.getClientOffset(),Q=((N==null?void 0:N.y)??0)-O.top;a<I&&Q<H||a>I&&Q>H||(c(a,I),b.index=I)}}),[{isDragging:y},w]=bt.useDrag({type:Rn,item:()=>({index:o}),collect:b=>({isDragging:b.isDragging()})});w(h(d));const k=()=>{const b=parseInt(u);if(isNaN(b)){f(i.toString());return}const S=Math.max(bi,Math.min(vi,b));f(S.toString()),l(t.name,S)},m=b=>{(b===""||/^\d+$/.test(b))&&f(b)},v=b=>{b.key==="Enter"&&(b.preventDefault(),k(),b.target.blur())},j=b=>({string:"primary.main",number:"success.main",boolean:"#9334e6",array:"#ea8600",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[b]||"text.secondary";return e.jsxs(r.TableRow,{ref:d,"data-handler-id":g,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(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(r.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:e.jsx(T.DragIndicator,{sx:{fontSize:20}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:vt(t.name)})]})}),e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsx(r.Chip,{label:t.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${j(t.type)}15`,color:j(t.type),border:`1px solid ${j(t.type)}30`,"& .MuiChip-label":{px:1}}})}),e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.TextField,{type:"text",value:u,onChange:b=>m(b.target.value),onBlur:k,onKeyDown:v,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(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:"px"})]})}),e.jsx(r.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(r.IconButton,{onClick:()=>s(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(T.Visibility,{sx:{fontSize:20}}):e.jsx(T.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(r.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?"#e6f4ea":"grey.100",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function pd({schema:t,columnVisibility:o,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:l="",onUpdateColumnVisibility:c,onUpdateColumnOrder:d,onUpdateColumnWidth:u,onResetLayout:f,onSaveToCurrentView:g,onSaveToAllViews:h,onSelectView:y,onClose:w}){const[k,m]=p.useState(!1),[v,j]=p.useState(n),[b,S]=p.useState("all"),[a,I]=p.useState(null);p.useEffect(()=>{j(n)},[n]);const O=(V,ie)=>{const ce=[...v],[Te]=ce.splice(V,1);ce.splice(ie,0,Te),j(ce),d(ce)},H=()=>{f(),m(!1)},Q=v.map(V=>t.find(ie=>ie.name===V)).filter(V=>V!==void 0).filter(V=>{const ie=o[V.name]??!0;return b==="active"?ie:b==="hidden"?!ie:!0}),ee=Object.values(o).filter(V=>V).length,oe=t.length,x=s.find(V=>V.id===l),F=s.filter(V=>!V.isDeleted),$=F.length>1,_=p.useMemo(()=>{if(!x)return!1;const V=x.snapshot,ie=JSON.stringify(o)!==JSON.stringify(V.columnVisibility),ce=JSON.stringify(n)!==JSON.stringify(V.columnOrder),Te=JSON.stringify(i)!==JSON.stringify(V.columnWidths);return ie||ce||Te},[x,o,n,i]);return e.jsx(bt.DndProvider,{backend:Mo.HTML5Backend,children:e.jsx(r.Box,{onClick:w,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(r.Paper,{onClick:V=>V.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(r.Box,{sx:{px:3,pt:2,pb:1.5,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs(r.Box,{sx:{flex:1},children:[e.jsxs(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",e.jsx(Ut,{content:Gt.columns,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5},children:[ee," of ",oe," columns visible • Drag to reorder"]})]}),F.length>0&&y&&e.jsxs(r.Box,{sx:{ml:2},children:[e.jsx(r.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(r.Button,{onClick:V=>I(V.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(T.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(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(x==null?void 0:x.name)||"Select View"})}),e.jsx(r.Menu,{anchorEl:a,open:!!a,onClose:()=>I(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:"0 2px 6px rgba(60, 64, 67, 0.15)"}},children:F.map(V=>e.jsx(r.MenuItem,{onClick:()=>{y(V.id),I(null)},selected:V.id===l,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:ie=>W(ie.palette.primary.main,.2)}}},children:V.name},V.id))})]}),e.jsx(r.IconButton,{onClick:w,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(T.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Tabs,{value:b,onChange:(V,ie)=>S(ie),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:"primary.main",height:3}},children:[e.jsx(r.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(r.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(r.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(r.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(r.Table,{stickyHeader:!0,sx:{minWidth:650},children:[e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{children:[e.jsx(r.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(r.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(r.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(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",e.jsx(r.Tooltip,{title:`Column width in pixels (min: ${bi}px, max: ${vi}px)`,arrow:!0,placement:"top",children:e.jsx(T.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),e.jsx(r.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(r.TableBody,{children:Q.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):Q.map((V,ie)=>e.jsx(ud,{column:V,index:ie,isVisible:o[V.name]??!0,width:i[V.name]||150,onToggleVisibility:c,onWidthChange:u||(()=>{}),moveColumn:O},V.name))})]})}),e.jsxs(r.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(r.Button,{onClick:()=>m(!0),disabled:!_,variant:"outlined",startIcon:e.jsx(T.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(r.Stack,{direction:"row",spacing:1.25,children:[g&&e.jsx(r.Button,{onClick:()=>{g(),w()},disabled:!_,variant:"contained",startIcon:e.jsx(T.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"}),h&&$&&e.jsx(r.Button,{onClick:()=>{h(),w()},disabled:!_||!$,variant:"contained",startIcon:e.jsx(T.GridView,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"success.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:"success.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 all views"})]})]}),k&&e.jsx(r.Box,{onClick:()=>m(!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(r.Paper,{onClick:V=>V.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(r.Box,{sx:{px:3,py:2.5},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),e.jsx(r.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(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"grey.50"},children:[e.jsx(r.Button,{onClick:()=>m(!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(r.Button,{onClick:H,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 xd({schema:t,grouping:o,onApply:n,onClose:i}){var O;const[s,l]=p.useState(o||{enabled:!1,levels:[],collapsedGroups:[]}),[c,d]=p.useState(""),[u,f]=p.useState(null),g=p.useMemo(()=>ps(t),[t]),h=p.useMemo(()=>g.filter(H=>!s.levels.some((N,Q)=>N.column===H.name&&Q!==u)),[g,s.levels,u]),y=$r(),w=s.levels.length<y.grouping.maxLevels&&h.length>0,k=p.useCallback(()=>{!w||!c||(l({...s,levels:[...s.levels,{column:c}],enabled:!0}),d(""))},[w,c,s]),m=p.useCallback(H=>{const N=s.levels.filter((Q,ee)=>ee!==H);if(N.length===0){n(null),i();return}l({...s,levels:N,enabled:N.length>0})},[s,n,i]),v=p.useCallback(H=>{f(H),d(s.levels[H].column)},[s.levels]),j=p.useCallback(()=>{if(u===null||!c)return;const H=[...s.levels];H[u]={column:c},l({...s,levels:H}),f(null),d("")},[u,c,s]),b=p.useCallback(()=>{f(null),d("")},[]),S=p.useCallback((H,N)=>{const Q=N==="up"?H-1:H+1;if(Q<0||Q>=s.levels.length)return;const ee=[...s.levels],[oe]=ee.splice(H,1);ee.splice(Q,0,oe),l({...s,levels:ee})},[s]),a=p.useCallback(()=>{n(null),i()},[n,i]),I=p.useCallback(()=>{s.levels.length===0?n(null):n({...s,enabled:!0,collapsedGroups:(o==null?void 0:o.collapsedGroups)||[]}),i()},[s,o,n,i]);return e.jsx(r.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(r.Paper,{onClick:H=>H.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(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),e.jsx(Ut,{content:Gt.grouping,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.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(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:e.jsxs(r.Stack,{spacing:2.5,children:[u===null&&e.jsxs(r.Box,{children:[e.jsx(r.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(r.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(r.Select,{value:c,onChange:H=>d(H.target.value),disabled:!w,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(r.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),h.map(H=>e.jsxs(r.MenuItem,{value:H.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"grey.100"},"&.Mui-selected":{bgcolor:"primary.lighter","&:hover":{bgcolor:N=>W(N.palette.primary.main,.2)}}},children:[vt(H.name)," (",H.type.toUpperCase(),")"]},H.name))]})}),e.jsx(r.Button,{onClick:k,disabled:!w||!c,variant:"outlined",startIcon:e.jsx(T.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"}),s.levels.length>=y.grouping.maxLevels&&e.jsx(r.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"}),g.length===0&&e.jsx(r.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."})]}),u!==null&&e.jsxs(r.Alert,{severity:"warning",sx:{borderRadius:"8px",border:"1px solid #fdd663",bgcolor:"#fef7e0","& .MuiAlert-icon":{color:"#ea8600"}},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"text.primary"},children:["Edit Group Level ",u+1]}),e.jsx(r.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(r.Select,{value:c,onChange:H=>d(H.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(r.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),e.jsxs(r.MenuItem,{value:s.levels[u].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[s.levels[u].column," (",(O=t.find(H=>H.name===s.levels[u].column))==null?void 0:O.type.toUpperCase(),")"]}),h.filter(H=>H.name!==s.levels[u].column).map(H=>e.jsxs(r.MenuItem,{value:H.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:"primary.lighter"}},children:[vt(H.name)," (",H.type.toUpperCase(),")"]},H.name))]})}),e.jsxs(r.Stack,{direction:"row",spacing:1.5,children:[e.jsx(r.Button,{onClick:j,disabled:!c,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(r.Button,{onClick:b,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"})]})]}),s.levels.length>0&&u===null&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[e.jsx(r.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),e.jsx(r.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(r.Stack,{spacing:1.5,children:s.levels.map((H,N)=>{const Q=t.find(ee=>ee.name===H.column);return e.jsxs(r.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(r.Chip,{label:`L${N+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(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:H.column}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:Q==null?void 0:Q.type.toUpperCase()})]}),e.jsxs(r.Stack,{direction:"row",spacing:.5,children:[e.jsx(r.IconButton,{size:"small",onClick:()=>S(N,"up"),disabled:N===0,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(T.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>S(N,"down"),disabled:N===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(T.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>v(N),sx:{color:"text.secondary","&:hover":{bgcolor:"grey.100",color:"primary.main"}},children:e.jsx(T.Edit,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>m(N),sx:{color:"text.secondary","&:hover":{bgcolor:"rgba(217, 48, 37, 0.08)",color:"error.main"}},children:e.jsx(T.Delete,{sx:{fontSize:18}})})]})]},N)})})]})]})}),e.jsxs(r.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(r.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(r.Button,{onClick:I,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 fd={filters:T.FilterList,sorting:T.UnfoldMore,visibility:T.Visibility,order:T.ViewColumn,widths:T.Straighten,grouping:T.Layers};function hd({changes:t,onClose:o}){const n=i=>({filters:"primary",sorting:"secondary",visibility:"success",order:"warning",widths:"info",grouping:"error"})[i]||"default";return e.jsxs(r.Dialog,{open:!0,onClose:o,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(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["View Changes Summary",e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary"},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{dividers:!0,children:t.length===0?e.jsx(r.Box,{sx:{textAlign:"center",py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No changes detected"})}):e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"The following modifications have been made to this view:"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:t.map((i,s)=>{const l=fd[i.category];return e.jsxs(r.Paper,{elevation:0,sx:{display:"flex",gap:1.5,p:1.5,border:1,borderColor:"divider",borderRadius:1},children:[e.jsx(r.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(l,{sx:{fontSize:16}})}),e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:i.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:i.description})]})]},s)})})]})}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"common.white",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 md({viewName:t,isDefaultView:o,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:s,onCancel:l}){const[c,d]=p.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:"primary.lighter",borderBottom:u=>`1px solid ${W(u.palette.primary.main,.3)}`,zIndex:10},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:1.25},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:"text.primary"},children:['Unsaved changes to "',t,'"']}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Button,{onClick:l,variant:"text",size:"small",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2,py:.625,borderRadius:"18px",color:"text.secondary",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:"rgba(60, 64, 67, 0.08)",color:"text.primary"}},children:"Discard"}),e.jsx(r.Button,{onClick:s,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"})]})]})}),c&&e.jsx(hd,{changes:n,onClose:()=>d(!1)})]})}function gd({onExportAnyway:t,onSaveAndExport:o,onCancel:n}){return e.jsx(r.Box,{sx:{mb:2,mx:3,mt:2},children:e.jsxs(r.Alert,{severity:"warning",icon:e.jsx(T.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(T.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:"You are exporting with unsaved view changes"}),e.jsx(r.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Button,{onClick:o,variant:"contained",color:"primary",startIcon:e.jsx(T.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(r.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(T.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}function yd({auditHistory:t,onClose:o}){const[n,i]=p.useState(new Set),s=c=>{i(d=>{const u=new Set(d);return u.has(c)?u.delete(c):u.add(c),u})},l=[...t].sort((c,d)=>new Date(d.timestamp).getTime()-new Date(c.timestamp).getTime());return e.jsx(r.Box,{onClick:o,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(r.Paper,{onClick:c=>c.stopPropagation(),elevation:0,sx:{position:"relative",width:480,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(r.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{children:[e.jsxs(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Audit history",e.jsx(Ut,{content:Gt.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[l.length," event",l.length!==1?"s":""," recorded"]})]}),e.jsx(r.IconButton,{onClick:o,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto",px:2,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"grey.300",borderRadius:4,"&:hover":{bgcolor:"grey.400"}}},children:l.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,textAlign:"center"},children:[e.jsx(T.AccessTime,{sx:{fontSize:64,color:"divider",mb:2}}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",mb:.5},children:"No audit events recorded yet"}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"grey.400"},children:"Changes to this report will appear here"})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:l.map(c=>{const d=n.has(c.id),u=As(c.feature);return e.jsxs(r.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(r.Box,{onClick:()=>s(c.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(r.Box,{sx:{flexShrink:0,color:"text.secondary",transition:"transform 0.2s ease",transform:"rotate(0deg)"},children:d?e.jsx(T.KeyboardArrowDown,{sx:{fontSize:20}}):e.jsx(T.ChevronRight,{sx:{fontSize:20}})}),e.jsx(r.Chip,{label:Os(c.feature),size:"small",sx:{height:24,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${u}15`,color:u,border:`1px solid ${u}30`,"& .MuiChip-label":{px:1}}}),e.jsx(r.Typography,{variant:"body2",sx:{flex:1,fontWeight:400,fontSize:"0.875rem",color:"text.primary"},children:Ds(c.action)}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(T.AccessTime,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:Ms(c.timestamp)})]}),c.user&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,flexShrink:0},children:[e.jsx(T.Person,{sx:{fontSize:16,color:"text.secondary",opacity:.6}}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:c.user})]})]}),e.jsx(r.Collapse,{in:d,timeout:200,children:e.jsxs(r.Box,{sx:{px:2.5,pb:2,pt:1.5,borderTop:"1px solid divider",bgcolor:"grey.50"},children:[c.previousState&&e.jsxs(r.Box,{sx:{mb:2},children:[e.jsx(r.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(r.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(c.previousState)})]}),c.newState&&e.jsxs(r.Box,{children:[e.jsx(r.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(r.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(c.newState)})]})]})})]},c.id)})})})]})})}function bd({onSave:t,onClose:o}){const[n,i]=p.useState(""),[s,l]=p.useState(""),[c,d]=p.useState(""),[u,f]=p.useState([]),[g,h]=p.useState(""),[y,w]=p.useState(""),k=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),m=()=>{const I=c.trim();if(I){if(!k(I)){w("Please enter a valid email address");return}if(u.includes(I)){w("This email is already added");return}f([...u,I]),d(""),w("")}},v=I=>{f(u.filter(O=>O!==I))},j=I=>{I.key==="Enter"&&(I.preventDefault(),m())},b=()=>{if(!n.trim()){h("Preset name is required");return}t(n.trim(),s.trim(),u.length>0?u:void 0)},S=I=>{i(I),g&&h("")},a=I=>{d(I),y&&w("")};return e.jsx(r.Box,{onClick:o,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(r.Paper,{onClick:I=>I.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(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),e.jsx(r.IconButton,{onClick:o,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"grey.100",color:"text.primary"}},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.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(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(r.Alert,{severity:"info",icon:e.jsx(T.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:I=>`1px solid ${W(I.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(r.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(r.Box,{children:[e.jsx(r.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(r.TextField,{required:!0,value:n,onChange:I=>S(I.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!g,helperText:g,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(r.Box,{children:[e.jsx(r.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(r.TextField,{value:s,onChange:I=>l(I.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(r.Box,{children:[e.jsx(r.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(r.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[e.jsx(r.TextField,{value:c,onChange:I=>a(I.target.value),onKeyPress:j,placeholder:"Enter email address",error:!!y,helperText:y,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(T.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(r.Button,{onClick:m,variant:"outlined",startIcon:e.jsx(T.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"})]}),u.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(I=>e.jsx(r.Chip,{label:I,onDelete:()=>v(I),deleteIcon:e.jsx(T.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"}}}},I))}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:u.length>0?`An email with the shareable link will be sent to ${u.length} recipient${u.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),e.jsxs(r.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(r.Button,{onClick:o,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(r.Button,{onClick:b,variant:"contained",startIcon:e.jsx(T.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 vd({presetName:t,onClear:o}){return e.jsx(r.Chip,{icon:e.jsx(T.Link,{sx:{fontSize:14}}),label:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset: ",e.jsx(r.Box,{component:"span",sx:{fontWeight:600},children:t})]}),onDelete:o,deleteIcon:e.jsx(r.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:e.jsx(T.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>W(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 Sd({presets:t,reportId:o,onOpenPreset:n,onDeletePreset:i,onClose:s}){const[l,c]=p.useState(null),d=u=>new Date(u).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx(r.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(r.Paper,{onClick:u=>u.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:"common.white",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(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[t.length," saved ",t.length===1?"preset":"presets"]})]}),e.jsx(r.IconButton,{onClick:s,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"text.primary"}},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"divider",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:t.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(T.Share,{sx:{fontSize:48,color:"divider",mb:2}}),e.jsx(r.Typography,{variant:"body1",sx:{fontSize:"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"#80868b",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:t.map(u=>e.jsxs(r.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"common.white",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:"0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.05)"}},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"text.primary",mb:.5},children:u.name}),u.description&&e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:u.description})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(r.Chip,{label:`Created ${d(u.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"text.secondary","& .MuiChip-label":{px:1}}}),e.jsx(r.Chip,{label:`By ${u.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"#f1f3f4",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),e.jsx(r.Divider,{sx:{my:1.5,borderColor:"#f1f3f4"}}),e.jsx(r.Box,{sx:{display:"flex",gap:1},children:e.jsx(r.Button,{onClick:()=>i(u.id,u.name),variant:"outlined",size:"small",startIcon:e.jsx(T.Delete,{sx:{fontSize:16}}),sx:{textTransform:"none",fontSize:"0.8125rem",fontWeight:500,color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:"4px","&:hover":{borderColor:"error.main",bgcolor:"rgba(217, 48, 37, 0.04)"}},children:"Delete"})})]},u.id))})}),e.jsx(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:e.jsx(r.Button,{onClick:s,variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"common.white",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 Cd({totalRows:t,visibleRows:o,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,onExport:l,onClose:c}){const d=$r(),[u,f]=p.useState(d.export.allowedFormats[0]||"csv"),[g,h]=p.useState("visible"),[y,w]=p.useState("visible"),k=t>5e4,m=g==="visible"?o:t,v=y==="visible"?i:s,j=()=>{l({format:u,scope:g,columnScope:y}),c()},b={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"};return e.jsx(r.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(r.Paper,{onClick:S=>S.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:"common.white",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(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Export report"}),e.jsx(Ut,{content:Gt.export,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:c,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"#f1f3f4",color:"text.primary"}},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"divider",borderRadius:4,"&:hover":{bgcolor:"#bdc1c6"}}},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[k&&e.jsxs(r.Alert,{severity:"warning",icon:e.jsx(T.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:"text.primary",mb:.5},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.secondary"}},children:[e.jsx(r.AlertTitle,{children:"Large dataset warning"}),"This export contains over 50,000 rows. Processing may take a few moments."]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Format"}),e.jsxs(r.RadioGroup,{value:u,onChange:S=>f(S.target.value),children:[d.export.allowedFormats.includes("csv")&&e.jsx(r.FormControlLabel,{value:"csv",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"CSV"}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},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(r.FormControlLabel,{value:"excel",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Excel (.xlsx)"}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},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(r.FormControlLabel,{value:"json",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"JSON"}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},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(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Rows"}),e.jsxs(r.RadioGroup,{value:g,onChange:S=>h(S.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible rows"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",o.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(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All rows"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},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(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,textTransform:"uppercase"},children:"Columns"}),e.jsxs(r.RadioGroup,{value:y,onChange:S=>w(S.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible columns only"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},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(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:{color:"text.secondary","&.Mui-checked":{color:"primary.main"}}}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All columns"}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export all ",s," 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(r.Box,{sx:{pt:1},children:[e.jsx(r.Divider,{sx:{mb:2,borderColor:"divider"}}),e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Format:"}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:b[u]})]}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Rows to export:"}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:m.toLocaleString()})]}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Columns to export:"}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:v})]})]})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"#f8f9fa"},children:[e.jsx(r.Button,{onClick:c,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.jsxs(r.Button,{onClick:j,variant:"contained",startIcon:e.jsx(T.Download,{sx:{fontSize:18}}),sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,bgcolor:"primary.main",color:"common.white",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:["Download ",b[u]]})]})]})})}function jd({warning:t,onDismiss:o}){return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:"warning",icon:e.jsx(T.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:e.jsx(T.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[e.jsx(r.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),e.jsx(r.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:t.message}),e.jsxs(r.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 wd({error:t,onDismiss:o,autoDismiss:n=!0,autoDismissDelay:i=5e3}){p.useEffect(()=>{if(n){const d=setTimeout(()=>{o()},i);return()=>clearTimeout(d)}},[n,i,o]);const l=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(T.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(T.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(T.InfoOutlined,{sx:{fontSize:20}})}}})(),c=Ys(t);return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:l.severity,icon:l.icon,action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:`${l.severity}.main`},children:e.jsx(T.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${l.severity}.main`,boxShadow:3},children:[e.jsxs(r.AlertTitle,{sx:{fontWeight:600},children:[t.context.charAt(0).toUpperCase()+t.context.slice(1)," Error"]}),e.jsx(r.Box,{sx:{fontSize:"body2.fontSize"},children:c}),t.details&&process.env.NODE_ENV==="development"&&e.jsx(r.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 kd extends p.Component{constructor(o){super(o),this.handleReset=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(o){return{hasError:!0,error:o}}componentDidCatch(o,n){console.error("[ErrorBoundary] Caught error:",o,n),this.props.onError&&this.props.onError(o,n)}render(){var o,n;return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx(r.Paper,{sx:{bgcolor:i=>W(i.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(T.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:600},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),e.jsx(r.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((o=this.state.error)==null?void 0:o.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&e.jsx(r.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:i=>W(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(r.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(T.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Dr({children:t,feature:o,onError:n}){return e.jsx(kd,{context:o,onError:(i,s)=>{n&&n(i)},fallback:e.jsxs(r.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(T.Warning,{sx:{fontSize:20}}),children:[e.jsxs(r.AlertTitle,{children:[o," temporarily unavailable"]}),"Other features continue to work normally"]}),children:t})}const Td=[{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"}],zd=[{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 Or({children:t,active:o}){return e.jsx(r.Box,{hidden:!o,sx:{pt:2.5,pb:1,display:o?"flex":"none",flexDirection:"column",gap:2.5},children:t})}function Id({open:t,onClose:o,config:n,onApply:i}){const[s,l]=p.useState(0),[c,d]=p.useState(n),u=()=>d(n),f=()=>d(Ze),g=()=>{i(c),o()},h={sort:v=>d(j=>({...j,sort:{...j.sort,...v}})),filter:v=>d(j=>({...j,filter:{...j.filter,...v}})),columns:v=>d(j=>({...j,columns:{...j.columns,...v}})),grouping:v=>d(j=>({...j,grouping:{...j.grouping,...v}})),export:v=>d(j=>({...j,export:{...j.export,...v}}))},y=v=>{const j=c.filter.allowedOperators,b=j.includes(v)?j.filter(S=>S!==v):[...j,v];b.length!==0&&h.filter({allowedOperators:b})},w=v=>{const j=c.export.allowedFormats,b=j.includes(v)?j.filter(S=>S!==v):[...j,v];b.length!==0&&h.export({allowedFormats:b})},k=[{label:"Sort",icon:e.jsx(T.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(T.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(T.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(T.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(T.Download,{sx:{fontSize:17}})}],m=v=>JSON.stringify(c[v])===JSON.stringify(Ze[v]);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(60,64,67,0.2)"}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(r.Box,{sx:{width:32,height:32,borderRadius:"8px",bgcolor:v=>W(v.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem"},children:"⚙️"}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"text.secondary"},children:e.jsx(T.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(r.Tabs,{value:s,onChange:(v,j)=>l(j),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:k.map((v,j)=>e.jsx(r.Tab,{label:v.label,icon:v.icon,iconPosition:"start"},j))})}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Or,{active:s===0,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!m("sort")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),e.jsx(r.Slider,{value:c.sort.maxLevels,onChange:(v,j)=>h.sort({maxLevels:j}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]}),e.jsxs(r.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:['The "Add sort column" button is hidden once users reach this limit. Default is ',e.jsx("strong",{children:"5"}),"."]})]}),e.jsxs(Or,{active:s===1,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!m("filter")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),e.jsx(r.Slider,{value:c.filter.maxConditions,onChange:(v,j)=>h.filter({maxConditions:j}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),e.jsx(r.Divider,{}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter type dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(v=>e.jsxs(r.Box,{sx:{mb:1.5},children:[e.jsx(r.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:v}),e.jsx(r.FormGroup,{row:!0,sx:{gap:.5},children:Td.filter(j=>j.group===v).map(j=>e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(j.value),onChange:()=>y(j.value)}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:j.label}),sx:{mr:1.5}},j.value))})]},v))]})]}),e.jsxs(Or,{active:s===2,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!m("columns")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),e.jsx(r.Slider,{value:c.columns.maxVisible,onChange:(v,j)=>h.columns({maxVisible:j}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),e.jsx(r.Divider,{}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),e.jsxs(r.Box,{sx:{display:"flex",gap:2},children:[e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),e.jsx(r.Slider,{value:c.columns.minColumnWidth,onChange:(v,j)=>h.columns({minColumnWidth:j}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:v=>`${v}px`})]}),e.jsxs(r.Box,{sx:{flex:1},children:[e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),e.jsx(r.Slider,{value:c.columns.maxColumnWidth,onChange:(v,j)=>h.columns({maxColumnWidth:j}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:v=>`${v}px`})]})]})]})]}),e.jsxs(Or,{active:s===3,children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!m("grouping")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(v=>e.jsxs(r.Box,{onClick:()=>h.grouping({maxLevels:v}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===v?"primary.main":"divider",bgcolor:c.grouping.maxLevels===v?j=>W(j.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:j=>W(j.palette.primary.main,.04)}},children:[e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===v?"primary.main":"text.secondary"},children:v}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][v-1]})]},v))}),e.jsxs(r.FormGroup,{row:!0,sx:{gap:2},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:c.grouping.allowNested,onChange:v=>h.grouping({allowNested:v.target.checked})}),label:e.jsx(r.Typography,{variant:"body2",children:"Allow nested groups"})}),e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:c.grouping.allowCollapse,onChange:v=>h.grouping({allowCollapse:v.target.checked})}),label:e.jsx(r.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),e.jsx(r.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),e.jsx(Or,{active:s===4,children:e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!m("export")&&e.jsx(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog and the bulk export action. At least one must remain checked."}),e.jsx(r.FormGroup,{sx:{gap:1},children:zd.map(v=>e.jsxs(r.Box,{onClick:()=>w(v.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:c.export.allowedFormats.includes(v.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(v.value)?j=>W(j.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(r.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(v.value),onChange:()=>w(v.value),onClick:j=>j.stopPropagation()}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:v.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:v.desc})]})]},v.value))})]})})]}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:v=>W(v.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(r.Button,{startIcon:e.jsx(T.RestartAlt,{sx:{fontSize:18}}),onClick:f,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:v=>W(v.palette.text.primary,.06)}},children:"Reset to defaults"}),e.jsxs(r.Box,{sx:{display:"flex",gap:1},children:[e.jsx(r.Button,{onClick:o,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(r.Button,{onClick:g,size:"small",variant:"contained",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const Ed=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Bd={1:"1st",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",8:"8th",9:"9th",10:"10th",11:"11th",12:"12th",13:"13th",14:"14th",15:"15th",16:"16th",17:"17th",18:"18th",19:"19th",20:"20th",21:"21st",22:"22nd",23:"23rd",24:"24th",25:"25th",26:"26th",27:"27th",28:"28th"};function Xr(t,o,n,i,s=new Date){const[l,c]=o.split(":").map(Number),d=new Date(s);if(d.setSeconds(0,0),d.setHours(l,c,0,0),t==="daily")return d<=s&&d.setDate(d.getDate()+1),d.toISOString();if(t==="weekly"){const u=n??1,f=d.getDay();let g=u-f;return g<0&&(g+=7),g===0&&d<=s&&(g=7),d.setDate(d.getDate()+g),d.toISOString()}if(t==="monthly"){const u=Math.min(i??1,28);return d.setDate(u),d<=s&&(d.setMonth(d.getMonth()+1),d.setDate(u)),d.toISOString()}return d.toISOString()}function Dd(t){const o=Si(t.time);return t.frequency==="daily"?`Daily at ${o}`:t.frequency==="weekly"?`Every ${Ed[t.dayOfWeek??1]} at ${o}`:t.frequency==="monthly"?`Monthly on the ${Bd[t.dayOfMonth??1]??`${t.dayOfMonth}th`} at ${o}`:o}function Si(t){const[o,n]=t.split(":").map(Number),i=o>=12?"PM":"AM";return`${o%12||12}:${String(n).padStart(2,"0")} ${i}`}function Od(t){const o=new Date(t).getTime()-Date.now();if(o<=0)return"now";const n=Math.floor(o/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),l=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${l}m`:l>0?`in ${l}m`:"in less than a minute"}function Ad(t){const o=new Date(t),n=new Date,i=o.toDateString()===n.toDateString(),s=Si(`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`);return i?`Today at ${s}`:`${o.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${s}`}function Ci(t){return`urm_schedules_${t}`}function ji(t){try{const o=localStorage.getItem(Ci(t));return o?JSON.parse(o).map(i=>({...i,runCount:typeof i.runCount=="number"?i.runCount:0,isActive:typeof i.isActive=="boolean"?i.isActive:!0,createdAt:i.createdAt||new Date().toISOString()})):[]}catch{return[]}}function wi(t,o){try{localStorage.setItem(Ci(t),JSON.stringify(o))}catch{}}const Md=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}],ki={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},Lt={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function Wd({initial:t=ki,isEditing:o=!1,onSave:n,onBack:i}){const[s,l]=p.useState(t),c=(u,f)=>l(g=>({...g,[u]:f})),d=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time);return e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[e.jsx(r.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:u=>W(u.palette.text.primary,.06)}},children:e.jsx(T.ArrowBack,{sx:{fontSize:18}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:o?"Edit schedule":"New schedule"})]}),e.jsx(r.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:u=>c("name",u.target.value),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,sx:Lt}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:Lt,children:[e.jsx(r.InputLabel,{children:"Frequency"}),e.jsxs(r.Select,{value:s.frequency,label:"Frequency",onChange:u=>c("frequency",u.target.value),children:[e.jsx(r.MenuItem,{value:"daily",children:"Daily"}),e.jsx(r.MenuItem,{value:"weekly",children:"Weekly"}),e.jsx(r.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:Lt,children:[e.jsx(r.InputLabel,{children:"Day of week"}),e.jsx(r.Select,{value:s.dayOfWeek,label:"Day of week",onChange:u=>c("dayOfWeek",Number(u.target.value)),children:Md.map(u=>e.jsx(r.MenuItem,{value:u.value,children:u.label},u.value))})]}),s.frequency==="monthly"&&e.jsx(r.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:u=>c("dayOfMonth",Math.max(1,Math.min(28,Number(u.target.value)))),inputProps:{min:1,max:28},helperText:"Capped at 28 to work safely in all months",sx:Lt}),e.jsx(r.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:u=>c("time",u.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:Lt}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:Lt,children:[e.jsx(r.InputLabel,{children:"Export format"}),e.jsxs(r.Select,{value:s.format,label:"Export format",onChange:u=>c("format",u.target.value),children:[e.jsx(r.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),e.jsx(r.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),e.jsx(r.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),e.jsxs(r.RadioGroup,{row:!0,value:s.scope,onChange:u=>c("scope",u.target.value),sx:{gap:2},children:[e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small"}),label:e.jsx(r.Typography,{variant:"body2",children:"All rows"})}),e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small"}),label:e.jsx(r.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:u=>c("email",u.target.value),placeholder:"user@company.com",InputProps:{startAdornment:e.jsx(T.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Lt}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[e.jsx(T.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),e.jsx(r.Typography,{variant:"caption",color:"text.disabled",sx:{lineHeight:1.5},children:"Opens your device's email app when the schedule fires. Requires a default mail app (e.g. Outlook, Mail) on this device."})]})]}),e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[e.jsx(r.Button,{onClick:i,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:u=>W(u.palette.text.primary,.06)}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>d&&n(s),disabled:!d,size:"small",variant:"contained",disableElevation:!0,sx:{textTransform:"none",fontWeight:500,fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:o?"Save changes":"Create schedule"})]})]})}function Rd({schedule:t,onToggle:o,onRunNow:n,onEdit:i,onDelete:s}){const l=t.isActive;return e.jsxs(r.Box,{sx:{border:"1px solid",borderColor:l?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:l?c=>W(c.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:l?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(r.Chip,{label:l?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:l?c=>W(c.palette.success.main,.1):c=>W(c.palette.text.primary,.06),color:l?"success.dark":"text.secondary"}})]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Dd(t)}),e.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[e.jsx(r.Chip,{label:t.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:c=>W(c.palette.primary.main,.08),color:"primary.main"}}),e.jsx(r.Chip,{label:t.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:c=>W(c.palette.text.primary,.06),color:"text.secondary"}}),t.email&&e.jsx(r.Chip,{icon:e.jsx(T.Email,{sx:{fontSize:11}}),label:t.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:c=>W(c.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[e.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[l&&e.jsxs(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",Od(t.nextRunAt)]}),t.lastRunAt?e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Ad(t.lastRunAt)," · ",t.runCount," run",t.runCount!==1?"s":""]}):e.jsx(r.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[e.jsx(r.Tooltip,{title:"Edit",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>i(t),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:c=>W(c.palette.primary.main,.08)}},children:e.jsx(T.Edit,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:l?"Pause":"Resume",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>o(t.id),sx:{color:l?"warning.main":"success.main","&:hover":{bgcolor:l?c=>W(c.palette.warning.main,.08):c=>W(c.palette.success.main,.08)}},children:l?e.jsx(T.Pause,{sx:{fontSize:15}}):e.jsx(T.PlayArrow,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Export now",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>n(t),sx:{color:"primary.main","&:hover":{bgcolor:c=>W(c.palette.primary.main,.08)}},children:e.jsx(T.Download,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Delete",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>s(t.id),sx:{color:"error.main","&:hover":{bgcolor:c=>W(c.palette.error.main,.08)}},children:e.jsx(T.Delete,{sx:{fontSize:15}})})})]})]})]})}function Pd({open:t,onClose:o,reportId:n,reportName:i,onRunNow:s}){const[l,c]=p.useState([]),[d,u]=p.useState({type:"list"}),[f,g]=p.useState(0);p.useEffect(()=>{t&&(c(ji(n)),u({type:"list"}))},[t,n]),p.useEffect(()=>{if(!t)return;const S=setInterval(()=>g(a=>a+1),3e4);return()=>clearInterval(S)},[t]);const h=p.useCallback(S=>{c(S),wi(n,S)},[n]),y=S=>{const a=Xr(S.frequency,S.time,S.dayOfWeek,S.dayOfMonth),I={id:`sched-${Date.now()}`,reportId:n,name:S.name.trim(),frequency:S.frequency,dayOfWeek:S.frequency==="weekly"?S.dayOfWeek:void 0,dayOfMonth:S.frequency==="monthly"?S.dayOfMonth:void 0,time:S.time,format:S.format,scope:S.scope,email:S.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:a,runCount:0};h([...l,I]),u({type:"list"})},w=S=>{if(d.type!=="edit")return;const a=d.schedule,I=Xr(S.frequency,S.time,S.dayOfWeek,S.dayOfMonth);h(l.map(O=>O.id===a.id?{...a,name:S.name.trim(),frequency:S.frequency,dayOfWeek:S.frequency==="weekly"?S.dayOfWeek:void 0,dayOfMonth:S.frequency==="monthly"?S.dayOfMonth:void 0,time:S.time,format:S.format,scope:S.scope,email:S.email.trim()||void 0,nextRunAt:I}:O)),u({type:"list"})},k=S=>{h(l.map(a=>{if(a.id!==S)return a;const I=a.isActive?a.nextRunAt:Xr(a.frequency,a.time,a.dayOfWeek,a.dayOfMonth);return{...a,isActive:!a.isActive,nextRunAt:I}}))},m=S=>h(l.filter(a=>a.id!==S)),v=S=>({name:S.name,frequency:S.frequency,dayOfWeek:S.dayOfWeek??1,dayOfMonth:S.dayOfMonth??1,time:S.time,format:S.format,scope:S.scope,email:S.email??""}),j=d.type!=="list",b=l.filter(S=>S.isActive).length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:j,PaperProps:{sx:{borderRadius:"12px",maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:6}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,borderBottom:"1px solid",borderColor:"divider",flexShrink:0,minHeight:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(r.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:S=>W(S.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(T.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{variant:"subtitle2",sx:{fontWeight:600,lineHeight:1},children:"Scheduled Reports"}),e.jsx(Ut,{content:Gt.schedule,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"text.secondary","&:hover":{bgcolor:S=>W(S.palette.text.primary,.06)}},children:e.jsx(T.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[j&&e.jsx(Wd,{initial:d.type==="edit"?v(d.schedule):ki,isEditing:d.type==="edit",onSave:d.type==="edit"?w:y,onBack:()=>u({type:"list"})}),d.type==="list"&&e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:l.length===0?"No schedules yet":`${b} of ${l.length} active`}),e.jsx(r.Button,{startIcon:e.jsx(T.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",disableElevation:!0,onClick:()=>u({type:"create"}),sx:{textTransform:"none",fontWeight:500,fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),l.length===0?e.jsxs(r.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[e.jsx(T.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"text.secondary"},children:"No scheduled reports yet"}),e.jsx(r.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map(S=>e.jsx(Rd,{schedule:S,tick:f,onToggle:k,onRunNow:s,onEdit:a=>u({type:"edit",schedule:a}),onDelete:m},S.id))})]})]}),d.type==="list"&&e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:S=>W(S.palette.warning.main,.06),border:"1px solid",borderColor:S=>W(S.palette.warning.main,.2)},children:[e.jsx(T.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),e.jsx(r.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),e.jsx(r.Button,{onClick:o,size:"small",sx:{textTransform:"none",fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:S=>W(S.palette.text.primary,.06)}},children:"Close"})]})]})}const $d=6e4;function _d({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:l,columnVisibility:c,columnOrder:d,filters:u,sortStack:f,onFired:g}){const h=p.useRef({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:l,columnVisibility:c,columnOrder:d,filters:u,sortStack:f,onFired:g});p.useEffect(()=>{h.current={reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:l,columnVisibility:c,columnOrder:d,filters:u,sortStack:f,onFired:g}});const y=p.useCallback(w=>{var H,N;const{reportName:k,uploadedData:m,processedData:v,schema:j,activeView:b,columnVisibility:S,columnOrder:a,filters:I,sortStack:O}=h.current;try{const Q=w.scope==="all"?m:v,ee=Qr(Q,j,I,O,b,S,a),oe=`${w.name}_scheduled`;switch(w.format){case"csv":Zr(ee,oe,{scope:w.scope});break;case"excel":eo(ee,oe,{scope:w.scope});break;case"json":to(ee,oe,{scope:w.scope});break}if(w.email){const x=encodeURIComponent(`Scheduled Report: ${w.name}`),F=encodeURIComponent(`Your scheduled report "${w.name}" has been generated.
|
|
90
|
+
|
|
91
|
+
Report: ${k}
|
|
92
|
+
Format: ${w.format.toUpperCase()}
|
|
93
|
+
Generated: ${new Date().toLocaleString()}
|
|
94
|
+
|
|
95
|
+
The file has been downloaded to your device.`);window.open(`mailto:${w.email}?subject=${x}&body=${F}`,"_blank")}(N=(H=h.current).onFired)==null||N.call(H,w)}catch(Q){console.error("[Scheduler] Export failed for schedule:",w.name,Q)}},[]);p.useEffect(()=>{if(!t)return;const w=()=>{const{reportId:m}=h.current;if(!m)return;const v=ji(m),j=new Date;let b=!1;const S=v.map(a=>{if(!a.isActive)return a;if(new Date(a.nextRunAt)<=j){y(a);const O=Xr(a.frequency,a.time,a.dayOfWeek,a.dayOfMonth,j);return b=!0,{...a,lastRunAt:j.toISOString(),nextRunAt:O,runCount:a.runCount+1}}return a});b&&wi(m,S)};w();const k=setInterval(w,$d);return()=>clearInterval(k)},[t,y])}function Ti({reportEngine:t}){var D,q,de,Ae;const{activeReport:o,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:l,activeView:c,isDirty:d,currentTableState:u,viewChanges:f,showFilterPanel:g,setShowFilterPanel:h,filterFocusColumn:y,handleAddFilter:w,handleUpdateFilter:k,handleRemoveFilter:m,handleClearAllFilters:v,handleOpenFilterForColumn:j,handleCloseFilterPanel:b,handleClearFiltersForColumn:S,showSortPanel:a,setShowSortPanel:I,handleSort:O,handleUpdateSortStack:H,handleSortAscending:N,handleSortDescending:Q,showManageViews:ee,setShowManageViews:oe,showCreateViewModal:x,setShowCreateViewModal:F,showEditViewModal:$,setShowEditViewModal:_,showDeleteConfirmation:V,setShowDeleteConfirmation:ie,editingView:ce,deletingView:Te,handleSelectView:M,handleCreateView:Y,handleUpdateCurrentView:Z,handleSaveColumnConfigToCurrentView:re,handleSaveColumnConfigToAllViews:ne,handleSaveAsNewView:R,handleRevertChanges:X,handleToggleDefault:te,handleToggleFavorite:ae,handleSoftDelete:se,handleRestoreView:le,handlePermanentDelete:we,handleEditView:G,handleSaveEditView:De,handleConfirmDelete:He,showManageColumns:Ct,setShowManageColumns:At,handleUpdateColumnVisibility:et,handleUpdateColumnOrder:jt,handleUpdateColumnWidth:Oe,handleResetColumnLayout:Ke,showGroupPanel:tt,setShowGroupPanel:Ue,handleGroup:$e,handleToggleGroupCollapse:wt,searchQuery:Yt,searchHistory:dt,handleSearchChange:Xe,handleAddToSearchHistory:Ne,handleToggleSearchFavourite:fr,handleDeleteSearchHistory:qt,selectedRowIds:rt,handleToggleRowSelection:kt,handleToggleAllRows:Mt,handleRangeSelection:ut,handleClearSelection:hr,currentPage:Fr,pageSize:Jt,paginationEngine:ot,handlePageChange:Wt,handlePageSizeChange:Kt,isExporting:Tt,showExportModal:Ce,setShowExportModal:mr,showDirtyExportWarning:zt,handleExport:nt,handleExportWithConfig:P,handleExportSelected:Qe,handleExportAnyway:ge,handleSaveAndExport:Re,handleCancelExport:Rt,showAuditHistory:gr,setShowAuditHistory:it,showCreatePreset:yr,setShowCreatePreset:pt,showManagePresets:Pt,setShowManagePresets:$t,generatedPreset:br,activePreset:ke,handleOpenManagePresets:L,handleCreatePreset:Me,handleCopyPresetLink:Se,handleOpenPreset:xt,handleClearActivePreset:_e,handleOpenPresetById:Xt,handleCopyPresetLinkById:vr,handleDeletePresetById:Qt,isViewerRole:Zt,userRole:Sr,featureLimitWarning:er,setFeatureLimitWarning:tr,reportError:Pe,setReportError:st,handleError:at,updateReport:Fe,showSnack:rr,favoriteRowIndices:Cr,resolvedFavoritesSet:or,showFavoritesOnly:_t,handleToggleRowFavorite:jr,handleBulkSetFavorites:wr,handleToggleFavoritesFilter:kr}=t,[Tr,Nt]=p.useState(!1);_d({reportId:o==null?void 0:o.id,reportName:(o==null?void 0:o.name)||"Report",uploadedData:(o==null?void 0:o.uploadedData)||[],processedData:i||[],schema:(o==null?void 0:o.schema)||[],activeView:c,columnVisibility:(o==null?void 0:o.columnVisibility)||((D=c==null?void 0:c.snapshot)==null?void 0:D.columnVisibility)||{},columnOrder:(o==null?void 0:o.columnOrder)||((q=c==null?void 0:c.snapshot)==null?void 0:q.columnOrder)||[],filters:(o==null?void 0:o.filters)||[],sortStack:(o==null?void 0:o.sortStack)||[],onFired:J=>{rr(`Scheduled export "${J.name}" completed`,"success")}});const nr=p.useCallback((J,ye)=>{if(!(o!=null&&o.uploadedData))return;const Ge=[...o.uploadedData];Ge[J]=ye,Fe(o.id,{uploadedData:Ge})},[o,Fe]),We=p.useCallback(J=>{if(!(o!=null&&o.uploadedData))return;const ye=o.uploadedData.filter((Ge,So)=>So!==J);Fe(o.id,{uploadedData:ye})},[o,Fe]),ir=p.useCallback((J,ye)=>{if(!(o!=null&&o.uploadedData))return;const Ge=[...o.uploadedData];Ge.splice(J+1,0,{...ye}),Fe(o.id,{uploadedData:Ge})},[o,Fe]),sr=$r(),{handleDevConfigChange:It}=io(),[zr,Et]=p.useState(!1);return p.useEffect(()=>{const J=ye=>{ye.ctrlKey&&ye.shiftKey&&ye.key==="D"&&(ye.preventDefault(),Et(!0))};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[]),!o||!o.schemaLocked||!o.schema||!o.uploadedData||!o.views?null:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:[!Zt&&d&&c&&e.jsx(md,{viewName:c.name,isDefaultView:c.isDefault,changes:f,onSaveToCurrentView:c.isDefault?void 0:Z,onSaveAsNewView:R,onCancel:X}),e.jsxs(r.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",position:"relative"},children:[er&&e.jsx(jd,{warning:er,onDismiss:()=>tr(null)}),Pe&&e.jsx(wd,{error:Pe,onDismiss:()=>st(null)}),zt&&e.jsx(gd,{onExportAnyway:ge,onSaveAndExport:Re,onCancel:Rt}),e.jsx(id,{schema:o.schema,data:n,sortStack:o.sortStack,filters:o.filters,views:o.views,activeViewId:o.activeViewId,isDirty:d,isExporting:Tt,columnVisibility:o.columnVisibility||(c==null?void 0:c.snapshot.columnVisibility),columnOrder:o.columnOrder||(c==null?void 0:c.snapshot.columnOrder),columnWidths:o.columnWidths||(c==null?void 0:c.snapshot.columnWidths),grouping:o.grouping,onSort:O,onSortAscending:N,onSortDescending:Q,onOpenFilters:()=>h(!0),onOpenSort:()=>I(!0),onOpenFilterForColumn:j,onSelectView:M,onCreateView:()=>F(!0),onManageViews:()=>oe(!0),onUpdateCurrentView:Z,onSaveAsNewView:R,onToggleDefault:te,onToggleFavorite:ae,onRestoreView:le,onPermanentDelete:we,onExport:nt,onOpenColumns:()=>At(!0),onUpdateColumnWidth:Oe,onUpdateColumnOrder:jt,onUpdateColumnVisibility:et,onClearFiltersForColumn:S,onResetLayout:Ke,onOpenGroup:()=>Ue(!0),onToggleGroupCollapse:wt,onOpenAuditHistory:()=>it(!0),onOpenScheduledReports:()=>Nt(!0),searchQuery:Yt,searchHistory:dt,onAddToSearchHistory:Ne,onToggleSearchFavourite:fr,onDeleteSearchHistory:qt,selectedRowIds:rt,onSearchChange:Xe,onToggleRowSelection:kt,onToggleAllRows:Mt,onRangeSelection:ut,onClearSelection:hr,onExportSelected:Qe,currentPage:(ot==null?void 0:ot.currentPage)||Fr,pageSize:(ot==null?void 0:ot.pageSize)||Jt,onPageChange:Wt,onPageSizeChange:Kt,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:Zt,userRole:Sr,reportName:o.name,onEditRow:nr,onDeleteRow:We,onDuplicateRow:ir,favoriteRowIndices:Cr,resolvedFavoritesSet:or,showFavoritesOnly:_t,onToggleRowFavorite:jr,onBulkSetFavorites:wr,onToggleFavoritesFilter:kr,showDevPanel:sr.display.showDevPanel,onOpenDevConfig:()=>Et(!0)})]}),g&&e.jsx(Dr,{feature:"Filters",onError:J=>{const ye=yt("ui","filters",J);at(ye)},children:e.jsx(sd,{schema:o.schema,filters:o.filters??[],onAddFilter:w,onUpdateFilter:k,onRemoveFilter:m,onClearAll:v,onClose:b,focusColumn:y})}),a&&e.jsx(Dr,{feature:"Sorting",onError:J=>{const ye=yt("ui","sorting",J);at(ye)},children:e.jsx(ld,{schema:o.schema,sortStack:o.sortStack??[],onUpdateSortStack:H,onClose:()=>I(!1)})}),ee&&e.jsx(Dr,{feature:"Views",onError:J=>{const ye=yt("ui","views",J);at(ye)},children:e.jsx(cd,{views:o.views,activeViewId:o.activeViewId??"",onSelectView:M,onCreateView:()=>{oe(!1),F(!0)},onEditView:G,onDeleteView:se,onRestoreView:le,onPermanentDelete:we,onClose:()=>oe(!1)})}),x&&u&&e.jsx(Wn,{currentSnapshot:u,onSave:Y,onClose:()=>F(!1)}),$&&ce&&e.jsx(Wn,{currentSnapshot:ce.snapshot,onSave:De,onClose:()=>{_(!1)},isEditMode:!0,initialName:ce.name,initialDescription:ce.description,initialIsDefault:ce.isDefault}),V&&Te&&e.jsx(dd,{viewName:Te.name,onConfirm:He,onCancel:()=>{ie(!1)}}),Ct&&c&&e.jsx(pd,{schema:o.schema,columnVisibility:o.columnVisibility||c.snapshot.columnVisibility,columnOrder:o.columnOrder||c.snapshot.columnOrder,columnWidths:o.columnWidths||c.snapshot.columnWidths,views:o.views,activeViewId:o.activeViewId,onUpdateColumnVisibility:et,onUpdateColumnOrder:jt,onUpdateColumnWidth:Oe,onResetLayout:Ke,onSelectView:J=>{M(J)},onSaveToCurrentView:()=>{re(),At(!1)},onSaveToAllViews:()=>{ne(),At(!1)},onClose:()=>At(!1)}),tt&&e.jsx(Dr,{feature:"Grouping",onError:J=>{const ye=yt("ui","grouping",J);at(ye)},children:e.jsx(xd,{schema:o.schema,grouping:o.grouping||null,onApply:$e,onClose:()=>Ue(!1)})}),gr&&e.jsx(yd,{auditHistory:o.auditHistory||[],onClose:()=>it(!1)}),yr&&e.jsx(bd,{onSave:Me,onClose:()=>pt(!1)}),Pt&&e.jsx(Sd,{presets:o.presets||[],reportId:o.id,onOpenPreset:Xt,onCopyLink:vr,onDeletePreset:Qt,onClose:()=>$t(!1)}),ke&&e.jsx(r.Box,{sx:{mt:2},children:e.jsx(vd,{presetName:ke.name,onClear:_e})}),Ce&&e.jsx(Dr,{feature:"Export",onError:J=>{const ye=yt("ui","export",J);at(ye)},children:e.jsx(Cd,{totalRows:(s==null?void 0:s.totalRows)||((de=o.uploadedData)==null?void 0:de.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((Ae=l==null?void 0:l.columnEngine)==null?void 0:Ae.visibleColumns.length)||o.schema.length,totalColumnsCount:o.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,onExport:P,onClose:()=>{mr(!1)}})}),o&&e.jsx(Pd,{open:Tr,onClose:()=>Nt(!1),reportId:o.id,reportName:o.name,onRunNow:J=>{const ye=J.scope==="all"?o.uploadedData||[]:i||[],Ge=Qr(ye,o.schema||[],o.filters||[],o.sortStack||[],c,o.columnVisibility,o.columnOrder);J.format==="csv"&&Zr(Ge,J.name),J.format==="excel"&&eo(Ge,J.name),J.format==="json"&&to(Ge,J.name),rr(`"${J.name}" exported successfully`,"success")}}),e.jsx(Id,{open:zr,onClose:()=>Et(!1),config:sr,onApply:It})]})}function zi({open:t,message:o,severity:n,onClose:i}){return e.jsx(r.Snackbar,{open:t,autoHideDuration:4e3,onClose:i,anchorOrigin:{vertical:"top",horizontal:"right"},children:e.jsx(r.Alert,{onClose:i,severity:n,variant:"filled",sx:{width:"100%",boxShadow:3},children:o})})}function Ii({hasExternalData:t=!1}){const o=io(),{reports:n,activeReportId:i,activeReport:s,uploadState:l,schema:c,hasSchemaConflicts:d,isModalOpen:u,setIsModalOpen:f,setActiveReportId:g,createReport:h,handleFileUpload:y,handleUploadError:w,handleRetry:k,handleConfirm:m,snack:v,handleSnackClose:j}=o,b=t&&l==="uploading"&&n.length===0;return e.jsxs(r.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(fa,{onCreateReport:()=>f(!0),reports:n,activeReportId:i,onReportClick:g}),e.jsx(r.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:b?e.jsxs(r.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[e.jsx(r.CircularProgress,{size:40,thickness:3}),e.jsx(r.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?e.jsx(gi,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?e.jsx(e.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?e.jsx(Ti,{reportEngine:o}):e.jsx(r.Box,{sx:{p:3},children:l==="preview"&&s.schema&&s.uploadedData?e.jsx(Tc,{schema:s.schema,onConfirm:m,hasConflicts:d}):s.uploadError?e.jsx(zc,{error:s.uploadError,onRetry:k}):e.jsx(kc,{onFileUpload:y,onError:w,isUploading:l==="uploading"})})}):null}),!t&&e.jsx(wc,{isOpen:u,onClose:()=>f(!1),onCreate:h}),e.jsx(zi,{open:v.open,message:v.message,severity:v.severity,onClose:j})]})}function Nd({data:t,dataSource:o,reportName:n,autoLoad:i=!0,config:s}={}){return e.jsx(Po,{mode:"builder",data:t,dataSource:o,reportName:n,autoLoad:i,config:s,children:e.jsx(Ii,{hasExternalData:!!(t||o)})})}function Ei(){const t=io(),{snack:o,handleSnackClose:n}=t;return e.jsxs(r.Box,{sx:{minHeight:"100vh"},children:[e.jsx(r.Box,{component:"main",children:t.activeReport?e.jsx(Ti,{reportEngine:t}):e.jsx(gi,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(zi,{open:o.open,message:o.message,severity:o.severity,onClose:n})]})}function Fd({data:t,autoLoad:o=!0,config:n}){return e.jsx(Po,{data:t,mode:"viewer",autoLoad:o,config:n,children:e.jsx(Ei,{})})}exports.URMBuilder=Nd;exports.URMBuilderRaw=Ii;exports.URMProvider=Po;exports.URMViewer=Fd;exports.URMViewerRaw=Ei;exports.useURMContext=io;
|