dts-universal-report-module 1.1.0 → 1.1.1
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 +4287 -4560
- package/dist/index.js +24 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";var Bs=Object.defineProperty;var Is=(t,o,n)=>o in t?Bs(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n;var bn=(t,o,n)=>Is(t,typeof o!="symbol"?o+"":o,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),Ds=require("xlsx"),B=require("@mui/icons-material"),r=require("@mui/material"),gi=require("react-dom"),Es=require("@emotion/react"),kt=require("react-dnd"),tn=require("react-dnd-html5-backend");function yi(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 vo=yi(p),ro=yi(Ds),qe={sort:{maxLevels:5},filter:{maxConditions:3,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"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},bi="urm_dev_config";function Os(){try{const t=localStorage.getItem(bi);if(!t)return qe;const o=JSON.parse(t),n={sort:{...qe.sort,...o.sort},filter:{...qe.filter,...o.filter},columns:{...qe.columns,...o.columns},grouping:{...qe.grouping,...o.grouping},export:{...qe.export,...o.export},views:{...qe.views,...o.views},dates:{...qe.dates,...o.dates},display:{...qe.display,...o.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return qe}}function As(t){try{localStorage.setItem(bi,JSON.stringify(t))}catch{}}function $s(t,o,n){if(!n||!o)return t;const i={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},views:{...t.views,...o.views},dates:{...t.dates,...o.dates},display:{...t.display,...o.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const vi=p.createContext(qe);function nr(){return p.useContext(vi)}const Ms=/^\d{4}-\d{2}-\d{2}$/,Rs=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,_s=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Ws=9783072e5,Ps=41024448e5,Ns=978307200,Ls=4102444800;function Fs(t){return t==null||t===""?"unknown":typeof t=="number"?Number.isInteger(t)&&t>=Ws&&t<=Ps?"timestamp_ms":Number.isInteger(t)&&t>=Ns&&t<=Ls?"timestamp_s":"unknown":typeof t!="string"?"unknown":Rs.test(t)||Ms.test(t)?"iso":_s.test(t.trim())?"locale_string":"unknown"}function Vs(t,o){const n=o.map(c=>c[t]).filter(c=>c!=null&&c!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const c of n){const l=Fs(c);i[l]++}const s=n.length,d=.7;for(const c of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[c]/s>=d)return c;return"unknown"}function Hs(t,o){if(t==null||t==="")return null;try{switch(o){case"timestamp_ms":{const n=new Date(Number(t));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(t)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(t));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(t));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const vn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Us=["January","February","March","April","May","June","July","August","September","October","November","December"];function Oe(t){return String(t).padStart(2,"0")}function Ys(t){const o=Date.now()-t.getTime(),n=Math.abs(o),i=o>0,s=Math.floor(n/1e3),d=Math.floor(s/60),c=Math.floor(d/60),l=Math.floor(c/24),u=Math.floor(l/7),f=Math.floor(l/30),m=Math.floor(l/365);let h;return s<60?h="just now":d<60?h=`${d} minute${d!==1?"s":""}`:c<24?h=`${c} hour${c!==1?"s":""}`:l<7?h=`${l} day${l!==1?"s":""}`:u<5?h=`${u} week${u!==1?"s":""}`:f<12?h=`${f} month${f!==1?"s":""}`:h=`${m} year${m!==1?"s":""}`,s<60?h:i?`${h} ago`:`in ${h}`}function Gs(t,o){const n=t.getFullYear(),i=t.getMonth(),s=t.getDate(),d=t.getHours(),c=t.getMinutes();switch(o){case"YYYY-MM-DD":return`${n}-${Oe(i+1)}-${Oe(s)}`;case"DD/MM/YYYY":return`${Oe(s)}/${Oe(i+1)}/${n}`;case"MM/DD/YYYY":return`${Oe(i+1)}/${Oe(s)}/${n}`;case"MMM DD, YYYY":return`${vn[i]} ${Oe(s)}, ${n}`;case"DD MMM YYYY":return`${Oe(s)} ${vn[i]} ${n}`;case"MMMM D, YYYY":return`${Us[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Oe(i+1)}-${Oe(s)} ${Oe(d)}:${Oe(c)}`;case"DD/MM/YYYY HH:mm":return`${Oe(s)}/${Oe(i+1)}/${n} ${Oe(d)}:${Oe(c)}`;case"MM/DD/YYYY HH:mm":return`${Oe(i+1)}/${Oe(s)}/${n} ${Oe(d)}:${Oe(c)}`;case"relative":return Ys(t);case"locale":return t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return t.toLocaleDateString()}}function qs(t,o,n){if(!n||o==="unknown")return String(t);const i=Hs(t,o);return!i||isNaN(i.getTime())?String(t):Gs(i,n)}function Js(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 Si(t,o="",n=0){if(n>2)return{[o]:t};const i={};for(const s of Object.keys(t)){const d=o?`${o}.${s}`:s,c=t[s];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,Si(c,d,n+1)):i[d]=c}return i}function co(t){return t.map(o=>typeof o!="object"||o===null||Array.isArray(o)?o:Si(o))}function Wr(t){if(!Array.isArray(t)||t.length===0)return[];const o=co(t),n=new Set;o.forEach(c=>{typeof c=="object"&&c!==null&&Object.keys(c).forEach(l=>n.add(l))});const i=[];n.forEach(c=>{const l=new Set;let u=0;o.forEach(x=>{typeof x=="object"&&x!==null&&c in x&&(u++,l.add(Js(x[c])))});const f=u===o.length,m=l.size>1&&!l.has("null");let h="mixed";if(l.size===1)h=Array.from(l)[0];else if(l.size===2&&l.has("null")){const x=Array.from(l).filter(b=>b!=="null");x.length===1&&(h=x[0])}i.push({name:c,type:h,required:f,hasConflict:m})});const d=o.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=Vs(c.name,d);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function Ks(t){return t.some(o=>o.hasConflict)}function Ke(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 Sn(t){return t==null}function Xs(t){return(o,n,i)=>{const s=Sn(o),d=Sn(n);if(s&&d)return 0;if(s)return 1;if(d)return-1;let c=0;switch(t){case"number":const l=Number(o),u=Number(n);c=l-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 Qs(t,o,n){if(!n||n.length===0)return t;const i=[...n].sort((s,d)=>s.priority-d.priority);return[...t].sort((s,d)=>{for(const c of i){const l=o.find(m=>m.name===c.column);if(!l)continue;const f=Xs(l.type)(s[c.column],d[c.column],c.direction);if(f!==0)return f}return 0})}function Zs(t){return t===null?"asc":t==="asc"?"desc":null}function ea(t){return t==="string"||t==="boolean"}function ta(t){return t.filter(o=>ea(o.type))}function ra(t,o){const n={};return o.forEach(i=>{if(i.type==="number"){const s=t.map(d=>d[i.name]).filter(d=>typeof d=="number");s.length>0&&(n[i.name]=s.reduce((d,c)=>d+c,0))}}),n}function oa(t,o,n){if(!n.enabled||n.levels.length===0)return t;const i=ji(t,n.levels,o);return Ci(i,n.collapsedGroups||[])}function ji(t,o,n,i="",s=0){if(s>=o.length)return t;const d=o[s].column,c=new Map;t.forEach(f=>{const m=f[d],h=m==null?"(empty)":String(m);c.has(h)||c.set(h,[]),c.get(h).push(f)});const l=[];return Array.from(c.keys()).sort().forEach(f=>{const m=c.get(f),h=`${d}:${f}`,x=i?`${i}|${h}`:h,b=ra(m,n),D=s<o.length-1?ji(m,o,n,x,s+1):m,g={key:x,level:s,column:d,value:f,rowCount:m.length,aggregates:b,children:D};l.push(g)}),l}function Ci(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&&Ci(i.children,o,n)}else n.push(i);return n}function na(t,o){const n=t.collapsedGroups||[],i=n.includes(o)?n.filter(s=>s!==o):[...n,o];return{...t,collapsedGroups:i}}function wi(t,o){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function ki(t,o,n){return`${o}: ${n}`}function Vr(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 Ti(t,o,n){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const i=o.levels.map(d=>d.column),s=t.filter(d=>!i.includes(d));if(n){const d=[],c=new Set(i),l=new Set(s);let u=0;for(const f of n)c.has(f)?d.push(f):l.has(f)&&u<s.length?(d.push(s[u]),u++):l.has(f)||d.push(f);for(let f=u;f<s.length;f++)d.includes(s[f])||d.push(s[f]);return d}return[...t]}function No(t){const o={},n=[],i={};return t.forEach(s=>{o[s.name]=!0,n.push(s.name),i[s.name]=170}),{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 ia(t,o,n,i,s,d,c,l){const u={},f=[],m={};n.forEach(b=>{u[b.name]=!0,f.push(b.name),m[b.name]=170});const x=Ti(s||f,c||null,l||f);return{filters:t||[],sortStack:o||[],columnVisibility:i||u,columnOrder:x,columnWidths:d||m,grouping:c||null}}function sa(t,o){const n=x=>{if(x==null)return x;if(Array.isArray(x))return x.map(b=>n(b));if(typeof x=="object"){const b={};return Object.keys(x).sort().forEach(D=>{b[D]=n(x[D])}),b}return x},i=x=>JSON.stringify(n(x));if(i(t.filters)!==i(o.filters)||i(t.sortStack)!==i(o.sortStack))return!0;const s=t.columnVisibility??{},d=o.columnVisibility??{};if(i(s)!==i(d))return!0;const c=[...t.columnOrder||[]].sort().join(","),l=[...o.columnOrder||[]].sort().join(",");if(c!==l)return!1;const u=[...o.columnOrder||[]].sort().join(",");if((o.columnOrder||[]).join(",")!==u){if((t.columnOrder||[]).join(",")!==(o.columnOrder||[]).join(","))return!0}else{const x=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==x)return!0}const m=t.columnWidths??{},h=o.columnWidths??{};return i(m)!==i(h)||i(t.grouping)!==i(o.grouping)}function aa(t){return!t||t.length===0?"None":t.sort((o,n)=>o.priority-n.priority).map(o=>`${o.column} ${o.direction==="asc"?"↑":"↓"}`).join(", ")}function la(t,o){var g,j,w;const n=[],i=JSON.stringify(t.filters),s=JSON.stringify(o.filters);if(i!==s){const I=t.filters.length,v=o.filters.length;I>v?n.push({category:"filters",label:"Filters Added",description:`${I-v} new filter${I-v>1?"s":""} added`}):I<v?n.push({category:"filters",label:"Filters Removed",description:`${v-I} filter${v-I>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const d=JSON.stringify(t.sortStack),c=JSON.stringify(o.sortStack);if(d!==c){const I=t.sortStack.length,v=o.sortStack.length;I>v?n.push({category:"sorting",label:"Sorting Added",description:`${I-v} new sort rule${I-v>1?"s":""} added`}):I<v?n.push({category:"sorting",label:"Sorting Removed",description:`${v-I} sort rule${v-I>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const l=JSON.stringify(t.columnVisibility),u=JSON.stringify(o.columnVisibility);if(l!==u){const I=Object.values(t.columnVisibility).filter(S=>S).length,v=Object.values(o.columnVisibility).filter(S=>S).length;I>v?n.push({category:"visibility",label:"Columns Shown",description:`${I-v} column${I-v>1?"s":""} made visible`}):I<v?n.push({category:"visibility",label:"Columns Hidden",description:`${v-I} column${v-I>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const f=JSON.stringify(t.columnOrder),m=JSON.stringify(o.columnOrder);f!==m&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const h=JSON.stringify(t.columnWidths),x=JSON.stringify(o.columnWidths);if(h!==x){const I=Object.keys(t.columnWidths).filter(v=>t.columnWidths[v]!==o.columnWidths[v]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${I} column width${I>1?"s":""} modified`})}const b=JSON.stringify(t.grouping),D=JSON.stringify(o.grouping);if(b!==D){const I=(g=t.grouping)==null?void 0:g.enabled,v=(j=o.grouping)==null?void 0:j.enabled;if(I&&!v){const S=((w=t.grouping)==null?void 0:w.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${S} grouping level${S>1?"s":""} added`})}else!I&&v?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}function jn(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Cn(t){return`[${t}]`}const rr={warn(t,o,...n){jn()&&console.warn(Cn(t),o,...n)},error(t,o,...n){jn()&&console.error(Cn(t),o,...n)}},zi="urm_report_";function ca(t,o){try{const n=`${zi}${t}`;localStorage.setItem(n,JSON.stringify(o))}catch(n){rr.error("urm:persistence","Failed to save report state",n)}}function da(t){try{const o=`${zi}${t}`,n=localStorage.getItem(o);return n?JSON.parse(n):null}catch(o){return rr.error("urm:persistence","Failed to load report state",o),null}}function So(t,o,n=0){const i=[];for(const s of t){const d=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:d}),!d&&s.children&&s.children.length>0){const c=s.children[0];if(ua(c)){const l=s.children,u=So(l,o,n+1);i.push(...u)}else{const l=s.children;for(const u of l)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function ua(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 rn(t){return t.filter(o=>o.type==="row").map(o=>o.type==="row"?o.data:null).filter(o=>o!==null)}function on(t,o){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),d=String(n.getDate()).padStart(2,"0"),c=`${i}-${s}-${d}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${o}`}function mo(t,o,n,i,s,d,c){let l,u;d?(l={...d},u=c||o.map(m=>m.name)):s?(l={...s.snapshot.columnVisibility},u=c||[...s.snapshot.columnOrder]):(l={},u=[],o.forEach(m=>{l[m.name]=!0,u.push(m.name)}));const f=Object.entries(l).filter(([m,h])=>!h).map(([m,h])=>m);return{data:t,schema:o,appliedFilters:n,appliedSortStack:i,columnVisibility:l,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 ho(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,c=s.filter(h=>t.columnVisibility[h]);let l;if(d&&d.enabled){const h=d.collapsedGroups??[],x=So(i,h);l=rn(x)}else l=i;const u=c.join(","),f=l.map(h=>c.map(x=>{const b=h[x];if(b==null)return"";const D=String(b);return D.includes(",")||D.includes('"')||D.includes(`
|
|
2
|
-
`)?`"${
|
|
3
|
-
`);Bi(m,on(o,"csv"),"text/csv;charset=utf-8;")}function fo(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,c=s.filter(h=>t.columnVisibility[h]);let l;if(d&&d.enabled){const h=d.collapsedGroups??[],x=So(i,h);l=rn(x)}else l=i;const u=[c,...l.map(h=>c.map(x=>h[x]??""))],f=ro.utils.aoa_to_sheet(u),m=ro.utils.book_new();ro.utils.book_append_sheet(m,f,"Data"),ro.writeFile(m,on(o,"xlsx"))}function go(t,o="export",n){const{data:i,appliedFilters:s,appliedSortStack:d,viewMeta:c,hiddenColumns:l,columnOrder:u,grouping:f}=t;let m;if(f&&f.enabled){const b=f.collapsedGroups??[],D=So(i,b);m=rn(D)}else m=i;const h={meta:{exportedAt:new Date().toISOString(),reportName:o,view:(c==null?void 0:c.name)||"Default View",filters:s.map(b=>({field:b.column,operator:b.operator,value:b.value})),sortStack:d.map(b=>({field:b.column,direction:b.direction,priority:b.priority})),grouping:f||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:m},x=JSON.stringify(h,null,2);Bi(x,on(o,"json"),"application/json;charset=utf-8;")}function Bi(t,o,n){const i=new Blob([t],{type:n}),s=URL.createObjectURL(i),d=document.createElement("a");d.href=s,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(s)}const wn=10;function pa(t,o){const n=o.trim();if(!n)return t;const i=t.findIndex(d=>d.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>wn&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,wn)),s}function xa(t,o){return t.map(n=>n.query===o?{...n,isFavourite:!n.isFavourite}:n)}function ma(t,o){return t.filter(n=>n.query!==o)}function ha(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 fa={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data","promote_global_view"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function ga(t,o){return!t||t.owner===o?"owner":t.editors.includes(o)?"editor":(t.viewers.includes(o),"viewer")}function ut(t,o){return fa[o].includes(t)}function pt(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",promote_global_view:"promote views to global"}[t]||"perform this action"}.`}function ya(t){return t==="viewer"}const kn=1e3;function Xo(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)}function ht(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return Xo(n)}const ba={equals:"equals",contains:"contains",startsWith:"starts with",endsWith:"ends with",gt:"is greater than",lt:"is less than",gte:"is greater than or equal to",lte:"is less than or equal to",isTrue:"is true",isFalse:"is false",NULL:"is empty",NOT_NULL:"is not empty"};function Lo(t){if(!t||!t.column)return"a filter";const o=ht(t.column),n=ba[t.operator]??t.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(t.operator)?`"${o}" ${n}`:`"${o}" ${n} "${t.value}"`}function Tn(t){return!t||!t.enabled||t.levels.length===0?"grouping removed":`grouped by ${t.levels.map(n=>`"${ht(n.column)}"`).join(", ")}`}function va(t){var s,d,c;const{action:o,previousState:n,newState:i}=t;switch(o){case"filter_added":{const l=i&&Array.isArray(i)?i[i.length-1]:i;return{summary:`Filter added: ${Lo(l)}`}}case"filter_removed":return{summary:`Filter removed: ${Lo(n)}`};case"filter_updated":{const l=n,u=i;return(l==null?void 0:l.column)!==(u==null?void 0:u.column)?{summary:`Filter changed on "${ht(u==null?void 0:u.column)}"`,detail:`Previously filtered "${ht(l==null?void 0:l.column)}"`}:{summary:`Filter updated: ${Lo(u)}`}}case"filter_cleared":{const l=Array.isArray(n)?n.length:0;return{summary:l>0?`All filters cleared (${l} filter${l!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const l=i!=null&&i.column?ht(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:l?`Sort added: "${l}" ${u}`:"Sort level added"}}case"sort_level_removed":{const l=n!=null&&n.column?ht(n.column):"";return{summary:l?`Sort removed: "${l}"`:"Sort level removed"}}case"sort_reordered":return{summary:"Sort order changed"};case"sort_cleared":return{summary:"All sorting cleared"};case"group_level_added":return{summary:`Grouping applied: ${Tn(i)}`};case"group_level_removed":{const l=n,u=(d=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&d.column?ht(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Tn(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column hidden: "${ht(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${ht(l)}"`:"Column made visible"}}case"column_reordered":{const l=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return l.length>0&&u.length>0?{summary:"Column order changed",detail:`${u.length} column${u.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const l=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:l?`Column resized: "${ht(l)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const l=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:l?`View created: "${l}"`:"New view created"}}case"view_updated":{const l=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:l?`View updated: "${l}"`:"View updated"}}case"view_deleted":{const l=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:l?`View deleted: "${l}"`:"View deleted"}}case"view_set_default":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Default view set to "${l}"`:"Default view changed"}}case"view_switched":{const l=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return l&&u?{summary:`Switched to view "${u}"`,detail:`From "${l}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":{const l=o==="export_csv"?"CSV":o==="export_excel"?"Excel":"JSON",u=i==null?void 0:i.rowCount,f=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",m=(i==null?void 0:i.viewName)??"",h=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${h}`,detail:m?`${Xo(f)} · View: "${m}"`:Xo(f)}}case"export_triggered":{const l=((c=i==null?void 0:i.format)==null?void 0:c.toUpperCase())??"";return{summary:l?`Export triggered: ${l}`:"Export triggered"}}case"preset_created":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset created: "${l}"`:"New preset created"}}case"preset_applied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset applied: "${l}"`:"Preset applied"}}case"preset_deleted":{const l=(n==null?void 0:n.name)??"";return{summary:l?`Preset deleted: "${l}"`:"Preset deleted"}}case"preset_link_copied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset link copied: "${l}"`:"Preset link copied to clipboard"}}case"theme_changed":{const l=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return l&&u?{summary:`Theme changed from "${l}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const l=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:l?`Details: ${String(l).slice(0,120)}`:void 0}}default:return{summary:ja(o)}}}function Sa(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ii(t,o,n,i,s,d){return{id:Sa(),user:o,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:d}}function Di(t,o){const n=[o,...t];return n.length>kn?n.slice(0,kn):n}function ja(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 Ca(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function wa(t){const o=new Date(t),i=new Date().getTime()-o.getTime(),s=Math.floor(i/6e4),d=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:d<24?`${d} hour${d>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"})}const zn=100;function ka(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ta(t){var d;const o=(d=t.views)==null?void 0:d.find(c=>c.id===t.activeViewId),n=o==null?void 0:o.snapshot.columnOrder,i=t.columnOrder||[],s=Ti(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 za(t,o,n,i){return{id:ka(),name:t,description:o,createdBy:n,createdAt:Date.now(),config:i}}function Ba(t,o){const n=t||[];if(n.length>=zn)throw new Error(`Maximum of ${zn} presets reached. Please delete old presets first.`);return[...n,o]}function Ia(t,o){return(t||[]).filter(i=>i.id!==o)}function Bn(t,o){if(t)return t.find(n=>n.id===o)}function Da(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Ea(t){const o=t.columnOrder,n=Vr(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 Oa(t,o){return{totalRows:t.length,totalColumns:o.length}}function wt(t,o,n,i){const s=n instanceof Error?n.message:n,d={type:t,context:o,message:s,details:i,timestamp:Date.now(),recoverable:Aa(t,o)};return process.env.NODE_ENV==="development"&&rr.error("urm:error-handling","[Report Error]",{type:t,context:o,message:s,details:i}),d}function Aa(t,o){return t==="ui"?!0:o==="export"?!1:t==="processing"&&["filters","sorting","grouping","columns"].includes(o)?!0:t!=="system"}function $a(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 Ma(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 Ra(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 _a(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 Ei(t,o){const n=[],i=[],s=new Set(o.map(d=>d.name));return t.forEach(d=>{s.has(d.column)?n.push(d):i.push(d.column)}),{validRules:n,invalidColumns:i}}function Oi(t,o){if(!t||!t.levels||t.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(o.map(d=>d.name)),i=[],s=[];return t.levels.forEach(d=>{n.has(d.column)?i.push(d):s.push(d.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...t,levels:i},invalidColumns:s}}function Wa(t,o){const n=[],i=new Set(o.map(d=>d.name)),s={...t};if(s.filters&&Array.isArray(s.filters)){const d=s.filters.filter(c=>{const l=i.has(c.column);return l||n.push(`Filter for column "${c.column}" ignored (column not found)`),l});s.filters=d.length>0?d:void 0}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:d,invalidColumns:c}=Ei(s.sortStack,o);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),s.sortStack=d.length>0?d:void 0}if(s.grouping){const{validGrouping:d,invalidColumns:c}=Oi(s.grouping,o);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),s.grouping=d}if(s.columnVisibility){const d={};Object.entries(s.columnVisibility).forEach(([c,l])=>{i.has(c)?d[c]=l:n.push(`Column visibility for "${c}" ignored (column not found)`)}),s.columnVisibility=Object.keys(d).length>0?d:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const d=s.columnOrder.filter(c=>{const l=i.has(c);return l||n.push(`Column "${c}" in order ignored (column not found)`),l});s.columnOrder=d.length>0?d:void 0}if(s.columnWidths){const d={};Object.entries(s.columnWidths).forEach(([c,l])=>{i.has(c)?d[c]=l:n.push(`Column width for "${c}" ignored (column not found)`)}),s.columnWidths=Object.keys(d).length>0?d:void 0}return{sanitizedConfig:s,warnings:n}}function Pa(t,o){return wt("processing","export",t,{retryAvailable:!!(o!=null&&o.onRetry)})}function In(t,o,n,i){const s=Ii(t,o,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Di(i||[],s)}function Na(t){return t==null}function La(t,o){const{operator:n,value:i}=o;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(Na(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 Fa(t,o){return!o||o.length===0?t:t.filter(n=>o.every(i=>La(n[i.column],i)))}function Dn(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 oo(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function Va({data:t,filters:o}){return{filteredData:p.useMemo(()=>!o||o.length===0?t:Fa(t,o),[t,o])}}function Ha(t,o,n,i){if(!n||n.trim()==="")return t;const s=n.toLowerCase().trim(),d=o.filter(c=>i.includes(c.name));return t.filter(c=>d.some(l=>{const u=c[l.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function Ua({data:t,searchQuery:o,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!o||o.trim()===""?t:Ha(t,n,o,i),[t,o,n,i])}}function Ya({data:t,sortStack:o,schema:n}){return{sortedData:p.useMemo(()=>!o||o.length===0?t:Qs(t,n,o),[t,o,n])}}function Ga({data:t,grouping:o,schema:n}){const i=p.useMemo(()=>!o||!o.enabled||o.levels.length===0?t:oa(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 qa({schema:t,columnVisibility:o,columnOrder:n}){const i=p.useMemo(()=>n.filter(l=>o[l]!==!1),[n,o]),s=p.useMemo(()=>Object.entries(o).filter(([l,u])=>!u).map(([l,u])=>l),[o]),d=p.useMemo(()=>n.map(l=>t.find(f=>f.name===l)||{name:l,type:"string"}),[n,t]),c=p.useMemo(()=>i.map(l=>t.find(f=>f.name===l)||{name:l,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:s,allColumns:d,visibleColumnSchemas:c,hiddenCount:s.length}}function Ja({views:t,activeViewId:o,currentState:n}){const i=p.useMemo(()=>t.find(f=>f.id===o),[t,o]),s=p.useMemo(()=>i?sa(n,i.snapshot):!1,[i,n]),d=p.useMemo(()=>t.find(f=>f.isDefault),[t]),c=p.useMemo(()=>t.filter(f=>!f.isDefault&&!f.isDeleted),[t]),l=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:d,customViews:c,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Ka({data:t,enabled:o=!1,pageSize:n=100,initialPage:i=1}){const[s,d]=p.useState(i),c=t.length,l=Math.ceil(c/n),u=p.useMemo(()=>{if(!o)return t;const b=(s-1)*n,D=b+n;return t.slice(b,D)},[t,o,s,n]),f=p.useCallback(b=>{const D=Math.max(1,Math.min(b,l));d(D)},[l]),m=p.useCallback(()=>{s<l&&d(s+1)},[s,l]),h=p.useCallback(()=>{s>1&&d(s-1)},[s]),x=p.useCallback(()=>{d(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:f,nextPage:m,prevPage:h,resetPage:x,hasNextPage:s<l,hasPrevPage:s>1}}function Xa(t){const{rawData:o,schema:n,filters:i,sortStack:s,grouping:d,searchQuery:c,columnVisibility:l,columnOrder:u,columnWidths:f,views:m,activeViewId:h,pagination:x}=t,b=p.useMemo(()=>({filters:i,sortStack:s,grouping:d,columnVisibility:l,columnOrder:u,columnWidths:f}),[i,s,d,l,u,f]),D=Ja({views:m,activeViewId:h,currentState:b}),g=qa({schema:n,columnVisibility:l,columnOrder:u}),{filteredData:j}=Va({data:o,filters:i}),{sortedData:w}=Ya({data:j,sortStack:s,schema:n}),{groupedData:I,isGrouped:v}=Ga({data:w,grouping:d,schema:n}),{searchedData:S}=Ua({data:I,searchQuery:c,schema:n,visibleColumns:g.visibleColumns}),C=Ka({data:S,enabled:(x==null?void 0:x.enabled)||!1,pageSize:(x==null?void 0:x.pageSize)||100,initialPage:(x==null?void 0:x.currentPage)||1}),a=x!=null&&x.enabled?C.paginatedData:S,z=p.useMemo(()=>({totalRows:o.length,filteredRows:j.length,sortedRows:w.length,groupedRows:v?I.length:w.length,searchedRows:S.length,visibleRows:a.length,hiddenColumns:g.hiddenCount,activeFilters:i.length,activeSorts:s.length,isGrouped:v}),[o.length,j.length,w.length,I.length,S.length,a.length,g.hiddenCount,i.length,s.length,v]);return{data:a,filteredData:j,sortedData:w,groupedData:I,searchedData:S,viewEngine:D,columnEngine:g,paginationEngine:C,metrics:z,isGrouped:v,isPaginated:(x==null?void 0:x.enabled)||!1}}let Qa=0;function Za(t){t!==null&&t.__urm_row_id__===void 0&&Object.defineProperty(t,"__urm_row_id__",{value:Qa++,writable:!1,enumerable:!1,configurable:!1})}const xt="user-demo-001";function el(t={}){var xn,mn,hn,fn,gn;const{mode:o="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:d,sharedReportId:c,config:l={}}=t,[u,f]=p.useState([]),m=nr(),[h,x]=p.useState(""),[b,D]=p.useState(!1),[g,j]=p.useState(!1),[w,I]=p.useState({message:"",severity:"info",open:!1}),v=(T,O="info")=>{I({message:T,severity:O,open:!0})},S=()=>I(T=>({...T,open:!1})),C=l.notifDurationMs??2e3,a=u.find(T=>T.id===h),[z,R]=p.useState("idle"),[q,K]=p.useState(!1),[ee,y]=p.useState(!1),[M,W]=p.useState(!1),[V,Q]=p.useState(!1),[xe,de]=p.useState(!1),[L,A]=p.useState(!1),[H,ie]=p.useState(void 0),[Y,re]=p.useState(null),[se,oe]=p.useState(null),[P,ne]=p.useState(!1),[ce,ae]=p.useState(!1),[fe,G]=p.useState(null),[Ae,Qe]=p.useState(!1),[Ze,Bt]=p.useState(!1),[ar,It]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Dt,Et]=p.useState(""),[lt,Ve]=p.useState(""),[Vt,et]=p.useState(new Set),[Ue,He]=p.useState(1),[nt,Ir]=p.useState(15),[lr,Ht]=p.useState(!1),[cr,Ut]=p.useState(!1),[Dr,Yt]=p.useState(!1),[ft,it]=p.useState(null),[dr,Gt]=p.useState(!1),[ur,qt]=p.useState(null),[Er,tt]=p.useState(null),Ot=p.useRef(null),ke=p.useMemo(()=>a?ga(a.permissions,xt):"owner",[a]),At=ya(ke),Or=p.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:Oa(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),Ye=p.useCallback(()=>{a&&(Ot.current=Ma(a))},[a]),F=p.useCallback((T,O)=>{f(_=>_.map($=>$.id===T?{...$,...O}:$))},[]),Ge=p.useCallback(T=>{if(!a)return;tt(T);const O=In(a.id,xt,T,a.auditHistory||[]);F(a.id,{auditHistory:O}),v(T.message,"error"),T.recoverable&&Ot.current&&setTimeout(()=>{Ra(a,Ot.current,F),v("Previous state restored","success")},100)},[a,F]),be=p.useCallback((T,O,_,$)=>{if(!a)return;const Z=Ii(a.id,xt,T,O,_,$),X=a.auditHistory||[],me=Di(X,Z);setTimeout(()=>{F(a.id,{auditHistory:me})},0)},[a,F]);p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const T=No(a.schema);(()=>{try{const O=localStorage.getItem("urm_dev_config");return O?JSON.parse(O):null}catch{return null}})(),F(a.id,{views:[T],activeViewId:T.id,filters:T.snapshot.filters,sortStack:T.snapshot.sortStack,columnVisibility:T.snapshot.columnVisibility,columnOrder:T.snapshot.columnOrder,columnWidths:T.snapshot.columnWidths,grouping:T.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,F]),p.useEffect(()=>{if(i&&n&&!g&&u.length===0){const T=co(i),O={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:T,schema:Wr(T),permissions:{owner:xt,editors:[],viewers:[]}};f([O]),x(O.id),j(!0),R("confirmed")}},[i,n,g,u.length,o,d]),p.useEffect(()=>{if(!s||g)return;let T=!1,O=null;const _=async()=>{try{R("uploading");let $;if(s.type==="api"){const X=await fetch(s.url,{headers:s.headers||{}});if(!X.ok)throw new Error(`HTTP ${X.status}: ${X.statusText}`);$=await X.json()}else $=await s.fetch();if(T)return;if(!Array.isArray($))throw new Error("Data source must return an array of objects");const Z=Wr($);if(g)f(X=>X.map(me=>me.id===h?{...me,uploadedData:$}:me)),R("confirmed");else{const X={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:co($),schema:Wr(co($)),permissions:{owner:xt,editors:[],viewers:[]}};f([X]),x(X.id),j(!0),R("confirmed")}}catch($){T||(R("error"),a&&F(a.id,{uploadError:($==null?void 0:$.message)||"Failed to load data from source"}))}};return _(),s.refreshInterval&&s.refreshInterval>0&&(O=setInterval(_,s.refreshInterval)),()=>{T=!0,O&&clearInterval(O)}},[s,d,o]);const Pe=(xn=a==null?void 0:a.views)==null?void 0:xn.find(T=>T.id===a.activeViewId),Ar=p.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(Za),a.uploadedData):[],[a==null?void 0:a.uploadedData]),gt=Xa({rawData:Ar,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:lt||"",columnVisibility:(a==null?void 0:a.columnVisibility)||(Pe==null?void 0:Pe.snapshot.columnVisibility)||{},columnOrder:(a==null?void 0:a.columnOrder)||(Pe==null?void 0:Pe.snapshot.columnOrder)||[],columnWidths:(a==null?void 0:a.columnWidths)||(Pe==null?void 0:Pe.snapshot.columnWidths)||{},views:(a==null?void 0:a.views)||[],activeViewId:(a==null?void 0:a.activeViewId)||"",pagination:{enabled:!0,pageSize:nt,currentPage:Ue}}),{data:$r=[],searchedData:yt=[],groupedData:Jt=[],metrics:Kt={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:pr=!1,paginationEngine:Te}=gt||{},U=((mn=gt.viewEngine)==null?void 0:mn.activeView)||Pe,_e=((hn=gt.viewEngine)==null?void 0:hn.isDirty)||!1;p.useEffect(()=>{if(!(!U||!a)&&!a.columnOrder){const T=U.snapshot.columnOrder,O=Vr(T,U.snapshot.grouping);F(a.id,{columnOrder:O})}},[a==null?void 0:a.activeViewId]);const we=p.useMemo(()=>!(a!=null&&a.schema)||!U?null:ia(a.filters||[],a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,U.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,U]),ct=p.useMemo(()=>!U||!we||!_e?[]:la(we,U.snapshot),[U,we,_e]),Le=p.useCallback((T,O,_)=>{const $={id:`report-${Date.now()}`,name:T,description:O,schemaLocked:!1,permissions:{owner:xt,editors:[],viewers:[]}};if(_&&Array.isArray(_)&&_.length>0){const Z=Wr(_),X=No(Z);$.uploadedData=_,$.schema=Z,$.schemaLocked=!0,$.views=[X],$.activeViewId=X.id,$.sortStack=X.snapshot.sortStack,$.filters=X.snapshot.filters,$.columnVisibility=X.snapshot.columnVisibility,$.columnOrder=X.snapshot.columnOrder,$.columnWidths=X.snapshot.columnWidths,$.grouping=X.snapshot.grouping}f(Z=>[...Z,$]),x($.id),D(!1),R("confirmed")},[]),xr=p.useCallback(T=>{a&&(R("uploading"),setTimeout(()=>{const O=Wr(T);F(a.id,{uploadedData:T,schema:O,uploadError:void 0}),R("preview")},500))},[a,F]),mr=p.useCallback(T=>{a&&(F(a.id,{uploadError:T}),R("idle"))},[a,F]),hr=p.useCallback(()=>{a&&(F(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),R("idle"))},[a,F]),bt=p.useCallback(()=>{a&&(F(a.id,{schemaLocked:!0}),R("confirmed"))},[a,F]),Mr=p.useCallback(T=>{if(!a)return;if(!ut("edit_sorting",ke)){v(pt("edit_sorting"),"error");return}const O=a.sortStack??[],_=O.find($=>$.column===T);if(_){const $=Zs(_.direction);if($===null){const Z=O.filter(X=>X.column!==T).map((X,me)=>({...X,priority:me+1}));F(a.id,{sortStack:Z.length>0?Z:void 0})}else{const Z=$,X=O.map(me=>me.column===T?{...me,direction:Z}:me);F(a.id,{sortStack:X})}}else{if(O.length>=m.sort.maxLevels){v(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:T,direction:"asc",priority:O.length+1};F(a.id,{sortStack:[...O,$]})}},[a,ke,F]),vt=p.useCallback(T=>{if(a)if(a.schema){const{validRules:O,invalidColumns:_}=Ei(T,a.schema);_.length>0&&v(`Removed invalid sort columns: ${_.join(", ")}`),Ye();try{F(a.id,{sortStack:O.length>0?O:void 0})}catch($){const Z=wt("processing","sorting",$);Ge(Z)}}else F(a.id,{sortStack:T.length>0?T:void 0})},[a,F,Ye,Ge]),Xt=p.useCallback(T=>{if(!a)return;const O=a.sortStack??[],_=O.find($=>$.column===T);if(!(_&&_.direction==="asc"))if(_){const $=O.map(Z=>Z.column===T?{...Z,direction:"asc"}:Z);F(a.id,{sortStack:$})}else{if(O.length>=m.sort.maxLevels){v(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:T,direction:"asc",priority:O.length+1};F(a.id,{sortStack:[...O,$]})}},[a,F]),St=p.useCallback(T=>{if(!a)return;const O=a.sortStack??[],_=O.find($=>$.column===T);if(!(_&&_.direction==="desc"))if(_){const $=O.map(Z=>Z.column===T?{...Z,direction:"desc"}:Z);F(a.id,{sortStack:$})}else{if(O.length>=m.sort.maxLevels){v(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:T,direction:"desc",priority:O.length+1};F(a.id,{sortStack:[...O,$]})}},[a,F]),st=p.useCallback(T=>{var _;if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const O=(_=a.schema)==null?void 0:_.find($=>$.name===T.column);if(O&&T.value!==void 0){const $=_a(O.type,T.operator,T.value);if(!$.isValid){v($.errorMessage||"Invalid filter value","error");return}}Ye();try{const $=a.filters??[];be("filters","filter_added",$,[...$,T]),F(a.id,{filters:[...$,T]})}catch($){const Z=wt("processing","filters",$);Ge(Z)}},[a,ke,F,Ye,Ge,be]),jt=p.useCallback((T,O)=>{if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const _=a.filters??[],$=[..._];be("filters","filter_updated",_[T],O),$[T]=O,F(a.id,{filters:$})},[a,ke,F,be]),fr=p.useCallback(T=>{if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const O=a.filters??[],_=O.filter(($,Z)=>Z!==T);be("filters","filter_removed",O[T],null),F(a.id,{filters:_.length>0?_:void 0})},[a,ke,F,be]),Fe=p.useCallback(()=>{if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const T=a.filters??[];be("filters","filter_cleared",T,null),F(a.id,{filters:void 0})},[a,ke,F,be]),$t=p.useCallback(T=>{if(!a)return;if(!ut("edit_filters",ke)){v(pt("edit_filters"),"error");return}const O=a.filters??[];be("filters","filter_cleared",O,T),F(a.id,{filters:T.length>0?T:void 0})},[a,ke,F,be]),Mt=p.useCallback(T=>{var Z;if(!a)return;const O=(Z=a.views)==null?void 0:Z.find(X=>X.id===T);if(!O)return;const _=O.snapshot.columnOrder,$=Vr(_,O.snapshot.grouping);F(a.id,{filters:O.snapshot.filters.length>0?[...O.snapshot.filters]:void 0,sortStack:O.snapshot.sortStack.length>0?[...O.snapshot.sortStack]:void 0,columnVisibility:{...O.snapshot.columnVisibility},columnOrder:$,columnWidths:{...O.snapshot.columnWidths},grouping:O.snapshot.grouping,activeViewId:T}),et(new Set),W(!1)},[a,F]),dt=p.useCallback((T,O,_)=>{var yn;if(!(a!=null&&a.schema)||!we)return;const $=a.views??[],Z=$.filter(Po=>!Po.isDeleted).length,X=((yn=m.views)==null?void 0:yn.maxViews)??10;if(Z>=X){v(`View limit reached — you can have at most ${X} saved views. Delete an existing view to create a new one.`,"error");return}const me={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:T,description:O||void 0,isDefault:_,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:xt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...we}},ze=_?$.map(Po=>({...Po,isDefault:!1})):$;F(a.id,{views:[...ze,me],activeViewId:me.id}),v(`"${T}" view created`,"success")},[a,we,F]),at=p.useCallback(()=>{var O;if(!U||!we||U.isDefault||!a)return;const T=(O=a.views)==null?void 0:O.map(_=>_.id===U.id?{..._,snapshot:{...we}}:_);F(a.id,{views:T}),v(`"${U.name}" view updated`,"success")},[U,we,a,F]),Rt=p.useCallback(T=>{var $;if(!U||!we||!a)return;const O=T??we.columnWidths,_=($=a.views)==null?void 0:$.map(Z=>Z.id===U.id?{...Z,snapshot:{...Z.snapshot,columnVisibility:we.columnVisibility,columnOrder:we.columnOrder,columnWidths:O},updatedAt:Date.now()}:Z);F(a.id,{views:_,columnWidths:O}),v(`Column configuration saved to "${U.name}"`,"success")},[U,we,a,F]),Rr=p.useCallback(T=>{var X,me;if(!we||!a||!U)return;const O=T??we.columnWidths,_={...U,snapshot:{...U.snapshot,columnVisibility:we.columnVisibility,columnOrder:we.columnOrder,columnWidths:O},updatedAt:Date.now()},$=(X=a.views)==null?void 0:X.map(ze=>ze.id===U.id?_:{...ze,snapshot:{...ze.snapshot,columnVisibility:we.columnVisibility,columnOrder:we.columnOrder,columnWidths:O},updatedAt:Date.now()});F(a.id,{views:$,columnWidths:O});const Z=(((me=a.views)==null?void 0:me.length)||0)-1;v(`Column configuration saved to current view and ${Z} other view${Z===1?"":"s"}`,"success")},[we,a,U,F]),Qt=p.useCallback(()=>{Q(!0)},[]),gr=p.useCallback(()=>{if(!U||!a)return;const T=U.snapshot.columnOrder,O=Vr(T,U.snapshot.grouping);F(a.id,{filters:U.snapshot.filters.length>0?[...U.snapshot.filters]:void 0,sortStack:U.snapshot.sortStack.length>0?[...U.snapshot.sortStack]:void 0,columnVisibility:{...U.snapshot.columnVisibility},columnOrder:O,columnWidths:{...U.snapshot.columnWidths},grouping:U.snapshot.grouping}),v("Changes reverted to last saved state","success")},[U,a,F]),yr=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.map($=>({...$,isDefault:$.id===T}));F(a.id,{views:O});const _=a.views.find($=>$.id===T);_&&v(`"${_.name}" set as default view`,"success")},[a,F]),br=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.map($=>$.id===T?{...$,isFavorite:!$.isFavorite,updatedAt:Date.now()}:$);F(a.id,{views:O});const _=a.views.find($=>$.id===T);_&&!_.isFavorite?v(`"${_.name}" added to favorites`,"success"):_&&v(`"${_.name}" removed from favorites`,"info")},[a,F]),vr=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.map(X=>X.id===T?{...X,isDeleted:!0,updatedAt:Date.now()}:X),_=a.activeViewId===T,$=O.find(X=>X.isDefault&&!X.isDeleted);F(a.id,{views:O,activeViewId:_&&$?$.id:a.activeViewId,filters:_&&$?$.snapshot.filters.length>0?$.snapshot.filters:void 0:a.filters,sortStack:_&&$?$.snapshot.sortStack.length>0?$.snapshot.sortStack:void 0:a.sortStack});const Z=a.views.find(X=>X.id===T);Z&&v(`"${Z.name}" moved to Recently Deleted`,"info")},[a,F]),Sr=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.map($=>$.id===T?{...$,isDeleted:!1,updatedAt:Date.now()}:$);F(a.id,{views:O});const _=a.views.find($=>$.id===T);_&&v(`"${_.name}" restored`,"success")},[a,F]),le=p.useCallback(T=>{if(!(a!=null&&a.views))return;const O=a.views.find(ze=>ze.id===T),_=a.views.filter(ze=>!ze.isDeleted||ze.id===T);if((O==null?void 0:O.isDefault)&&_.filter(ze=>ze.isDefault).length===1){v("Cannot delete the last default view","error");return}const Z=a.views.filter(ze=>ze.id!==T),X=a.activeViewId===T,me=Z.find(ze=>ze.isDefault&&!ze.isDeleted);F(a.id,{views:Z,activeViewId:X&&me?me.id:a.activeViewId,filters:X&&me?me.snapshot.filters.length>0?me.snapshot.filters:void 0:a.filters,sortStack:X&&me?me.snapshot.sortStack.length>0?me.snapshot.sortStack:void 0:a.sortStack}),O&&v(`"${O.name}" permanently deleted`,"success")},[a,F]),he=p.useCallback(T=>{re(T),de(!0),W(!1)},[]),$e=p.useCallback((T,O)=>{if(!Y||!(a!=null&&a.views))return;const _=a.views.map($=>$.id===Y?{...$,name:T,description:O||void 0}:$);F(a.id,{views:_}),re(null)},[Y,a,F]),_t=p.useCallback(T=>{oe(T),A(!0),W(!1)},[]),Wt=p.useCallback(()=>{if(!se||!(a!=null&&a.views))return;const T=a.views.filter($=>$.id!==se),O=a.activeViewId===se,_=T.find($=>$.isDefault);F(a.id,{views:T,activeViewId:O&&_?_.id:a.activeViewId,filters:O&&_?_.snapshot.filters.length>0?_.snapshot.filters:void 0:a.filters,sortStack:O&&_?_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0:a.sortStack}),oe(null),A(!1)},[se,a,F]),We=p.useCallback(T=>{var Z;if(!(a!=null&&a.views))return;if(!(((Z=m.views)==null?void 0:Z.isAdmin)??!1)){v("Only administrators can promote views to Global.","error");return}const _=a.views.find(X=>X.id===T);if(!_)return;if(_.scope==="global"){v(`"${_.name}" is already a Global View.`,"info");return}const $=a.views.map(X=>X.id===T?{...X,scope:"global",isDefault:!0,updatedAt:Date.now()}:X.scope==="global"&&X.isDefault?{...X,isDefault:!1}:X);F(a.id,{views:$}),v(`"${_.name}" promoted to Global View and set as default.`,"success")},[a,m,F]);p.useEffect(()=>{Te!=null&&Te.resetPage?Te.resetPage():He(1)},[a==null?void 0:a.filters,lt,a==null?void 0:a.activeViewId]),p.useEffect(()=>{Te&&Te.currentPage!==Ue&&He(Te.currentPage)},[Te==null?void 0:Te.currentPage]);const Pt=p.useCallback(T=>{Te!=null&&Te.goToPage&&Te.goToPage(T),He(T)},[Te]),Qr=p.useCallback(T=>{const O=(Ue-1)*nt,_=Math.floor(O/T)+1;Ir(T),He(_),Te==null||Te.goToPage(_)},[Ue,nt,Te]),pn=p.useCallback((T,O)=>{if(!a)return;if(!ut("edit_columns",ke)){v(pt("edit_columns"),"error");return}const $={...a.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{},[T]:O};F(a.id,{columnVisibility:$})},[a,U,ke,F]),jr=p.useCallback(T=>{if(a){if(!ut("edit_columns",ke)){v(pt("edit_columns"),"error");return}F(a.id,{columnOrder:T})}},[a,ke,F]),_o=p.useCallback((T,O)=>{if(!a)return;if(!ut("edit_columns",ke)){v(pt("edit_columns"),"error");return}const $={...a.columnWidths||(U==null?void 0:U.snapshot.columnWidths)||{},[T]:O};F(a.id,{columnWidths:$})},[a,U,ke,F]),Zr=p.useCallback(T=>{if(!a)return;const _=(a.filters??[]).filter($=>$.column!==T);F(a.id,{filters:_.length>0?_:void 0})},[a,F]),eo=p.useCallback(()=>{if(!U||!(a!=null&&a.schema))return;const T={},O=[],_={};a.schema.forEach($=>{T[$.name]=!0,O.push($.name),_[$.name]=170}),F(a.id,{columnVisibility:T,columnOrder:O,columnWidths:_,filters:void 0,sortStack:void 0}),v("Reset to default layout - all filters and sorts cleared","success")},[U,a,F]);p.useEffect(()=>{const T=setTimeout(()=>Ve(Dt),300);return()=>clearTimeout(T)},[Dt]);const E=p.useCallback(T=>{Et(T)},[]),J=p.useCallback(T=>{if(!T.trim()||!a)return;const O=a.searchHistory||[],_=pa(O,T);F(a.id,{searchHistory:_})},[a,F]),ue=p.useCallback(T=>{if(!a)return;const O=a.searchHistory||[],_=xa(O,T);F(a.id,{searchHistory:_})},[a,F]),Ne=p.useCallback(T=>{if(!a)return;const O=a.searchHistory||[],_=ma(O,T);F(a.id,{searchHistory:_})},[a,F]),pe=p.useCallback(T=>{const O=T==null?void 0:T.__urm_row_id__;et(_=>{const $=new Set(_);if(O!==void 0){const Z=Array.from($).find(X=>(X==null?void 0:X.__urm_row_id__)===O);Z!==void 0?$.delete(Z):$.add(T)}else{const Z=JSON.stringify(T),X=Array.from($).find(me=>JSON.stringify(me)===Z);X!==void 0?$.delete(X):$.add(T)}return $})},[]),Zt=p.useCallback((T,O)=>{et(_=>{const $=new Set(_);for(const Z of O)T?$.add(Z):$.delete(Z);return $})},[]),Wo=p.useCallback((T,O,_)=>{et($=>{const Z=new Set($),X=Math.min(T,O),me=Math.max(T,O);for(let ze=X;ze<=me;ze++)_[ze]!==void 0&&Z.add(_[ze]);return Z})},[]),cs=p.useCallback(()=>{et(new Set)},[]),ds=p.useCallback(T=>{const O=T==null?void 0:T.__urm_row_id__;et(_=>{const $=new Set(_);if(O!==void 0){const Z=Array.from($).find(X=>(X==null?void 0:X.__urm_row_id__)===O);Z!==void 0&&$.delete(Z)}else $.delete(T);return $})},[]),us=p.useCallback(T=>{if(a){if(!ut("edit_columns",ke)){v(pt("edit_columns"),"error");return}if(T&&a.schema){const{validGrouping:O,invalidColumns:_}=Oi(T,a.schema);_.length>0&&v(`Removed invalid grouping columns: ${_.join(", ")}`,"warning"),Ye();try{const $=a.grouping;O===null?be("grouping","group_cleared",$,null):$?be("grouping","group_reordered",$,O):be("grouping","group_level_added",null,O);const Z=(U==null?void 0:U.snapshot.columnOrder)||a.columnOrder||[],X=Vr(Z,O);F(a.id,{grouping:O,columnOrder:X}),JSON.stringify(X)!==JSON.stringify(a.columnOrder)&&be("columns","column_reordered",a.columnOrder,X),Bt(!1)}catch($){const Z=wt("processing","grouping",$);Ge(Z)}}else{const O=a.grouping;be("grouping","group_cleared",O,null);const _=(U==null?void 0:U.snapshot.columnOrder)||a.columnOrder||[];F(a.id,{grouping:T,columnOrder:[..._]}),JSON.stringify(_)!==JSON.stringify(a.columnOrder)&&be("columns","column_reordered",a.columnOrder,_),Bt(!1)}}},[a,U,ke,F,Ye,Ge,be]),ps=p.useCallback(T=>{if(!a)return;const O=a.grouping;if(!O)return;const _=na(O,T);F(a.id,{grouping:_})},[a,F]),xs=p.useCallback(()=>{Gt(!0)},[]),_r=p.useCallback(T=>{a!=null&&a.schema&&(ne(!0),setTimeout(()=>{try{let O;T.scope==="visible"?O=yt:O=a.uploadedData||[];let _;T.columnScope==="all"?(_={},(a.schema??[]).forEach(ze=>{_[ze.name]=!0})):_=a.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{};const $=a.columnOrder||(U==null?void 0:U.snapshot.columnOrder),Z=mo(O,a.schema,a.filters??[],a.sortStack??[],U,_,$),X=a.name;let me;switch(T.format){case"csv":ho(Z,X,T),me="export_csv";break;case"excel":fo(Z,X,T),me="export_excel";break;case"json":go(Z,X,T),me="export_json";break}be("export",me,null,{format:T.format,scope:T.scope,columnScope:T.columnScope,rowCount:O.length,viewName:(U==null?void 0:U.name)||"Default View"}),v(`Export completed successfully (${T.format.toUpperCase()})`,"success")}catch(O){const _=Pa(O,{onRetry:()=>_r(T)});v(`Export failed: ${_.message}. Click Export to retry.`,"error");const $=In(a.id,xt,_,a.auditHistory||[]);F(a.id,{auditHistory:$}),rr.error("urm:report-engine","Export failed",O)}finally{ne(!1)}},500))},[a,U,yt,F,be]),ms=p.useCallback(T=>{if(a!=null&&a.schema){if(_e&&U&&!U.isDefault){G(T.format),ae(!0),Gt(!1);return}_r(T),Gt(!1)}},[a,U,_e,_r]),to=p.useCallback(T=>{_r({format:T,scope:"visible",columnScope:"visible"})},[_r]),hs=p.useCallback(()=>{fe&&to(fe),ae(!1),G(null)},[fe,to]),fs=p.useCallback(()=>{at(),fe&&to(fe),ae(!1),G(null)},[at,fe,to]),gs=p.useCallback(()=>{ae(!1),G(null)},[]),ys=p.useCallback(T=>{!(a!=null&&a.schema)||Vt.size===0||(ne(!0),setTimeout(()=>{try{const O=Array.from(Vt),_=mo(O,a.schema,a.filters??[],a.sortStack??[],U),$=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(T){case"csv":ho(_,$);break;case"excel":fo(_,$);break;case"json":go(_,$);break}v(`Exported ${O.length} selected rows`,"info")}catch(O){v("Export failed. Please try again.","error"),rr.error("urm:report-engine","Bulk export failed",O)}finally{ne(!1)}},500))},[a,U,Vt,Jt]),bs=p.useCallback((T,O)=>{if(a)try{const _=Ta(a),$=za(T,O,xt,_),Z=Ba(a.presets,$);F(a.id,{presets:Z}),be("presets","preset_created",null,{presetId:$.id,name:$.name}),Ut(!1),v(`Preset "${T}" saved successfully`,"success")}catch(_){v(_ instanceof Error?_.message:"Failed to create preset","error")}},[a,F,be]),vs=p.useCallback(()=>{it(null),v("Exited preset view","info")},[]),Ss=p.useCallback(()=>{Yt(!0)},[]),js=p.useCallback((T,O)=>{if(!a)return;const _=Ia(a.presets,T);F(a.id,{presets:_}),be("presets","preset_deleted",{presetId:T,name:O},null),ft===T&&it(null),v(`Preset "${O}" deleted`,"success")},[a,ft,F,be]);p.useEffect(()=>{if(!c||u.length===0)return;const T=u.find(O=>O.id===c);T&&T.id!==h&&x(T.id)},[c,u,h]),p.useEffect(()=>{if(!a)return;const T=Da();if(T&&a.presets&&a.schemaLocked&&a.schema){const O=Bn(a.presets,T);if(O){const{sanitizedConfig:_,warnings:$}=Wa(O.config,a.schema);$.length>0&&$.forEach(X=>v(X,"warning"));const Z=Ea(_);F(a.id,Z),it(T),be("presets","preset_applied",null,{presetId:O.id,name:O.name}),v(`Loaded preset: ${O.name}`,"info")}else v("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const Cs=ft?Bn(a==null?void 0:a.presets,ft):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&ca(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 T=da(a.id);if(T&&T.views.length>0){const O=T.views.find(_=>_.id===T.activeViewId);if(O)F(a.id,{views:T.views,activeViewId:T.activeViewId,filters:O.snapshot.filters.length>0?O.snapshot.filters:void 0,sortStack:O.snapshot.sortStack.length>0?O.snapshot.sortStack:void 0});else{const _=T.views.find($=>$.isDefault)||No(a.schema);F(a.id,{views:T.views,activeViewId:_.id,filters:_.snapshot.filters.length>0?_.snapshot.filters:void 0,sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0})}}}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id]);const ws=p.useCallback(T=>{var $;const O=(a==null?void 0:a.filters)??[],_=(($=m.filter)==null?void 0:$.maxConditions)??3;if(O.length>=_){v(`Filter limit reached — maximum ${_} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}ie(T),K(!0)},[a,m,v]),ks=p.useCallback(()=>{K(!1),ie(void 0)},[]),Ts=(fn=a==null?void 0:a.views)==null?void 0:fn.find(T=>T.id===Y),zs=(gn=a==null?void 0:a.views)==null?void 0:gn.find(T=>T.id===se);return{reports:u,activeReport:a,activeReportId:h,setActiveReportId:x,isModalOpen:b,setIsModalOpen:D,createReport:Le,updateReport:F,uploadState:z,handleFileUpload:xr,handleUploadError:mr,handleRetry:hr,handleConfirm:bt,paginatedData:$r,processedData:yt,displayData:Jt,tableMetrics:Kt,isGrouped:pr,tableEngine:gt,activeView:U,isDirty:_e,currentTableState:we,viewChanges:ct,filters:a==null?void 0:a.filters,showFilterPanel:q,setShowFilterPanel:K,filterFocusColumn:H,handleAddFilter:st,handleUpdateFilter:jt,handleRemoveFilter:fr,handleClearAllFilters:Fe,handleReplaceFilters:$t,handleOpenFilterForColumn:ws,handleCloseFilterPanel:ks,handleClearFiltersForColumn:Zr,sortStack:a==null?void 0:a.sortStack,showSortPanel:ee,setShowSortPanel:y,handleSort:Mr,handleUpdateSortStack:vt,handleSortAscending:Xt,handleSortDescending:St,views:a==null?void 0:a.views,showManageViews:M,setShowManageViews:W,showCreateViewModal:V,setShowCreateViewModal:Q,showEditViewModal:xe,setShowEditViewModal:de,showDeleteConfirmation:L,setShowDeleteConfirmation:A,editingView:Ts,deletingView:zs,editingViewId:Y,deletingViewId:se,handleSelectView:Mt,handleCreateView:dt,handleUpdateCurrentView:at,handleSaveColumnConfigToCurrentView:Rt,handleSaveColumnConfigToAllViews:Rr,handleSaveAsNewView:Qt,handleRevertChanges:gr,handleToggleDefault:yr,handleToggleFavorite:br,handleSoftDelete:vr,handleRestoreView:Sr,handlePermanentDelete:le,handleEditView:he,handleSaveEditView:$e,handleDeleteView:_t,handleConfirmDelete:Wt,handlePromoteToGlobal:We,showManageColumns:Ae,setShowManageColumns:Qe,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:pn,handleUpdateColumnOrder:jr,handleUpdateColumnWidth:_o,handleResetColumnLayout:eo,showGroupPanel:Ze,setShowGroupPanel:Bt,grouping:a==null?void 0:a.grouping,groupingState:ar,handleGroup:us,handleToggleGroupCollapse:ps,searchQuery:Dt,debouncedSearchQuery:lt,searchHistory:ha((a==null?void 0:a.searchHistory)||[]),handleSearchChange:E,handleAddToSearchHistory:J,handleToggleSearchFavourite:ue,handleDeleteSearchHistory:Ne,selectedRowIds:Vt,handleToggleRowSelection:pe,handleToggleAllRows:Zt,handleRangeSelection:Wo,handleClearSelection:cs,handleUpdateSelectionAfterDelete:ds,currentPage:Ue,pageSize:nt,paginationEngine:Te,handlePageChange:Pt,handlePageSizeChange:Qr,isExporting:P,showExportModal:dr,setShowExportModal:Gt,showDirtyExportWarning:ce,handleExport:xs,handleExportWithConfig:ms,handleExportSelected:ys,handleExportAnyway:hs,handleSaveAndExport:fs,handleCancelExport:gs,showAuditHistory:lr,setShowAuditHistory:Ht,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:cr,setShowCreatePreset:Ut,showManagePresets:Dr,setShowManagePresets:Yt,activePreset:Cs,activePresetId:ft,handleOpenManagePresets:Ss,handleCreatePreset:bs,handleClearActivePreset:vs,handleDeletePresetById:js,userRole:ke,isViewerRole:At,currentUserId:xt,featureLimitWarning:ur,setFeatureLimitWarning:qt,datasetMeta:Or,reportError:Er,setReportError:tt,handleError:Ge,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?Ks(a.schema):!1,snack:w,handleSnackClose:S,showSnack:v,snackDurationMs:C}}const Ai=p.createContext(void 0);function nn(t){const{children:o,initialData:n,data:i,reportName:s,dataSource:d,mode:c="builder",autoLoad:l=!0,config:u,devConfig:f,showDevPanel:m=!1,sharedReportId:h}=t,b=el({mode:c,autoLoad:l,initialData:i||n,dataSource:d,reportName:s,sharedReportId:h,config:u}),[D,g]=p.useState(()=>Os()),j=(()=>{const S=$s(D,f,!!f);return{...S,display:{...S.display,showDevPanel:m||S.display.showDevPanel}}})(),w=p.useCallback(v=>{g(v),As(v)},[]),I={...b,activeDevConfig:j,handleDevConfigChange:w};return e.jsx(vi.Provider,{value:j,children:e.jsx(Ai.Provider,{value:I,children:o})})}function jo(){const t=p.useContext(Ai);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function tl({onCreateReport:t,reports:o=[],activeReportId:n,onReportClick:i}){const s=o.find(d=>d.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(B.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(B.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(B.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function or(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 rl="$$material";function ol(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var no={exports:{}},io={exports:{}},ge={};/** @license React v16.13.1
|
|
1
|
+
"use strict";var Is=Object.defineProperty;var Bs=(t,o,n)=>o in t?Is(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n;var wn=(t,o,n)=>Bs(t,typeof o!="symbol"?o+"":o,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),Es=require("xlsx"),B=require("@mui/icons-material"),r=require("@mui/material"),ji=require("react-dom"),Ds=require("@emotion/react"),Dt=require("react-dnd"),an=require("react-dnd-html5-backend");function Ci(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 vo=Ci(u),ro=Ci(Es),Ge={sort:{maxLevels:5},filter:{maxConditions:3,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"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},wi="urm_dev_config";function Os(){try{const t=localStorage.getItem(wi);if(!t)return Ge;const o=JSON.parse(t),n={sort:{...Ge.sort,...o.sort},filter:{...Ge.filter,...o.filter},columns:{...Ge.columns,...o.columns},grouping:{...Ge.grouping,...o.grouping},export:{...Ge.export,...o.export},views:{...Ge.views,...o.views},dates:{...Ge.dates,...o.dates},display:{...Ge.display,...o.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return Ge}}function $s(t){try{localStorage.setItem(wi,JSON.stringify(t))}catch{}}function As(t,o,n){if(!n||!o)return t;const i={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},views:{...t.views,...o.views},dates:{...t.dates,...o.dates},display:{...t.display,...o.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const ki=u.createContext(Ge);function dr(){return u.useContext(ki)}const Ms=/^\d{4}-\d{2}-\d{2}$/,Rs=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,_s=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Ws=9783072e5,Ps=41024448e5,Ls=978307200,Ns=4102444800;function Fs(t){return t==null||t===""?"unknown":typeof t=="number"?Number.isInteger(t)&&t>=Ws&&t<=Ps?"timestamp_ms":Number.isInteger(t)&&t>=Ls&&t<=Ns?"timestamp_s":"unknown":typeof t!="string"?"unknown":Rs.test(t)||Ms.test(t)?"iso":_s.test(t.trim())?"locale_string":"unknown"}function Vs(t,o){const n=o.map(c=>c[t]).filter(c=>c!=null&&c!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const c of n){const l=Fs(c);i[l]++}const s=n.length,d=.7;for(const c of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[c]/s>=d)return c;return"unknown"}function Hs(t,o){if(t==null||t==="")return null;try{switch(o){case"timestamp_ms":{const n=new Date(Number(t));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(t)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(t));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(t));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const kn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Us=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ae(t){return String(t).padStart(2,"0")}function Gs(t){const o=Date.now()-t.getTime(),n=Math.abs(o),i=o>0,s=Math.floor(n/1e3),d=Math.floor(s/60),c=Math.floor(d/60),l=Math.floor(c/24),p=Math.floor(l/7),f=Math.floor(l/30),m=Math.floor(l/365);let h;return s<60?h="just now":d<60?h=`${d} minute${d!==1?"s":""}`:c<24?h=`${c} hour${c!==1?"s":""}`:l<7?h=`${l} day${l!==1?"s":""}`:p<5?h=`${p} week${p!==1?"s":""}`:f<12?h=`${f} month${f!==1?"s":""}`:h=`${m} year${m!==1?"s":""}`,s<60?h:i?`${h} ago`:`in ${h}`}function Ys(t,o){const n=t.getFullYear(),i=t.getMonth(),s=t.getDate(),d=t.getHours(),c=t.getMinutes();switch(o){case"YYYY-MM-DD":return`${n}-${Ae(i+1)}-${Ae(s)}`;case"DD/MM/YYYY":return`${Ae(s)}/${Ae(i+1)}/${n}`;case"MM/DD/YYYY":return`${Ae(i+1)}/${Ae(s)}/${n}`;case"MMM DD, YYYY":return`${kn[i]} ${Ae(s)}, ${n}`;case"DD MMM YYYY":return`${Ae(s)} ${kn[i]} ${n}`;case"MMMM D, YYYY":return`${Us[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ae(i+1)}-${Ae(s)} ${Ae(d)}:${Ae(c)}`;case"DD/MM/YYYY HH:mm":return`${Ae(s)}/${Ae(i+1)}/${n} ${Ae(d)}:${Ae(c)}`;case"MM/DD/YYYY HH:mm":return`${Ae(i+1)}/${Ae(s)}/${n} ${Ae(d)}:${Ae(c)}`;case"relative":return Gs(t);case"locale":return t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return t.toLocaleDateString()}}function qs(t,o,n){if(!n||o==="unknown")return String(t);const i=Hs(t,o);return!i||isNaN(i.getTime())?String(t):Ys(i,n)}function Js(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 Ti(t,o="",n=0){if(n>2)return{[o]:t};const i={};for(const s of Object.keys(t)){const d=o?`${o}.${s}`:s,c=t[s];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,Ti(c,d,n+1)):i[d]=c}return i}function co(t){return t.map(o=>typeof o!="object"||o===null||Array.isArray(o)?o:Ti(o))}function Rr(t){if(!Array.isArray(t)||t.length===0)return[];const o=co(t),n=new Set;o.forEach(c=>{typeof c=="object"&&c!==null&&Object.keys(c).forEach(l=>n.add(l))});const i=[];n.forEach(c=>{const l=new Set;let p=0;o.forEach(x=>{typeof x=="object"&&x!==null&&c in x&&(p++,l.add(Js(x[c])))});const f=p===o.length,m=l.size>1&&!l.has("null");let h="mixed";if(l.size===1)h=Array.from(l)[0];else if(l.size===2&&l.has("null")){const x=Array.from(l).filter(b=>b!=="null");x.length===1&&(h=x[0])}i.push({name:c,type:h,required:f,hasConflict:m})});const d=o.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=Vs(c.name,d);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function Ks(t){return t.some(o=>o.hasConflict)}function qe(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 Tn(t){return t==null}function Xs(t){return(o,n,i)=>{const s=Tn(o),d=Tn(n);if(s&&d)return 0;if(s)return 1;if(d)return-1;let c=0;switch(t){case"number":const l=Number(o),p=Number(n);c=l-p;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 Qs(t,o,n){if(!n||n.length===0)return t;const i=[...n].sort((s,d)=>s.priority-d.priority);return[...t].sort((s,d)=>{for(const c of i){const l=o.find(m=>m.name===c.column);if(!l)continue;const f=Xs(l.type)(s[c.column],d[c.column],c.direction);if(f!==0)return f}return 0})}function Zs(t){return t===null?"asc":t==="asc"?"desc":null}function ea(t){return t==="string"||t==="boolean"}function ta(t){return t.filter(o=>ea(o.type))}function ra(t,o){const n={};return o.forEach(i=>{if(i.type==="number"){const s=t.map(d=>d[i.name]).filter(d=>typeof d=="number");s.length>0&&(n[i.name]=s.reduce((d,c)=>d+c,0))}}),n}function oa(t,o,n){if(!n.enabled||n.levels.length===0)return t;const i=zi(t,n.levels,o);return Ii(i,n.collapsedGroups||[])}function zi(t,o,n,i="",s=0){if(s>=o.length)return t;const d=o[s].column,c=new Map;t.forEach(f=>{const m=f[d],h=m==null?"(empty)":String(m);c.has(h)||c.set(h,[]),c.get(h).push(f)});const l=[];return Array.from(c.keys()).sort().forEach(f=>{const m=c.get(f),h=`${d}:${f}`,x=i?`${i}|${h}`:h,b=ra(m,n),E=s<o.length-1?zi(m,o,n,x,s+1):m,g={key:x,level:s,column:d,value:f,rowCount:m.length,aggregates:b,children:E};l.push(g)}),l}function Ii(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&&Ii(i.children,o,n)}else n.push(i);return n}function na(t,o){const n=t.collapsedGroups||[],i=n.includes(o)?n.filter(s=>s!==o):[...n,o];return{...t,collapsedGroups:i}}function Bi(t,o){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function Ei(t,o,n){return`${o}: ${n}`}function Nr(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 Di(t,o,n){if(!o||!o.enabled||!o.levels||o.levels.length===0)return[...t];const i=o.levels.map(d=>d.column),s=t.filter(d=>!i.includes(d));if(n){const d=[],c=new Set(i),l=new Set(s);let p=0;for(const f of n)c.has(f)?d.push(f):l.has(f)&&p<s.length?(d.push(s[p]),p++):l.has(f)||d.push(f);for(let f=p;f<s.length;f++)d.includes(s[f])||d.push(s[f]);return d}return[...t]}function Uo(t){const o={},n=[],i={};return t.forEach(s=>{o[s.name]=!0,n.push(s.name),i[s.name]=170}),{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 ia(t,o,n,i,s,d,c,l){const p={},f=[],m={};n.forEach(b=>{p[b.name]=!0,f.push(b.name),m[b.name]=170});const x=Di(s||f,c||null,l||f);return{filters:t||[],sortStack:o||[],columnVisibility:i||p,columnOrder:x,columnWidths:d||m,grouping:c||null}}function sa(t,o){const n=x=>{if(x==null)return x;if(Array.isArray(x))return x.map(b=>n(b));if(typeof x=="object"){const b={};return Object.keys(x).sort().forEach(E=>{b[E]=n(x[E])}),b}return x},i=x=>JSON.stringify(n(x));if(i(t.filters)!==i(o.filters)||i(t.sortStack)!==i(o.sortStack))return!0;const s=t.columnVisibility??{},d=o.columnVisibility??{};if(i(s)!==i(d))return!0;const c=[...t.columnOrder||[]].sort().join(","),l=[...o.columnOrder||[]].sort().join(",");if(c!==l)return!1;const p=[...o.columnOrder||[]].sort().join(",");if((o.columnOrder||[]).join(",")!==p){if((t.columnOrder||[]).join(",")!==(o.columnOrder||[]).join(","))return!0}else{const x=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==x)return!0}const m=t.columnWidths??{},h=o.columnWidths??{};return i(m)!==i(h)||i(t.grouping)!==i(o.grouping)}function aa(t){return!t||t.length===0?"None":t.sort((o,n)=>o.priority-n.priority).map(o=>`${o.column} ${o.direction==="asc"?"↑":"↓"}`).join(", ")}function la(t,o){var g,j,k;const n=[],i=JSON.stringify(t.filters),s=JSON.stringify(o.filters);if(i!==s){const v=t.filters.length,C=o.filters.length;v>C?n.push({category:"filters",label:"Filters Added",description:`${v-C} new filter${v-C>1?"s":""} added`}):v<C?n.push({category:"filters",label:"Filters Removed",description:`${C-v} filter${C-v>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const d=JSON.stringify(t.sortStack),c=JSON.stringify(o.sortStack);if(d!==c){const v=t.sortStack.length,C=o.sortStack.length;v>C?n.push({category:"sorting",label:"Sorting Added",description:`${v-C} new sort rule${v-C>1?"s":""} added`}):v<C?n.push({category:"sorting",label:"Sorting Removed",description:`${C-v} sort rule${C-v>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const l=JSON.stringify(t.columnVisibility),p=JSON.stringify(o.columnVisibility);if(l!==p){const v=Object.values(t.columnVisibility).filter(S=>S).length,C=Object.values(o.columnVisibility).filter(S=>S).length;v>C?n.push({category:"visibility",label:"Columns Shown",description:`${v-C} column${v-C>1?"s":""} made visible`}):v<C?n.push({category:"visibility",label:"Columns Hidden",description:`${C-v} column${C-v>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const f=JSON.stringify(t.columnOrder),m=JSON.stringify(o.columnOrder);f!==m&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const h=JSON.stringify(t.columnWidths),x=JSON.stringify(o.columnWidths);if(h!==x){const v=Object.keys(t.columnWidths).filter(C=>t.columnWidths[C]!==o.columnWidths[C]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${v} column width${v>1?"s":""} modified`})}const b=JSON.stringify(t.grouping),E=JSON.stringify(o.grouping);if(b!==E){const v=(g=t.grouping)==null?void 0:g.enabled,C=(j=o.grouping)==null?void 0:j.enabled;if(v&&!C){const S=((k=t.grouping)==null?void 0:k.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${S} grouping level${S>1?"s":""} added`})}else!v&&C?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}function zn(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function In(t){return`[${t}]`}const lr={warn(t,o,...n){zn()&&console.warn(In(t),o,...n)},error(t,o,...n){zn()&&console.error(In(t),o,...n)}},Oi="urm_report_";function ca(t,o){try{const n=`${Oi}${t}`;localStorage.setItem(n,JSON.stringify(o))}catch(n){lr.error("urm:persistence","Failed to save report state",n)}}function da(t){try{const o=`${Oi}${t}`,n=localStorage.getItem(o);return n?JSON.parse(n):null}catch(o){return lr.error("urm:persistence","Failed to load report state",o),null}}function So(t,o,n=0){const i=[];for(const s of t){const d=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:d}),!d&&s.children&&s.children.length>0){const c=s.children[0];if(ua(c)){const l=s.children,p=So(l,o,n+1);i.push(...p)}else{const l=s.children;for(const p of l)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:p})}}}return i}function ua(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 ln(t){return t.filter(o=>o.type==="row").map(o=>o.type==="row"?o.data:null).filter(o=>o!==null)}function cn(t,o){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),d=String(n.getDate()).padStart(2,"0"),c=`${i}-${s}-${d}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${o}`}function mo(t,o,n,i,s,d,c){let l,p;d?(l={...d},p=c||o.map(m=>m.name)):s?(l={...s.snapshot.columnVisibility},p=c||[...s.snapshot.columnOrder]):(l={},p=[],o.forEach(m=>{l[m.name]=!0,p.push(m.name)}));const f=Object.entries(l).filter(([m,h])=>!h).map(([m,h])=>m);return{data:t,schema:o,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:p,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 ho(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,c=s.filter(h=>t.columnVisibility[h]);let l;if(d&&d.enabled){const h=d.collapsedGroups??[],x=So(i,h);l=ln(x)}else l=i;const p=c.join(","),f=l.map(h=>c.map(x=>{const b=h[x];if(b==null)return"";const E=String(b);return E.includes(",")||E.includes('"')||E.includes(`
|
|
2
|
+
`)?`"${E.replace(/"/g,'""')}"`:E}).join(",")),m=[p,...f].join(`
|
|
3
|
+
`);$i(m,cn(o,"csv"),"text/csv;charset=utf-8;")}function fo(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,c=s.filter(h=>t.columnVisibility[h]);let l;if(d&&d.enabled){const h=d.collapsedGroups??[],x=So(i,h);l=ln(x)}else l=i;const p=[c,...l.map(h=>c.map(x=>h[x]??""))],f=ro.utils.aoa_to_sheet(p),m=ro.utils.book_new();ro.utils.book_append_sheet(m,f,"Data"),ro.writeFile(m,cn(o,"xlsx"))}function go(t,o="export",n){const{data:i,appliedFilters:s,appliedSortStack:d,viewMeta:c,hiddenColumns:l,columnOrder:p,grouping:f}=t;let m;if(f&&f.enabled){const b=f.collapsedGroups??[],E=So(i,b);m=ln(E)}else m=i;const h={meta:{exportedAt:new Date().toISOString(),reportName:o,view:(c==null?void 0:c.name)||"Default View",filters:s.map(b=>({field:b.column,operator:b.operator,value:b.value})),sortStack:d.map(b=>({field:b.column,direction:b.direction,priority:b.priority})),grouping:f||{},hiddenColumns:l,columnOrder:p,exportConfig:n||{scope:"visible"}},data:m},x=JSON.stringify(h,null,2);$i(x,cn(o,"json"),"application/json;charset=utf-8;")}function $i(t,o,n){const i=new Blob([t],{type:n}),s=URL.createObjectURL(i),d=document.createElement("a");d.href=s,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(s)}const Bn=10;function pa(t,o){const n=o.trim();if(!n)return t;const i=t.findIndex(d=>d.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>Bn&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Bn)),s}function xa(t,o){return t.map(n=>n.query===o?{...n,isFavourite:!n.isFavourite}:n)}function ma(t,o){return t.filter(n=>n.query!==o)}function ha(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 fa={owner:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","delete_report","export_data","promote_global_view"],editor:["view_report","edit_columns","edit_filters","edit_sorting","edit_views","create_views","delete_views","export_data"],viewer:["view_report","export_data"]};function ga(t,o){return!t||t.owner===o?"owner":t.editors.includes(o)?"editor":(t.viewers.includes(o),"viewer")}function ft(t,o){return fa[o].includes(t)}function gt(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",promote_global_view:"promote views to global"}[t]||"perform this action"}.`}function ya(t){return t==="viewer"}const En=1e3;function rn(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)}function vt(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return rn(n)}const ba={equals:"equals",contains:"contains",startsWith:"starts with",endsWith:"ends with",gt:"is greater than",lt:"is less than",gte:"is greater than or equal to",lte:"is less than or equal to",isTrue:"is true",isFalse:"is false",NULL:"is empty",NOT_NULL:"is not empty"};function Go(t){if(!t||!t.column)return"a filter";const o=vt(t.column),n=ba[t.operator]??t.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(t.operator)?`"${o}" ${n}`:`"${o}" ${n} "${t.value}"`}function Dn(t){return!t||!t.enabled||t.levels.length===0?"grouping removed":`grouped by ${t.levels.map(n=>`"${vt(n.column)}"`).join(", ")}`}function va(t){var s,d,c;const{action:o,previousState:n,newState:i}=t;switch(o){case"filter_added":{const l=i&&Array.isArray(i)?i[i.length-1]:i;return{summary:`Filter added: ${Go(l)}`}}case"filter_removed":return{summary:`Filter removed: ${Go(n)}`};case"filter_updated":{const l=n,p=i;return(l==null?void 0:l.column)!==(p==null?void 0:p.column)?{summary:`Filter changed on "${vt(p==null?void 0:p.column)}"`,detail:`Previously filtered "${vt(l==null?void 0:l.column)}"`}:{summary:`Filter updated: ${Go(p)}`}}case"filter_cleared":{const l=Array.isArray(n)?n.length:0;return{summary:l>0?`All filters cleared (${l} filter${l!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const l=i!=null&&i.column?vt(i.column):"",p=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:l?`Sort added: "${l}" ${p}`:"Sort level added"}}case"sort_level_removed":{const l=n!=null&&n.column?vt(n.column):"";return{summary:l?`Sort removed: "${l}"`:"Sort level removed"}}case"sort_reordered":return{summary:"Sort order changed"};case"sort_cleared":return{summary:"All sorting cleared"};case"group_level_added":return{summary:`Grouping applied: ${Dn(i)}`};case"group_level_removed":{const l=n,p=(d=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&d.column?vt(l.levels[0].column):"";return{summary:p?`Group level removed: "${p}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Dn(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column hidden: "${vt(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${vt(l)}"`:"Column made visible"}}case"column_reordered":{const l=Array.isArray(n)?n:[],p=Array.isArray(i)?i:[];return l.length>0&&p.length>0?{summary:"Column order changed",detail:`${p.length} column${p.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const l=(i==null?void 0:i.column)??"",p=(i==null?void 0:i.width)??"";return{summary:l?`Column resized: "${vt(l)}"`:"Column resized",detail:p?`New width: ${p}px`:void 0}}case"view_created":{const l=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:l?`View created: "${l}"`:"New view created"}}case"view_updated":{const l=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:l?`View updated: "${l}"`:"View updated"}}case"view_deleted":{const l=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:l?`View deleted: "${l}"`:"View deleted"}}case"view_set_default":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Default view set to "${l}"`:"Default view changed"}}case"view_switched":{const l=(n==null?void 0:n.name)??"",p=(i==null?void 0:i.name)??"";return l&&p?{summary:`Switched to view "${p}"`,detail:`From "${l}"`}:p?{summary:`Switched to view "${p}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":{const l=o==="export_csv"?"CSV":o==="export_excel"?"Excel":"JSON",p=i==null?void 0:i.rowCount,f=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",m=(i==null?void 0:i.viewName)??"",h=typeof p=="number"?` (${p.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${h}`,detail:m?`${rn(f)} · View: "${m}"`:rn(f)}}case"export_triggered":{const l=((c=i==null?void 0:i.format)==null?void 0:c.toUpperCase())??"";return{summary:l?`Export triggered: ${l}`:"Export triggered"}}case"preset_created":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset created: "${l}"`:"New preset created"}}case"preset_applied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset applied: "${l}"`:"Preset applied"}}case"preset_deleted":{const l=(n==null?void 0:n.name)??"";return{summary:l?`Preset deleted: "${l}"`:"Preset deleted"}}case"preset_link_copied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset link copied: "${l}"`:"Preset link copied to clipboard"}}case"theme_changed":{const l=typeof n=="string"?n:(n==null?void 0:n.theme)??"",p=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return l&&p?{summary:`Theme changed from "${l}" to "${p}"`}:p?{summary:`Theme changed to "${p}"`}:{summary:"Theme changed"}}case"error_occurred":{const l=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:l?`Details: ${String(l).slice(0,120)}`:void 0}}default:return{summary:ja(o)}}}function Sa(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ai(t,o,n,i,s,d){return{id:Sa(),user:o,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:d}}function Mi(t,o){const n=[o,...t];return n.length>En?n.slice(0,En):n}function ja(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 Ca(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function wa(t){const o=new Date(t),i=new Date().getTime()-o.getTime(),s=Math.floor(i/6e4),d=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:d<24?`${d} hour${d>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"})}const On=100;function ka(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ta(t){var d;const o=(d=t.views)==null?void 0:d.find(c=>c.id===t.activeViewId),n=o==null?void 0:o.snapshot.columnOrder,i=t.columnOrder||[],s=Di(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 za(t,o,n,i){return{id:ka(),name:t,description:o,createdBy:n,createdAt:Date.now(),config:i}}function Ia(t,o){const n=t||[];if(n.length>=On)throw new Error(`Maximum of ${On} presets reached. Please delete old presets first.`);return[...n,o]}function Ba(t,o){return(t||[]).filter(i=>i.id!==o)}function $n(t,o){if(t)return t.find(n=>n.id===o)}function Ea(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Da(t){const o=t.columnOrder,n=Nr(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 Oa(t,o){return{totalRows:t.length,totalColumns:o.length}}function Et(t,o,n,i){const s=n instanceof Error?n.message:n,d={type:t,context:o,message:s,details:i,timestamp:Date.now(),recoverable:$a(t,o)};return process.env.NODE_ENV==="development"&&lr.error("urm:error-handling","[Report Error]",{type:t,context:o,message:s,details:i}),d}function $a(t,o){return t==="ui"?!0:o==="export"?!1:t==="processing"&&["filters","sorting","grouping","columns"].includes(o)?!0:t!=="system"}function Aa(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 Ma(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 Ra(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 _a(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 Ri(t,o){const n=[],i=[],s=new Set(o.map(d=>d.name));return t.forEach(d=>{s.has(d.column)?n.push(d):i.push(d.column)}),{validRules:n,invalidColumns:i}}function _i(t,o){if(!t||!t.levels||t.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(o.map(d=>d.name)),i=[],s=[];return t.levels.forEach(d=>{n.has(d.column)?i.push(d):s.push(d.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...t,levels:i},invalidColumns:s}}function Wa(t,o){const n=[],i=new Set(o.map(d=>d.name)),s={...t};if(s.filters&&Array.isArray(s.filters)){const d=s.filters.filter(c=>{const l=i.has(c.column);return l||n.push(`Filter for column "${c.column}" ignored (column not found)`),l});s.filters=d.length>0?d:void 0}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:d,invalidColumns:c}=Ri(s.sortStack,o);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),s.sortStack=d.length>0?d:void 0}if(s.grouping){const{validGrouping:d,invalidColumns:c}=_i(s.grouping,o);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),s.grouping=d}if(s.columnVisibility){const d={};Object.entries(s.columnVisibility).forEach(([c,l])=>{i.has(c)?d[c]=l:n.push(`Column visibility for "${c}" ignored (column not found)`)}),s.columnVisibility=Object.keys(d).length>0?d:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const d=s.columnOrder.filter(c=>{const l=i.has(c);return l||n.push(`Column "${c}" in order ignored (column not found)`),l});s.columnOrder=d.length>0?d:void 0}if(s.columnWidths){const d={};Object.entries(s.columnWidths).forEach(([c,l])=>{i.has(c)?d[c]=l:n.push(`Column width for "${c}" ignored (column not found)`)}),s.columnWidths=Object.keys(d).length>0?d:void 0}return{sanitizedConfig:s,warnings:n}}function Pa(t,o){return Et("processing","export",t,{retryAvailable:!!(o!=null&&o.onRetry)})}function An(t,o,n,i){const s=Ai(t,o,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Mi(i||[],s)}function La(t){return t==null}function Na(t,o){const{operator:n,value:i}=o;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(La(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 Fa(t,o){return!o||o.length===0?t:t.filter(n=>o.every(i=>Na(n[i.column],i)))}function Mn(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 oo(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function Va({data:t,filters:o}){return{filteredData:u.useMemo(()=>!o||o.length===0?t:Fa(t,o),[t,o])}}function Ha(t,o,n,i){if(!n||n.trim()==="")return t;const s=n.toLowerCase().trim(),d=o.filter(c=>i.includes(c.name));return t.filter(c=>d.some(l=>{const p=c[l.name];return p==null?!1:String(p).toLowerCase().includes(s)}))}function Ua({data:t,searchQuery:o,schema:n,visibleColumns:i}){return{searchedData:u.useMemo(()=>!o||o.trim()===""?t:Ha(t,n,o,i),[t,o,n,i])}}function Ga({data:t,sortStack:o,schema:n}){return{sortedData:u.useMemo(()=>!o||o.length===0?t:Qs(t,n,o),[t,o,n])}}function Ya({data:t,grouping:o,schema:n}){const i=u.useMemo(()=>!o||!o.enabled||o.levels.length===0?t:oa(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 qa({schema:t,columnVisibility:o,columnOrder:n}){const i=u.useMemo(()=>n.filter(l=>o[l]!==!1),[n,o]),s=u.useMemo(()=>Object.entries(o).filter(([l,p])=>!p).map(([l,p])=>l),[o]),d=u.useMemo(()=>n.map(l=>t.find(f=>f.name===l)||{name:l,type:"string"}),[n,t]),c=u.useMemo(()=>i.map(l=>t.find(f=>f.name===l)||{name:l,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:s,allColumns:d,visibleColumnSchemas:c,hiddenCount:s.length}}function Ja({views:t,activeViewId:o,currentState:n}){const i=u.useMemo(()=>t.find(f=>f.id===o),[t,o]),s=u.useMemo(()=>i?sa(n,i.snapshot):!1,[i,n]),d=u.useMemo(()=>t.find(f=>f.isDefault),[t]),c=u.useMemo(()=>t.filter(f=>!f.isDefault&&!f.isDeleted),[t]),l=u.useMemo(()=>t.filter(f=>f.isFavorite&&!f.isDeleted),[t]),p=u.useMemo(()=>t.filter(f=>f.isDeleted),[t]);return{activeView:i,isDirty:s,defaultView:d,customViews:c,favoriteViews:l,deletedViews:p,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Ka({data:t,enabled:o=!1,pageSize:n=100,initialPage:i=1}){const[s,d]=u.useState(i),c=t.length,l=Math.ceil(c/n),p=u.useMemo(()=>{if(!o)return t;const b=(s-1)*n,E=b+n;return t.slice(b,E)},[t,o,s,n]),f=u.useCallback(b=>{const E=Math.max(1,Math.min(b,l));d(E)},[l]),m=u.useCallback(()=>{s<l&&d(s+1)},[s,l]),h=u.useCallback(()=>{s>1&&d(s-1)},[s]),x=u.useCallback(()=>{d(1)},[]);return{paginatedData:p,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:f,nextPage:m,prevPage:h,resetPage:x,hasNextPage:s<l,hasPrevPage:s>1}}function Xa(t){const{rawData:o,schema:n,filters:i,sortStack:s,grouping:d,searchQuery:c,columnVisibility:l,columnOrder:p,columnWidths:f,views:m,activeViewId:h,pagination:x}=t,b=u.useMemo(()=>({filters:i,sortStack:s,grouping:d,columnVisibility:l,columnOrder:p,columnWidths:f}),[i,s,d,l,p,f]),E=Ja({views:m,activeViewId:h,currentState:b}),g=qa({schema:n,columnVisibility:l,columnOrder:p}),{filteredData:j}=Va({data:o,filters:i}),{sortedData:k}=Ga({data:j,sortStack:s,schema:n}),{groupedData:v,isGrouped:C}=Ya({data:k,grouping:d,schema:n}),{searchedData:S}=Ua({data:v,searchQuery:c,schema:n,visibleColumns:g.visibleColumns}),w=Ka({data:S,enabled:(x==null?void 0:x.enabled)||!1,pageSize:(x==null?void 0:x.pageSize)||100,initialPage:(x==null?void 0:x.currentPage)||1}),a=x!=null&&x.enabled?w.paginatedData:S,I=u.useMemo(()=>({totalRows:o.length,filteredRows:j.length,sortedRows:k.length,groupedRows:C?v.length:k.length,searchedRows:S.length,visibleRows:a.length,hiddenColumns:g.hiddenCount,activeFilters:i.length,activeSorts:s.length,isGrouped:C}),[o.length,j.length,k.length,v.length,S.length,a.length,g.hiddenCount,i.length,s.length,C]);return{data:a,filteredData:j,sortedData:k,groupedData:v,searchedData:S,viewEngine:E,columnEngine:g,paginationEngine:w,metrics:I,isGrouped:C,isPaginated:(x==null?void 0:x.enabled)||!1}}let Qa=0;function Za(t){t!==null&&t.__urm_row_id__===void 0&&Object.defineProperty(t,"__urm_row_id__",{value:Qa++,writable:!1,enumerable:!1,configurable:!1})}const yt="user-demo-001";function el(t={}){var yn,bn,vn,Sn,jn;const{mode:o="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:d,sharedReportId:c,config:l={}}=t,[p,f]=u.useState([]),m=dr(),[h,x]=u.useState(""),[b,E]=u.useState(!1),[g,j]=u.useState(!1),[k,v]=u.useState({message:"",severity:"info",open:!1}),C=(T,$="info")=>{v({message:T,severity:$,open:!0})},S=()=>v(T=>({...T,open:!1})),w=l.notifDurationMs??2e3,a=p.find(T=>T.id===h),[I,R]=u.useState("idle"),[G,q]=u.useState(!1),[ee,y]=u.useState(!1),[M,W]=u.useState(!1),[V,X]=u.useState(!1),[ue,ce]=u.useState(!1),[F,O]=u.useState(!1),[H,re]=u.useState(void 0),[U,te]=u.useState(null),[se,ne]=u.useState(null),[P,ie]=u.useState(!1),[de,ae]=u.useState(!1),[ge,K]=u.useState(null),[Ee,Ue]=u.useState(!1),[it,St]=u.useState(!1),[et,xr]=u.useState({enabled:!1,levels:[],collapsedGroups:[]}),[jt,mr]=u.useState(""),[st,qt]=u.useState(""),[Me,at]=u.useState(new Set),[lt,tt]=u.useState(1),[Ve,At]=u.useState(15),[Er,hr]=u.useState(!1),[Jt,Kt]=u.useState(!1),[fr,gr]=u.useState(!1),[ct,Xt]=u.useState(null),[Ct,dt]=u.useState(!1),[Kr,Dr]=u.useState(null),[Ke,yr]=u.useState(null),Mt=u.useRef(null),Te=u.useMemo(()=>a?ga(a.permissions,yt):"owner",[a]),Or=ya(Te),Rt=u.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:Oa(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),ut=u.useCallback(()=>{a&&(Mt.current=Ma(a))},[a]),N=u.useCallback((T,$)=>{f(_=>_.map(A=>A.id===T?{...A,...$}:A))},[]),rt=u.useCallback(T=>{if(!a)return;yr(T);const $=An(a.id,yt,T,a.auditHistory||[]);N(a.id,{auditHistory:$}),C(T.message,"error"),T.recoverable&&Mt.current&&setTimeout(()=>{Ra(a,Mt.current,N),C("Previous state restored","success")},100)},[a,N]),be=u.useCallback((T,$,_,A)=>{if(!a)return;const Z=Ai(a.id,yt,T,$,_,A),J=a.auditHistory||[],he=Mi(J,Z);setTimeout(()=>{N(a.id,{auditHistory:he})},0)},[a,N]);u.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const T=Uo(a.schema);(()=>{try{const $=localStorage.getItem("urm_dev_config");return $?JSON.parse($):null}catch{return null}})(),N(a.id,{views:[T],activeViewId:T.id,filters:T.snapshot.filters,sortStack:T.snapshot.sortStack,columnVisibility:T.snapshot.columnVisibility,columnOrder:T.snapshot.columnOrder,columnWidths:T.snapshot.columnWidths,grouping:T.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,N]),u.useEffect(()=>{if(i&&n&&!g&&p.length===0){const T=co(i),$={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:T,schema:Rr(T),permissions:{owner:yt,editors:[],viewers:[]}};f([$]),x($.id),j(!0),R("confirmed")}},[i,n,g,p.length,o,d]),u.useEffect(()=>{if(!s||g)return;let T=!1,$=null;const _=async()=>{try{R("uploading");let A;if(s.type==="api"){const J=await fetch(s.url,{headers:s.headers||{}});if(!J.ok)throw new Error(`HTTP ${J.status}: ${J.statusText}`);A=await J.json()}else A=await s.fetch();if(T)return;if(!Array.isArray(A))throw new Error("Data source must return an array of objects");const Z=Rr(A);if(g)f(J=>J.map(he=>he.id===h?{...he,uploadedData:A}:he)),R("confirmed");else{const J={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:co(A),schema:Rr(co(A)),permissions:{owner:yt,editors:[],viewers:[]}};f([J]),x(J.id),j(!0),R("confirmed")}}catch(A){T||(R("error"),a&&N(a.id,{uploadError:(A==null?void 0:A.message)||"Failed to load data from source"}))}};return _(),s.refreshInterval&&s.refreshInterval>0&&($=setInterval(_,s.refreshInterval)),()=>{T=!0,$&&clearInterval($)}},[s,d,o]);const Fe=(yn=a==null?void 0:a.views)==null?void 0:yn.find(T=>T.id===a.activeViewId),Qt=u.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(Za),a.uploadedData):[],[a==null?void 0:a.uploadedData]),_t=Xa({rawData:Qt,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:st||"",columnVisibility:(a==null?void 0:a.columnVisibility)||(Fe==null?void 0:Fe.snapshot.columnVisibility)||{},columnOrder:(a==null?void 0:a.columnOrder)||(Fe==null?void 0:Fe.snapshot.columnOrder)||[],columnWidths:(a==null?void 0:a.columnWidths)||(Fe==null?void 0:Fe.snapshot.columnWidths)||{},views:(a==null?void 0:a.views)||[],activeViewId:(a==null?void 0:a.activeViewId)||"",pagination:{enabled:!0,pageSize:Ve,currentPage:lt}}),{data:br=[],searchedData:Wt=[],groupedData:Pt=[],metrics:$r={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Zt=!1,paginationEngine:ze}=_t||{},Q=((bn=_t.viewEngine)==null?void 0:bn.activeView)||Fe,fe=((vn=_t.viewEngine)==null?void 0:vn.isDirty)||!1;u.useEffect(()=>{if(!(!Q||!a)&&!a.columnOrder){const T=Q.snapshot.columnOrder,$=Nr(T,Q.snapshot.grouping);N(a.id,{columnOrder:$})}},[a==null?void 0:a.activeViewId]);const me=u.useMemo(()=>!(a!=null&&a.schema)||!Q?null:ia(a.filters||[],a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,Q.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,Q]),vr=u.useMemo(()=>!Q||!me||!fe?[]:la(me,Q.snapshot),[Q,me,fe]),Xe=u.useCallback((T,$,_)=>{const A={id:`report-${Date.now()}`,name:T,description:$,schemaLocked:!1,permissions:{owner:yt,editors:[],viewers:[]}};if(_&&Array.isArray(_)&&_.length>0){const Z=Rr(_),J=Uo(Z);A.uploadedData=_,A.schema=Z,A.schemaLocked=!0,A.views=[J],A.activeViewId=J.id,A.sortStack=J.snapshot.sortStack,A.filters=J.snapshot.filters,A.columnVisibility=J.snapshot.columnVisibility,A.columnOrder=J.snapshot.columnOrder,A.columnWidths=J.snapshot.columnWidths,A.grouping=J.snapshot.grouping}f(Z=>[...Z,A]),x(A.id),E(!1),R("confirmed")},[]),Lt=u.useCallback(T=>{a&&(R("uploading"),setTimeout(()=>{const $=Rr(T);N(a.id,{uploadedData:T,schema:$,uploadError:void 0}),R("preview")},500))},[a,N]),pt=u.useCallback(T=>{a&&(N(a.id,{uploadError:T}),R("idle"))},[a,N]),er=u.useCallback(()=>{a&&(N(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),R("idle"))},[a,N]),Sr=u.useCallback(()=>{a&&(N(a.id,{schemaLocked:!0}),R("confirmed"))},[a,N]),ot=u.useCallback(T=>{if(!a)return;if(!ft("edit_sorting",Te)){C(gt("edit_sorting"),"error");return}const $=a.sortStack??[],_=$.find(A=>A.column===T);if(_){const A=Zs(_.direction);if(A===null){const Z=$.filter(J=>J.column!==T).map((J,he)=>({...J,priority:he+1}));N(a.id,{sortStack:Z.length>0?Z:void 0})}else{const Z=A,J=$.map(he=>he.column===T?{...he,direction:Z}:he);N(a.id,{sortStack:J})}}else{if($.length>=m.sort.maxLevels){C(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const A={column:T,direction:"asc",priority:$.length+1};N(a.id,{sortStack:[...$,A]})}},[a,Te,N]),He=u.useCallback(T=>{if(a)if(a.schema){const{validRules:$,invalidColumns:_}=Ri(T,a.schema);_.length>0&&C(`Removed invalid sort columns: ${_.join(", ")}`),ut();try{N(a.id,{sortStack:$.length>0?$:void 0})}catch(A){const Z=Et("processing","sorting",A);rt(Z)}}else N(a.id,{sortStack:T.length>0?T:void 0})},[a,N,ut,rt]),xt=u.useCallback(T=>{if(!a)return;const $=a.sortStack??[],_=$.find(A=>A.column===T);if(!(_&&_.direction==="asc"))if(_){const A=$.map(Z=>Z.column===T?{...Z,direction:"asc"}:Z);N(a.id,{sortStack:A})}else{if($.length>=m.sort.maxLevels){C(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const A={column:T,direction:"asc",priority:$.length+1};N(a.id,{sortStack:[...$,A]})}},[a,N]),mt=u.useCallback(T=>{if(!a)return;const $=a.sortStack??[],_=$.find(A=>A.column===T);if(!(_&&_.direction==="desc"))if(_){const A=$.map(Z=>Z.column===T?{...Z,direction:"desc"}:Z);N(a.id,{sortStack:A})}else{if($.length>=m.sort.maxLevels){C(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const A={column:T,direction:"desc",priority:$.length+1};N(a.id,{sortStack:[...$,A]})}},[a,N]),tr=u.useCallback(T=>{var _;if(!a)return;if(!ft("edit_filters",Te)){C(gt("edit_filters"),"error");return}const $=(_=a.schema)==null?void 0:_.find(A=>A.name===T.column);if($&&T.value!==void 0){const A=_a($.type,T.operator,T.value);if(!A.isValid){C(A.errorMessage||"Invalid filter value","error");return}}ut();try{const A=a.filters??[];be("filters","filter_added",A,[...A,T]),N(a.id,{filters:[...A,T]})}catch(A){const Z=Et("processing","filters",A);rt(Z)}},[a,Te,N,ut,rt,be]),Nt=u.useCallback((T,$)=>{if(!a)return;if(!ft("edit_filters",Te)){C(gt("edit_filters"),"error");return}const _=a.filters??[],A=[..._];be("filters","filter_updated",_[T],$),A[T]=$,N(a.id,{filters:A})},[a,Te,N,be]),jr=u.useCallback(T=>{if(!a)return;if(!ft("edit_filters",Te)){C(gt("edit_filters"),"error");return}const $=a.filters??[],_=$.filter((A,Z)=>Z!==T);be("filters","filter_removed",$[T],null),N(a.id,{filters:_.length>0?_:void 0})},[a,Te,N,be]),Ft=u.useCallback(()=>{if(!a)return;if(!ft("edit_filters",Te)){C(gt("edit_filters"),"error");return}const T=a.filters??[];be("filters","filter_cleared",T,null),N(a.id,{filters:void 0})},[a,Te,N,be]),rr=u.useCallback(T=>{if(!a)return;if(!ft("edit_filters",Te)){C(gt("edit_filters"),"error");return}const $=a.filters??[];be("filters","filter_cleared",$,T),N(a.id,{filters:T.length>0?T:void 0})},[a,Te,N,be]),Ar=u.useCallback(T=>{var Z;if(!a)return;const $=(Z=a.views)==null?void 0:Z.find(J=>J.id===T);if(!$)return;const _=$.snapshot.columnOrder,A=Nr(_,$.snapshot.grouping);N(a.id,{filters:$.snapshot.filters.length>0?[...$.snapshot.filters]:void 0,sortStack:$.snapshot.sortStack.length>0?[...$.snapshot.sortStack]:void 0,columnVisibility:{...$.snapshot.columnVisibility},columnOrder:A,columnWidths:{...$.snapshot.columnWidths},grouping:$.snapshot.grouping,activeViewId:T}),at(new Set),W(!1)},[a,N]),wt=u.useCallback((T,$,_)=>{var Cn;if(!(a!=null&&a.schema)||!me)return;const A=a.views??[],Z=A.filter(Ho=>!Ho.isDeleted).length,J=((Cn=m.views)==null?void 0:Cn.maxViews)??10;if(Z>=J){C(`View limit reached — you can have at most ${J} saved views. Delete an existing view to create a new one.`,"error");return}const he={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:T,description:$||void 0,isDefault:_,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:yt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...me}},Ie=_?A.map(Ho=>({...Ho,isDefault:!1})):A;N(a.id,{views:[...Ie,he],activeViewId:he.id}),C(`"${T}" view created`,"success")},[a,me,N]),ht=u.useCallback(()=>{var $;if(!Q||!me||!a)return;const T=($=a.views)==null?void 0:$.map(_=>_.id===Q.id?{..._,snapshot:{...me}}:_);N(a.id,{views:T}),C(`"${Q.name}" view updated`,"success")},[Q,me,a,N]),Cr=u.useCallback(T=>{var A;if(!Q||!me||!a)return;const $=T??me.columnWidths,_=(A=a.views)==null?void 0:A.map(Z=>Z.id===Q.id?{...Z,snapshot:{...Z.snapshot,columnVisibility:me.columnVisibility,columnOrder:me.columnOrder,columnWidths:$},updatedAt:Date.now()}:Z);N(a.id,{views:_,columnWidths:$}),C(`Column configuration saved to "${Q.name}"`,"success")},[Q,me,a,N]),Le=u.useCallback(T=>{var J,he;if(!me||!a||!Q)return;const $=T??me.columnWidths,_={...Q,snapshot:{...Q.snapshot,columnVisibility:me.columnVisibility,columnOrder:me.columnOrder,columnWidths:$},updatedAt:Date.now()},A=(J=a.views)==null?void 0:J.map(Ie=>Ie.id===Q.id?_:{...Ie,snapshot:{...Ie.snapshot,columnVisibility:me.columnVisibility,columnOrder:me.columnOrder,columnWidths:$},updatedAt:Date.now()});N(a.id,{views:A,columnWidths:$});const Z=(((he=a.views)==null?void 0:he.length)||0)-1;C(`Column configuration saved to current view and ${Z} other view${Z===1?"":"s"}`,"success")},[me,a,Q,N]),kt=u.useCallback(()=>{X(!0)},[]),Tt=u.useCallback(()=>{if(!Q||!a)return;const T=Q.snapshot.columnOrder,$=Nr(T,Q.snapshot.grouping);N(a.id,{filters:Q.snapshot.filters.length>0?[...Q.snapshot.filters]:void 0,sortStack:Q.snapshot.sortStack.length>0?[...Q.snapshot.sortStack]:void 0,columnVisibility:{...Q.snapshot.columnVisibility},columnOrder:$,columnWidths:{...Q.snapshot.columnWidths},grouping:Q.snapshot.grouping}),C("Changes reverted to last saved state","success")},[Q,a,N]),nt=u.useCallback(T=>{if(!(a!=null&&a.views))return;const $=a.views.map(A=>({...A,isDefault:A.id===T}));N(a.id,{views:$});const _=a.views.find(A=>A.id===T);_&&C(`"${_.name}" set as default view`,"success")},[a,N]),or=u.useCallback(T=>{if(!(a!=null&&a.views))return;const $=a.views.map(A=>A.id===T?{...A,isFavorite:!A.isFavorite,updatedAt:Date.now()}:A);N(a.id,{views:$});const _=a.views.find(A=>A.id===T);_&&!_.isFavorite?C(`"${_.name}" added to favorites`,"success"):_&&C(`"${_.name}" removed from favorites`,"info")},[a,N]),zt=u.useCallback(T=>{if(!(a!=null&&a.views))return;const $=a.views.map(J=>J.id===T?{...J,isDeleted:!0,updatedAt:Date.now()}:J),_=a.activeViewId===T,A=$.find(J=>J.isDefault&&!J.isDeleted);N(a.id,{views:$,activeViewId:_&&A?A.id:a.activeViewId,filters:_&&A?A.snapshot.filters.length>0?A.snapshot.filters:void 0:a.filters,sortStack:_&&A?A.snapshot.sortStack.length>0?A.snapshot.sortStack:void 0:a.sortStack});const Z=a.views.find(J=>J.id===T);Z&&C(`"${Z.name}" moved to Recently Deleted`,"info")},[a,N]),le=u.useCallback(T=>{if(!(a!=null&&a.views))return;const $=a.views.map(A=>A.id===T?{...A,isDeleted:!1,updatedAt:Date.now()}:A);N(a.id,{views:$});const _=a.views.find(A=>A.id===T);_&&C(`"${_.name}" restored`,"success")},[a,N]),ye=u.useCallback(T=>{if(!(a!=null&&a.views))return;const $=a.views.find(Ie=>Ie.id===T),_=a.views.filter(Ie=>!Ie.isDeleted||Ie.id===T);if(($==null?void 0:$.isDefault)&&_.filter(Ie=>Ie.isDefault).length===1){C("Cannot delete the last default view","error");return}const Z=a.views.filter(Ie=>Ie.id!==T),J=a.activeViewId===T,he=Z.find(Ie=>Ie.isDefault&&!Ie.isDeleted);N(a.id,{views:Z,activeViewId:J&&he?he.id:a.activeViewId,filters:J&&he?he.snapshot.filters.length>0?he.snapshot.filters:void 0:a.filters,sortStack:J&&he?he.snapshot.sortStack.length>0?he.snapshot.sortStack:void 0:a.sortStack}),$&&C(`"${$.name}" permanently deleted`,"success")},[a,N]),Re=u.useCallback(T=>{te(T),ce(!0),W(!1)},[]),Vt=u.useCallback((T,$)=>{if(!U||!(a!=null&&a.views))return;const _=a.views.map(A=>A.id===U?{...A,name:T,description:$||void 0}:A);N(a.id,{views:_}),te(null)},[U,a,N]),Ht=u.useCallback(T=>{ne(T),O(!0),W(!1)},[]),_o=u.useCallback(()=>{if(!se||!(a!=null&&a.views))return;const T=a.views.filter(A=>A.id!==se),$=a.activeViewId===se,_=T.find(A=>A.isDefault);N(a.id,{views:T,activeViewId:$&&_?_.id:a.activeViewId,filters:$&&_?_.snapshot.filters.length>0?_.snapshot.filters:void 0:a.filters,sortStack:$&&_?_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0:a.sortStack}),ne(null),O(!1)},[se,a,N]),Wo=u.useCallback(T=>{var Z;if(!(a!=null&&a.views))return;if(!(((Z=m.views)==null?void 0:Z.isAdmin)??!1)){C("Only administrators can promote views to Global.","error");return}const _=a.views.find(J=>J.id===T);if(!_)return;if(_.scope==="global"){C(`"${_.name}" is already a Global View.`,"info");return}const A=a.views.map(J=>J.id===T?{...J,scope:"global",isDefault:!0,updatedAt:Date.now()}:J.scope==="global"&&J.isDefault?{...J,isDefault:!1}:J);N(a.id,{views:A}),C(`"${_.name}" promoted to Global View and set as default.`,"success")},[a,m,N]);u.useEffect(()=>{ze!=null&&ze.resetPage?ze.resetPage():tt(1)},[a==null?void 0:a.filters,st,a==null?void 0:a.activeViewId]),u.useEffect(()=>{ze&&ze.currentPage!==lt&&tt(ze.currentPage)},[ze==null?void 0:ze.currentPage]);const Po=u.useCallback(T=>{ze!=null&&ze.goToPage&&ze.goToPage(T),tt(T)},[ze]),Lo=u.useCallback(T=>{const $=(lt-1)*Ve,_=Math.floor($/T)+1;At(T),tt(_),ze==null||ze.goToPage(_)},[lt,Ve,ze]),Xr=u.useCallback((T,$)=>{if(!a)return;if(!ft("edit_columns",Te)){C(gt("edit_columns"),"error");return}const A={...a.columnVisibility||(Q==null?void 0:Q.snapshot.columnVisibility)||{},[T]:$};N(a.id,{columnVisibility:A})},[a,Q,Te,N]),No=u.useCallback(T=>{if(a){if(!ft("edit_columns",Te)){C(gt("edit_columns"),"error");return}N(a.id,{columnOrder:T})}},[a,Te,N]),Fo=u.useCallback((T,$)=>{if(!a)return;if(!ft("edit_columns",Te)){C(gt("edit_columns"),"error");return}const A={...a.columnWidths||(Q==null?void 0:Q.snapshot.columnWidths)||{},[T]:$};N(a.id,{columnWidths:A})},[a,Q,Te,N]),We=u.useCallback(T=>{if(!a)return;const _=(a.filters??[]).filter(A=>A.column!==T);N(a.id,{filters:_.length>0?_:void 0})},[a,N]),It=u.useCallback(()=>{if(!Q||!(a!=null&&a.schema))return;const T={},$=[],_={};a.schema.forEach(A=>{T[A.name]=!0,$.push(A.name),_[A.name]=170}),N(a.id,{columnVisibility:T,columnOrder:$,columnWidths:_,filters:void 0,sortStack:void 0}),C("Reset to default layout - all filters and sorts cleared","success")},[Q,a,N]);u.useEffect(()=>{const T=setTimeout(()=>qt(jt),300);return()=>clearTimeout(T)},[jt]);const Qr=u.useCallback(T=>{mr(T)},[]),gn=u.useCallback(T=>{if(!T.trim()||!a)return;const $=a.searchHistory||[],_=pa($,T);N(a.id,{searchHistory:_})},[a,N]),Mr=u.useCallback(T=>{if(!a)return;const $=a.searchHistory||[],_=xa($,T);N(a.id,{searchHistory:_})},[a,N]),Vo=u.useCallback(T=>{if(!a)return;const $=a.searchHistory||[],_=ma($,T);N(a.id,{searchHistory:_})},[a,N]),Zr=u.useCallback(T=>{const $=T==null?void 0:T.__urm_row_id__;at(_=>{const A=new Set(_);if($!==void 0){const Z=Array.from(A).find(J=>(J==null?void 0:J.__urm_row_id__)===$);Z!==void 0?A.delete(Z):A.add(T)}else{const Z=JSON.stringify(T),J=Array.from(A).find(he=>JSON.stringify(he)===Z);J!==void 0?A.delete(J):A.add(T)}return A})},[]),eo=u.useCallback((T,$)=>{at(_=>{const A=new Set(_);for(const Z of $)T?A.add(Z):A.delete(Z);return A})},[]),D=u.useCallback((T,$,_)=>{at(A=>{const Z=new Set(A),J=Math.min(T,$),he=Math.max(T,$);for(let Ie=J;Ie<=he;Ie++)_[Ie]!==void 0&&Z.add(_[Ie]);return Z})},[]),Y=u.useCallback(()=>{at(new Set)},[]),pe=u.useCallback(T=>{const $=T==null?void 0:T.__urm_row_id__;at(_=>{const A=new Set(_);if($!==void 0){const Z=Array.from(A).find(J=>(J==null?void 0:J.__urm_row_id__)===$);Z!==void 0&&A.delete(Z)}else A.delete(T);return A})},[]),Ne=u.useCallback(T=>{if(a){if(!ft("edit_columns",Te)){C(gt("edit_columns"),"error");return}if(T&&a.schema){const{validGrouping:$,invalidColumns:_}=_i(T,a.schema);_.length>0&&C(`Removed invalid grouping columns: ${_.join(", ")}`,"warning"),ut();try{const A=a.grouping;$===null?be("grouping","group_cleared",A,null):A?be("grouping","group_reordered",A,$):be("grouping","group_level_added",null,$);const Z=(Q==null?void 0:Q.snapshot.columnOrder)||a.columnOrder||[],J=Nr(Z,$);N(a.id,{grouping:$,columnOrder:J}),JSON.stringify(J)!==JSON.stringify(a.columnOrder)&&be("columns","column_reordered",a.columnOrder,J),St(!1)}catch(A){const Z=Et("processing","grouping",A);rt(Z)}}else{const $=a.grouping;be("grouping","group_cleared",$,null);const _=(Q==null?void 0:Q.snapshot.columnOrder)||a.columnOrder||[];N(a.id,{grouping:T,columnOrder:[..._]}),JSON.stringify(_)!==JSON.stringify(a.columnOrder)&&be("columns","column_reordered",a.columnOrder,_),St(!1)}}},[a,Q,Te,N,ut,rt,be]),xe=u.useCallback(T=>{if(!a)return;const $=a.grouping;if(!$)return;const _=na($,T);N(a.id,{grouping:_})},[a,N]),nr=u.useCallback(()=>{dt(!0)},[]),ir=u.useCallback(T=>{a!=null&&a.schema&&(ie(!0),setTimeout(()=>{try{let $;T.scope==="visible"?$=Wt:$=a.uploadedData||[];let _;T.columnScope==="all"?(_={},(a.schema??[]).forEach(Ie=>{_[Ie.name]=!0})):_=a.columnVisibility||(Q==null?void 0:Q.snapshot.columnVisibility)||{};const A=a.columnOrder||(Q==null?void 0:Q.snapshot.columnOrder),Z=mo($,a.schema,a.filters??[],a.sortStack??[],Q,_,A),J=a.name;let he;switch(T.format){case"csv":ho(Z,J,T),he="export_csv";break;case"excel":fo(Z,J,T),he="export_excel";break;case"json":go(Z,J,T),he="export_json";break}be("export",he,null,{format:T.format,scope:T.scope,columnScope:T.columnScope,rowCount:$.length,viewName:(Q==null?void 0:Q.name)||"Default View"}),C(`Export completed successfully (${T.format.toUpperCase()})`,"success")}catch($){const _=Pa($,{onRetry:()=>ir(T)});C(`Export failed: ${_.message}. Click Export to retry.`,"error");const A=An(a.id,yt,_,a.auditHistory||[]);N(a.id,{auditHistory:A}),lr.error("urm:report-engine","Export failed",$)}finally{ie(!1)}},500))},[a,Q,Wt,N,be]),ms=u.useCallback(T=>{if(a!=null&&a.schema){if(fe&&Q&&!Q.isDefault){K(T.format),ae(!0),dt(!1);return}ir(T),dt(!1)}},[a,Q,fe,ir]),to=u.useCallback(T=>{ir({format:T,scope:"visible",columnScope:"visible"})},[ir]),hs=u.useCallback(()=>{ge&&to(ge),ae(!1),K(null)},[ge,to]),fs=u.useCallback(()=>{ht(),ge&&to(ge),ae(!1),K(null)},[ht,ge,to]),gs=u.useCallback(()=>{ae(!1),K(null)},[]),ys=u.useCallback(T=>{!(a!=null&&a.schema)||Me.size===0||(ie(!0),setTimeout(()=>{try{const $=Array.from(Me),_=mo($,a.schema,a.filters??[],a.sortStack??[],Q),A=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(T){case"csv":ho(_,A);break;case"excel":fo(_,A);break;case"json":go(_,A);break}C(`Exported ${$.length} selected rows`,"info")}catch($){C("Export failed. Please try again.","error"),lr.error("urm:report-engine","Bulk export failed",$)}finally{ie(!1)}},500))},[a,Q,Me,Pt]),bs=u.useCallback((T,$)=>{if(a)try{const _=Ta(a),A=za(T,$,yt,_),Z=Ia(a.presets,A);N(a.id,{presets:Z}),be("presets","preset_created",null,{presetId:A.id,name:A.name}),Kt(!1),C(`Preset "${T}" saved successfully`,"success")}catch(_){C(_ instanceof Error?_.message:"Failed to create preset","error")}},[a,N,be]),vs=u.useCallback(()=>{Xt(null),C("Exited preset view","info")},[]),Ss=u.useCallback(()=>{gr(!0)},[]),js=u.useCallback((T,$)=>{if(!a)return;const _=Ba(a.presets,T);N(a.id,{presets:_}),be("presets","preset_deleted",{presetId:T,name:$},null),ct===T&&Xt(null),C(`Preset "${$}" deleted`,"success")},[a,ct,N,be]);u.useEffect(()=>{if(!c||p.length===0)return;const T=p.find($=>$.id===c);T&&T.id!==h&&x(T.id)},[c,p,h]),u.useEffect(()=>{if(!a)return;const T=Ea();if(T&&a.presets&&a.schemaLocked&&a.schema){const $=$n(a.presets,T);if($){const{sanitizedConfig:_,warnings:A}=Wa($.config,a.schema);A.length>0&&A.forEach(J=>C(J,"warning"));const Z=Da(_);N(a.id,Z),Xt(T),be("presets","preset_applied",null,{presetId:$.id,name:$.name}),C(`Loaded preset: ${$.name}`,"info")}else C("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const Cs=ct?$n(a==null?void 0:a.presets,ct):void 0;u.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&ca(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]),u.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const T=da(a.id);if(T&&T.views.length>0){const $=T.views.find(_=>_.id===T.activeViewId);if($)N(a.id,{views:T.views,activeViewId:T.activeViewId,filters:$.snapshot.filters.length>0?$.snapshot.filters:void 0,sortStack:$.snapshot.sortStack.length>0?$.snapshot.sortStack:void 0});else{const _=T.views.find(A=>A.isDefault)||Uo(a.schema);N(a.id,{views:T.views,activeViewId:_.id,filters:_.snapshot.filters.length>0?_.snapshot.filters:void 0,sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0})}}}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id]);const ws=u.useCallback(T=>{var A;const $=(a==null?void 0:a.filters)??[],_=((A=m.filter)==null?void 0:A.maxConditions)??3;if($.length>=_){C(`Filter limit reached — maximum ${_} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}re(T),q(!0)},[a,m,C]),ks=u.useCallback(()=>{q(!1),re(void 0)},[]),Ts=(Sn=a==null?void 0:a.views)==null?void 0:Sn.find(T=>T.id===U),zs=(jn=a==null?void 0:a.views)==null?void 0:jn.find(T=>T.id===se);return{reports:p,activeReport:a,activeReportId:h,setActiveReportId:x,isModalOpen:b,setIsModalOpen:E,createReport:Xe,updateReport:N,uploadState:I,handleFileUpload:Lt,handleUploadError:pt,handleRetry:er,handleConfirm:Sr,paginatedData:br,processedData:Wt,displayData:Pt,tableMetrics:$r,isGrouped:Zt,tableEngine:_t,activeView:Q,isDirty:fe,currentTableState:me,viewChanges:vr,filters:a==null?void 0:a.filters,showFilterPanel:G,setShowFilterPanel:q,filterFocusColumn:H,handleAddFilter:tr,handleUpdateFilter:Nt,handleRemoveFilter:jr,handleClearAllFilters:Ft,handleReplaceFilters:rr,handleOpenFilterForColumn:ws,handleCloseFilterPanel:ks,handleClearFiltersForColumn:We,sortStack:a==null?void 0:a.sortStack,showSortPanel:ee,setShowSortPanel:y,handleSort:ot,handleUpdateSortStack:He,handleSortAscending:xt,handleSortDescending:mt,views:a==null?void 0:a.views,showManageViews:M,setShowManageViews:W,showCreateViewModal:V,setShowCreateViewModal:X,showEditViewModal:ue,setShowEditViewModal:ce,showDeleteConfirmation:F,setShowDeleteConfirmation:O,editingView:Ts,deletingView:zs,editingViewId:U,deletingViewId:se,handleSelectView:Ar,handleCreateView:wt,handleUpdateCurrentView:ht,handleSaveColumnConfigToCurrentView:Cr,handleSaveColumnConfigToAllViews:Le,handleSaveAsNewView:kt,handleRevertChanges:Tt,handleToggleDefault:nt,handleToggleFavorite:or,handleSoftDelete:zt,handleRestoreView:le,handlePermanentDelete:ye,handleEditView:Re,handleSaveEditView:Vt,handleDeleteView:Ht,handleConfirmDelete:_o,handlePromoteToGlobal:Wo,showManageColumns:Ee,setShowManageColumns:Ue,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:Xr,handleUpdateColumnOrder:No,handleUpdateColumnWidth:Fo,handleResetColumnLayout:It,showGroupPanel:it,setShowGroupPanel:St,grouping:a==null?void 0:a.grouping,groupingState:et,handleGroup:Ne,handleToggleGroupCollapse:xe,searchQuery:jt,debouncedSearchQuery:st,searchHistory:ha((a==null?void 0:a.searchHistory)||[]),handleSearchChange:Qr,handleAddToSearchHistory:gn,handleToggleSearchFavourite:Mr,handleDeleteSearchHistory:Vo,selectedRowIds:Me,handleToggleRowSelection:Zr,handleToggleAllRows:eo,handleRangeSelection:D,handleClearSelection:Y,handleUpdateSelectionAfterDelete:pe,currentPage:lt,pageSize:Ve,paginationEngine:ze,handlePageChange:Po,handlePageSizeChange:Lo,isExporting:P,showExportModal:Ct,setShowExportModal:dt,showDirtyExportWarning:de,handleExport:nr,handleExportWithConfig:ms,handleExportSelected:ys,handleExportAnyway:hs,handleSaveAndExport:fs,handleCancelExport:gs,showAuditHistory:Er,setShowAuditHistory:hr,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:Jt,setShowCreatePreset:Kt,showManagePresets:fr,setShowManagePresets:gr,activePreset:Cs,activePresetId:ct,handleOpenManagePresets:Ss,handleCreatePreset:bs,handleClearActivePreset:vs,handleDeletePresetById:js,userRole:Te,isViewerRole:Or,currentUserId:yt,featureLimitWarning:Kr,setFeatureLimitWarning:Dr,datasetMeta:Rt,reportError:Ke,setReportError:yr,handleError:rt,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?Ks(a.schema):!1,snack:k,handleSnackClose:S,showSnack:C,snackDurationMs:w}}const Wi=u.createContext(void 0);function dn(t){const{children:o,initialData:n,data:i,reportName:s,dataSource:d,mode:c="builder",autoLoad:l=!0,config:p,devConfig:f,showDevPanel:m=!1,sharedReportId:h}=t,b=el({mode:c,autoLoad:l,initialData:i||n,dataSource:d,reportName:s,sharedReportId:h,config:p}),[E,g]=u.useState(()=>Os()),j=(()=>{const S=As(E,f,!!f);return{...S,display:{...S.display,showDevPanel:m||S.display.showDevPanel}}})(),k=u.useCallback(C=>{g(C),$s(C)},[]),v={...b,activeDevConfig:j,handleDevConfigChange:k};return e.jsx(ki.Provider,{value:j,children:e.jsx(Wi.Provider,{value:v,children:o})})}function jo(){const t=u.useContext(Wi);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function tl({onCreateReport:t,reports:o=[],activeReportId:n,onReportClick:i}){const s=o.find(d=>d.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(B.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(B.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(B.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function cr(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 rl="$$material";function ol(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var no={exports:{}},io={exports:{}},ve={};/** @license React v16.13.1
|
|
4
4
|
* react-is.production.min.js
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var
|
|
10
|
+
*/var Rn;function nl(){if(Rn)return ve;Rn=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,d=t?Symbol.for("react.profiler"):60114,c=t?Symbol.for("react.provider"):60109,l=t?Symbol.for("react.context"):60110,p=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,h=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,b=t?Symbol.for("react.memo"):60115,E=t?Symbol.for("react.lazy"):60116,g=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,k=t?Symbol.for("react.responder"):60118,v=t?Symbol.for("react.scope"):60119;function C(w){if(typeof w=="object"&&w!==null){var a=w.$$typeof;switch(a){case o:switch(w=w.type,w){case p:case f:case i:case d:case s:case h:return w;default:switch(w=w&&w.$$typeof,w){case l:case m:case E:case b:case c:return w;default:return a}}case n:return a}}}function S(w){return C(w)===f}return ve.AsyncMode=p,ve.ConcurrentMode=f,ve.ContextConsumer=l,ve.ContextProvider=c,ve.Element=o,ve.ForwardRef=m,ve.Fragment=i,ve.Lazy=E,ve.Memo=b,ve.Portal=n,ve.Profiler=d,ve.StrictMode=s,ve.Suspense=h,ve.isAsyncMode=function(w){return S(w)||C(w)===p},ve.isConcurrentMode=S,ve.isContextConsumer=function(w){return C(w)===l},ve.isContextProvider=function(w){return C(w)===c},ve.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===o},ve.isForwardRef=function(w){return C(w)===m},ve.isFragment=function(w){return C(w)===i},ve.isLazy=function(w){return C(w)===E},ve.isMemo=function(w){return C(w)===b},ve.isPortal=function(w){return C(w)===n},ve.isProfiler=function(w){return C(w)===d},ve.isStrictMode=function(w){return C(w)===s},ve.isSuspense=function(w){return C(w)===h},ve.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===i||w===f||w===d||w===s||w===h||w===x||typeof w=="object"&&w!==null&&(w.$$typeof===E||w.$$typeof===b||w.$$typeof===c||w.$$typeof===l||w.$$typeof===m||w.$$typeof===j||w.$$typeof===k||w.$$typeof===v||w.$$typeof===g)},ve.typeOf=C,ve}var Se={};/** @license React v16.13.1
|
|
11
11
|
* react-is.development.js
|
|
12
12
|
*
|
|
13
13
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var _n;function il(){return _n||(_n=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,d=t?Symbol.for("react.profiler"):60114,c=t?Symbol.for("react.provider"):60109,l=t?Symbol.for("react.context"):60110,p=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,h=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,b=t?Symbol.for("react.memo"):60115,E=t?Symbol.for("react.lazy"):60116,g=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,k=t?Symbol.for("react.responder"):60118,v=t?Symbol.for("react.scope"):60119;function C(K){return typeof K=="string"||typeof K=="function"||K===i||K===f||K===d||K===s||K===h||K===x||typeof K=="object"&&K!==null&&(K.$$typeof===E||K.$$typeof===b||K.$$typeof===c||K.$$typeof===l||K.$$typeof===m||K.$$typeof===j||K.$$typeof===k||K.$$typeof===v||K.$$typeof===g)}function S(K){if(typeof K=="object"&&K!==null){var Ee=K.$$typeof;switch(Ee){case o:var Ue=K.type;switch(Ue){case p:case f:case i:case d:case s:case h:return Ue;default:var it=Ue&&Ue.$$typeof;switch(it){case l:case m:case E:case b:case c:return it;default:return Ee}}case n:return Ee}}}var w=p,a=f,I=l,R=c,G=o,q=m,ee=i,y=E,M=b,W=n,V=d,X=s,ue=h,ce=!1;function F(K){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.")),O(K)||S(K)===p}function O(K){return S(K)===f}function H(K){return S(K)===l}function re(K){return S(K)===c}function U(K){return typeof K=="object"&&K!==null&&K.$$typeof===o}function te(K){return S(K)===m}function se(K){return S(K)===i}function ne(K){return S(K)===E}function P(K){return S(K)===b}function ie(K){return S(K)===n}function de(K){return S(K)===d}function ae(K){return S(K)===s}function ge(K){return S(K)===h}Se.AsyncMode=w,Se.ConcurrentMode=a,Se.ContextConsumer=I,Se.ContextProvider=R,Se.Element=G,Se.ForwardRef=q,Se.Fragment=ee,Se.Lazy=y,Se.Memo=M,Se.Portal=W,Se.Profiler=V,Se.StrictMode=X,Se.Suspense=ue,Se.isAsyncMode=F,Se.isConcurrentMode=O,Se.isContextConsumer=H,Se.isContextProvider=re,Se.isElement=U,Se.isForwardRef=te,Se.isFragment=se,Se.isLazy=ne,Se.isMemo=P,Se.isPortal=ie,Se.isProfiler=de,Se.isStrictMode=ae,Se.isSuspense=ge,Se.isValidElementType=C,Se.typeOf=S})()),Se}var Wn;function Pi(){return Wn||(Wn=1,process.env.NODE_ENV==="production"?io.exports=nl():io.exports=il()),io.exports}/*
|
|
18
18
|
object-assign
|
|
19
19
|
(c) Sindre Sorhus
|
|
20
20
|
@license MIT
|
|
21
|
-
*/var
|
|
22
|
-
Valid keys: `+JSON.stringify(Object.keys(
|
|
21
|
+
*/var Yo,Pn;function sl(){if(Pn)return Yo;Pn=1;var t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(d){if(d==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(d)}function s(){try{if(!Object.assign)return!1;var d=new String("abc");if(d[5]="de",Object.getOwnPropertyNames(d)[0]==="5")return!1;for(var c={},l=0;l<10;l++)c["_"+String.fromCharCode(l)]=l;var p=Object.getOwnPropertyNames(c).map(function(m){return c[m]});if(p.join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(m){f[m]=m}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Yo=s()?Object.assign:function(d,c){for(var l,p=i(d),f,m=1;m<arguments.length;m++){l=Object(arguments[m]);for(var h in l)o.call(l,h)&&(p[h]=l[h]);if(t){f=t(l);for(var x=0;x<f.length;x++)n.call(l,f[x])&&(p[f[x]]=l[f[x]])}}return p},Yo}var qo,Ln;function un(){if(Ln)return qo;Ln=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return qo=t,qo}var Jo,Nn;function Li(){return Nn||(Nn=1,Jo=Function.call.bind(Object.prototype.hasOwnProperty)),Jo}var Ko,Fn;function al(){if(Fn)return Ko;Fn=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var o=un(),n={},i=Li();t=function(d){var c="Warning: "+d;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(d,c,l,p,f){if(process.env.NODE_ENV!=="production"){for(var m in d)if(i(d,m)){var h;try{if(typeof d[m]!="function"){var x=Error((p||"React class")+": "+l+" type `"+m+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[m]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw x.name="Invariant Violation",x}h=d[m](c,m,p,l,null,o)}catch(E){h=E}if(h&&!(h instanceof Error)&&t((p||"React class")+": type specification of "+l+" `"+m+"` 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 b=f?f():"";t("Failed "+l+" type: "+h.message+(b??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Ko=s,Ko}var Xo,Vn;function ll(){if(Vn)return Xo;Vn=1;var t=Pi(),o=sl(),n=un(),i=Li(),s=al(),d=function(){};process.env.NODE_ENV!=="production"&&(d=function(l){var p="Warning: "+l;typeof console<"u"&&console.error(p);try{throw new Error(p)}catch{}});function c(){return null}return Xo=function(l,p){var f=typeof Symbol=="function"&&Symbol.iterator,m="@@iterator";function h(O){var H=O&&(f&&O[f]||O[m]);if(typeof H=="function")return H}var x="<<anonymous>>",b={array:k("array"),bigint:k("bigint"),bool:k("boolean"),func:k("function"),number:k("number"),object:k("object"),string:k("string"),symbol:k("symbol"),any:v(),arrayOf:C,element:S(),elementType:w(),instanceOf:a,node:q(),objectOf:R,oneOf:I,oneOfType:G,shape:y,exact:M};function E(O,H){return O===H?O!==0||1/O===1/H:O!==O&&H!==H}function g(O,H){this.message=O,this.data=H&&typeof H=="object"?H:{},this.stack=""}g.prototype=Error.prototype;function j(O){if(process.env.NODE_ENV!=="production")var H={},re=0;function U(se,ne,P,ie,de,ae,ge){if(ie=ie||x,ae=ae||P,ge!==n){if(p){var K=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 K.name="Invariant Violation",K}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Ee=ie+":"+P;!H[Ee]&&re<3&&(d("You are manually calling a React.PropTypes validation function for the `"+ae+"` prop on `"+ie+"`. 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."),H[Ee]=!0,re++)}}return ne[P]==null?se?ne[P]===null?new g("The "+de+" `"+ae+"` is marked as required "+("in `"+ie+"`, but its value is `null`.")):new g("The "+de+" `"+ae+"` is marked as required in "+("`"+ie+"`, but its value is `undefined`.")):null:O(ne,P,ie,de,ae)}var te=U.bind(null,!1);return te.isRequired=U.bind(null,!0),te}function k(O){function H(re,U,te,se,ne,P){var ie=re[U],de=X(ie);if(de!==O){var ae=ue(ie);return new g("Invalid "+se+" `"+ne+"` of type "+("`"+ae+"` supplied to `"+te+"`, expected ")+("`"+O+"`."),{expectedType:O})}return null}return j(H)}function v(){return j(c)}function C(O){function H(re,U,te,se,ne){if(typeof O!="function")return new g("Property `"+ne+"` of component `"+te+"` has invalid PropType notation inside arrayOf.");var P=re[U];if(!Array.isArray(P)){var ie=X(P);return new g("Invalid "+se+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+te+"`, expected an array."))}for(var de=0;de<P.length;de++){var ae=O(P,de,te,se,ne+"["+de+"]",n);if(ae instanceof Error)return ae}return null}return j(H)}function S(){function O(H,re,U,te,se){var ne=H[re];if(!l(ne)){var P=X(ne);return new g("Invalid "+te+" `"+se+"` of type "+("`"+P+"` supplied to `"+U+"`, expected a single ReactElement."))}return null}return j(O)}function w(){function O(H,re,U,te,se){var ne=H[re];if(!t.isValidElementType(ne)){var P=X(ne);return new g("Invalid "+te+" `"+se+"` of type "+("`"+P+"` supplied to `"+U+"`, expected a single ReactElement type."))}return null}return j(O)}function a(O){function H(re,U,te,se,ne){if(!(re[U]instanceof O)){var P=O.name||x,ie=F(re[U]);return new g("Invalid "+se+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+te+"`, expected ")+("instance of `"+P+"`."))}return null}return j(H)}function I(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&(arguments.length>1?d("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])."):d("Invalid argument supplied to oneOf, expected an array.")),c;function H(re,U,te,se,ne){for(var P=re[U],ie=0;ie<O.length;ie++)if(E(P,O[ie]))return null;var de=JSON.stringify(O,function(ge,K){var Ee=ue(K);return Ee==="symbol"?String(K):K});return new g("Invalid "+se+" `"+ne+"` of value `"+String(P)+"` "+("supplied to `"+te+"`, expected one of "+de+"."))}return j(H)}function R(O){function H(re,U,te,se,ne){if(typeof O!="function")return new g("Property `"+ne+"` of component `"+te+"` has invalid PropType notation inside objectOf.");var P=re[U],ie=X(P);if(ie!=="object")return new g("Invalid "+se+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+te+"`, expected an object."));for(var de in P)if(i(P,de)){var ae=O(P,de,te,se,ne+"."+de,n);if(ae instanceof Error)return ae}return null}return j(H)}function G(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&d("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var H=0;H<O.length;H++){var re=O[H];if(typeof re!="function")return d("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ce(re)+" at index "+H+"."),c}function U(te,se,ne,P,ie){for(var de=[],ae=0;ae<O.length;ae++){var ge=O[ae],K=ge(te,se,ne,P,ie,n);if(K==null)return null;K.data&&i(K.data,"expectedType")&&de.push(K.data.expectedType)}var Ee=de.length>0?", expected one of type ["+de.join(", ")+"]":"";return new g("Invalid "+P+" `"+ie+"` supplied to "+("`"+ne+"`"+Ee+"."))}return j(U)}function q(){function O(H,re,U,te,se){return W(H[re])?null:new g("Invalid "+te+" `"+se+"` supplied to "+("`"+U+"`, expected a ReactNode."))}return j(O)}function ee(O,H,re,U,te){return new g((O||"React class")+": "+H+" type `"+re+"."+U+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+te+"`.")}function y(O){function H(re,U,te,se,ne){var P=re[U],ie=X(P);if(ie!=="object")return new g("Invalid "+se+" `"+ne+"` of type `"+ie+"` "+("supplied to `"+te+"`, expected `object`."));for(var de in O){var ae=O[de];if(typeof ae!="function")return ee(te,se,ne,de,ue(ae));var ge=ae(P,de,te,se,ne+"."+de,n);if(ge)return ge}return null}return j(H)}function M(O){function H(re,U,te,se,ne){var P=re[U],ie=X(P);if(ie!=="object")return new g("Invalid "+se+" `"+ne+"` of type `"+ie+"` "+("supplied to `"+te+"`, expected `object`."));var de=o({},re[U],O);for(var ae in de){var ge=O[ae];if(i(O,ae)&&typeof ge!="function")return ee(te,se,ne,ae,ue(ge));if(!ge)return new g("Invalid "+se+" `"+ne+"` key `"+ae+"` supplied to `"+te+"`.\nBad object: "+JSON.stringify(re[U],null," ")+`
|
|
22
|
+
Valid keys: `+JSON.stringify(Object.keys(O),null," "));var K=ge(P,ae,te,se,ne+"."+ae,n);if(K)return K}return null}return j(H)}function W(O){switch(typeof O){case"number":case"string":case"undefined":return!0;case"boolean":return!O;case"object":if(Array.isArray(O))return O.every(W);if(O===null||l(O))return!0;var H=h(O);if(H){var re=H.call(O),U;if(H!==O.entries){for(;!(U=re.next()).done;)if(!W(U.value))return!1}else for(;!(U=re.next()).done;){var te=U.value;if(te&&!W(te[1]))return!1}}else return!1;return!0;default:return!1}}function V(O,H){return O==="symbol"?!0:H?H["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&H instanceof Symbol:!1}function X(O){var H=typeof O;return Array.isArray(O)?"array":O instanceof RegExp?"object":V(H,O)?"symbol":H}function ue(O){if(typeof O>"u"||O===null)return""+O;var H=X(O);if(H==="object"){if(O instanceof Date)return"date";if(O instanceof RegExp)return"regexp"}return H}function ce(O){var H=ue(O);switch(H){case"array":case"object":return"an "+H;case"boolean":case"date":case"regexp":return"a "+H;default:return H}}function F(O){return!O.constructor||!O.constructor.name?x:O.constructor.name}return b.checkPropTypes=s,b.resetWarningCache=s.resetWarningCache,b.PropTypes=b,b},Xo}var Qo,Hn;function cl(){if(Hn)return Qo;Hn=1;var t=un();function o(){}function n(){}return n.resetWarningCache=o,Qo=function(){function i(c,l,p,f,m,h){if(h!==t){var x=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 x.name="Invariant Violation",x}}i.isRequired=i;function s(){return i}var d={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 d.PropTypes=d,d},Qo}var Un;function dl(){if(Un)return no.exports;if(Un=1,process.env.NODE_ENV!=="production"){var t=Pi(),o=!0;no.exports=ll()(t.isElement,o)}else no.exports=cl()();return no.exports}var ul=dl();const _r=ol(ul);var so={exports:{}},we={};/**
|
|
23
23
|
* @license React
|
|
24
24
|
* react-is.production.js
|
|
25
25
|
*
|
|
@@ -27,7 +27,7 @@ Valid keys: `+JSON.stringify(Object.keys(A),null," "));var G=fe(P,ae,re,se,oe+"
|
|
|
27
27
|
*
|
|
28
28
|
* This source code is licensed under the MIT license found in the
|
|
29
29
|
* LICENSE file in the root directory of this source tree.
|
|
30
|
-
*/var
|
|
30
|
+
*/var Gn;function pl(){if(Gn)return we;Gn=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"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),x=Symbol.for("react.view_transition"),b=Symbol.for("react.client.reference");function E(g){if(typeof g=="object"&&g!==null){var j=g.$$typeof;switch(j){case t:switch(g=g.type,g){case n:case s:case i:case p:case f:case x:return g;default:switch(g=g&&g.$$typeof,g){case c:case l:case h:case m:return g;case d:return g;default:return j}}case o:return j}}}return we.ContextConsumer=d,we.ContextProvider=c,we.Element=t,we.ForwardRef=l,we.Fragment=n,we.Lazy=h,we.Memo=m,we.Portal=o,we.Profiler=s,we.StrictMode=i,we.Suspense=p,we.SuspenseList=f,we.isContextConsumer=function(g){return E(g)===d},we.isContextProvider=function(g){return E(g)===c},we.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===t},we.isForwardRef=function(g){return E(g)===l},we.isFragment=function(g){return E(g)===n},we.isLazy=function(g){return E(g)===h},we.isMemo=function(g){return E(g)===m},we.isPortal=function(g){return E(g)===o},we.isProfiler=function(g){return E(g)===s},we.isStrictMode=function(g){return E(g)===i},we.isSuspense=function(g){return E(g)===p},we.isSuspenseList=function(g){return E(g)===f},we.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===n||g===s||g===i||g===p||g===f||typeof g=="object"&&g!==null&&(g.$$typeof===h||g.$$typeof===m||g.$$typeof===c||g.$$typeof===d||g.$$typeof===l||g.$$typeof===b||g.getModuleId!==void 0)},we.typeOf=E,we}var ke={};/**
|
|
31
31
|
* @license React
|
|
32
32
|
* react-is.development.js
|
|
33
33
|
*
|
|
@@ -35,15 +35,15 @@ Valid keys: `+JSON.stringify(Object.keys(A),null," "));var G=fe(P,ae,re,se,oe+"
|
|
|
35
35
|
*
|
|
36
36
|
* This source code is licensed under the MIT license found in the
|
|
37
37
|
* LICENSE file in the root directory of this source tree.
|
|
38
|
-
*/var
|
|
39
|
-
For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,d=Number.isNaN(+i)?i||0:+i;return t.containerQueries(s).up(d)}function bl(t){const o=(d,c)=>d.replace("@media",c?`@container ${c}`:"@container");function n(d,c){d.up=(...l)=>o(t.breakpoints.up(...l),c),d.down=(...l)=>o(t.breakpoints.down(...l),c),d.between=(...l)=>o(t.breakpoints.between(...l),c),d.only=(...l)=>o(t.breakpoints.only(...l),c),d.not=(...l)=>{const
|
|
38
|
+
*/var Yn;function xl(){return Yn||(Yn=1,process.env.NODE_ENV!=="production"&&(function(){function t(g){if(typeof g=="object"&&g!==null){var j=g.$$typeof;switch(j){case o:switch(g=g.type,g){case i:case d:case s:case f:case m:case b:return g;default:switch(g=g&&g.$$typeof,g){case l:case p:case x:case h:return g;case c:return g;default:return j}}case n:return j}}}var o=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),b=Symbol.for("react.view_transition"),E=Symbol.for("react.client.reference");ke.ContextConsumer=c,ke.ContextProvider=l,ke.Element=o,ke.ForwardRef=p,ke.Fragment=i,ke.Lazy=x,ke.Memo=h,ke.Portal=n,ke.Profiler=d,ke.StrictMode=s,ke.Suspense=f,ke.SuspenseList=m,ke.isContextConsumer=function(g){return t(g)===c},ke.isContextProvider=function(g){return t(g)===l},ke.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===o},ke.isForwardRef=function(g){return t(g)===p},ke.isFragment=function(g){return t(g)===i},ke.isLazy=function(g){return t(g)===x},ke.isMemo=function(g){return t(g)===h},ke.isPortal=function(g){return t(g)===n},ke.isProfiler=function(g){return t(g)===d},ke.isStrictMode=function(g){return t(g)===s},ke.isSuspense=function(g){return t(g)===f},ke.isSuspenseList=function(g){return t(g)===m},ke.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===i||g===d||g===s||g===f||g===m||typeof g=="object"&&g!==null&&(g.$$typeof===x||g.$$typeof===h||g.$$typeof===l||g.$$typeof===c||g.$$typeof===p||g.$$typeof===E||g.getModuleId!==void 0)},ke.typeOf=t})()),ke}var qn;function ml(){return qn||(qn=1,process.env.NODE_ENV==="production"?so.exports=pl():so.exports=xl()),so.exports}var Ni=ml();function Ut(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 Fi(t){if(vo.isValidElement(t)||Ni.isValidElementType(t)||!Ut(t))return t;const o={};return Object.keys(t).forEach(n=>{o[n]=Fi(t[n])}),o}function Je(t,o,n={clone:!0}){const i=n.clone?{...t}:t;return Ut(t)&&Ut(o)&&Object.keys(o).forEach(s=>{vo.isValidElement(o[s])||Ni.isValidElementType(o[s])?i[s]=o[s]:Ut(o[s])&&Object.prototype.hasOwnProperty.call(t,s)&&Ut(t[s])?i[s]=Je(t[s],o[s],n):n.clone?i[s]=Ut(o[s])?Fi(o[s]):o[s]:i[s]=o[s]}),i}const hl=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 fl(t){const{values:o={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=t,d=hl(o),c=Object.keys(d);function l(x){return`@media (min-width:${typeof o[x]=="number"?o[x]:x}${n})`}function p(x){return`@media (max-width:${(typeof o[x]=="number"?o[x]:x)-i/100}${n})`}function f(x,b){const E=c.indexOf(b);return`@media (min-width:${typeof o[x]=="number"?o[x]:x}${n}) and (max-width:${(E!==-1&&typeof o[c[E]]=="number"?o[c[E]]:b)-i/100}${n})`}function m(x){return c.indexOf(x)+1<c.length?f(x,c[c.indexOf(x)+1]):l(x)}function h(x){const b=c.indexOf(x);return b===0?l(c[1]):b===c.length-1?p(c[b]):f(x,c[c.indexOf(x)+1]).replace("@media","@media not all and")}return{keys:c,values:d,up:l,down:p,between:f,only:m,not:h,unit:n,...s}}function Jn(t,o){if(!t.containerQueries)return o;const n=Object.keys(o).filter(i=>i.startsWith("@container")).sort((i,s)=>{var c,l;const d=/min-width:\s*([0-9.]+)/;return+(((c=i.match(d))==null?void 0:c[1])||0)-+(((l=s.match(d))==null?void 0:l[1])||0)});return n.length?n.reduce((i,s)=>{const d=o[s];return delete i[s],i[s]=d,i},{...o}):o}function gl(t,o){return o==="@"||o.startsWith("@")&&(t.some(n=>o.startsWith(`@${n}`))||!!o.match(/^@\d/))}function yl(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,d=Number.isNaN(+i)?i||0:+i;return t.containerQueries(s).up(d)}function bl(t){const o=(d,c)=>d.replace("@media",c?`@container ${c}`:"@container");function n(d,c){d.up=(...l)=>o(t.breakpoints.up(...l),c),d.down=(...l)=>o(t.breakpoints.down(...l),c),d.between=(...l)=>o(t.breakpoints.between(...l),c),d.only=(...l)=>o(t.breakpoints.only(...l),c),d.not=(...l)=>{const p=o(t.breakpoints.not(...l),c);return p.includes("not all and")?p.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):p}}const i={},s=d=>(n(i,d),i);return n(s),{...t,containerQueries:s}}const vl={borderRadius:4},Yt=process.env.NODE_ENV!=="production"?_r.oneOfType([_r.number,_r.string,_r.object,_r.array]):{};function Ur(t,o){return o?Je(t,o,{clone:!1}):t}const Co={xs:0,sm:600,md:900,lg:1200,xl:1536},Kn={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${Co[t]}px)`},Sl={containerQueries:t=>({up:o=>{let n=typeof o=="number"?o:Co[o]||o;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function Ot(t,o,n){const i=t.theme||{};if(Array.isArray(o)){const d=i.breakpoints||Kn;return o.reduce((c,l,p)=>(c[d.up(d.keys[p])]=n(o[p]),c),{})}if(typeof o=="object"){const d=i.breakpoints||Kn;return Object.keys(o).reduce((c,l)=>{if(gl(d.keys,l)){const p=yl(i.containerQueries?i:Sl,l);p&&(c[p]=n(o[l],l))}else if(Object.keys(d.values||Co).includes(l)){const p=d.up(l);c[p]=n(o[l],l)}else{const p=l;c[p]=o[p]}return c},{})}return n(o)}function jl(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,s)=>{const d=t.up(s);return i[d]={},i},{}))||{}}function Xn(t,o){return t.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},o)}function Vi(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":cr(7));return t.charAt(0).toUpperCase()+t.slice(1)}function wo(t,o,n=!0){if(!o||typeof o!="string")return null;if(t&&t.vars&&n){const i=`vars.${o}`.split(".").reduce((s,d)=>s&&s[d]?s[d]:null,t);if(i!=null)return i}return o.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,t)}function yo(t,o,n,i=n){let s;return typeof t=="function"?s=t(n):Array.isArray(t)?s=t[n]||i:s=wo(t,n)||i,o&&(s=o(s,i,t)),s}function $e(t){const{prop:o,cssProperty:n=t.prop,themeKey:i,transform:s}=t,d=c=>{if(c[o]==null)return null;const l=c[o],p=c.theme,f=wo(p,i)||{};return Ot(c,l,h=>{let x=yo(f,s,h);return h===x&&typeof h=="string"&&(x=yo(f,s,`${o}${h==="default"?"":Vi(h)}`,h)),n===!1?x:{[n]:x}})};return d.propTypes=process.env.NODE_ENV!=="production"?{[o]:Yt}:{},d.filterProps=[o],d}function Cl(t){const o={};return n=>(o[n]===void 0&&(o[n]=t(n)),o[n])}const wl={m:"margin",p:"padding"},kl={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Qn={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Tl=Cl(t=>{if(t.length>2)if(Qn[t])t=Qn[t];else return[t];const[o,n]=t.split(""),i=wl[o],s=kl[n]||"";return Array.isArray(s)?s.map(d=>i+d):[i+s]}),ko=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],To=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],zl=[...ko,...To];function Yr(t,o,n,i){const s=wo(t,o,!0)??n;return typeof s=="number"||typeof s=="string"?d=>typeof d=="string"?d:(process.env.NODE_ENV!=="production"&&typeof d!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${d}.`),typeof s=="string"?s.startsWith("var(")&&d===0?0:s.startsWith("var(")&&d===1?s:`calc(${d} * ${s})`:s*d):Array.isArray(s)?d=>{if(typeof d=="string")return d;const c=Math.abs(d);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
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
41
|
`)));const l=s[c];return d>=0?l:typeof l=="number"?-l:typeof l=="string"&&l.startsWith("var(")?`calc(-1 * ${l})`:`-${l}`}: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 an(t){return Jr(t,"spacing",8,"spacing")}function Kr(t,o){return typeof o=="string"||o==null?o:t(o)}function Bl(t,o){return n=>t.reduce((i,s)=>(i[s]=Kr(o,n),i),{})}function Il(t,o,n,i){if(!o.includes(n))return null;const s=Tl(n),d=Bl(s,i),c=t[n];return Tt(t,c,d)}function Pi(t,o){const n=an(t.theme);return Object.keys(t).map(i=>Il(t,o,i,n)).reduce(Gr,{})}function Ie(t){return Pi(t,ko)}Ie.propTypes=process.env.NODE_ENV!=="production"?ko.reduce((t,o)=>(t[o]=Ft,t),{}):{};Ie.filterProps=ko;function De(t){return Pi(t,To)}De.propTypes=process.env.NODE_ENV!=="production"?To.reduce((t,o)=>(t[o]=Ft,t),{}):{};De.filterProps=To;process.env.NODE_ENV!=="production"&&zl.reduce((t,o)=>(t[o]=Ft,t),{});function Ni(t=8,o=an({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(d=>{const c=o(d);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function zo(...t){const o=t.reduce((i,s)=>(s.filterProps.forEach(d=>{i[d]=s}),i),{}),n=i=>Object.keys(i).reduce((s,d)=>o[d]?Gr(s,o[d](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 rt(t){return typeof t!="number"?t:`${t}px solid`}function ot(t,o){return Ee({prop:t,themeKey:"borders",transform:o})}const Dl=ot("border",rt),El=ot("borderTop",rt),Ol=ot("borderRight",rt),Al=ot("borderBottom",rt),$l=ot("borderLeft",rt),Ml=ot("borderColor"),Rl=ot("borderTopColor"),_l=ot("borderRightColor"),Wl=ot("borderBottomColor"),Pl=ot("borderLeftColor"),Nl=ot("outline",rt),Ll=ot("outlineColor"),Bo=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const o=Jr(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Kr(o,i)});return Tt(t,t.borderRadius,n)}return null};Bo.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Ft}:{};Bo.filterProps=["borderRadius"];zo(Dl,El,Ol,Al,$l,Ml,Rl,_l,Wl,Pl,Bo,Nl,Ll);const Io=t=>{if(t.gap!==void 0&&t.gap!==null){const o=Jr(t.theme,"spacing",8,"gap"),n=i=>({gap:Kr(o,i)});return Tt(t,t.gap,n)}return null};Io.propTypes=process.env.NODE_ENV!=="production"?{gap:Ft}:{};Io.filterProps=["gap"];const Do=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const o=Jr(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Kr(o,i)});return Tt(t,t.columnGap,n)}return null};Do.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Ft}:{};Do.filterProps=["columnGap"];const Eo=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const o=Jr(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Kr(o,i)});return Tt(t,t.rowGap,n)}return null};Eo.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Ft}:{};Eo.filterProps=["rowGap"];const Fl=Ee({prop:"gridColumn"}),Vl=Ee({prop:"gridRow"}),Hl=Ee({prop:"gridAutoFlow"}),Ul=Ee({prop:"gridAutoColumns"}),Yl=Ee({prop:"gridAutoRows"}),Gl=Ee({prop:"gridTemplateColumns"}),ql=Ee({prop:"gridTemplateRows"}),Jl=Ee({prop:"gridTemplateAreas"}),Kl=Ee({prop:"gridArea"});zo(Io,Do,Eo,Fl,Vl,Hl,Ul,Yl,Gl,ql,Jl,Kl);function Br(t,o){return o==="grey"?o:t}const Xl=Ee({prop:"color",themeKey:"palette",transform:Br}),Ql=Ee({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Br}),Zl=Ee({prop:"backgroundColor",themeKey:"palette",transform:Br});zo(Xl,Ql,Zl);function Je(t){return t<=1&&t!==0?`${t*100}%`:t}const ec=Ee({prop:"width",transform:Je}),ln=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const o=n=>{var s,d,c,l,u;const i=((c=(d=(s=t.theme)==null?void 0:s.breakpoints)==null?void 0:d.values)==null?void 0:c[n])||Co[n];return i?((u=(l=t.theme)==null?void 0:l.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Je(n)}};return Tt(t,t.maxWidth,o)}return null};ln.filterProps=["maxWidth"];const tc=Ee({prop:"minWidth",transform:Je}),rc=Ee({prop:"height",transform:Je}),oc=Ee({prop:"maxHeight",transform:Je}),nc=Ee({prop:"minHeight",transform:Je});Ee({prop:"size",cssProperty:"width",transform:Je});Ee({prop:"size",cssProperty:"height",transform:Je});const ic=Ee({prop:"boxSizing"});zo(ec,ln,tc,rc,oc,nc,ic);const Oo={border:{themeKey:"borders",transform:rt},borderTop:{themeKey:"borders",transform:rt},borderRight:{themeKey:"borders",transform:rt},borderBottom:{themeKey:"borders",transform:rt},borderLeft:{themeKey:"borders",transform:rt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:rt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Bo},color:{themeKey:"palette",transform:Br},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Br},backgroundColor:{themeKey:"palette",transform:Br},p:{style:De},pt:{style:De},pr:{style:De},pb:{style:De},pl:{style:De},px:{style:De},py:{style:De},padding:{style:De},paddingTop:{style:De},paddingRight:{style:De},paddingBottom:{style:De},paddingLeft:{style:De},paddingX:{style:De},paddingY:{style:De},paddingInline:{style:De},paddingInlineStart:{style:De},paddingInlineEnd:{style:De},paddingBlock:{style:De},paddingBlockStart:{style:De},paddingBlockEnd:{style:De},m:{style:Ie},mt:{style:Ie},mr:{style:Ie},mb:{style:Ie},ml:{style:Ie},mx:{style:Ie},my:{style:Ie},margin:{style:Ie},marginTop:{style:Ie},marginRight:{style:Ie},marginBottom:{style:Ie},marginLeft:{style:Ie},marginX:{style:Ie},marginY:{style:Ie},marginInline:{style:Ie},marginInlineStart:{style:Ie},marginInlineEnd:{style:Ie},marginBlock:{style:Ie},marginBlockStart:{style:Ie},marginBlockEnd:{style:Ie},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:Io},rowGap:{style:Eo},columnGap:{style:Do},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Je},maxWidth:{style:ln},minWidth:{transform:Je},height:{transform:Je},maxHeight:{transform:Je},minHeight:{transform:Je},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 sc(...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 ac(t,o){return typeof t=="function"?t(o):t}function lc(){function t(n,i,s,d){const c={[n]:i,theme:s},l=d[n];if(!l)return{[n]:i};const{cssProperty:u=n,themeKey:f,transform:m,style:h}=l;if(i==null)return null;if(f==="typography"&&i==="inherit")return{[n]:i};const x=wo(s,f)||{};return h?h(c):Tt(c,i,D=>{let g=yo(x,m,D);return D===g&&typeof D=="string"&&(g=yo(x,m,`${n}${D==="default"?"":Wi(D)}`,D)),u===!1?g:{[u]:g}})}function o(n){const{sx:i,theme:s={},nested:d}=n||{};if(!i)return null;const c=s.unstable_sxConfig??Oo;function l(u){let f=u;if(typeof u=="function")f=u(s);else if(typeof u!="object")return u;if(!f)return null;const m=jl(s.breakpoints),h=Object.keys(m);let x=m;return Object.keys(f).forEach(b=>{const D=ac(f[b],s);if(D!=null)if(typeof D=="object")if(c[b])x=Gr(x,t(b,D,s,c));else{const g=Tt({theme:s},D,j=>({[b]:j}));sc(g,D)?x[b]=o({sx:D,theme:s,nested:!0}):x=Gr(x,g)}else x=Gr(x,t(b,D,s,c))}),!d&&s.modularCssLayers?{"@layer sx":Hn(s,Yn(h,x))}:Hn(s,Yn(h,x))}return Array.isArray(i)?i.map(l):l(i)}return o}const Ao=lc();Ao.filterProps=["sx"];function cc(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:d={},...c}=t,l=fl(n),u=Ni(s);let f=Xe({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...vl,...d}},c);return f=bl(f),f.applyStyles=cc,f=o.reduce((m,h)=>Xe(m,h),f),f.unstable_sxConfig={...Oo,...c==null?void 0:c.unstable_sxConfig},f.unstable_sx=function(h){return Ao({sx:h,theme:this})},f}function dc(t){return Object.keys(t).length===0}function uc(t=null){const o=vo.useContext(Es.ThemeContext);return!o||dc(o)?t:o}const pc=Li();function xc(t=pc){return uc(t)}const qn=t=>t,mc=()=>{let t=qn;return{configure(o){t=o},generate(o){return t(o)},reset(){t=qn}}},hc=mc(),fc={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 gc(t,o,n="Mui"){const i=fc[o];return i?`${n}-${i}`:`${hc.generate(t)}-${o}`}function yc(t,o=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(o,Math.min(t,n))}function cn(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}].`),yc(t,o,n)}function bc(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 Lt(t){if(t.type)return t;if(t.charAt(0)==="#")return Lt(bc(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().`:
|
|
44
|
-
The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:
|
|
45
|
-
`))}return
|
|
46
|
-
The color object needs to have a \`main\` property or a \`${
|
|
42
|
+
`)),()=>{})}function pn(t){return Yr(t,"spacing",8,"spacing")}function qr(t,o){return typeof o=="string"||o==null?o:t(o)}function Il(t,o){return n=>t.reduce((i,s)=>(i[s]=qr(o,n),i),{})}function Bl(t,o,n,i){if(!o.includes(n))return null;const s=Tl(n),d=Il(s,i),c=t[n];return Ot(t,c,d)}function Hi(t,o){const n=pn(t.theme);return Object.keys(t).map(i=>Bl(t,o,i,n)).reduce(Ur,{})}function De(t){return Hi(t,ko)}De.propTypes=process.env.NODE_ENV!=="production"?ko.reduce((t,o)=>(t[o]=Yt,t),{}):{};De.filterProps=ko;function Oe(t){return Hi(t,To)}Oe.propTypes=process.env.NODE_ENV!=="production"?To.reduce((t,o)=>(t[o]=Yt,t),{}):{};Oe.filterProps=To;process.env.NODE_ENV!=="production"&&zl.reduce((t,o)=>(t[o]=Yt,t),{});function Ui(t=8,o=pn({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(d=>{const c=o(d);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function zo(...t){const o=t.reduce((i,s)=>(s.filterProps.forEach(d=>{i[d]=s}),i),{}),n=i=>Object.keys(i).reduce((s,d)=>o[d]?Ur(s,o[d](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 Ze(t,o){return $e({prop:t,themeKey:"borders",transform:o})}const El=Ze("border",Qe),Dl=Ze("borderTop",Qe),Ol=Ze("borderRight",Qe),$l=Ze("borderBottom",Qe),Al=Ze("borderLeft",Qe),Ml=Ze("borderColor"),Rl=Ze("borderTopColor"),_l=Ze("borderRightColor"),Wl=Ze("borderBottomColor"),Pl=Ze("borderLeftColor"),Ll=Ze("outline",Qe),Nl=Ze("outlineColor"),Io=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const o=Yr(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:qr(o,i)});return Ot(t,t.borderRadius,n)}return null};Io.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Yt}:{};Io.filterProps=["borderRadius"];zo(El,Dl,Ol,$l,Al,Ml,Rl,_l,Wl,Pl,Io,Ll,Nl);const Bo=t=>{if(t.gap!==void 0&&t.gap!==null){const o=Yr(t.theme,"spacing",8,"gap"),n=i=>({gap:qr(o,i)});return Ot(t,t.gap,n)}return null};Bo.propTypes=process.env.NODE_ENV!=="production"?{gap:Yt}:{};Bo.filterProps=["gap"];const Eo=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const o=Yr(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:qr(o,i)});return Ot(t,t.columnGap,n)}return null};Eo.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Yt}:{};Eo.filterProps=["columnGap"];const Do=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const o=Yr(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:qr(o,i)});return Ot(t,t.rowGap,n)}return null};Do.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Yt}:{};Do.filterProps=["rowGap"];const Fl=$e({prop:"gridColumn"}),Vl=$e({prop:"gridRow"}),Hl=$e({prop:"gridAutoFlow"}),Ul=$e({prop:"gridAutoColumns"}),Gl=$e({prop:"gridAutoRows"}),Yl=$e({prop:"gridTemplateColumns"}),ql=$e({prop:"gridTemplateRows"}),Jl=$e({prop:"gridTemplateAreas"}),Kl=$e({prop:"gridArea"});zo(Bo,Eo,Do,Fl,Vl,Hl,Ul,Gl,Yl,ql,Jl,Kl);function Br(t,o){return o==="grey"?o:t}const Xl=$e({prop:"color",themeKey:"palette",transform:Br}),Ql=$e({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Br}),Zl=$e({prop:"backgroundColor",themeKey:"palette",transform:Br});zo(Xl,Ql,Zl);function Ye(t){return t<=1&&t!==0?`${t*100}%`:t}const ec=$e({prop:"width",transform:Ye}),xn=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const o=n=>{var s,d,c,l,p;const i=((c=(d=(s=t.theme)==null?void 0:s.breakpoints)==null?void 0:d.values)==null?void 0:c[n])||Co[n];return i?((p=(l=t.theme)==null?void 0:l.breakpoints)==null?void 0:p.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Ye(n)}};return Ot(t,t.maxWidth,o)}return null};xn.filterProps=["maxWidth"];const tc=$e({prop:"minWidth",transform:Ye}),rc=$e({prop:"height",transform:Ye}),oc=$e({prop:"maxHeight",transform:Ye}),nc=$e({prop:"minHeight",transform:Ye});$e({prop:"size",cssProperty:"width",transform:Ye});$e({prop:"size",cssProperty:"height",transform:Ye});const ic=$e({prop:"boxSizing"});zo(ec,xn,tc,rc,oc,nc,ic);const Oo={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:Io},color:{themeKey:"palette",transform:Br},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Br},backgroundColor:{themeKey:"palette",transform:Br},p:{style:Oe},pt:{style:Oe},pr:{style:Oe},pb:{style:Oe},pl:{style:Oe},px:{style:Oe},py:{style:Oe},padding:{style:Oe},paddingTop:{style:Oe},paddingRight:{style:Oe},paddingBottom:{style:Oe},paddingLeft:{style:Oe},paddingX:{style:Oe},paddingY:{style:Oe},paddingInline:{style:Oe},paddingInlineStart:{style:Oe},paddingInlineEnd:{style:Oe},paddingBlock:{style:Oe},paddingBlockStart:{style:Oe},paddingBlockEnd:{style:Oe},m:{style:De},mt:{style:De},mr:{style:De},mb:{style:De},ml:{style:De},mx:{style:De},my:{style:De},margin:{style:De},marginTop:{style:De},marginRight:{style:De},marginBottom:{style:De},marginLeft:{style:De},marginX:{style:De},marginY:{style:De},marginInline:{style:De},marginInlineStart:{style:De},marginInlineEnd:{style:De},marginBlock:{style:De},marginBlockStart:{style:De},marginBlockEnd:{style:De},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:Bo},rowGap:{style:Do},columnGap:{style:Eo},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Ye},maxWidth:{style:xn},minWidth:{transform:Ye},height:{transform:Ye},maxHeight:{transform:Ye},minHeight:{transform:Ye},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 sc(...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 ac(t,o){return typeof t=="function"?t(o):t}function lc(){function t(n,i,s,d){const c={[n]:i,theme:s},l=d[n];if(!l)return{[n]:i};const{cssProperty:p=n,themeKey:f,transform:m,style:h}=l;if(i==null)return null;if(f==="typography"&&i==="inherit")return{[n]:i};const x=wo(s,f)||{};return h?h(c):Ot(c,i,E=>{let g=yo(x,m,E);return E===g&&typeof E=="string"&&(g=yo(x,m,`${n}${E==="default"?"":Vi(E)}`,E)),p===!1?g:{[p]:g}})}function o(n){const{sx:i,theme:s={},nested:d}=n||{};if(!i)return null;const c=s.unstable_sxConfig??Oo;function l(p){let f=p;if(typeof p=="function")f=p(s);else if(typeof p!="object")return p;if(!f)return null;const m=jl(s.breakpoints),h=Object.keys(m);let x=m;return Object.keys(f).forEach(b=>{const E=ac(f[b],s);if(E!=null)if(typeof E=="object")if(c[b])x=Ur(x,t(b,E,s,c));else{const g=Ot({theme:s},E,j=>({[b]:j}));sc(g,E)?x[b]=o({sx:E,theme:s,nested:!0}):x=Ur(x,g)}else x=Ur(x,t(b,E,s,c))}),!d&&s.modularCssLayers?{"@layer sx":Jn(s,Xn(h,x))}:Jn(s,Xn(h,x))}return Array.isArray(i)?i.map(l):l(i)}return o}const $o=lc();$o.filterProps=["sx"];function cc(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 Gi(t={},...o){const{breakpoints:n={},palette:i={},spacing:s,shape:d={},...c}=t,l=fl(n),p=Ui(s);let f=Je({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:p,shape:{...vl,...d}},c);return f=bl(f),f.applyStyles=cc,f=o.reduce((m,h)=>Je(m,h),f),f.unstable_sxConfig={...Oo,...c==null?void 0:c.unstable_sxConfig},f.unstable_sx=function(h){return $o({sx:h,theme:this})},f}function dc(t){return Object.keys(t).length===0}function uc(t=null){const o=vo.useContext(Ds.ThemeContext);return!o||dc(o)?t:o}const pc=Gi();function xc(t=pc){return uc(t)}const Zn=t=>t,mc=()=>{let t=Zn;return{configure(o){t=o},generate(o){return t(o)},reset(){t=Zn}}},hc=mc(),fc={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 gc(t,o,n="Mui"){const i=fc[o];return i?`${n}-${i}`:`${hc.generate(t)}-${o}`}function yc(t,o=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(o,Math.min(t,n))}function mn(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}].`),yc(t,o,n)}function bc(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 Gt(t){if(t.type)return t;if(t.charAt(0)==="#")return Gt(bc(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().`:cr(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.`:cr(10,s))}else i=i.split(",");return i=i.map(d=>parseFloat(d)),{type:n,values:i,colorSpace:s}}const vc=t=>{const o=Gt(t);return o.values.slice(0,3).map((n,i)=>o.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Fr=(t,o)=>{try{return vc(t)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),t}};function Ao(t){const{type:o,colorSpace:n}=t;let{values:i}=t;return o.includes("rgb")?i=i.map((s,d)=>d<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 Yi(t){t=Gt(t);const{values:o}=t,n=o[0],i=o[1]/100,s=o[2]/100,d=i*Math.min(s,1-s),c=(f,m=(f+n/30)%12)=>s-d*Math.max(Math.min(m-3,9-m,1),-1);let l="rgb";const p=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return t.type==="hsla"&&(l+="a",p.push(o[3])),Ao({type:l,values:p})}function on(t){t=Gt(t);let o=t.type==="hsl"||t.type==="hsla"?Gt(Yi(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 ei(t,o){const n=on(t),i=on(o);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function z(t,o){return t=Gt(t),o=mn(o),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${o}`:t.values[3]=o,Ao(t)}function sr(t,o,n){try{return z(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Mo(t,o){if(t=Gt(t),o=mn(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 Ao(t)}function je(t,o,n){try{return Mo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Ro(t,o){if(t=Gt(t),o=mn(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 Ao(t)}function Ce(t,o,n){try{return Ro(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Sc(t,o=.15){return on(t)>.5?Mo(t,o):Ro(t,o)}function ao(t,o,n){try{return Sc(t,o)}catch{return t}}function jc(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 ti=(t,o,n,i=[])=>{let s=t;o.forEach((d,c)=>{c===o.length-1?Array.isArray(s)?s[Number(d)]=n:s&&typeof s=="object"&&(s[d]=n):s&&typeof s=="object"&&(s[d]||(s[d]=i.includes(d)?[]:{}),s=s[d])})},Cc=(t,o,n)=>{function i(s,d=[],c=[]){Object.entries(s).forEach(([l,p])=>{(!n||n&&!n([...d,l]))&&p!=null&&(typeof p=="object"&&Object.keys(p).length>0?i(p,[...d,l],Array.isArray(p)?[...c,l]:c):o([...d,l],p,c))})}i(t)},wc=(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 Zo(t,o){const{prefix:n,shouldSkipGeneratingVar:i}=o||{},s={},d={},c={};return Cc(t,(l,p,f)=>{if((typeof p=="string"||typeof p=="number")&&(!i||!i(l,p))){const m=`--${n?`${n}-`:""}${l.join("-")}`,h=wc(l,p);Object.assign(s,{[m]:h}),ti(d,l,`var(${m})`,f),ti(c,l,`var(${m}, ${h})`,f)}},l=>l[0]==="vars"),{css:s,vars:d,varsWithDefaults:c}}function kc(t,o={}){const{getSelector:n=k,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:d}=o,{colorSchemes:c={},components:l,defaultColorScheme:p="light",...f}=t,{vars:m,css:h,varsWithDefaults:x}=Zo(f,o);let b=x;const E={},{[p]:g,...j}=c;if(Object.entries(j||{}).forEach(([S,w])=>{const{vars:a,css:I,varsWithDefaults:R}=Zo(w,o);b=Je(b,R),E[S]={css:I,vars:a}}),g){const{css:S,vars:w,varsWithDefaults:a}=Zo(g,o);b=Je(b,a),E[p]={css:S,vars:w}}function k(S,w){var I,R;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),S){if(a==="media")return t.defaultColorScheme===S?":root":{[`@media (prefers-color-scheme: ${((R=(I=c[S])==null?void 0:I.palette)==null?void 0:R.mode)||S})`]:{":root":w}};if(a)return t.defaultColorScheme===S?`:root, ${a.replace("%s",String(S))}`:a.replace("%s",String(S))}return":root"}return{vars:b,generateThemeVars:()=>{let S={...m};return Object.entries(E).forEach(([,{vars:w}])=>{S=Je(S,w)}),S},generateStyleSheets:()=>{var G,q;const S=[],w=t.defaultColorScheme||"light";function a(ee,y){Object.keys(y).length&&S.push(typeof ee=="string"?{[ee]:{...y}}:ee)}a(n(void 0,{...h}),h);const{[w]:I,...R}=E;if(I){const{css:ee}=I,y=(q=(G=c[w])==null?void 0:G.palette)==null?void 0:q.mode,M=!i&&y?{colorScheme:y,...ee}:{...ee};a(n(w,{...M}),M)}return Object.entries(R).forEach(([ee,{css:y}])=>{var V,X;const M=(X=(V=c[ee])==null?void 0:V.palette)==null?void 0:X.mode,W=!i&&M?{colorScheme:M,...y}:{...y};a(n(ee,{...W}),W)}),d&&S.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)"}}),S}}}function Tc(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 Gr={black:"#000",white:"#fff"},zc={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"},wr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},kr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Wr={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},Tr={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},zr={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},Ir={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function qi(){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:Gr.white,default:Gr.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 Ji=qi();function Ki(){return{text:{primary:Gr.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:Gr.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 nn=Ki();function ri(t,o,n,i){const s=i.light||i,d=i.dark||i*1.5;t[o]||(t.hasOwnProperty(n)?t[o]=t[n]:o==="light"?t.light=Ro(t.main,s):o==="dark"&&(t.dark=Mo(t.main,d)))}function oi(t,o,n,i,s){const d=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 ${(d*100).toFixed(0)}%)`:n==="dark"&&(o.dark=`color-mix(in ${t}, ${o.main}, #000 ${(c*100).toFixed(0)}%)`))}function Ic(t="light"){return t==="dark"?{main:Tr[200],light:Tr[50],dark:Tr[400]}:{main:Tr[700],light:Tr[400],dark:Tr[800]}}function Bc(t="light"){return t==="dark"?{main:wr[200],light:wr[50],dark:wr[400]}:{main:wr[500],light:wr[300],dark:wr[700]}}function Ec(t="light"){return t==="dark"?{main:kr[500],light:kr[300],dark:kr[700]}:{main:kr[700],light:kr[400],dark:kr[800]}}function Dc(t="light"){return t==="dark"?{main:zr[400],light:zr[300],dark:zr[700]}:{main:zr[700],light:zr[500],dark:zr[900]}}function Oc(t="light"){return t==="dark"?{main:Ir[400],light:Ir[300],dark:Ir[700]}:{main:Ir[800],light:Ir[500],dark:Ir[900]}}function $c(t="light"){return t==="dark"?{main:Wr[400],light:Wr[300],dark:Wr[700]}:{main:"#ed6c02",light:Wr[500],dark:Wr[900]}}function Ac(t){return`oklch(from ${t} var(--__l) 0 h / var(--__a))`}function hn(t){const{mode:o="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...d}=t,c=t.primary||Ic(o),l=t.secondary||Bc(o),p=t.error||Ec(o),f=t.info||Dc(o),m=t.success||Oc(o),h=t.warning||$c(o);function x(j){if(s)return Ac(j);const k=ei(j,nn.text.primary)>=n?nn.text.primary:Ji.text.primary;if(process.env.NODE_ENV!=="production"){const v=ei(j,k);v<3&&console.error([`MUI: The contrast ratio of ${v}:1 for ${k} on ${j}`,"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 k}const b=({color:j,name:k,mainShade:v=500,lightShade:C=300,darkShade:S=700})=>{if(j={...j},!j.main&&j[v]&&(j.main=j[v]),!j.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${k?` (${k})`:""} provided to augmentColor(color) is invalid.
|
|
46
|
+
The color object needs to have a \`main\` property or a \`${v}\` property.`:cr(11,k?` (${k})`:"",v));if(typeof j.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${k?` (${k})`:""} provided to augmentColor(color) is invalid.
|
|
47
47
|
\`color.main\` should be a string, but \`${JSON.stringify(j.main)}\` was provided instead.
|
|
48
48
|
|
|
49
49
|
Did you intend to use one of the following approaches?
|
|
@@ -56,17 +56,17 @@ const theme1 = createTheme({ palette: {
|
|
|
56
56
|
|
|
57
57
|
const theme2 = createTheme({ palette: {
|
|
58
58
|
primary: { main: green[500] },
|
|
59
|
-
} });`:
|
|
60
|
-
`)),Object.keys(f).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(f).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(m=>`${m} ${typeof c=="string"?c:
|
|
59
|
+
} });`:cr(12,k?` (${k})`:"",JSON.stringify(j.main)));return s?(oi(s,j,"light",C,i),oi(s,j,"dark",S,i)):(ri(j,"light",C,i),ri(j,"dark",S,i)),j.contrastText||(j.contrastText=x(j.main)),j};let E;return o==="light"?E=qi():o==="dark"&&(E=Ki()),process.env.NODE_ENV!=="production"&&(E||console.error(`MUI: The palette mode \`${o}\` is not supported.`)),Je({common:{...Gr},mode:o,primary:b({color:c,name:"primary"}),secondary:b({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:b({color:p,name:"error"}),warning:b({color:h,name:"warning"}),info:b({color:f,name:"info"}),success:b({color:m,name:"success"}),grey:zc,contrastThreshold:n,getContrastText:x,augmentColor:b,tonalOffset:i,...E},d)}function Mc(t){const o={};return Object.entries(t).forEach(i=>{const[s,d]=i;typeof d=="object"&&(o[s]=`${d.fontStyle?`${d.fontStyle} `:""}${d.fontVariant?`${d.fontVariant} `:""}${d.fontWeight?`${d.fontWeight} `:""}${d.fontStretch?`${d.fontStretch} `:""}${d.fontSize||""}${d.lineHeight?`/${d.lineHeight} `:""}${d.fontFamily||""}`)}),o}function Rc(t,o){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...o}}function _c(t){return Math.round(t*1e5)/1e5}const ni={textTransform:"uppercase"},ii='"Roboto", "Helvetica", "Arial", sans-serif';function Wc(t,o){const{fontFamily:n=ii,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:d=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:p=16,allVariants:f,pxToRem:m,...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 p!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const x=i/14,b=m||(j=>`${j/p*x}rem`),E=(j,k,v,C,S)=>({fontFamily:n,fontWeight:j,fontSize:b(k),lineHeight:v,...n===ii?{letterSpacing:`${_c(C/k)}em`}:{},...S,...f}),g={h1:E(s,96,1.167,-1.5),h2:E(s,60,1.2,-.5),h3:E(d,48,1.167,0),h4:E(d,34,1.235,.25),h5:E(d,24,1.334,0),h6:E(c,20,1.6,.15),subtitle1:E(d,16,1.75,.15),subtitle2:E(c,14,1.57,.1),body1:E(d,16,1.5,.15),body2:E(d,14,1.43,.15),button:E(c,14,1.75,.4,ni),caption:E(d,12,1.66,.4),overline:E(d,12,2.66,1,ni),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Je({htmlFontSize:p,pxToRem:b,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:d,fontWeightMedium:c,fontWeightBold:l,...g},h,{clone:!1})}const Pc=.2,Lc=.14,Nc=.12;function Be(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${Pc})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${Lc})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${Nc})`].join(",")}const Fc=["none",Be(0,2,1,-1,0,1,1,0,0,1,3,0),Be(0,3,1,-2,0,2,2,0,0,1,5,0),Be(0,3,3,-2,0,3,4,0,0,1,8,0),Be(0,2,4,-1,0,4,5,0,0,1,10,0),Be(0,3,5,-1,0,5,8,0,0,1,14,0),Be(0,3,5,-1,0,6,10,0,0,1,18,0),Be(0,4,5,-2,0,7,10,1,0,2,16,1),Be(0,5,5,-3,0,8,10,1,0,3,14,2),Be(0,5,6,-3,0,9,12,1,0,3,16,2),Be(0,6,6,-3,0,10,14,1,0,4,18,3),Be(0,6,7,-4,0,11,15,1,0,4,20,3),Be(0,7,8,-4,0,12,17,2,0,5,22,4),Be(0,7,8,-4,0,13,19,2,0,5,24,4),Be(0,7,9,-4,0,14,21,2,0,5,26,4),Be(0,8,9,-5,0,15,22,2,0,6,28,5),Be(0,8,10,-5,0,16,24,2,0,6,30,5),Be(0,8,11,-5,0,17,26,2,0,6,32,5),Be(0,9,11,-5,0,18,28,2,0,7,34,6),Be(0,9,12,-6,0,19,29,2,0,7,36,6),Be(0,10,13,-6,0,20,31,3,0,8,38,7),Be(0,10,13,-6,0,21,33,3,0,8,40,7),Be(0,10,14,-6,0,22,35,3,0,8,42,7),Be(0,11,14,-7,0,23,36,3,0,9,44,8),Be(0,11,15,-7,0,24,38,3,0,9,46,8)],Vc={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)"},Hc={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function si(t){return`${Math.round(t)}ms`}function Uc(t){if(!t)return 0;const o=t/36;return Math.min(Math.round((4+15*o**.25+o/5)*10),3e3)}function Gc(t){const o={...Vc,...t.easing},n={...Hc,...t.duration};return{getAutoHeightDuration:Uc,create:(s=["all"],d={})=>{const{duration:c=n.standard,easing:l=o.easeInOut,delay:p=0,...f}=d;if(process.env.NODE_ENV!=="production"){const m=x=>typeof x=="string",h=x=>!Number.isNaN(parseFloat(x));!m(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!h(c)&&!m(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),m(l)||console.error('MUI: Argument "easing" must be a string.'),!h(p)&&!m(p)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof d!="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(m=>`${m} ${typeof c=="string"?c:si(c)} ${l} ${typeof p=="string"?p:si(p)}`).join(",")},...t,easing:o,duration:n}}const Yc={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function qc(t){return Ut(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 d=0;d<s.length;d++){const[c,l]=s[d];!qc(l)||c.startsWith("unstable_")?delete i[c]:Ut(l)&&(i[c]={...l},n(i[c]))}}return n(o),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
|
|
61
61
|
|
|
62
62
|
const theme = ${JSON.stringify(o,null,2)};
|
|
63
63
|
|
|
64
64
|
theme.breakpoints = createBreakpoints(theme.breakpoints || {});
|
|
65
65
|
theme.transitions = createTransitions(theme.transitions || {});
|
|
66
66
|
|
|
67
|
-
export default theme;`}function
|
|
68
|
-
`))}j[
|
|
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 nd(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const mt=t=>{try{return t()}catch{}},id=(t="mui")=>jc(t);function Jo(t,o,n,i,s){if(!n)return;n=n===!0?{}:n;const d=s==="dark"?"dark":"light";if(!i){o[s]=Zc({...n,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:c,...l}=en({...i,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return o[s]={...n,palette:c,opacity:{...Gi(d),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||qi(d)},l}function sd(t={},...o){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:d="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=ed,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:f=":root",...m}=t,h=Object.keys(n)[0],x=i||(n.light&&h!=="light"?"light":h),b=id(d),{[x]:D,light:g,dark:j,...w}=n,I={...w};let v=D;if((x==="dark"&&!("dark"in n)||x==="light"&&!("light"in n))&&(v=!0),!v)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${x}\` option is either missing or invalid.`:or(21,x));let S;c&&(S="oklch");const C=Jo(S,I,v,m,x);g&&!I.light&&Jo(S,I,g,void 0,"light"),j&&!I.dark&&Jo(S,I,j,void 0,"dark");let a={defaultColorScheme:x,...C,cssVarPrefix:d,colorSchemeSelector:u,rootSelector:f,getCssVar:b,colorSchemes:I,font:{...Mc(C.typography),...C.font},spacing:nd(m.spacing)};Object.keys(a.colorSchemes).forEach(ee=>{const y=a.colorSchemes[ee].palette,M=V=>{const Q=V.split("-"),xe=Q[1],de=Q[2];return b(V,y[xe][de])};y.mode==="light"&&(N(y.common,"background","#fff"),N(y.common,"onBackground","#000")),y.mode==="dark"&&(N(y.common,"background","#000"),N(y.common,"onBackground","#fff"));function W(V,Q,xe){if(S){let de;return V===er&&(de=`transparent ${((1-xe)*100).toFixed(0)}%`),V===ve&&(de=`#000 ${(xe*100).toFixed(0)}%`),V===Se&&(de=`#fff ${(xe*100).toFixed(0)}%`),`color-mix(in ${S}, ${Q}, ${de})`}return V(Q,xe)}if(od(y,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),y.mode==="light"){N(y.Alert,"errorColor",W(ve,y.error.light,.6)),N(y.Alert,"infoColor",W(ve,y.info.light,.6)),N(y.Alert,"successColor",W(ve,y.success.light,.6)),N(y.Alert,"warningColor",W(ve,y.warning.light,.6)),N(y.Alert,"errorFilledBg",M("palette-error-main")),N(y.Alert,"infoFilledBg",M("palette-info-main")),N(y.Alert,"successFilledBg",M("palette-success-main")),N(y.Alert,"warningFilledBg",M("palette-warning-main")),N(y.Alert,"errorFilledColor",mt(()=>y.getContrastText(y.error.main))),N(y.Alert,"infoFilledColor",mt(()=>y.getContrastText(y.info.main))),N(y.Alert,"successFilledColor",mt(()=>y.getContrastText(y.success.main))),N(y.Alert,"warningFilledColor",mt(()=>y.getContrastText(y.warning.main))),N(y.Alert,"errorStandardBg",W(Se,y.error.light,.9)),N(y.Alert,"infoStandardBg",W(Se,y.info.light,.9)),N(y.Alert,"successStandardBg",W(Se,y.success.light,.9)),N(y.Alert,"warningStandardBg",W(Se,y.warning.light,.9)),N(y.Alert,"errorIconColor",M("palette-error-main")),N(y.Alert,"infoIconColor",M("palette-info-main")),N(y.Alert,"successIconColor",M("palette-success-main")),N(y.Alert,"warningIconColor",M("palette-warning-main")),N(y.AppBar,"defaultBg",M("palette-grey-100")),N(y.Avatar,"defaultBg",M("palette-grey-400")),N(y.Button,"inheritContainedBg",M("palette-grey-300")),N(y.Button,"inheritContainedHoverBg",M("palette-grey-A100")),N(y.Chip,"defaultBorder",M("palette-grey-400")),N(y.Chip,"defaultAvatarColor",M("palette-grey-700")),N(y.Chip,"defaultIconColor",M("palette-grey-700")),N(y.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),N(y.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),N(y.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),N(y.LinearProgress,"primaryBg",W(Se,y.primary.main,.62)),N(y.LinearProgress,"secondaryBg",W(Se,y.secondary.main,.62)),N(y.LinearProgress,"errorBg",W(Se,y.error.main,.62)),N(y.LinearProgress,"infoBg",W(Se,y.info.main,.62)),N(y.LinearProgress,"successBg",W(Se,y.success.main,.62)),N(y.LinearProgress,"warningBg",W(Se,y.warning.main,.62)),N(y.Skeleton,"bg",S?W(er,y.text.primary,.11):`rgba(${M("palette-text-primaryChannel")} / 0.11)`),N(y.Slider,"primaryTrack",W(Se,y.primary.main,.62)),N(y.Slider,"secondaryTrack",W(Se,y.secondary.main,.62)),N(y.Slider,"errorTrack",W(Se,y.error.main,.62)),N(y.Slider,"infoTrack",W(Se,y.info.main,.62)),N(y.Slider,"successTrack",W(Se,y.success.main,.62)),N(y.Slider,"warningTrack",W(Se,y.warning.main,.62));const V=S?W(ve,y.background.default,.6825):ao(y.background.default,.8);N(y.SnackbarContent,"bg",V),N(y.SnackbarContent,"color",mt(()=>S?Zo.text.primary:y.getContrastText(V))),N(y.SpeedDialAction,"fabHoverBg",ao(y.background.paper,.15)),N(y.StepConnector,"border",M("palette-grey-400")),N(y.StepContent,"border",M("palette-grey-400")),N(y.Switch,"defaultColor",M("palette-common-white")),N(y.Switch,"defaultDisabledColor",M("palette-grey-100")),N(y.Switch,"primaryDisabledColor",W(Se,y.primary.main,.62)),N(y.Switch,"secondaryDisabledColor",W(Se,y.secondary.main,.62)),N(y.Switch,"errorDisabledColor",W(Se,y.error.main,.62)),N(y.Switch,"infoDisabledColor",W(Se,y.info.main,.62)),N(y.Switch,"successDisabledColor",W(Se,y.success.main,.62)),N(y.Switch,"warningDisabledColor",W(Se,y.warning.main,.62)),N(y.TableCell,"border",W(Se,W(er,y.divider,1),.88)),N(y.Tooltip,"bg",W(er,y.grey[700],.92))}if(y.mode==="dark"){N(y.Alert,"errorColor",W(Se,y.error.light,.6)),N(y.Alert,"infoColor",W(Se,y.info.light,.6)),N(y.Alert,"successColor",W(Se,y.success.light,.6)),N(y.Alert,"warningColor",W(Se,y.warning.light,.6)),N(y.Alert,"errorFilledBg",M("palette-error-dark")),N(y.Alert,"infoFilledBg",M("palette-info-dark")),N(y.Alert,"successFilledBg",M("palette-success-dark")),N(y.Alert,"warningFilledBg",M("palette-warning-dark")),N(y.Alert,"errorFilledColor",mt(()=>y.getContrastText(y.error.dark))),N(y.Alert,"infoFilledColor",mt(()=>y.getContrastText(y.info.dark))),N(y.Alert,"successFilledColor",mt(()=>y.getContrastText(y.success.dark))),N(y.Alert,"warningFilledColor",mt(()=>y.getContrastText(y.warning.dark))),N(y.Alert,"errorStandardBg",W(ve,y.error.light,.9)),N(y.Alert,"infoStandardBg",W(ve,y.info.light,.9)),N(y.Alert,"successStandardBg",W(ve,y.success.light,.9)),N(y.Alert,"warningStandardBg",W(ve,y.warning.light,.9)),N(y.Alert,"errorIconColor",M("palette-error-main")),N(y.Alert,"infoIconColor",M("palette-info-main")),N(y.Alert,"successIconColor",M("palette-success-main")),N(y.Alert,"warningIconColor",M("palette-warning-main")),N(y.AppBar,"defaultBg",M("palette-grey-900")),N(y.AppBar,"darkBg",M("palette-background-paper")),N(y.AppBar,"darkColor",M("palette-text-primary")),N(y.Avatar,"defaultBg",M("palette-grey-600")),N(y.Button,"inheritContainedBg",M("palette-grey-800")),N(y.Button,"inheritContainedHoverBg",M("palette-grey-700")),N(y.Chip,"defaultBorder",M("palette-grey-700")),N(y.Chip,"defaultAvatarColor",M("palette-grey-300")),N(y.Chip,"defaultIconColor",M("palette-grey-300")),N(y.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),N(y.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),N(y.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),N(y.LinearProgress,"primaryBg",W(ve,y.primary.main,.5)),N(y.LinearProgress,"secondaryBg",W(ve,y.secondary.main,.5)),N(y.LinearProgress,"errorBg",W(ve,y.error.main,.5)),N(y.LinearProgress,"infoBg",W(ve,y.info.main,.5)),N(y.LinearProgress,"successBg",W(ve,y.success.main,.5)),N(y.LinearProgress,"warningBg",W(ve,y.warning.main,.5)),N(y.Skeleton,"bg",S?W(er,y.text.primary,.13):`rgba(${M("palette-text-primaryChannel")} / 0.13)`),N(y.Slider,"primaryTrack",W(ve,y.primary.main,.5)),N(y.Slider,"secondaryTrack",W(ve,y.secondary.main,.5)),N(y.Slider,"errorTrack",W(ve,y.error.main,.5)),N(y.Slider,"infoTrack",W(ve,y.info.main,.5)),N(y.Slider,"successTrack",W(ve,y.success.main,.5)),N(y.Slider,"warningTrack",W(ve,y.warning.main,.5));const V=S?W(Se,y.background.default,.985):ao(y.background.default,.98);N(y.SnackbarContent,"bg",V),N(y.SnackbarContent,"color",mt(()=>S?Hi.text.primary:y.getContrastText(V))),N(y.SpeedDialAction,"fabHoverBg",ao(y.background.paper,.15)),N(y.StepConnector,"border",M("palette-grey-600")),N(y.StepContent,"border",M("palette-grey-600")),N(y.Switch,"defaultColor",M("palette-grey-300")),N(y.Switch,"defaultDisabledColor",M("palette-grey-600")),N(y.Switch,"primaryDisabledColor",W(ve,y.primary.main,.55)),N(y.Switch,"secondaryDisabledColor",W(ve,y.secondary.main,.55)),N(y.Switch,"errorDisabledColor",W(ve,y.error.main,.55)),N(y.Switch,"infoDisabledColor",W(ve,y.info.main,.55)),N(y.Switch,"successDisabledColor",W(ve,y.success.main,.55)),N(y.Switch,"warningDisabledColor",W(ve,y.warning.main,.55)),N(y.TableCell,"border",W(ve,W(er,y.divider,1),.68)),N(y.Tooltip,"bg",W(er,y.grey[700],.92))}Ct(y.background,"default"),Ct(y.background,"paper"),Ct(y.common,"background"),Ct(y.common,"onBackground"),Ct(y,"divider"),Object.keys(y).forEach(V=>{const Q=y[V];V!=="tonalOffset"&&Q&&typeof Q=="object"&&(Q.main&&N(y[V],"mainChannel",Hr(Ur(Q.main))),Q.light&&N(y[V],"lightChannel",Hr(Ur(Q.light))),Q.dark&&N(y[V],"darkChannel",Hr(Ur(Q.dark))),Q.contrastText&&N(y[V],"contrastTextChannel",Hr(Ur(Q.contrastText))),V==="text"&&(Ct(y[V],"primary"),Ct(y[V],"secondary")),V==="action"&&(Q.active&&Ct(y[V],"active"),Q.selected&&Ct(y[V],"selected")))})}),a=o.reduce((ee,y)=>Xe(ee,y),a);const z={prefix:d,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:rd(a),enableContrastVars:c},{vars:R,generateThemeVars:q,generateStyleSheets:K}=kc(a,z);return a.vars=R,Object.entries(a.colorSchemes[a.defaultColorScheme]).forEach(([ee,y])=>{a[ee]=y}),a.generateThemeVars=q,a.generateStyleSheets=K,a.generateSpacing=function(){return Ni(m.spacing,an(this))},a.getColorSchemeSelector=Tc(u),a.spacing=a.generateSpacing(),a.shouldSkipGeneratingVar=l,a.unstable_sxConfig={...Oo,...m==null?void 0:m.unstable_sxConfig},a.unstable_sx=function(y){return Ao({sx:y,theme:this})},a.toRuntimeSource=Yi,a}function oi(t,o,n){t.colorSchemes&&n&&(t.colorSchemes[o]={...n!==!0&&n,palette:dn({...n===!0?{}:n.palette,mode:o})})}function ad(t={},...o){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:d=n==null?void 0:n.mode,...c}=t,l=d||"light",u=s==null?void 0:s[l],f={...s,...n?{[l]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return en(t,...o);let m=n;"palette"in t||f[l]&&(f[l]!==!0?m=f[l].palette:l==="dark"&&(m={mode:"dark"}));const h=en({...t,palette:m},...o);return h.defaultColorScheme=l,h.colorSchemes=f,h.palette.mode==="light"&&(h.colorSchemes.light={...f.light!==!0&&f.light,palette:h.palette},oi(h,"dark",f.dark)),h.palette.mode==="dark"&&(h.colorSchemes.dark={...f.dark!==!0&&f.dark,palette:h.palette},oi(h,"light",f.light)),h}return!n&&!("light"in f)&&l==="light"&&(f.light=!0),sd({...c,colorSchemes:f,defaultColorScheme:l,...typeof i!="boolean"&&i},...o)}const ld=ad();function zt(){const t=xc(ld);return process.env.NODE_ENV!=="production"&&vo.useDebugValue(t),t[rl]||t}async function cd(t,o,n){try{new URL(t)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};o&&(i.Authorization=`Bearer ${o}`);const s=new AbortController,d=setTimeout(()=>s.abort(),3e4);let c;try{c=await fetch(t,{headers:i,signal:s.signal})}catch(f){throw clearTimeout(d),(f==null?void 0:f.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(d)}if(c.status===401)throw new Error("Authentication failed (401) — check your API key");if(!c.ok)throw new Error(`API error ${c.status}: ${c.statusText}`);let l;try{l=await c.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(l))u=l;else if(n&&l[n]&&Array.isArray(l[n]))u=l[n];else{const m=["data","results","items","records"].find(h=>l[h]&&Array.isArray(l[h]));if(m)u=l[m];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:t,fetchedAt:new Date().toISOString()}}function dd(t,o){return o.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${k(t.palette.common.black,n.opacity)}`).join(", ")}const ud={menu:[{x:0,y:8,blur:16,spread:4,opacity:.12},{x:0,y:4,blur:16,spread:0,opacity:.08},{x:0,y:0,blur:0,spread:1,opacity:.05}],restButton:[{x:0,y:1,blur:2,spread:0,opacity:.3},{x:0,y:1,blur:3,spread:1,opacity:.15}],restButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1},{x:0,y:1,blur:3,spread:1,opacity:.05}],hoverButton:[{x:0,y:1,blur:3,spread:0,opacity:.3},{x:0,y:4,blur:8,spread:3,opacity:.15}],pressedButton:[{x:0,y:1,blur:2,spread:0,opacity:.3}],pressedButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1}],small:[{x:0,y:2,blur:6,spread:0,opacity:.15}],cardRest:[{x:0,y:1,blur:3,spread:0,opacity:.08},{x:0,y:1,blur:2,spread:0,opacity:.06}],cardHover:[{x:0,y:4,blur:16,spread:0,opacity:.15},{x:0,y:1,blur:4,spread:0,opacity:.08}],popover:[{x:0,y:4,blur:20,spread:0,opacity:.15},{x:0,y:1,blur:6,spread:0,opacity:.1}],flatHover:[{x:0,y:1,blur:2,spread:0,opacity:.06}]};function te(t,o){return dd(t,ud[o])}function Me(t){return`${Number(t.shape.borderRadius)*1.5}px`}function Xr(t){return`${Number(t.shape.borderRadius)}px`}function pd({isOpen:t,onClose:o,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[d,c]=p.useState(""),[l,u]=p.useState(!1),[f,m]=p.useState(""),[h,x]=p.useState(null),[b,D]=p.useState(null),[g,j]=p.useState(!1),[w,I]=p.useState(""),v=p.useRef(null),[S,C]=p.useState("json"),[a,z]=p.useState(""),[R,q]=p.useState(""),[K,ee]=p.useState(""),[y,M]=p.useState("idle"),[W,V]=p.useState(""),[Q,xe]=p.useState(null),[de,L]=p.useState(0),A=async P=>{if(I(""),!P.name.endsWith(".json")){I("Only .json files are allowed");return}const ne=10*1024*1024;if(P.size>ne){I("File size exceeds 10MB limit");return}try{const ce=await P.text();let ae;try{ae=JSON.parse(ce)}catch{I("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ae)){I("JSON must be an array of objects");return}if(ae.length===0){I("No data rows found in JSON file");return}x(P),D(ae)}catch{I("Network error — please try again")}},H=P=>{P.preventDefault();const ne=P.dataTransfer.files[0];ne&&A(ne)},ie=async()=>{if(a.trim()){M("loading"),V("");try{const P=await cd(a.trim(),R.trim()||void 0,K.trim()||void 0);xe(P.data),L(P.data.length),M("ready")}catch(P){V((P==null?void 0:P.message)||"Connection failed"),M("error")}}},Y=()=>{if(!d.trim()){u(!0);return}const P=S==="api"?Q:i||b;P&&(n(d.trim(),f.trim(),P),re())},re=()=>{c(""),u(!1),m(""),x(null),D(null),I(""),C("json"),z(""),q(""),ee(""),M("idle"),V(""),xe(null),L(0),o()},se=i||b,oe=l&&!d.trim();return d.trim(),e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:re,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:P=>Me(P),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:P=>te(P,"menu")}},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:re,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.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:d,onChange:P=>{c(P.target.value),l&&P.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:oe,helperText:oe?"Report name is required":void 0,inputProps:{maxLength:255},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:f,onChange:P=>m(P.target.value),placeholder:"Add details about this report",inputProps:{maxLength:500},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:S==="json"?0:1,onChange:(P,ne)=>{C(ne===0?"json":"api"),M("idle"),V("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40},children:[e.jsx(r.Tab,{label:"Upload JSON",icon:e.jsx(B.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(B.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),S==="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:P=>k(P.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:P=>k(P.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.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:()=>j(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(B.Info,{sx:{fontSize:16}})})]}),e.jsxs(r.Box,{onDrop:H,onDragOver:P=>P.preventDefault(),onPaste:P=>P.preventDefault(),onClick:()=>{var P;return(P=v.current)==null?void 0:P.click()},sx:{position:"relative",border:"1.5px",borderStyle:b?"solid":"dashed",borderColor:b?"success.main":w?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:b?P=>k(P.palette.success.main,.04):w?P=>k(P.palette.error.main,.04):P=>k(P.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:b?P=>k(P.palette.success.main,.08):w?P=>k(P.palette.error.main,.08):P=>k(P.palette.primary.main,.08),borderColor:b?"success.dark":w?"error.dark":"primary.dark"}},children:[e.jsx(r.Box,{component:"input",ref:v,type:"file",accept:".json",sx:{display:"none"},onChange:P=>{var ne;return((ne=P.target.files)==null?void 0:ne[0])&&A(P.target.files[0])}}),b?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:P=>k(P.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(B.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:h==null?void 0:h.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:P=>k(P.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(B.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"}),w&&e.jsx(r.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:P=>k(P.palette.error.main,.08),border:1,borderColor:P=>k(P.palette.error.main,.2)},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:w})})]})]})]})}),S==="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:P=>{z(P.target.value),M("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:R,onChange:P=>q(P.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",children:e.jsx(B.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:K,onChange:P=>ee(P.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()||y==="loading",onClick:ie,startIcon:y==="loading"?e.jsx(r.CircularProgress,{size:16,color:"inherit"}):e.jsx(B.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:P=>k(P.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:y==="loading"?"Connecting...":"Test Connection & Load Data"}),y==="ready"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:P=>k(P.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(B.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:[de.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})]})]}),y==="error"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:P=>k(P.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(B.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:W})]})]})]})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[e.jsx(r.Button,{onClick:re,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:P=>k(P.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(r.Button,{onClick:Y,disabled:S==="json"&&!se||S==="api"&&y!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),e.jsxs(r.Dialog,{open:g,onClose:()=>j(!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:()=>j(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(B.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:`[
|
|
67
|
+
export default theme;`}function ai(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const Jc=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 Kc(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})`:z(o,Jc(n))},lighten(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #fff ${ai(n)})`:Ro(o,n)},darken(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #000 ${ai(n)})`:Mo(o,n)}})}function sn(t={},...o){const{breakpoints:n,mixins:i={},spacing:s,palette:d={},transitions:c={},typography:l={},shape:p,colorSpace:f,...m}=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.":cr(20));const h=hn({...d,colorSpace:f}),x=Gi(t);let b=Je(x,{mixins:Rc(x.breakpoints,i),palette:h,shadows:Fc.slice(),typography:Wc(h,l),transitions:Gc(c),zIndex:{...Yc}});if(b=Je(b,m),b=o.reduce((E,g)=>Je(E,g),b),process.env.NODE_ENV!=="production"){const E=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],g=(j,k)=>{let v;for(v in j){const C=j[v];if(E.includes(v)&&Object.keys(C).length>0){if(process.env.NODE_ENV!=="production"){const S=gc("",v);console.error([`MUI: The \`${k}\` component increases the CSS specificity of the \`${v}\` internal state.`,"You can not override it like this: ",JSON.stringify(j,null,2),"",`Instead, you need to use the '&.${S}' syntax:`,JSON.stringify({root:{[`&.${S}`]:C}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
|
|
68
|
+
`))}j[v]={}}}};Object.keys(b.components).forEach(j=>{const k=b.components[j].styleOverrides;k&&j.startsWith("Mui")&&g(k,j)})}return b.unstable_sxConfig={...Oo,...m==null?void 0:m.unstable_sxConfig},b.unstable_sx=function(g){return $o({sx:g,theme:this})},b.toRuntimeSource=Xi,Kc(b),b}function Xc(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 Qc=[...Array(25)].map((t,o)=>{if(o===0)return"none";const n=Xc(o);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Qi(t){return{inputPlaceholder:t==="dark"?.5:.42,inputUnderline:t==="dark"?.7:.42,switchTrackDisabled:t==="dark"?.2:.12,switchTrack:t==="dark"?.3:.38}}function Zi(t){return t==="dark"?Qc:[]}function Zc(t){const{palette:o={mode:"light"},opacity:n,overlays:i,colorSpace:s,...d}=t,c=hn({...o,colorSpace:s});return{palette:c,opacity:{...Qi(c.mode),...n},overlays:i||Zi(c.mode),...d}}function ed(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 td=t=>[...[...Array(25)].map((o,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],rd=t=>(o,n)=>{const i=t.rootSelector||":root",s=t.colorSchemeSelector;let d=s;if(s==="class"&&(d=".%s"),s==="data"&&(d="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(d=`[${s}="%s"]`),t.defaultColorScheme===o){if(o==="dark"){const c={};return td(t.cssVarPrefix).forEach(l=>{c[l]=n[l],delete n[l]}),d==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:c}}:d?{[d.replace("%s",o)]:c,[`${i}, ${d.replace("%s",o)}`]:n}:{[i]:{...n,...c}}}if(d&&d!=="media")return`${i}, ${d.replace("%s",String(o))}`}else if(o){if(d==="media")return{[`@media (prefers-color-scheme: ${String(o)})`]:{[i]:n}};if(d)return d.replace("%s",String(o))}return i};function od(t,o){o.forEach(n=>{t[n]||(t[n]={})})}function L(t,o,n){!t[o]&&n&&(t[o]=n)}function Vr(t){return typeof t!="string"||!t.startsWith("hsl")?t:Yi(t)}function Bt(t,o){`${o}Channel`in t||(t[`${o}Channel`]=Fr(Vr(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 nd(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const bt=t=>{try{return t()}catch{}},id=(t="mui")=>jc(t);function en(t,o,n,i,s){if(!n)return;n=n===!0?{}:n;const d=s==="dark"?"dark":"light";if(!i){o[s]=Zc({...n,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:c,...l}=sn({...i,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return o[s]={...n,palette:c,opacity:{...Qi(d),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||Zi(d)},l}function sd(t={},...o){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:d="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=ed,colorSchemeSelector:p=n.light&&n.dark?"media":void 0,rootSelector:f=":root",...m}=t,h=Object.keys(n)[0],x=i||(n.light&&h!=="light"?"light":h),b=id(d),{[x]:E,light:g,dark:j,...k}=n,v={...k};let C=E;if((x==="dark"&&!("dark"in n)||x==="light"&&!("light"in n))&&(C=!0),!C)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${x}\` option is either missing or invalid.`:cr(21,x));let S;c&&(S="oklch");const w=en(S,v,C,m,x);g&&!v.light&&en(S,v,g,void 0,"light"),j&&!v.dark&&en(S,v,j,void 0,"dark");let a={defaultColorScheme:x,...w,cssVarPrefix:d,colorSchemeSelector:p,rootSelector:f,getCssVar:b,colorSchemes:v,font:{...Mc(w.typography),...w.font},spacing:nd(m.spacing)};Object.keys(a.colorSchemes).forEach(ee=>{const y=a.colorSchemes[ee].palette,M=V=>{const X=V.split("-"),ue=X[1],ce=X[2];return b(V,y[ue][ce])};y.mode==="light"&&(L(y.common,"background","#fff"),L(y.common,"onBackground","#000")),y.mode==="dark"&&(L(y.common,"background","#000"),L(y.common,"onBackground","#fff"));function W(V,X,ue){if(S){let ce;return V===sr&&(ce=`transparent ${((1-ue)*100).toFixed(0)}%`),V===je&&(ce=`#000 ${(ue*100).toFixed(0)}%`),V===Ce&&(ce=`#fff ${(ue*100).toFixed(0)}%`),`color-mix(in ${S}, ${X}, ${ce})`}return V(X,ue)}if(od(y,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),y.mode==="light"){L(y.Alert,"errorColor",W(je,y.error.light,.6)),L(y.Alert,"infoColor",W(je,y.info.light,.6)),L(y.Alert,"successColor",W(je,y.success.light,.6)),L(y.Alert,"warningColor",W(je,y.warning.light,.6)),L(y.Alert,"errorFilledBg",M("palette-error-main")),L(y.Alert,"infoFilledBg",M("palette-info-main")),L(y.Alert,"successFilledBg",M("palette-success-main")),L(y.Alert,"warningFilledBg",M("palette-warning-main")),L(y.Alert,"errorFilledColor",bt(()=>y.getContrastText(y.error.main))),L(y.Alert,"infoFilledColor",bt(()=>y.getContrastText(y.info.main))),L(y.Alert,"successFilledColor",bt(()=>y.getContrastText(y.success.main))),L(y.Alert,"warningFilledColor",bt(()=>y.getContrastText(y.warning.main))),L(y.Alert,"errorStandardBg",W(Ce,y.error.light,.9)),L(y.Alert,"infoStandardBg",W(Ce,y.info.light,.9)),L(y.Alert,"successStandardBg",W(Ce,y.success.light,.9)),L(y.Alert,"warningStandardBg",W(Ce,y.warning.light,.9)),L(y.Alert,"errorIconColor",M("palette-error-main")),L(y.Alert,"infoIconColor",M("palette-info-main")),L(y.Alert,"successIconColor",M("palette-success-main")),L(y.Alert,"warningIconColor",M("palette-warning-main")),L(y.AppBar,"defaultBg",M("palette-grey-100")),L(y.Avatar,"defaultBg",M("palette-grey-400")),L(y.Button,"inheritContainedBg",M("palette-grey-300")),L(y.Button,"inheritContainedHoverBg",M("palette-grey-A100")),L(y.Chip,"defaultBorder",M("palette-grey-400")),L(y.Chip,"defaultAvatarColor",M("palette-grey-700")),L(y.Chip,"defaultIconColor",M("palette-grey-700")),L(y.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),L(y.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),L(y.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),L(y.LinearProgress,"primaryBg",W(Ce,y.primary.main,.62)),L(y.LinearProgress,"secondaryBg",W(Ce,y.secondary.main,.62)),L(y.LinearProgress,"errorBg",W(Ce,y.error.main,.62)),L(y.LinearProgress,"infoBg",W(Ce,y.info.main,.62)),L(y.LinearProgress,"successBg",W(Ce,y.success.main,.62)),L(y.LinearProgress,"warningBg",W(Ce,y.warning.main,.62)),L(y.Skeleton,"bg",S?W(sr,y.text.primary,.11):`rgba(${M("palette-text-primaryChannel")} / 0.11)`),L(y.Slider,"primaryTrack",W(Ce,y.primary.main,.62)),L(y.Slider,"secondaryTrack",W(Ce,y.secondary.main,.62)),L(y.Slider,"errorTrack",W(Ce,y.error.main,.62)),L(y.Slider,"infoTrack",W(Ce,y.info.main,.62)),L(y.Slider,"successTrack",W(Ce,y.success.main,.62)),L(y.Slider,"warningTrack",W(Ce,y.warning.main,.62));const V=S?W(je,y.background.default,.6825):ao(y.background.default,.8);L(y.SnackbarContent,"bg",V),L(y.SnackbarContent,"color",bt(()=>S?nn.text.primary:y.getContrastText(V))),L(y.SpeedDialAction,"fabHoverBg",ao(y.background.paper,.15)),L(y.StepConnector,"border",M("palette-grey-400")),L(y.StepContent,"border",M("palette-grey-400")),L(y.Switch,"defaultColor",M("palette-common-white")),L(y.Switch,"defaultDisabledColor",M("palette-grey-100")),L(y.Switch,"primaryDisabledColor",W(Ce,y.primary.main,.62)),L(y.Switch,"secondaryDisabledColor",W(Ce,y.secondary.main,.62)),L(y.Switch,"errorDisabledColor",W(Ce,y.error.main,.62)),L(y.Switch,"infoDisabledColor",W(Ce,y.info.main,.62)),L(y.Switch,"successDisabledColor",W(Ce,y.success.main,.62)),L(y.Switch,"warningDisabledColor",W(Ce,y.warning.main,.62)),L(y.TableCell,"border",W(Ce,W(sr,y.divider,1),.88)),L(y.Tooltip,"bg",W(sr,y.grey[700],.92))}if(y.mode==="dark"){L(y.Alert,"errorColor",W(Ce,y.error.light,.6)),L(y.Alert,"infoColor",W(Ce,y.info.light,.6)),L(y.Alert,"successColor",W(Ce,y.success.light,.6)),L(y.Alert,"warningColor",W(Ce,y.warning.light,.6)),L(y.Alert,"errorFilledBg",M("palette-error-dark")),L(y.Alert,"infoFilledBg",M("palette-info-dark")),L(y.Alert,"successFilledBg",M("palette-success-dark")),L(y.Alert,"warningFilledBg",M("palette-warning-dark")),L(y.Alert,"errorFilledColor",bt(()=>y.getContrastText(y.error.dark))),L(y.Alert,"infoFilledColor",bt(()=>y.getContrastText(y.info.dark))),L(y.Alert,"successFilledColor",bt(()=>y.getContrastText(y.success.dark))),L(y.Alert,"warningFilledColor",bt(()=>y.getContrastText(y.warning.dark))),L(y.Alert,"errorStandardBg",W(je,y.error.light,.9)),L(y.Alert,"infoStandardBg",W(je,y.info.light,.9)),L(y.Alert,"successStandardBg",W(je,y.success.light,.9)),L(y.Alert,"warningStandardBg",W(je,y.warning.light,.9)),L(y.Alert,"errorIconColor",M("palette-error-main")),L(y.Alert,"infoIconColor",M("palette-info-main")),L(y.Alert,"successIconColor",M("palette-success-main")),L(y.Alert,"warningIconColor",M("palette-warning-main")),L(y.AppBar,"defaultBg",M("palette-grey-900")),L(y.AppBar,"darkBg",M("palette-background-paper")),L(y.AppBar,"darkColor",M("palette-text-primary")),L(y.Avatar,"defaultBg",M("palette-grey-600")),L(y.Button,"inheritContainedBg",M("palette-grey-800")),L(y.Button,"inheritContainedHoverBg",M("palette-grey-700")),L(y.Chip,"defaultBorder",M("palette-grey-700")),L(y.Chip,"defaultAvatarColor",M("palette-grey-300")),L(y.Chip,"defaultIconColor",M("palette-grey-300")),L(y.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),L(y.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),L(y.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),L(y.LinearProgress,"primaryBg",W(je,y.primary.main,.5)),L(y.LinearProgress,"secondaryBg",W(je,y.secondary.main,.5)),L(y.LinearProgress,"errorBg",W(je,y.error.main,.5)),L(y.LinearProgress,"infoBg",W(je,y.info.main,.5)),L(y.LinearProgress,"successBg",W(je,y.success.main,.5)),L(y.LinearProgress,"warningBg",W(je,y.warning.main,.5)),L(y.Skeleton,"bg",S?W(sr,y.text.primary,.13):`rgba(${M("palette-text-primaryChannel")} / 0.13)`),L(y.Slider,"primaryTrack",W(je,y.primary.main,.5)),L(y.Slider,"secondaryTrack",W(je,y.secondary.main,.5)),L(y.Slider,"errorTrack",W(je,y.error.main,.5)),L(y.Slider,"infoTrack",W(je,y.info.main,.5)),L(y.Slider,"successTrack",W(je,y.success.main,.5)),L(y.Slider,"warningTrack",W(je,y.warning.main,.5));const V=S?W(Ce,y.background.default,.985):ao(y.background.default,.98);L(y.SnackbarContent,"bg",V),L(y.SnackbarContent,"color",bt(()=>S?Ji.text.primary:y.getContrastText(V))),L(y.SpeedDialAction,"fabHoverBg",ao(y.background.paper,.15)),L(y.StepConnector,"border",M("palette-grey-600")),L(y.StepContent,"border",M("palette-grey-600")),L(y.Switch,"defaultColor",M("palette-grey-300")),L(y.Switch,"defaultDisabledColor",M("palette-grey-600")),L(y.Switch,"primaryDisabledColor",W(je,y.primary.main,.55)),L(y.Switch,"secondaryDisabledColor",W(je,y.secondary.main,.55)),L(y.Switch,"errorDisabledColor",W(je,y.error.main,.55)),L(y.Switch,"infoDisabledColor",W(je,y.info.main,.55)),L(y.Switch,"successDisabledColor",W(je,y.success.main,.55)),L(y.Switch,"warningDisabledColor",W(je,y.warning.main,.55)),L(y.TableCell,"border",W(je,W(sr,y.divider,1),.68)),L(y.Tooltip,"bg",W(sr,y.grey[700],.92))}Bt(y.background,"default"),Bt(y.background,"paper"),Bt(y.common,"background"),Bt(y.common,"onBackground"),Bt(y,"divider"),Object.keys(y).forEach(V=>{const X=y[V];V!=="tonalOffset"&&X&&typeof X=="object"&&(X.main&&L(y[V],"mainChannel",Fr(Vr(X.main))),X.light&&L(y[V],"lightChannel",Fr(Vr(X.light))),X.dark&&L(y[V],"darkChannel",Fr(Vr(X.dark))),X.contrastText&&L(y[V],"contrastTextChannel",Fr(Vr(X.contrastText))),V==="text"&&(Bt(y[V],"primary"),Bt(y[V],"secondary")),V==="action"&&(X.active&&Bt(y[V],"active"),X.selected&&Bt(y[V],"selected")))})}),a=o.reduce((ee,y)=>Je(ee,y),a);const I={prefix:d,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:rd(a),enableContrastVars:c},{vars:R,generateThemeVars:G,generateStyleSheets:q}=kc(a,I);return a.vars=R,Object.entries(a.colorSchemes[a.defaultColorScheme]).forEach(([ee,y])=>{a[ee]=y}),a.generateThemeVars=G,a.generateStyleSheets=q,a.generateSpacing=function(){return Ui(m.spacing,pn(this))},a.getColorSchemeSelector=Tc(p),a.spacing=a.generateSpacing(),a.shouldSkipGeneratingVar=l,a.unstable_sxConfig={...Oo,...m==null?void 0:m.unstable_sxConfig},a.unstable_sx=function(y){return $o({sx:y,theme:this})},a.toRuntimeSource=Xi,a}function li(t,o,n){t.colorSchemes&&n&&(t.colorSchemes[o]={...n!==!0&&n,palette:hn({...n===!0?{}:n.palette,mode:o})})}function ad(t={},...o){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:d=n==null?void 0:n.mode,...c}=t,l=d||"light",p=s==null?void 0:s[l],f={...s,...n?{[l]:{...typeof p!="boolean"&&p,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return sn(t,...o);let m=n;"palette"in t||f[l]&&(f[l]!==!0?m=f[l].palette:l==="dark"&&(m={mode:"dark"}));const h=sn({...t,palette:m},...o);return h.defaultColorScheme=l,h.colorSchemes=f,h.palette.mode==="light"&&(h.colorSchemes.light={...f.light!==!0&&f.light,palette:h.palette},li(h,"dark",f.dark)),h.palette.mode==="dark"&&(h.colorSchemes.dark={...f.dark!==!0&&f.dark,palette:h.palette},li(h,"light",f.light)),h}return!n&&!("light"in f)&&l==="light"&&(f.light=!0),sd({...c,colorSchemes:f,defaultColorScheme:l,...typeof i!="boolean"&&i},...o)}const ld=ad();function $t(){const t=xc(ld);return process.env.NODE_ENV!=="production"&&vo.useDebugValue(t),t[rl]||t}async function cd(t,o,n){try{new URL(t)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};o&&(i.Authorization=`Bearer ${o}`);const s=new AbortController,d=setTimeout(()=>s.abort(),3e4);let c;try{c=await fetch(t,{headers:i,signal:s.signal})}catch(f){throw clearTimeout(d),(f==null?void 0:f.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(d)}if(c.status===401)throw new Error("Authentication failed (401) — check your API key");if(!c.ok)throw new Error(`API error ${c.status}: ${c.statusText}`);let l;try{l=await c.json()}catch{throw new Error("Response is not valid JSON")}let p;if(Array.isArray(l))p=l;else if(n&&l[n]&&Array.isArray(l[n]))p=l[n];else{const m=["data","results","items","records"].find(h=>l[h]&&Array.isArray(l[h]));if(m)p=l[m];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:p,source:t,fetchedAt:new Date().toISOString()}}function dd(t,o){return o.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${z(t.palette.common.black,n.opacity)}`).join(", ")}const ud={menu:[{x:0,y:8,blur:16,spread:4,opacity:.12},{x:0,y:4,blur:16,spread:0,opacity:.08},{x:0,y:0,blur:0,spread:1,opacity:.05}],restButton:[{x:0,y:1,blur:2,spread:0,opacity:.3},{x:0,y:1,blur:3,spread:1,opacity:.15}],restButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1},{x:0,y:1,blur:3,spread:1,opacity:.05}],hoverButton:[{x:0,y:1,blur:3,spread:0,opacity:.3},{x:0,y:4,blur:8,spread:3,opacity:.15}],pressedButton:[{x:0,y:1,blur:2,spread:0,opacity:.3}],pressedButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1}],small:[{x:0,y:2,blur:6,spread:0,opacity:.15}],cardRest:[{x:0,y:1,blur:3,spread:0,opacity:.08},{x:0,y:1,blur:2,spread:0,opacity:.06}],cardHover:[{x:0,y:4,blur:16,spread:0,opacity:.15},{x:0,y:1,blur:4,spread:0,opacity:.08}],popover:[{x:0,y:4,blur:20,spread:0,opacity:.15},{x:0,y:1,blur:6,spread:0,opacity:.1}],flatHover:[{x:0,y:1,blur:2,spread:0,opacity:.06}]};function oe(t,o){return dd(t,ud[o])}function _e(t){return`${Number(t.shape.borderRadius)*1.5}px`}function Jr(t){return`${Number(t.shape.borderRadius)}px`}function pd({isOpen:t,onClose:o,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[d,c]=u.useState(""),[l,p]=u.useState(!1),[f,m]=u.useState(""),[h,x]=u.useState(null),[b,E]=u.useState(null),[g,j]=u.useState(!1),[k,v]=u.useState(""),C=u.useRef(null),[S,w]=u.useState("json"),[a,I]=u.useState(""),[R,G]=u.useState(""),[q,ee]=u.useState(""),[y,M]=u.useState("idle"),[W,V]=u.useState(""),[X,ue]=u.useState(null),[ce,F]=u.useState(0),O=async P=>{if(v(""),!P.name.endsWith(".json")){v("Only .json files are allowed");return}const ie=10*1024*1024;if(P.size>ie){v("File size exceeds 10MB limit");return}try{const de=await P.text();let ae;try{ae=JSON.parse(de)}catch{v("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ae)){v("JSON must be an array of objects");return}if(ae.length===0){v("No data rows found in JSON file");return}x(P),E(ae)}catch{v("Network error — please try again")}},H=P=>{P.preventDefault();const ie=P.dataTransfer.files[0];ie&&O(ie)},re=async()=>{if(a.trim()){M("loading"),V("");try{const P=await cd(a.trim(),R.trim()||void 0,q.trim()||void 0);ue(P.data),F(P.data.length),M("ready")}catch(P){V((P==null?void 0:P.message)||"Connection failed"),M("error")}}},U=()=>{if(!d.trim()){p(!0);return}const P=S==="api"?X:i||b;P&&(n(d.trim(),f.trim(),P),te())},te=()=>{c(""),p(!1),m(""),x(null),E(null),v(""),w("json"),I(""),G(""),ee(""),M("idle"),V(""),ue(null),F(0),o()},se=i||b,ne=l&&!d.trim();return d.trim(),e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:te,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:P=>_e(P),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:P=>oe(P,"menu")}},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:te,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.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:d,onChange:P=>{c(P.target.value),l&&P.target.value.trim()&&p(!1)},placeholder:"Enter report name",autoFocus:!0,error:ne,helperText:ne?"Report name is required":void 0,inputProps:{maxLength:255},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:f,onChange:P=>m(P.target.value),placeholder:"Add details about this report",inputProps:{maxLength:500},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:S==="json"?0:1,onChange:(P,ie)=>{w(ie===0?"json":"api"),M("idle"),V("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40},children:[e.jsx(r.Tab,{label:"Upload JSON",icon:e.jsx(B.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(B.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),S==="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:P=>z(P.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:P=>z(P.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.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:()=>j(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(B.Info,{sx:{fontSize:16}})})]}),e.jsxs(r.Box,{onDrop:H,onDragOver:P=>P.preventDefault(),onPaste:P=>P.preventDefault(),onClick:()=>{var P;return(P=C.current)==null?void 0:P.click()},sx:{position:"relative",border:"1.5px",borderStyle:b?"solid":"dashed",borderColor:b?"success.main":k?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:b?P=>z(P.palette.success.main,.04):k?P=>z(P.palette.error.main,.04):P=>z(P.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:b?P=>z(P.palette.success.main,.08):k?P=>z(P.palette.error.main,.08):P=>z(P.palette.primary.main,.08),borderColor:b?"success.dark":k?"error.dark":"primary.dark"}},children:[e.jsx(r.Box,{component:"input",ref:C,type:"file",accept:".json",sx:{display:"none"},onChange:P=>{var ie;return((ie=P.target.files)==null?void 0:ie[0])&&O(P.target.files[0])}}),b?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:P=>z(P.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(B.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:h==null?void 0:h.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:P=>z(P.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(B.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"}),k&&e.jsx(r.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:P=>z(P.palette.error.main,.08),border:1,borderColor:P=>z(P.palette.error.main,.2)},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:k})})]})]})]})}),S==="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:P=>{I(P.target.value),M("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:R,onChange:P=>G(P.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",children:e.jsx(B.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:q,onChange:P=>ee(P.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()||y==="loading",onClick:re,startIcon:y==="loading"?e.jsx(r.CircularProgress,{size:16,color:"inherit"}):e.jsx(B.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:P=>z(P.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:y==="loading"?"Connecting...":"Test Connection & Load Data"}),y==="ready"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:P=>z(P.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(B.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:[ce.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})]})]}),y==="error"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:P=>z(P.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(B.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:W})]})]})]})]})}),e.jsxs(r.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[e.jsx(r.Button,{onClick:te,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:P=>z(P.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(r.Button,{onClick:U,disabled:S==="json"&&!se||S==="api"&&y!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),e.jsxs(r.Dialog,{open:g,onClose:()=>j(!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:()=>j(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(B.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:`[
|
|
70
70
|
{
|
|
71
71
|
"id": 1,
|
|
72
72
|
"customerName": "John Smith",
|
|
@@ -76,7 +76,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${o}Chann
|
|
|
76
76
|
"memberSince": "2024-01-15",
|
|
77
77
|
"status": "active"
|
|
78
78
|
}
|
|
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:()=>j(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function
|
|
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:()=>j(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function es({isOpen:t,onClose:o}){return t?e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:n=>_e(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:n=>oe(n,"menu"),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(B.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:`[
|
|
80
80
|
{
|
|
81
81
|
"Active Sessions": 33,
|
|
82
82
|
"Active State": true,
|
|
@@ -86,10 +86,10 @@ To suppress this warning, you need to explicitly provide the \`palette.${o}Chann
|
|
|
86
86
|
"Region": "Europe",
|
|
87
87
|
"Subscription Type": "Basic"
|
|
88
88
|
}
|
|
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:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:n=>`${n.shape.borderRadius}px`,boxShadow:n=>te(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>te(n,"hoverButton")},"&:active":{boxShadow:n=>te(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function xd({onFileUpload:t,onError:o,isUploading:n}){const[i,s]=p.useState(!1),[d,c]=p.useState(""),[l,u]=p.useState(!1),f=p.useRef(null),m=async w=>{if(!w.name.endsWith(".json")){o("Only .json files are allowed");return}const I=10*1024*1024;if(w.size>I){o("File size exceeds 10MB limit");return}c(w.name);try{const v=await w.text();let S;try{S=JSON.parse(v)}catch{o("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(S)){o("JSON must be an array of objects");return}if(S.length===0){o("No data rows found in JSON file");return}t(S)}catch{o("Network error — please try again")}finally{c("")}},h=w=>{w.preventDefault(),s(!0)},x=w=>{w.preventDefault(),s(!1)},b=w=>{w.preventDefault(),s(!1);const I=w.dataTransfer.files[0];I&&m(I)},D=()=>{var w;(w=f.current)==null||w.click()},g=w=>{var v;const I=(v=w.target.files)==null?void 0:v[0];I&&m(I)},j=w=>{w.stopPropagation(),u(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{onDragOver:h,onDragLeave:x,onDrop:b,onPaste:w=>w.preventDefault(),onClick:D,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?w=>k(w.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:g,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..."}),d&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:d})]}):e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:w=>k(w.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.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:j,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(B.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(Ji,{isOpen:l,onClose:()=>u(!1)})]})}function md({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=>k(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(B.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 hd({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=>k(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=>k(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.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(B.Upload,{sx:{fontSize:16}}),onClick:o,sx:{fontWeight:500},children:"Try Again"})]})}function Ki({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=>k(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(B.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 fd({value:t,onChange:o,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:d,disabled:c}){const[l,u]=p.useState(!1),[f,m]=p.useState(!1),[h,x]=p.useState(-1),b=p.useRef(null),D=p.useRef(null);p.useEffect(()=>{function R(q){b.current&&!b.current.contains(q.target)&&(u(!1),m(!1))}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[]);const g=p.useCallback(()=>{m(!0),x(-1),n.length>0&&u(!0)},[n.length]),j=p.useCallback(R=>{o(R),x(-1)},[o]),w=p.useCallback(R=>{var q;o(R),i(R),u(!1),(q=D.current)==null||q.blur()},[o,i]),I=p.useCallback(R=>{x(-1),w(R)},[w]),v=p.useCallback(R=>{var q;R.key==="Enter"?h>=0&&h<n.length?(R.preventDefault(),I(n[h].query)):t.trim()&&w(t.trim()):R.key==="Escape"?(u(!1),x(-1),(q=D.current)==null||q.blur()):R.key==="ArrowDown"?(R.preventDefault(),n.length>0&&(l||u(!0),x(K=>K<n.length-1?K+1:K))):R.key==="ArrowUp"&&(R.preventDefault(),x(K=>K>0?K-1:-1))},[h,n,t,l,I,w]),S=p.useCallback(()=>{var R;o(""),(R=D.current)==null||R.focus()},[o]),C=p.useMemo(()=>n.filter(R=>R.isFavourite),[n]),a=p.useMemo(()=>n.filter(R=>!R.isFavourite),[n]),z=l&&n.length>0;return e.jsxs(r.Box,{sx:{position:"relative",width:240},ref:b,children:[e.jsx(r.TextField,{inputRef:D,size:"small",fullWidth:!0,value:t,onChange:R=>j(R.target.value),onFocus:g,onKeyDown:v,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:R=>k(R.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:R=>k(R.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",sx:{ml:.5},children:e.jsx(B.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:t?e.jsx(r.InputAdornment,{position:"end",children:e.jsx(r.IconButton,{size:"small",onClick:S,edge:"end",sx:{mr:-.5},children:e.jsx(B.Close,{sx:{fontSize:16}})})}):null}}),z&&e.jsxs(r.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[C.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"}),C.map((R,q)=>e.jsx(ni,{entry:R,isSelected:h===q,onClick:()=>I(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`fav-${R.query}`))]}),a.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[C.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"}),a.map((R,q)=>{const K=C.length+q;return e.jsx(ni,{entry:R,isSelected:h===K,onClick:()=>I(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`recent-${R.query}`)})]})]})]})}const ni=p.memo(function({entry:o,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:d}){const c=p.useCallback(u=>{u.stopPropagation(),s()},[s]),l=p.useCallback(u=>{u.stopPropagation(),d()},[d]);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>k(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>k(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(B.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(B.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(r.IconButton,{size:"small",onClick:l,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(B.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function gd({views:t,activeViewId:o,isDirty:n,onSelectView:i,onCreateView:s,onManageViews:d,onToggleDefault:c,onToggleFavorite:l,onRestoreView:u,onPermanentDelete:f,isReadOnly:m,isAdmin:h=!1}){const x=zt(),[b,D]=p.useState(!1),[g,j]=p.useState(!1),[w,I]=p.useState({top:0,left:0}),[v,S]=p.useState(null),C=p.useRef(null),a=p.useRef(null),z=t.find(A=>A.id===o),R=z==null?void 0:z.isDefault,q=t.filter(A=>A.scope==="global"&&!A.isDeleted),K=t.filter(A=>A.scope!=="global"&&!A.isDeleted),ee=t.filter(A=>A.isFavorite&&!A.isDeleted).sort((A,H)=>(H.updatedAt||0)-(A.updatedAt||0)),y=t.filter(A=>A.isDeleted);p.useEffect(()=>{if(b&&a.current){const A=a.current.getBoundingClientRect();I({top:A.bottom+window.scrollY+8,left:A.right+window.scrollX-320})}},[b]),p.useEffect(()=>{const A=H=>{C.current&&!C.current.contains(H.target)&&a.current&&!a.current.contains(H.target)&&D(!1)};return b&&document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[b]);const M=A=>{if(n&&A!==o){S(A),D(!1);return}i(A),D(!1)},W=()=>{v&&(i(v),S(null))},V=()=>{S(null)},Q=(A,H=!1)=>{const ie=A.scope==="global",Y=!m&&(!ie||h);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:o===A.id?k(x.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:o===A.id?k(x.palette.primary.main,.12):x.palette.action.hover}},children:[e.jsxs(r.Button,{onClick:()=>M(A.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[o===A.id&&e.jsx(B.Check,{sx:{fontSize:16,flexShrink:0}}),o!==A.id&&e.jsx(r.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(r.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:o===A.id?x.palette.primary.dark:x.palette.text.primary,fontWeight:o===A.id?500:400},children:A.name}),H&&e.jsx(r.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:x.palette.text.secondary,backgroundColor:x.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[Y&&l&&e.jsx(r.IconButton,{onClick:re=>{re.stopPropagation(),l(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:A.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(B.Star,{sx:{fontSize:16}})}),Y&&c&&!A.isDefault&&e.jsx(r.IconButton,{onClick:re=>{re.stopPropagation(),c(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Set as default",children:e.jsx(B.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},A.id)},xe=A=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:x.palette.action.hover},children:[e.jsx(r.Typography,{sx:{color:x.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:A.name}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[u&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),u(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Restore view",children:e.jsx(B.Undo,{sx:{fontSize:16,color:"success.main"}})}),f&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),f(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Delete permanently",children:e.jsx(B.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},A.id),de=n||!R,L=n;return e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsxs(r.Button,{ref:a,onClick:()=>D(!b),variant:"outlined",size:"small",endIcon:e.jsx(B.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:de?"warning.main":"text.primary",borderColor:de?"warning.main":"divider",bgcolor:de?k(x.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:de?"warning.dark":"primary.main",bgcolor:de?k(x.palette.warning.main,.2):k(x.palette.text.primary,.06),color:de?"warning.dark":"text.primary"}},title:`View: ${(z==null?void 0:z.name)||"Default View"}`,children:[e.jsx(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(z==null?void 0:z.name)||"Default View"}),L&&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"}})]}),b&&gi.createPortal(e.jsxs(r.Box,{ref:C,sx:{position:"fixed",width:"320px",backgroundColor:x.palette.background.paper,border:`1px solid ${x.palette.divider}`,borderRadius:1,boxShadow:x.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:w.top,left:w.left},children:[q.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:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),q.map(A=>Q(A,A.isDefault))]}),ee.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.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:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(B.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),ee.map(A=>Q(A))]})]}),K.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.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:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),K.map(A=>Q(A))]})]}),y.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Button,{onClick:()=>j(!g),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsxs(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",y.length,")"]}),e.jsx(B.ChevronRight,{sx:{fontSize:16}})]}),g&&e.jsx(r.Box,{sx:{backgroundColor:x.palette.action.hover},children:y.map(A=>xe(A))})]})]}),e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Button,{onClick:()=>{s(),D(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:x.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsx(B.Add,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(r.Button,{onClick:()=>{d(),D(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:x.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsx(B.Settings,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body),e.jsxs(r.Dialog,{open:v!==null,onClose:V,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Xr(x)}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[e.jsx(B.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),e.jsx(r.DialogContent,{children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),e.jsxs(r.DialogActions,{sx:{px:3,pb:2,gap:1},children:[e.jsx(r.Button,{onClick:V,variant:"text",children:"Stay here"}),e.jsx(r.Button,{onClick:W,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function yd({columnName:t,columnType:o="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:d=!1,hasModifications:c=!1,position:l,onSortAscending:u,onSortDescending:f,onRemoveSort:m,onFilter:h,onClearFilter:x,onGroupByColumn:b,onHideColumn:D,onManageColumns:g,onManageViews:j,onResetLayout:w,onClose:I}){var ee,y;const v=zt(),S=v.palette,C=p.useRef(null);p.useEffect(()=>{if(!C.current)return;const M=C.current,W=M.getBoundingClientRect(),V=window.innerWidth,Q=window.innerHeight;W.right>V-8&&(M.style.left=`${V-W.width-8}px`),W.bottom>Q-8&&(M.style.top=`${Q-W.height-8}px`)},[l]),p.useEffect(()=>{const M=V=>{C.current&&!C.current.contains(V.target)&&I()},W=V=>{V.key==="Escape"&&I()};return document.addEventListener("mousedown",M),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",W)}},[I]);const a=p.useCallback(M=>()=>{M(),I()},[I]),z=(n==null?void 0:n.direction)==="asc",R=(n==null?void 0:n.direction)==="desc",q=o==="number"?"0→9":o==="boolean"?"F→T":"A→Z",K=o==="number"?"9→0":o==="boolean"?"T→F":"Z→A";return gi.createPortal(e.jsxs(r.Paper,{ref:C,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:v.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:Xr(v),overflow:"hidden",boxShadow:`0 4px 20px ${k(((ee=S.common)==null?void 0:ee.black)??"#000",.12)}, 0 1px 4px ${k(((y=S.common)==null?void 0:y.black)??"#000",.06)}`},children:[!d&&e.jsxs(r.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary"},children:"Sorting"}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[e.jsx(r.Tooltip,{title:`Sort Ascending (${q})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(()=>u(t)),sx:{p:.625,borderRadius:"6px",color:z?"primary.main":"text.secondary",bgcolor:z?k(S.primary.main,.1):"transparent","&:hover":{bgcolor:k(S.primary.main,.08),color:"primary.main"}},children:e.jsx(B.ArrowUpward,{sx:{fontSize:16}})})}),e.jsx(r.Tooltip,{title:`Sort Descending (${K})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(()=>f(t)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?k(S.primary.main,.1):"transparent","&:hover":{bgcolor:k(S.primary.main,.08),color:"primary.main"}},children:e.jsx(B.ArrowDownward,{sx:{fontSize:16}})})}),e.jsx(r.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:!s,onClick:a(()=>m(t)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:k(S.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:e.jsx(B.Close,{sx:{fontSize:16}})})})})]})]}),e.jsxs(r.MenuList,{dense:!0,sx:{py:.5},children:[e.jsxs(r.MenuItem,{onClick:a(()=>h(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!d&&e.jsxs(r.MenuItem,{onClick:a(()=>x(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:k(S.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!d&&b&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.25}}),e.jsx(r.MenuList,{dense:!0,sx:{py:.5},children:e.jsxs(r.MenuItem,{onClick:a(()=>b(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),e.jsx(r.Divider,{sx:{my:.25}}),e.jsxs(r.MenuList,{dense:!0,sx:{py:.5},children:[!d&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[e.jsxs(r.MenuItem,{onClick:a(()=>D(t)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),e.jsx(r.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(g),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:k(S.primary.main,.08),color:"primary.main"}},children:e.jsx(B.Settings,{sx:{fontSize:16}})})})]}),d&&e.jsxs(r.MenuItem,{onClick:a(g),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),j&&e.jsxs(r.MenuItem,{onClick:a(j),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.TableRows,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Views",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!d&&c&&w&&e.jsxs(r.MenuItem,{onClick:a(w),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:k(S.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const bd=176,ii="COLUMN_HEADER",vd=p.memo(function({column:o,index:n,sortRule:i,hasFilters:s,isInSortStack:d,isReadOnly:c=!1,hasModifications:l=!1,width:u,onColumnClick:f,onMoveColumn:m,onColumnDragEnd:h,onResizeStart:x,onSortAscending:b,onSortDescending:D,onRemoveSort:g,onOpenFilterForColumn:j,onClearFiltersForColumn:w,onGroupByColumn:I,onHideColumn:v,onManageColumns:S,onManageViews:C,onResetLayout:a}){const z=p.useRef(null),[R,q]=p.useState(!1),[K,ee]=p.useState({x:0,y:0}),[{handlerId:y,isOver:M},W]=kt.useDrop({accept:ii,collect(Y){return{handlerId:Y.getHandlerId(),isOver:Y.isOver()}},hover(Y,re){var fe;if(!z.current)return;const se=Y.index,oe=n;if(se===oe)return;const P=(fe=z.current)==null?void 0:fe.getBoundingClientRect(),ne=(P.right-P.left)/2,ce=re.getClientOffset(),ae=((ce==null?void 0:ce.x)??0)-P.left;se<oe&&ae<ne||se>oe&&ae>ne||(m(se,oe),Y.index=oe)}}),[{isDragging:V},Q]=kt.useDrag({type:ii,item:()=>({index:n,columnName:o.name}),collect:Y=>({isDragging:Y.isDragging()}),end:()=>{h==null||h()}});Q(W(z));const xe=p.useCallback(Y=>{Y.preventDefault(),Y.stopPropagation(),ee({x:Y.clientX,y:Y.clientY}),q(!0)},[]),de=p.useCallback(()=>q(!1),[]),L=p.useCallback(()=>{f(o.name)},[f,o.name]),A=p.useCallback(Y=>{Y.stopPropagation(),j(o.name)},[j,o.name]),H=p.useCallback(()=>i?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?e.jsx(B.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(B.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:"primary.contrastText",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),ie=p.useCallback(()=>s?e.jsx(B.FilterList,{onClick:A,titleAccess:"Active filter on this column — click to edit",sx:{ml:.5,fontSize:13,color:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.15)"},transition:"transform 0.12s ease"}}):null,[s,A]);return e.jsxs(e.Fragment,{children:[e.jsxs(r.TableCell,{ref:z,"data-handler-id":y,"data-column-index":n,onClick:L,onContextMenu:xe,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:V?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:M?Y=>k(Y.palette.primary.main,.08):"action.hover",boxShadow:Y=>`0 1px 0 ${k(Y.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:"1px solid",borderColor:"divider",py:0,px:2,height:34,"&:hover":{bgcolor:Y=>k(Y.palette.primary.main,.1),color:"primary.dark"},width:u?`${u}px`:`${bd}px`},children:[e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[Ke(o.name),H(),ie()]}),e.jsx(r.Box,{draggable:!1,onDragStart:Y=>Y.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:Y=>{Y.preventDefault(),Y.stopPropagation(),x(Y,o.name)},onClick:Y=>Y.stopPropagation(),children:e.jsx(r.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),M&&e.jsx(r.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),R&&e.jsx(yd,{columnName:o.name,columnType:o.type,currentSort:i,hasFilters:s,isInSortStack:d,isReadOnly:c,hasModifications:l,position:K,onSortAscending:b,onSortDescending:D,onRemoveSort:g,onFilter:j,onClearFilter:w,onGroupByColumn:I,onHideColumn:v,onManageColumns:S,onManageViews:C,onResetLayout:a,onClose:de})]})});function Sd({selectedCount:t,viewMode:o="list",onExportSelected:n,onClearSelection:i}){const[s,d]=p.useState(null);if(t===0)return null;const c=l=>{n(l),d(null)};return e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:l=>k(l.palette.primary.main,.08),borderBottom:l=>`1px solid ${k(l.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," ",o==="grid"?t===1?"card":"cards":t===1?"row":"rows"," ","selected"]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(r.Button,{onClick:i,startIcon:e.jsx(B.Close,{sx:{fontSize:16}}),size:"small",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:l=>k(l.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(r.Button,{onClick:l=>d(l.currentTarget),startIcon:e.jsx(B.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:l=>k(l.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:l=>k(l.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(r.Menu,{anchorEl:s,open:!!s,onClose:()=>d(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:()=>c("csv"),sx:{py:1,px:2},children:"Export as CSV"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>c("excel"),sx:{py:1,px:2},children:"Export as Excel"}),e.jsx(r.MenuItem,{dense:!0,onClick:()=>c("json"),sx:{py:1,px:2},children:"Export as JSON"})]})]})]})})}const jd={active:"success",completed:"success",approved:"success",success:"success",done:"success",contract:"info","in progress":"info","in review":"info",review:"info",pending:"info","on leave":"error","on hold":"warning",probation:"warning",cancelled:"error",rejected:"error",blocked:"error",inactive:"neutral","not started":"neutral",paused:"neutral"};function bo(t,o){const n=jd[o.toLowerCase().trim()];if(!n||n==="neutral")return{bg:t.palette.action.selected,color:t.palette.text.secondary};const i=t.palette[n];return{bg:k(i.main,t.palette.mode==="dark"?.24:.12),color:t.palette.mode==="dark"?i.light:i.dark}}function Cd(t,o){switch(o.toLowerCase().trim()){case"low":return t.palette.text.secondary;case"medium":return t.palette.warning.main;case"high":return t.palette.warning.dark;case"critical":case"urgent":return t.palette.error.main;default:return}}const wd={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"}};function kd(t,o){const n=wd[o];return n?t.palette[n.hue][n.shade]:t.palette.text.secondary}function Re(t){return k(t.palette.primary.main,t.palette.mode==="dark"?.24:.12)}function Td(t){const o=t.toLowerCase().trim();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=>bo(n,o).bg,color:n=>bo(n,o).color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function zd(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 Td(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return e.jsx(r.Box,{component:"span",sx:d=>{const c=Cd(d,s);return c?{color:c,fontWeight:600,fontSize:"0.8125rem"}:{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 Bd(t){const o=t.find(s=>{const d=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(d)})||t[0]||null,n=t.find(s=>{const d=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(d)&&s!==o})||null,i=t.filter(s=>s!==o&&s!==n).slice(0,4);return{primaryCol:o,idCol:n,bodyColumns:i}}function Id({row:t,rowIndex:o,visibleColumns:n,isSelected:i,isReadOnly:s,onToggleSelection:d,onView:c,onEdit:l,onDuplicate:u,onDelete:f}){const[m,h]=p.useState(null),[x,b]=p.useState(!1),{primaryCol:D,idCol:g,bodyColumns:j}=p.useMemo(()=>Bd(n),[n]),w=D?t[D.name]:null,I=g?t[g.name]:null,v=x||i||!!m;return e.jsxs(r.Box,{onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),onClick:()=>d(o),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":S=>k(S.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?S=>`0 0 0 3px ${k(S.palette.primary.main,.15)}, 0 2px 8px ${k(S.palette.common.black,.08)}`:x?S=>te(S,"cardHover"):S=>te(S,"cardRest"),transform:x&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:S=>k(S.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:w!=null&&w!==""?String(w):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:[j.map(S=>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:Ke(S.name)}),e.jsx(r.Box,{sx:{flex:1,lineHeight:1},children:zd(S,t[S.name])})]},S.name)),j.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:S=>k(S.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:I?.85:0,userSelect:"none"},children:I?String(I):" "}),e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:v?1:0,transition:"opacity 0.15s ease"},onClick:S=>S.stopPropagation(),children:e.jsx(r.Tooltip,{title:"More actions",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:S=>{S.stopPropagation(),h(S.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:S=>k(S.palette.text.primary,.08)}},children:e.jsx(B.MoreVert,{sx:{fontSize:17}})})})})]}),e.jsxs(r.Popover,{open:!!m,anchorEl:m,onClose:()=>h(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:S=>te(S,"popover")}},onClick:S=>S.stopPropagation(),children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{c(t),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(B.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),!s&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{l(t,o),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(B.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),!s&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{u(o,t),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(B.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),!s&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{f(o,t),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(B.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Dd({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:s=>te(s,"flatHover"),"&:hover":{bgcolor:s=>k(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(B.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(B.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:ki(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=>k(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,d])=>wi(d)).filter(Boolean).join(" • ")})]})}function Ed({data:t,visibleColumns:o,grouping:n,selectedRowIds:i,isReadOnly:s,isGrouped:d,sortStack:c=[],onSort:l,onToggleRowSelection:u,onToggleGroupCollapse:f,onViewRow:m,onEditRow:h,onDuplicateRow:x,onDeleteRow:b}){const D=p.useMemo(()=>{const g=new Set;return i.forEach(j=>{const w=j==null?void 0:j.__urm_row_id__;w!==void 0&&g.add(w)}),g},[i]);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.jsxs(r.Box,{sx:{fontFamily:g=>g.typography.fontFamily},children:[l&&o.length>0&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,px:2,py:1,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper",flexWrap:"wrap"},children:[e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontWeight:500,mr:.5,whiteSpace:"nowrap"},children:"Sort by:"}),o.map(g=>{const j=c.find(w=>w.column===g.name);return e.jsxs(r.Box,{onClick:()=>l(g.name),sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.25,py:.375,borderRadius:"6px",border:"1px solid",borderColor:j?"primary.main":"divider",bgcolor:j?w=>k(w.palette.primary.main,.07):"transparent",cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light",bgcolor:w=>k(w.palette.primary.main,.05)}},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",fontWeight:j?600:400,color:j?"primary.main":"text.secondary",whiteSpace:"nowrap"},children:Ke(g.name)}),j?j.direction==="asc"?e.jsx(B.ArrowUpward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(B.ArrowDownward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(B.SwapVert,{sx:{fontSize:12,color:"text.disabled"}})]},g.name)})]}),e.jsx(r.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(272px, 1fr))",gap:1.5,alignContent:"start"},children:t.map((g,j)=>d&&g.isGroupHeader?e.jsx(Dd,{row:g,grouping:n,onToggleCollapse:f||(()=>{})},`group-${g.groupKey}`):e.jsx(Id,{row:g,rowIndex:j,visibleColumns:o,isSelected:D.has(g==null?void 0:g.__urm_row_id__),isReadOnly:s,onToggleSelection:()=>u(g),onView:m,onEdit:h,onDuplicate:x,onDelete:b},`card-${j}`))})]})}const si=[10,15,25,50,100];function Od(t,o){const n=t.trim();if(n==="")return"Page number is required";if(!/^-?\d+$/.test(n))return"Must be a number";const i=parseInt(n,10);return i<1?"Page number must be at least 1":i>o?"Entered page number is out of range":null}function Ad({currentPage:t,pageSize:o,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:d}){var M;const l=zt().palette,u=Math.ceil(n/o),[f,m]=p.useState(String(t)),[h,x]=p.useState(null),[b,D]=p.useState(!1),g=p.useRef(null);p.useEffect(()=>{b||(m(String(t)),x(null))},[t,b]);const j=p.useCallback(()=>{const W=Od(f,u);if(W){x(W);return}const V=parseInt(f.trim(),10);x(null),D(!1),V!==t&&s(V)},[f,u,t,s]),w=p.useCallback(W=>{var V;W.key==="Enter"?(W.preventDefault(),j()):W.key==="Escape"&&(m(String(t)),x(null),D(!1),(V=g.current)==null||V.blur())},[j,t]),I=p.useCallback(()=>{m(String(t)),x(null),D(!1)},[t]),v=p.useCallback(()=>{D(!0),x(null),setTimeout(()=>{var W;return(W=g.current)==null?void 0:W.select()},0)},[]);if(n<=Math.min(...si))return null;const S=()=>{m(String(t)),x(null),D(!1)},C=()=>{S(),s(1)},a=()=>{S(),t>1&&s(t-1)},z=()=>{S(),t<u&&s(t+1)},R=()=>{S(),s(u)},q=(t-1)*o+1,K=Math.min(t*o,n),ee=`${Math.max(2,String(u).length+.5)}ch`,y={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};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:W=>d(Number(W.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:si.map(W=>e.jsx(r.MenuItem,{value:W,sx:{fontSize:"0.8125rem"},children:W},W))})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[q,"–",K," of ",n]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),e.jsxs(r.Box,{sx:{position:"relative"},children:[h&&e.jsx(r.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:k(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${k(((M=l.common)==null?void 0:M.black)??"#000",.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:k(l.error.main,.4)}},children:e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:500,color:"error.main",lineHeight:1.3},children:h})}),e.jsx(r.InputBase,{inputRef:g,value:f,onChange:W=>{m(W.target.value),h&&x(null)},onKeyDown:w,onFocus:v,onBlur:I,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:ee,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:h?"error.main":"text.primary",border:"1px solid",borderColor:h?"error.main":b?"primary.main":"divider",borderRadius:"4px",bgcolor:h?k(l.error.main,.04):b?k(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:h?"error.main":"text.secondary"},"&:focus-within":{boxShadow:h?`0 0 0 2px ${k(l.error.main,.2)}`:`0 0 0 2px ${k(l.primary.main,.2)}`}}})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.IconButton,{onClick:C,disabled:t===1,size:"small",title:"First page",sx:y,children:e.jsx(B.FirstPage,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:a,disabled:t===1,size:"small",title:"Previous page",sx:y,children:e.jsx(B.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:z,disabled:t===u,size:"small",title:"Next page",sx:y,children:e.jsx(B.ChevronRight,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:R,disabled:t===u,size:"small",title:"Last page",sx:y,children:e.jsx(B.LastPage,{sx:{fontSize:20}})})]})]})]})}function $d(){return e.jsx(r.Chip,{icon:e.jsx(B.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const Xi="urm_hint_seen_";function Md(t){try{return localStorage.getItem(Xi+t)==="true"}catch{return!1}}function Rd(t){try{localStorage.setItem(Xi+t,"true")}catch{}}function ai(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 li(t){const o={fontSize:11};switch(t){case"number":return e.jsx(B.Numbers,{sx:o});case"boolean":return e.jsx(B.CheckBox,{sx:o});case"array":return e.jsx(B.DataArray,{sx:o});case"object":return e.jsx(B.DataObject,{sx:o});default:return e.jsx(B.TextFields,{sx:o})}}function ci(t,o){var n,i;switch(t){case"number":return{bg:k(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:k(((n=o.success)==null?void 0:n.main)??"#2e7d32",.08),color:((i=o.success)==null?void 0:i.main)??"#2e7d32"};case"array":case"object":return{bg:k(o.secondary.main,.08),color:o.secondary.main};default:return{bg:k(o.text.secondary,.07),color:o.text.secondary}}}function _d({open:t,onClose:o,row:n,schema:i,reportName:s}){var h,x;const d=zt(),c=d.palette;if(!n)return null;const l=i.filter(b=>b.name in n),u=l.filter(b=>b.type!=="object"&&b.type!=="array"),f=l.filter(b=>b.type==="object"||b.type==="array"),m=l.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Me(d),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${k(((h=c.common)==null?void 0:h.black)??"#000",.14)}, 0 2px 8px ${k(((x=c.common)==null?void 0:x.black)??"#000",.08)}`,overflow:"hidden"}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:k(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"View Record"}),s&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",m," ",m===1?"field":"fields"]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:0,overflowY:"auto",flex:1,bgcolor:k(c.text.primary,.015)},children:[u.length>0&&e.jsx(r.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"1px",bgcolor:"divider",m:2,mb:f.length>0?1.5:2,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:u.map((b,D)=>{const g=n[b.name],j=ai(g,b.type),w=!j,I=ci(b.type,c),v=D===u.length-1&&u.length%2!==0;return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",px:2,py:1.75,gridColumn:v?"span 2":"span 1",display:"flex",flexDirection:"column",gap:.75},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,px:.75,py:.25,borderRadius:"4px",bgcolor:I.bg,color:I.color,flexShrink:0},children:li(b.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ke(b.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:w?400:500,color:w?"text.disabled":"text.primary",fontStyle:w?"italic":"normal",lineHeight:1.5,wordBreak:"break-word",fontFamily:b.type==="number"?'"Roboto Mono", monospace':"inherit"},children:w?"No value":j})]},b.name)})}),f.map(b=>{const D=n[b.name],g=ai(D,b.type),j=!g,w=ci(b.type,c);return e.jsxs(r.Box,{sx:{mx:2,mb:1.5,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{px:2,py:1.25,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,px:.75,py:.25,borderRadius:"4px",bgcolor:w.bg,color:w.color},children:li(b.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Ke(b.name)}),e.jsx(r.Chip,{label:b.type,size:"small",sx:{height:18,fontSize:"0.625rem",fontWeight:600,ml:"auto",bgcolor:w.bg,color:w.color,border:"none",letterSpacing:"0.03em"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:2,py:1.5,bgcolor:k(c.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:j?"text.disabled":"text.primary",fontStyle:j?"italic":"normal",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6},children:j?"No value":g})]},b.name)}),l.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(B.VisibilityOutlined,{sx:{fontSize:40,opacity:.4}}),e.jsx(r.Typography,{variant:"body2",children:"No fields to display"})]})]}),e.jsx(r.Divider,{}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:b=>`${b.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function Wd({open:t,onClose:o,onConfirm:n,rowPreview:i}){return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:s=>Me(s),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:s=>te(s,"menu")}},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:s=>k(s.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.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:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pb:2},children:e.jsx(r.Box,{sx:{p:2,borderRadius:"8px",bgcolor:s=>k(s.palette.error.main,.1),border:s=>`1px solid ${k(s.palette.error.main,.5)}`},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:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,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(B.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,boxShadow:s=>te(s,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:s=>te(s,"hoverButton")},"&:active":{boxShadow:s=>te(s,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Ko(t){const o={fontSize:11};switch(t){case"number":return e.jsx(B.Numbers,{sx:o});case"boolean":return e.jsx(B.CheckBox,{sx:o});case"array":return e.jsx(B.DataArray,{sx:o});case"object":return e.jsx(B.DataObject,{sx:o});default:return e.jsx(B.TextFields,{sx:o})}}function di(t,o){var n,i;switch(t){case"number":return{bg:k(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:k(((n=o.success)==null?void 0:n.main)??"#2e7d32",.08),color:((i=o.success)==null?void 0:i.main)??"#2e7d32"};case"array":case"object":return{bg:k(o.secondary.main,.08),color:o.secondary.main};default:return{bg:k(o.text.secondary,.07),color:o.text.secondary}}}function Pd({open:t,onClose:o,onSave:n,row:i,schema:s,reportName:d}){var j,w,I;const c=zt(),l=c.palette,[u,f]=p.useState({});if(p.useEffect(()=>{t&&i&&f({...i})},[t,i]),!i)return null;const m=s.filter(v=>v.name in i),h=m.filter(v=>v.type!=="object"&&v.type!=="array"),x=m.filter(v=>v.type==="object"||v.type==="array"),b=(v,S)=>{f(C=>({...C,[v]:S}))},D=()=>{const v={...u};m.forEach(S=>{const C=u[S.name];if(S.type==="number"){const a=Number(C);v[S.name]=isNaN(a)?i[S.name]:a}else S.type==="boolean"&&(v[S.name]=!!C)}),n(v),o()},g=m.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Me(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${k(((j=l.common)==null?void 0:j.black)??"#000",.14)}, 0 2px 8px ${k(((w=l.common)==null?void 0:w.black)??"#000",.08)}`,overflow:"hidden"}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:k(((I=l.warning)==null?void 0:I.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),d&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[d," · ",g," ",g===1?"field":"fields"]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:k(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[h.length>0&&e.jsxs(r.Box,{children:[h.length>1&&e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.08em",mb:1.25},children:"Fields"}),e.jsx(r.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:1.5},children:h.map((v,S)=>{const C=u[v.name],a=di(v.type,l),z=v.type==="boolean",R=!z&&S===h.filter(K=>K.type!=="boolean").length-1&&h.filter(K=>K.type!=="boolean").length%2!==0,q=z||R;return v.type==="boolean"?e.jsxs(r.Box,{sx:{gridColumn:"span 2",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",px:2,py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,transition:"border-color 0.15s","&:hover":{borderColor:"primary.main"}},children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.25},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:Ko(v.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Ke(v.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",ml:.25},children:C?"Enabled":"Disabled"})]}),e.jsx(r.Switch,{checked:!!C,onChange:K=>b(v.name,K.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}})]},v.name):e.jsxs(r.Box,{sx:{gridColumn:q?"span 2":"span 1",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",overflow:"hidden",transition:"border-color 0.15s","&:focus-within":{borderColor:"primary.main",boxShadow:`0 0 0 2px ${k(l.primary.main,.12)}`}},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:k(l.text.primary,.02),display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:Ko(v.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ke(v.name)})]}),e.jsx(r.TextField,{value:C??"",onChange:K=>b(v.name,K.target.value),type:v.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"standard",placeholder:`Enter ${v.type==="number"?"number":"value"}…`,InputProps:{disableUnderline:!0},sx:{"& .MuiInputBase-root":{px:1.5,py:1,fontSize:"0.875rem",fontWeight:500,color:"text.primary",fontFamily:v.type==="number"?'"Roboto Mono", monospace':"inherit"},"& .MuiInputBase-input":{p:0,"&::placeholder":{color:"text.disabled",opacity:1,fontWeight:400}}}})]},v.name)})})]}),x.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Read-only Fields"}),e.jsx(r.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:e.jsx(B.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:x.map(v=>{const S=i[v.name];let C="";try{C=S==null?"":JSON.stringify(S,null,2)}catch{C=String(S)}const a=di(v.type,l);return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",overflow:"hidden",opacity:.8},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:k(l.text.primary,.02),display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:Ko(v.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1},children:Ke(v.name)}),e.jsx(r.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:k(l.text.secondary,.07),color:"text.secondary",border:"none"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:C?"text.primary":"text.disabled",fontStyle:C?"normal":"italic",bgcolor:k(l.text.primary,.015),overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:120,overflowY:"auto"},children:C||"No value"})]},v.name)})})]}),m.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(B.EditOutlined,{sx:{fontSize:40,opacity:.4}}),e.jsx(r.Typography,{variant:"body2",children:"No editable fields"})]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:v=>`${v.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:D,variant:"contained",startIcon:e.jsx(B.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:v=>`${v.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Nd=176,Ld=170,Fd=40;function Qi(t){return t.type==="date"?180:Nd}function Vd(t,o){return o!=null&&o!==Ld&&o!==Qi(t)}function Hd(t,o,n){return p.useMemo(()=>{const i=t.map(h=>({name:h.name,width:o[h.name]??Qi(h),explicit:Vd(h,o[h.name])})),s={};i.forEach(h=>{s[h.name]=h.width});const d=i.reduce((h,x)=>h+x.width,0),l=Math.max(0,n-Fd)-d;if(l<=0)return{widths:s,fillerWidth:0};const u=i.filter(h=>!h.explicit);if(u.length===0)return{widths:s,fillerWidth:l};const f=u.reduce((h,x)=>h+x.width,0)||1;let m=0;return u.forEach((h,x)=>{const D=x===u.length-1?h.width+l-m:Math.round(h.width+l*h.width/f);s[h.name]=D,m+=D-h.width}),{widths:s,fillerWidth:0}},[t,o,n])}const ui=176,Ud={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Yd(t){const o=t.toLowerCase().trim();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=>bo(n,o).bg,color:n=>bo(n,o).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function Gd(t){const o=t.toLowerCase().trim(),n=Ud[o];return n?e.jsx(r.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function qd(t,o){const n=o.trim();if(!n)return t;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=t.split(new RegExp(`(${i})`,"gi"));return s.length===1?t:s.map((d,c)=>d.toLowerCase()===n.toLowerCase()?e.jsx(r.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:d},c):d)}function Jd(t,o,n,i=""){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(o);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase()))return Yd(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase()))return Gd(s);if(t.type==="date"){const l=t.dateFormat??"iso",u=qs(o,l,n??null);return e.jsx(r.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}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:"text.disabled"},children:"[ ]"});const l=o.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return e.jsxs(r.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[l,o.length>3?` +${o.length-3} more`:""]})}if(typeof o=="object"){const l=JSON.stringify(o);return e.jsx(r.Box,{component:"span",title:l,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:l.length>40?l.slice(0,40)+"…":l})}return qd(s,i)}function Kd({schema:t,data:o,sortStack:n=[],filters:i=[],views:s=[],activeViewId:d="",isDirty:c=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:f=[],columnWidths:m={},grouping:h=null,onSort:x,onSortAscending:b,onSortDescending:D,onOpenFilters:g,onOpenSort:j,onOpenFilterForColumn:w,onSelectView:I,onCreateView:v,onManageViews:S,onUpdateCurrentView:C,onSaveAsNewView:a,onToggleDefault:z,onToggleFavorite:R,onRestoreView:q,onPermanentDelete:K,isAdmin:ee=!1,onExport:y,onOpenColumns:M,onUpdateColumnWidth:W,onUpdateColumnOrder:V,onUpdateColumnVisibility:Q,onClearFiltersForColumn:xe,onResetLayout:de,onOpenGroup:L,onGroupByColumn:A,onToggleGroupCollapse:H,onOpenAuditHistory:ie,onOpenScheduledReports:Y,searchQuery:re,highlightQuery:se="",searchHistory:oe=[],onAddToSearchHistory:P,onToggleSearchFavourite:ne,onDeleteSearchHistory:ce,selectedRowIds:ae=new Set,onSearchChange:fe,onToggleRowSelection:G,onToggleAllRows:Ae,onRangeSelection:Qe,onClearSelection:Ze,onExportSelected:Bt,currentPage:ar=1,pageSize:It=15,totalRowsBeforePagination:Dt=o.length,onPageChange:Et,onPageSizeChange:lt,isReadOnly:Ve=!1,userRole:Vt,reportName:et,onEditRow:Ue,onDuplicateRow:He,onDeleteRow:nt,showDevPanel:Ir=!1,onOpenDevConfig:lr}){var eo;const[Ht,cr]=p.useState(null),[Ut,Dr]=p.useState(0),[Yt,ft]=p.useState(0),[it,dr]=p.useState(null),ur=((eo=nr().dates)==null?void 0:eo.displayFormat)??null,[qt,Er]=p.useState(null),[tt,Ot]=p.useState(null),[ke,At]=p.useState(null),[Or,Ye]=p.useState(!1),[F,Ge]=p.useState(!1),[be,Pe]=p.useState(null),[Ar,gt]=p.useState(""),[$r,yt]=p.useState(!1),[Jt,Kt]=p.useState(null),[pr,Te]=p.useState(null),[U,_e]=p.useState(null),[we,ct]=p.useState(null),[Le,xr]=p.useState("list"),[mr,hr]=p.useState(!1),[bt,Mr]=p.useState(()=>!Md("toolbar_search")),vt=p.useRef(null),Xt=p.useRef(null),[St,st]=p.useState(0);p.useLayoutEffect(()=>{const E=vt.current;if(!E)return;st(E.clientWidth);const J=new ResizeObserver(ue=>{st(ue[0].contentRect.width)});return J.observe(E),()=>J.disconnect()},[]);const jt=p.useCallback(()=>{Rd("toolbar_search"),Mr(!1)},[]);p.useEffect(()=>{if(!bt)return;const E=setTimeout(jt,2e3);return()=>clearTimeout(E)},[bt,jt]);const fr=p.useMemo(()=>{const E=it??f;return E.length>0?E.map(J=>t.find(ue=>ue.name===J)).filter(J=>J!==void 0):t},[it,f,t]),Fe=p.useMemo(()=>fr.filter(E=>u[E.name]!==!1),[fr,u]),{widths:$t,fillerWidth:Mt}=Hd(Fe,m,St),dt=p.useMemo(()=>t.filter(E=>u[E.name]===!1).length,[t,u]),at=p.useMemo(()=>t.map(E=>E.name),[t]),Rt=p.useMemo(()=>f.length===0?!1:JSON.stringify(f)!==JSON.stringify(at),[f,at]),Rr=p.useCallback((E,J)=>{E.preventDefault(),E.stopPropagation(),cr(J),Dr(E.clientX),ft(m[J]||150)},[m]);p.useEffect(()=>{if(!Ht)return;const E=ue=>{const Ne=ue.clientX-Ut,pe=Math.max(100,Math.min(600,Yt+Ne));W==null||W(Ht,pe)},J=()=>{cr(null)};return document.addEventListener("mousemove",E),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",J)}},[Ht,Ut,Yt,W]);const Qt=p.useCallback(E=>E==null?"-":typeof E=="object"?JSON.stringify(E):typeof E=="boolean"?E?"true":"false":String(E),[]);p.useCallback(E=>{const J=n.find(ue=>ue.column===E);return J?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[J.direction==="asc"?e.jsx(B.ArrowUpward,{sx:{fontSize:14}}):e.jsx(B.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:J.priority})]}):null},[n]),p.useCallback(E=>i.some(ue=>ue.column===E)?e.jsx(r.IconButton,{size:"small",onClick:ue=>{ue.stopPropagation(),w==null||w(E)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(B.FilterList,{sx:{fontSize:14}})}):null,[i,w]);const gr=p.useCallback(E=>{x&&x(E)},[x]),yr=p.useCallback((E,J)=>{dr(ue=>{const pe=[...ue??(f.length>0?f:t.map(Wo=>Wo.name))],[Zt]=pe.splice(E,1);return pe.splice(J,0,Zt),pe})},[f,t]),br=p.useCallback(()=>{it&&V&&V(it),dr(null)},[it,V]),vr=p.useCallback(E=>{if(!x)return;const J=n.find(ue=>ue.column===E);(!J||J.direction!=="asc")&&x(E)},[x,n]),Sr=p.useCallback(E=>{if(!x)return;const J=n.find(ue=>ue.column===E);J?J.direction==="asc"&&x(E):(x(E),setTimeout(()=>x(E),0))},[x,n]),le=p.useCallback(E=>{if(!x)return;const J=n.find(ue=>ue.column===E);J&&(J.direction==="asc"?(x(E),setTimeout(()=>x(E),0)):J.direction==="desc"&&x(E))},[x,n]),he=p.useCallback(E=>{Q&&Q(E,!1)},[Q]),$e=(h==null?void 0:h.enabled)&&o.length>0&&o[0]&&"isGroupHeader"in o[0],_t=n.length>0||i.length>0||((h==null?void 0:h.enabled)??!1)||Object.values(u).some(E=>E===!1),Wt=(ar-1)*It,We=o,Pt=p.useMemo(()=>{const E=new Set;return ae.forEach(J=>{const ue=J==null?void 0:J.__urm_row_id__;ue!==void 0&&E.add(ue)}),E},[ae]);p.useEffect(()=>{const E=J=>{!Ae||!Ze||J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||((J.ctrlKey||J.metaKey)&&J.key==="a"&&(J.preventDefault(),Ae(!0,We)),J.key==="Escape"&&(J.preventDefault(),Ze()))};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[Ae,Ze,We]);const Qr=p.useCallback((E,J)=>{G&&(J.shiftKey&&qt!==null?(J.preventDefault(),Qe&&Qe(qt,E,We)):(G(We[E]),Er(E)))},[G,qt,Qe,We]);!p.useMemo(()=>We.length>0&&Pt.size>0&&We.every(E=>Pt.has(E==null?void 0:E.__urm_row_id__)),[We,Pt])&&We.some(E=>Pt.has(E==null?void 0:E.__urm_row_id__));const jr=G&&Ae,_o=p.useCallback(E=>{var Ne;const J=E.groupLevel,ue=J*24;return e.jsx(r.TableRow,{onClick:()=>H==null?void 0:H(E.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(r.TableCell,{colSpan:Fe.length+(jr?1:0),sx:{pl:`${ue+24}px`},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[E.isCollapsed?e.jsx(B.ChevronRight,{sx:{fontSize:16}}):e.jsx(B.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:ki(J,((Ne=h==null?void 0:h.levels[J])==null?void 0:Ne.column)||"",E.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:pe=>k(pe.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[E.rowCount," ",E.rowCount===1?"row":"rows"]}),Object.keys(E.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(E.aggregates).map(([pe,Zt])=>wi(Zt)).filter(Boolean).join(" • ")})]})})},E.groupKey)},[Fe,jr,h,H]),Zr=p.useCallback((E,J)=>{const ue=Pt.has(E==null?void 0:E.__urm_row_id__),Ne=tt===J;return e.jsxs(r.TableRow,{"data-row-index":J,onMouseEnter:()=>Ot(J),onMouseLeave:()=>Ot(null),onClick:pe=>{!G||pe.target.closest("[data-row-action-btn]")||Qr(J,pe)},onContextMenu:pe=>{pe.preventDefault(),pe.stopPropagation(),_e({mouseX:pe.clientX,mouseY:pe.clientY,row:E,rowIndex:J})},sx:{height:34,cursor:"pointer",bgcolor:ue?pe=>k(pe.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:ue?pe=>k(pe.palette.warning.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[Fe.map(pe=>e.jsx(r.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,textAlign:"left",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"1px solid",borderColor:"divider",minWidth:m[pe.name]?`${m[pe.name]}px`:`${pe.type==="date"?Math.max(ui,180):ui}px`},children:Jd(pe,E[pe.name],ur,se)},pe.name)),e.jsx(r.TableCell,{sx:{p:0,border:"none",borderBottom:"1px solid",borderColor:"divider"}}),e.jsx(r.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:40,minWidth:40,maxWidth:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",background:Ne?pe=>`linear-gradient(to right, transparent, ${ue?k(pe.palette.warning.main,.12):pe.palette.background.paper} 32px)`:"transparent",opacity:Ne?1:0,transition:"opacity 0.12s ease, background 0.12s ease",zIndex:10,verticalAlign:"middle"},children:e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",height:"100%",px:1,gap:.25},children:e.jsx(r.IconButton,{"data-row-action-btn":"true",size:"small",onClick:pe=>{pe.stopPropagation(),pe.preventDefault(),_e({anchorEl:pe.currentTarget,row:E,rowIndex:J})},sx:{color:"text.secondary",opacity:Ne?1:0,transition:"opacity 0.12s ease",pointerEvents:Ne?"auto":"none","&:hover":{bgcolor:pe=>k(pe.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(B.MoreVert,{sx:{fontSize:18}})})})})]},J)},[ae,Wt,tt,Qr,Fe,m,se,Qt,Ue,He,nt,G,At,Ye,_e]);return e.jsxs(kt.DndProvider,{backend:tn.HTML5Backend,children:[e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[jr&&Bt&&Ze&&e.jsx(Sd,{selectedCount:Pt.size,viewMode:Le,onExportSelected:Bt,onClearSelection:Ze}),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:[Ve&&e.jsx($d,{}),fe&&P&&ne&&ce&&e.jsx(r.Tooltip,{open:bt,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:jt},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(fd,{value:re||"",onChange:E=>{bt&&jt(),fe(E)},searchHistory:oe,onAddToHistory:P,onToggleFavourite:ne,onDeleteHistory:ce,disabled:Ve})})}),e.jsx(r.Tooltip,{title:"JSON format guide",children:e.jsx(r.IconButton,{size:"small",onClick:()=>hr(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:E=>k(E.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(B.InfoOutlined,{sx:{fontSize:20}})})}),I&&v&&S&&C&&s.length>0&&e.jsx(gd,{views:s||[],activeViewId:d||"",isDirty:c,onSelectView:I,onCreateView:v,onManageViews:S,onToggleDefault:z,onToggleFavorite:R,onRestoreView:q,onPermanentDelete:K,isAdmin:ee,isReadOnly:Ve}),Ir&&lr&&e.jsx(r.Tooltip,{title:"Developer configuration",children:e.jsx(r.IconButton,{size:"small",onClick:lr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:E=>k(E.palette.text.secondary,.3),"&:hover":{bgcolor:E=>k(E.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(B.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(r.Box,{sx:{flexGrow:1}}),!Ve&&j&&e.jsx(r.Tooltip,{title:"Sort",children:e.jsxs(r.IconButton,{onClick:j,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?E=>Re(E):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(B.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Ve&&g&&e.jsx(r.Tooltip,{title:"Filter",children:e.jsxs(r.IconButton,{onClick:g,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?E=>Re(E):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(B.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:i.length})]})}),!Ve&&M&&e.jsx(r.Tooltip,{title:"Show/Hide Columns",children:e.jsxs(r.IconButton,{onClick:M,size:"small",sx:{position:"relative",color:dt>0||Rt?"primary.main":"text.secondary",bgcolor:dt>0||Rt?E=>Re(E):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:dt>0||Rt?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:dt>0||Rt?"primary.main":"text.primary"}},children:[e.jsx(B.ViewColumn,{sx:{fontSize:20}}),dt>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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:dt})]})}),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:()=>xr("list"),sx:{borderRadius:1,color:Le==="list"?"primary.main":"text.secondary",bgcolor:Le==="list"?E=>Re(E):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="list"?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:Le==="list"?"primary.main":"text.primary"}},children:e.jsx(B.TableRows,{sx:{fontSize:20}})})}),e.jsx(r.Tooltip,{title:"Grid view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>xr("grid"),sx:{borderRadius:1,color:Le==="grid"?"primary.main":"text.secondary",bgcolor:Le==="grid"?E=>Re(E):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="grid"?E=>k(E.palette.primary.main,.2):E=>k(E.palette.text.primary,.06),color:Le==="grid"?"primary.main":"text.primary"}},children:e.jsx(B.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:E=>ct(E.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:E=>k(E.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(B.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(r.Popover,{open:!!we,anchorEl:we,onClose:()=>ct(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:[y&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{y(),ct(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Export"})]}),!Ve&&L&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{L(),ct(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Grouping"})]}),ie&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{ie(),ct(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.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(),ct(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Scheduled Reports"})]})]}),e.jsxs(r.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Le==="grid"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:e.jsx(Ed,{data:We,visibleColumns:Fe,grouping:h,selectedRowIds:ae,isReadOnly:Ve,isGrouped:!!$e,sortStack:n,onSort:x,onToggleRowSelection:G||(()=>{}),onToggleGroupCollapse:H,onViewRow:E=>{At(E),Ye(!0)},onEditRow:(E,J)=>{Kt(E),Te(J),yt(!0)},onDuplicateRow:(E,J)=>He==null?void 0:He(E,J),onDeleteRow:(E,J)=>{Pe(J);const ue=Object.values(J).find(Ne=>Ne!=null&&Ne!=="");gt(ue?String(ue):""),Ge(!0)}})}),Le==="list"&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[e.jsx(r.Box,{ref:vt,onScroll:E=>{Xt.current&&(Xt.current.scrollLeft=E.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e.jsxs(r.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values($t).reduce((E,J)=>E+J,0)+Mt+40}px`},children:[e.jsxs("colgroup",{children:[Fe.map(E=>e.jsx("col",{style:{width:`${$t[E.name]}px`}},E.name)),e.jsx("col",{style:{width:`${Mt}px`}}),e.jsx("col",{style:{width:"40px"}})]}),e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[Fe.map((E,J)=>e.jsx(vd,{column:E,index:J,sortRule:n.find(ue=>ue.column===E.name),hasFilters:i.some(ue=>ue.column===E.name),isInSortStack:n.some(ue=>ue.column===E.name),isReadOnly:Ve,hasModifications:_t,width:m[E.name],onColumnClick:gr,onMoveColumn:yr,onColumnDragEnd:br,onResizeStart:Rr,onSortAscending:b||vr,onSortDescending:D||Sr,onRemoveSort:le,onOpenFilterForColumn:w||(()=>{}),onClearFiltersForColumn:xe||(()=>{}),onGroupByColumn:A,onHideColumn:he,onManageColumns:M||(()=>{}),onManageViews:S,onResetLayout:de},E.name)),e.jsx(r.TableCell,{sx:{p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}}),e.jsx(r.TableCell,{sx:{width:40,minWidth:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}})]})})]})}),e.jsx(r.Box,{ref:Xt,onScroll:E=>{vt.current&&(vt.current.scrollLeft=E.target.scrollLeft)},sx:{flex:1,overflowY:"auto",overflowX:"auto",minHeight:0,bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:E=>E.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:E=>E.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",borderSpacing:0,width:"100%",minWidth:`${Object.values($t).reduce((E,J)=>E+J,0)+Mt+40}px`},children:[e.jsxs("colgroup",{children:[Fe.map(E=>e.jsx("col",{style:{width:`${$t[E.name]}px`}},E.name)),e.jsx("col",{style:{width:`${Mt}px`}}),e.jsx("col",{style:{width:"40px"}})]}),e.jsx(r.TableBody,{children:We.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:Fe.length+(jr?1:0),align:"center",sx:{py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):$e?We.map((E,J)=>E.isGroupHeader?_o(E):Zr(E,J)):We.map((E,J)=>Zr(E,J))})]})})]}),Et&<&&e.jsx(Ad,{currentPage:ar,pageSize:It,totalRows:Dt,totalFields:t.length,onPageChange:Et,onPageSizeChange:lt}),!(Et&<)&&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:!!U,onClose:()=>_e(null),anchorEl:(U==null?void 0:U.anchorEl)||null,anchorReference:U!=null&&U.anchorEl?"anchorEl":"anchorPosition",anchorPosition:U&&!U.anchorEl?{top:U.mouseY,left:U.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:U!=null&&U.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:()=>{U&&(At(U.row),Ye(!0)),_e(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{U&&(Kt(U.row),Te(U.rowIndex),yt(!0)),_e(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{U&&(He==null||He(U.rowIndex,U.row)),_e(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.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(U){Pe(U.row);const E=Object.values(U.row).find(J=>J!=null&&J!=="");gt(E?String(E):""),Ge(!0)}_e(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(B.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(_d,{open:Or,onClose:()=>{Ye(!1),At(null)},row:ke,schema:t,reportName:et}),e.jsx(Pd,{open:$r,onClose:()=>{yt(!1),Kt(null),Te(null)},onSave:E=>{pr!==null&&(Ue==null||Ue(pr,E))},row:Jt,schema:t,reportName:et}),e.jsx(Wd,{open:F,onClose:()=>{Ge(!1),Pe(null)},onConfirm:()=>{be!==null&&(nt==null||nt(be))},rowPreview:Ar}),e.jsx(Ji,{isOpen:mr,onClose:()=>hr(!1)})]})}function ir({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=>k(s.palette.primary.main,.08)}},children:e.jsx(B.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=>k(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,d)=>e.jsx(r.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},d))}),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=>k(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>k(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 sr={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 Xd({schema:t,filters:o,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:s,onClearAll:d,onReplaceFilters:c,onClose:l,focusColumn:u}){const[f,m]=p.useState(""),[h,x]=p.useState(""),[b,D]=p.useState(""),[g,j]=p.useState([]),w=nr();p.useEffect(()=>{j([...o])},[o]),p.useEffect(()=>{u&&m(u)},[u]);const I=p.useCallback(()=>{m(""),x(""),D("")},[]),v=p.useMemo(()=>t.filter(M=>M.type!=="mixed"&&M.type!=="null"&&M.type!=="array"&&M.type!=="object"),[t]),S=t.find(M=>M.name===f),C=p.useMemo(()=>{const M=S?Dn(S.type):[],W=w.filter.allowedOperators;return W.length>0?M.filter(V=>W.includes(V.value)):M},[S]),a=p.useCallback(()=>!(!f||!h||oo(h)&&!b.trim()||g.length>=w.filter.maxConditions),[f,h,b,g,w]),z=p.useCallback(()=>{if(!a())return;const M={column:f,operator:h};if(oo(h)){const V=S==null?void 0:S.type;M.value=V==="number"?Number(b):b}if(g.some(V=>V.column===M.column&&V.operator===M.operator&&V.value===M.value)){I();return}j([...g,M]),I()},[a,f,h,S,b,g,I]),R=p.useCallback(M=>{j(g.filter((W,V)=>V!==M))},[g]),q=p.useMemo(()=>g.length!==o.length?!0:JSON.stringify(g)!==JSON.stringify(o),[g,o]),K=p.useCallback(()=>{c(g),l()},[g,c,l]),ee=p.useCallback(()=>{j([...o]),I(),l()},[o,I,l]),y=p.useCallback(M=>{var xe;const W=t.find(de=>de.name===M.column);if(!W)return"";const Q=((xe=Dn(W.type).find(de=>de.value===M.operator))==null?void 0:xe.label)||M.operator;return oo(M.operator)?`${M.column} ${Q.toLowerCase()} "${M.value}"`:`${M.column} ${Q.toLowerCase()}`},[t]);return e.jsx(r.Box,{onClick:ee,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:M=>k(M.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:M=>M.zIndex.modal,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:M=>M.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:M=>Me(M),bgcolor:"background.paper",outline:"none",boxShadow:M=>te(M,"menu"),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(ir,{content:sr.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:"action.hover",color:"text.primary"}},children:e.jsx(B.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:M=>k(M.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:M=>k(M.palette.text.primary,.3)}}},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,disabled:g.length>=w.filter.maxConditions,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(r.Select,{value:f,onChange:M=>{m(M.target.value),x(""),D("")},label:"Column",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:v.map(M=>e.jsxs(r.MenuItem,{value:M.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:W=>Re(W),"&:hover":{bgcolor:W=>k(W.palette.primary.main,.2)}}},children:[Ke(M.name)," (",M.type,")"]},M.name))})]}),f&&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:h,onChange:M=>{x(M.target.value),D("")},label:"Operator",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:C.map(M=>e.jsx(r.MenuItem,{value:M.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:W=>Re(W),"&:hover":{bgcolor:W=>k(W.palette.primary.main,.2)}}},children:M.label},M.value))})]}),h&&oo(h)&&e.jsx(r.TextField,{size:"small",fullWidth:!0,type:(S==null?void 0:S.type)==="number"?"number":"text",value:b,onChange:M=>D(M.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:"divider",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:z,disabled:!a(),sx:{mt:1.5,fontSize:"0.875rem",color:"primary.main",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"+ Add another filter"}),g.length>=w.filter.maxConditions&&e.jsxs(r.Typography,{variant:"caption",sx:{display:"block",mt:.75,color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Filter limit reached — maximum ",w.filter.maxConditions," filters allowed. Remove an existing filter to add a new one."]})]}),g.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 (",g.length,")"]}),e.jsx(r.Button,{onClick:()=>{d(),l()},sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:g.map((M,W)=>e.jsx(r.Chip,{label:y(M),onDelete:()=>R(W),sx:{bgcolor:V=>Re(V),color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:V=>`1px solid ${k(V.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:V=>k(V.palette.primary.main,.2),borderColor:V=>k(V.palette.primary.main,.5)},"& .MuiChip-label":{px:1.5,color:"primary.main"},"& .MuiChip-deleteIcon":{color:"primary.main",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"primary.dark"}}}},W))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:ee,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:M=>`${M.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:K,disabled:!q,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:M=>`${M.shape.borderRadius}px`,boxShadow:M=>te(M,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:M=>te(M,"hoverButton")},"&:active":{boxShadow:M=>te(M,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})})}const pi="SORT_RULE";function Qd({rule:t,index:o,onToggleDirection:n,onRemove:i,onMove:s}){const d=p.useRef(null),[{handlerId:c},l]=kt.useDrop({accept:pi,collect(m){return{handlerId:m.getHandlerId()}},hover(m,h){var I;if(!d.current)return;const x=m.index,b=o;if(x===b)return;const D=(I=d.current)==null?void 0:I.getBoundingClientRect(),g=(D.bottom-D.top)/2,j=h.getClientOffset(),w=((j==null?void 0:j.y)??0)-D.top;x<b&&w<g||x>b&&w>g||(s(x,b),m.index=b)}}),[{isDragging:u},f]=kt.useDrag({type:pi,item:()=>({index:o}),collect:m=>({isDragging:m.isDragging()})});return f(l(d)),e.jsxs(r.Box,{ref:d,"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:"action.hover",borderColor:"divider",boxShadow:m=>te(m,"restButtonLight"),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:m=>`0 1px 2px 0 ${k(m.palette.primary.main,.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:m=>n(o,m.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",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:"action.hover"},"&.Mui-selected":{bgcolor:m=>Re(m),"&:hover":{bgcolor:m=>k(m.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(r.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:m=>Re(m),"&:hover":{bgcolor:m=>k(m.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:m=>k(m.palette.error.main,.08),transform:"scale(1.1)"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]})}function Zd({schema:t,sortStack:o,onUpdateSortStack:n,onClose:i}){const[s,d]=p.useState(""),[c,l]=p.useState([]);p.useEffect(()=>{l([...o])},[o]);const u=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(o),[c,o]),f=nr(),m=p.useCallback(()=>!(c.length>=f.sort.maxLevels||!s||c.some(v=>v.column===s)),[c,s]),h=p.useCallback(()=>{if(!m())return;const v=c.length+1,S={column:s,direction:"asc",priority:v};l([...c,S]),d("")},[m,s,c]),x=p.useCallback(v=>{const C=c.filter((a,z)=>z!==v).map((a,z)=>({...a,priority:z+1}));l(C)},[c]),b=p.useCallback((v,S)=>{const C=[...c];C[v]={...C[v],direction:S},l(C)},[c]),D=p.useCallback((v,S)=>{const C=[...c],[a]=C.splice(v,1);C.splice(S,0,a);const z=C.map((R,q)=>({...R,priority:q+1}));l(z)},[c]),g=p.useCallback(()=>{n([]),i()},[n,i]),j=p.useCallback(()=>{n(c),i()},[c,n,i]),w=p.useCallback(()=>{l([...o]),d(""),i()},[o,i]),I=t.filter(v=>!c.some(S=>S.column===v.name));return e.jsx(kt.DndProvider,{backend:tn.HTML5Backend,children:e.jsx(r.Box,{onClick:w,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:v=>k(v.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:v=>v.zIndex.modal,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:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:v=>Me(v),bgcolor:"background.paper",outline:"none",boxShadow:v=>te(v,"menu"),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(ir,{content:sr.sort,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:w,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.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:v=>k(v.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:v=>k(v.palette.text.primary,.3)}}},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>=f.sort.maxLevels,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),e.jsx(r.Select,{value:s,onChange:v=>d(v.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:I.map(v=>e.jsx(r.MenuItem,{value:v.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:S=>Re(S),"&:hover":{bgcolor:S=>k(S.palette.primary.main,.2)}}},children:Ke(v.name)},v.name))})]}),e.jsx(r.Button,{onClick:h,disabled:!m(),sx:{mt:1.5,fontSize:"0.875rem",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:"text.disabled"}},children:"+ Add sort column"}),c.length>=f.sort.maxLevels&&e.jsxs(r.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",f.sort.maxLevels," sort levels allowed"]})]}),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,"/",f.sort.maxLevels,")"]}),e.jsx(r.Button,{onClick:g,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:c.map((v,S)=>e.jsx(Qd,{rule:v,index:S,onToggleDirection:b,onRemove:x,onMove:D},`${v.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:"action.hover"},children:[e.jsx(r.Button,{onClick:w,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:v=>`${v.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:j,variant:"contained",disabled:!u||c.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:v=>`${v.shape.borderRadius}px`,boxShadow:v=>te(v,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:v=>te(v,"hoverButton")},"&:active":{boxShadow:v=>te(v,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function eu({views:t,activeViewId:o,onSelectView:n,onCreateView:i,onEditView:s,onDeleteView:d,onRestoreView:c,onPermanentDelete:l,onPromoteToGlobal:u,isAdmin:f=!1,onClose:m}){var v,S;const h=zt(),x=h.palette,b=t.filter(C=>!C.isDeleted),D=t.filter(C=>C.isDeleted),g=b.filter(C=>C.scope==="global"),j=b.filter(C=>C.scope!=="global"),w=C=>{var K,ee,y,M,W;const a=C.scope==="global",z=C.id===o,R=f||!a,q=f&&!a;return e.jsx(r.Paper,{variant:"outlined",sx:{p:0,overflow:"hidden",borderRadius:"8px",borderColor:z?"primary.main":"divider",bgcolor:z?k(x.primary.main,.03):"background.paper",transition:"border-color 0.15s","&:hover":{borderColor:z?"primary.main":k(x.text.primary,.22)}},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.75,py:1.25,gap:1},children:[e.jsxs(r.Box,{sx:{flex:1,minWidth:0,cursor:"pointer",display:"flex",alignItems:"center",gap:1},onClick:()=>{n(C.id),m()},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:z?600:500,color:z?"primary.main":"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.name}),C.description&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.description})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[a&&e.jsx(r.Chip,{label:"Global",size:"small",icon:e.jsx(B.Language,{sx:{fontSize:"11px !important"}}),sx:{height:20,fontSize:"0.625rem",fontWeight:700,letterSpacing:"0.04em",bgcolor:k(((K=x.info)==null?void 0:K.main)??x.primary.main,.1),color:((ee=x.info)==null?void 0:ee.main)??x.primary.main,border:`1px solid ${k(((y=x.info)==null?void 0:y.main)??x.primary.main,.25)}`,"& .MuiChip-label":{px:.625},"& .MuiChip-icon":{ml:.5}}}),C.isDefault&&e.jsx(r.Chip,{label:"Default",size:"small",sx:{height:20,fontSize:"0.625rem",fontWeight:600,bgcolor:k(x.text.secondary,.08),color:"text.secondary","& .MuiChip-label":{px:.75}}})]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[q&&u&&e.jsx(r.Tooltip,{title:"Promote to Global View",arrow:!0,placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:V=>{V.stopPropagation(),u(C.id)},sx:{p:.625,color:"text.secondary",borderRadius:"6px","&:hover":{color:((M=x.info)==null?void 0:M.main)??x.primary.main,bgcolor:k(((W=x.info)==null?void 0:W.main)??x.primary.main,.08)}},children:e.jsx(B.Language,{sx:{fontSize:16}})})}),R&&e.jsx(r.Tooltip,{title:a&&!f?"Global Views are read-only":"Edit view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!f,onClick:V=>{V.stopPropagation(),s(C.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"primary.main",bgcolor:k(x.primary.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(B.Edit,{sx:{fontSize:15}})})})}),e.jsx(r.Tooltip,{title:a&&!f?"Only admins can delete Global Views":"Delete view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!f,onClick:V=>{V.stopPropagation(),d(C.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:k(x.error.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(B.Delete,{sx:{fontSize:15}})})})})]})]})},C.id)},I=C=>{var a;return e.jsxs(r.Paper,{variant:"outlined",sx:{px:1.75,py:1.25,borderRadius:"8px",borderColor:"divider",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:k(x.text.primary,.02)},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",color:"text.disabled",textDecoration:"line-through",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.name}),e.jsxs(r.Box,{sx:{display:"flex",gap:.25,flexShrink:0,ml:1},children:[c&&e.jsx(r.Tooltip,{title:"Restore view",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:z=>{z.stopPropagation(),c(C.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"success.main",bgcolor:k(((a=x.success)==null?void 0:a.main)??"#2e7d32",.08)}},children:e.jsx(B.Undo,{sx:{fontSize:15}})})}),l&&e.jsx(r.Tooltip,{title:"Delete permanently",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:z=>{z.stopPropagation(),l(C.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:k(x.error.main,.08)}},children:e.jsx(B.Delete,{sx:{fontSize:15}})})})]})]},C.id)};return e.jsxs(r.Dialog,{open:!0,onClose:m,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:Me(h),maxHeight:"min(640px, calc(100vh - 80px))",boxShadow:`0 8px 32px ${k(((v=x.common)==null?void 0:v.black)??"#000",.14)}`}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600},children:"Manage Views"}),f&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:"Admin mode — you can promote Personal Views to Global"})]}),e.jsx(r.IconButton,{onClick:m,size:"small",sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:19}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",pb:2},children:[e.jsx(r.Box,{sx:{mb:2},children:e.jsx(r.Button,{onClick:i,variant:"contained",startIcon:e.jsx(B.Add,{sx:{fontSize:16}}),size:"small",sx:{borderRadius:C=>`${C.shape.borderRadius}px`},children:"Create New View"})}),g.length>0&&e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1},children:[e.jsx(B.Language,{sx:{fontSize:14,color:((S=x.info)==null?void 0:S.main)??x.primary.main}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Global Views"}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:"— visible to all users"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:g.map(w)})]}),j.length>0&&e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.07em",mb:1},children:"Personal Views"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:j.map(w)})]}),D.length>0&&e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.disabled",textTransform:"uppercase",letterSpacing:"0.07em",mb:1},children:"Recently Deleted"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:D.map(I)})]}),b.length===0&&D.length===0&&e.jsx(r.Box,{sx:{py:4,textAlign:"center",color:"text.disabled"},children:e.jsx(r.Typography,{variant:"body2",children:"No views created yet"})})]}),e.jsx(r.DialogActions,{sx:{px:3,py:1.5,borderTop:"1px solid",borderColor:"divider",justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:m,variant:"contained",sx:{fontSize:"0.875rem",borderRadius:C=>`${C.shape.borderRadius}px`,px:3},children:"Close"})})]})}const lo=50;function xi({currentSnapshot:t,onSave:o,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:d="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:u=10}){const[f,m]=p.useState(s),[h,x]=p.useState(!1),[b,D]=p.useState(d),[g,j]=p.useState(c),w=()=>{if(!f.trim()){x(!0);return}if(f.trim().length>lo){x(!0);return}o(f.trim(),b.trim(),g),n()},I=S=>{S.key==="Enter"&&!S.shiftKey?w():S.key==="Escape"&&n()},v=()=>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:S=>Me(S),boxShadow:S=>te(S,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[v(),e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[l&&!i&&e.jsxs(r.Alert,{severity:"warning",sx:{borderRadius:"8px"},children:["You have reached the maximum of ",u," saved views. Delete an existing view before creating a new one."]}),e.jsx(r.TextField,{label:"View Name",required:!0,value:f,onChange:S=>{S.target.value.length<=lo&&m(S.target.value),h&&S.target.value.trim()&&x(!1)},onKeyDown:I,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:lo},error:h&&!f.trim(),helperText:h&&!f.trim()?"View name is required":`${f.length} / ${lo}`}),e.jsx(r.TextField,{label:"Description (optional)",value:b,onChange:S=>D(S.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: ",aa(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:g,onChange:S=>j(S.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:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:w,variant:"contained",disabled:l&&!i,startIcon:e.jsx(B.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,boxShadow:S=>te(S,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:S=>te(S,"hoverButton")},"&:active":{boxShadow:S=>te(S,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function tu({viewName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>Me(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:i=>te(i,"menu")}},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(B.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(B.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:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"action.selected",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>te(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>te(i,"hoverButton")},"&:active":{boxShadow:i=>te(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const uo=100,po=600,mi="COLUMN";function ru({column:t,index:o,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:d,moveColumn:c}){const l=p.useRef(null),[u,f]=p.useState(i.toString());p.useEffect(()=>{f(i.toString())},[i]);const[{handlerId:m},h]=kt.useDrop({accept:mi,collect(I){return{handlerId:I.getHandlerId()}},hover(I,v){var K;if(!l.current)return;const S=I.index,C=o;if(S===C)return;const a=(K=l.current)==null?void 0:K.getBoundingClientRect(),z=(a.bottom-a.top)/2,R=v.getClientOffset(),q=((R==null?void 0:R.y)??0)-a.top;S<C&&q<z||S>C&&q>z||(c(S,C),I.index=C)}}),[{isDragging:x},b]=kt.useDrag({type:mi,item:()=>({index:o}),collect:I=>({isDragging:I.isDragging()})});b(h(l));const D=()=>{const I=parseInt(u);if(isNaN(I)){f(i.toString()),d(t.name,i);return}const v=Math.max(uo,Math.min(po,I));f(v.toString()),d(t.name,v)},g=I=>{if(I===""||/^\d+$/.test(I)){f(I);const v=parseInt(I);if(!isNaN(v)&&v>=uo){const S=Math.min(po,v);d(t.name,S)}}},j=I=>{I.key==="Enter"&&(I.preventDefault(),D(),I.target.blur())},w=I=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[I]||"text.secondary";return e.jsxs(r.TableRow,{ref:l,"data-handler-id":m,sx:{opacity:x?.4:1,bgcolor:n?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:n?"action.hover":"action.selected"},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(B.DragIndicator,{sx:{fontSize:20}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:Ke(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:`${w(t.type)}15`,color:w(t.type),border:`1px solid ${w(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:"number",value:u,onChange:I=>g(I.target.value),onBlur:D,onKeyDown:j,placeholder:"150",size:"small",inputProps:{min:uo,max:po,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),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:"action.hover",color:n?"primary.dark":"primary.main"}},children:n?e.jsx(B.Visibility,{sx:{fontSize:20}}):e.jsx(B.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(r.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?I=>k(I.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function ou({schema:t,columnVisibility:o,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:d="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:f,onSaveToCurrentView:m,onSaveToAllViews:h,onSelectView:x,onClose:b}){const[D,g]=p.useState(!1),[j,w]=p.useState(n),[I,v]=p.useState(i),[S,C]=p.useState("all"),[a,z]=p.useState(null);p.useEffect(()=>{w(n)},[n]),p.useEffect(()=>{v(i)},[i]);const R=(L,A)=>{v(H=>({...H,[L]:A})),u==null||u(L,A)},q=(L,A)=>{const H=[...j],[ie]=H.splice(L,1);H.splice(A,0,ie),w(H),l(H)},K=()=>{f(),g(!1)},y=j.map(L=>t.find(A=>A.name===L)).filter(L=>L!==void 0).filter(L=>{const A=o[L.name]??!0;return S==="active"?A:S==="hidden"?!A:!0}),M=Object.values(o).filter(L=>L).length,W=t.length,V=s.find(L=>L.id===d),Q=s.filter(L=>!L.isDeleted),xe=Q.length>1,de=p.useMemo(()=>{if(!V)return!1;const L=V.snapshot,A=L.columnVisibility??{},H=JSON.stringify(o)!==JSON.stringify(A),ie=L.columnOrder??[],Y=n??[],re=JSON.stringify(Y)!==JSON.stringify(ie)&&!(Y.length===0&&ie.length===0),se=L.columnWidths??{},oe=JSON.stringify(I)!==JSON.stringify(se);return H||re||oe},[V,o,n,I]);return e.jsx(kt.DndProvider,{backend:tn.HTML5Backend,children:e.jsx(r.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:L=>k(L.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:L=>L.zIndex.modal,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:L=>L.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:L=>Me(L),bgcolor:"background.paper",outline:"none",boxShadow:L=>te(L,"menu"),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(ir,{content:sr.columns,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",mt:.5},children:[M," of ",W," columns visible • Drag to reorder"]})]}),Q.length>0&&x&&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:L=>z(L.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(B.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",fontSize:"0.875rem",color:"text.primary",borderColor:"divider",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:e.jsx(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(V==null?void 0:V.name)||"Select View"})}),e.jsx(r.Menu,{anchorEl:a,open:!!a,onClose:()=>z(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:L=>te(L,"small")}},children:Q.map(L=>e.jsx(r.MenuItem,{onClick:()=>{x(L.id),z(null)},selected:L.id===d,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:A=>Re(A),"&:hover":{bgcolor:A=>k(A.palette.primary.main,.2)}}},children:L.name},L.id))})]}),e.jsx(r.IconButton,{onClick:b,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Tabs,{value:S,onChange:(L,A)=>C(A),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:L=>k(L.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:L=>k(L.palette.text.primary,.3)}}},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:"background.paper",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:"background.paper",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:"background.paper",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: ${uo}px, max: ${po}px)`,arrow:!0,placement:"top",children:e.jsx(B.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:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),e.jsx(r.TableBody,{children:y.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"})})}):y.map((L,A)=>e.jsx(ru,{column:L,index:A,isVisible:o[L.name]??!0,width:I[L.name]||170,onToggleVisibility:c,onWidthChange:R,moveColumn:q},L.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:"action.hover"},children:[e.jsx(r.Button,{onClick:()=>g(!0),disabled:!de,variant:"outlined",startIcon:e.jsx(B.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:L=>`${L.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"}),e.jsxs(r.Stack,{direction:"row",spacing:1.25,children:[m&&e.jsx(r.Button,{onClick:()=>{m(I),b()},disabled:!de,variant:"contained",startIcon:e.jsx(B.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:L=>`${L.shape.borderRadius}px`,boxShadow:L=>te(L,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:L=>te(L,"hoverButton")},"&:active":{boxShadow:L=>te(L,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to current view"}),h&&xe&&e.jsx(r.Button,{onClick:()=>{h(I),b()},disabled:!de||!xe,variant:"contained",startIcon:e.jsx(B.GridView,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"success.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:L=>`${L.shape.borderRadius}px`,boxShadow:L=>te(L,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"success.dark",boxShadow:L=>te(L,"hoverButton")},"&:active":{boxShadow:L=>te(L,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to all views"})]})]}),D&&e.jsx(r.Box,{onClick:()=>g(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:L=>k(L.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:L=>L.zIndex.tooltip},children:e.jsxs(r.Paper,{onClick:L=>L.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:L=>Xr(L),bgcolor:"background.paper",boxShadow:L=>te(L,"menu")},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:"action.hover"},children:[e.jsx(r.Button,{onClick:()=>g(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:L=>`${L.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:K,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:L=>`${L.shape.borderRadius}px`,boxShadow:L=>te(L,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:L=>te(L,"hoverButton")},"&:active":{boxShadow:L=>te(L,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function nu({schema:t,grouping:o,onApply:n,onClose:i}){var a;const[s,d]=p.useState(o||{enabled:!1,levels:[],collapsedGroups:[]}),[c,l]=p.useState(""),[u,f]=p.useState(null),m=p.useMemo(()=>ta(t),[t]),h=p.useMemo(()=>m.filter(z=>!s.levels.some((R,q)=>R.column===z.name&&q!==u)),[m,s.levels,u]),x=nr(),b=s.levels.length<x.grouping.maxLevels&&h.length>0,D=p.useCallback(()=>{!b||!c||(d({...s,levels:[...s.levels,{column:c}],enabled:!0}),l(""))},[b,c,s]),g=p.useCallback(z=>{const R=s.levels.filter((q,K)=>K!==z);if(R.length===0){n(null),i();return}d({...s,levels:R,enabled:R.length>0})},[s,n,i]),j=p.useCallback(z=>{f(z),l(s.levels[z].column)},[s.levels]),w=p.useCallback(()=>{if(u===null||!c)return;const z=[...s.levels];z[u]={column:c},d({...s,levels:z}),f(null),l("")},[u,c,s]),I=p.useCallback(()=>{f(null),l("")},[]),v=p.useCallback((z,R)=>{const q=R==="up"?z-1:z+1;if(q<0||q>=s.levels.length)return;const K=[...s.levels],[ee]=K.splice(z,1);K.splice(q,0,ee),d({...s,levels:K})},[s]),S=p.useCallback(()=>{n(null),i()},[n,i]),C=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:z=>k(z.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:z=>z.zIndex.modal,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:z=>z.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:z=>Me(z),bgcolor:"background.paper",outline:"none",boxShadow:z=>te(z,"menu"),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"}),"// eslint-disable-next-line no-undef",e.jsx(ir,{content:sr.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:"action.hover",color:"text.primary"}},children:e.jsx(B.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:z=>k(z.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:z=>k(z.palette.text.primary,.3)}}},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:z=>l(z.target.value),disabled:!b,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[e.jsx(r.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),h.map(z=>e.jsxs(r.MenuItem,{value:z.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:R=>Re(R),"&:hover":{bgcolor:R=>k(R.palette.primary.main,.2)}}},children:[Ke(z.name)," (",z.type.toUpperCase(),")"]},z.name))]})}),e.jsx(r.Button,{onClick:D,disabled:!b||!c,variant:"outlined",startIcon:e.jsx(B.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",bgcolor:"action.hover"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Add group level"}),s.levels.length>=x.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"}),m.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:z=>`1px solid ${k(z.palette.warning.main,.5)}`,bgcolor:z=>k(z.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},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:z=>l(z.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&: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:z=>Re(z)}},children:[s.levels[u].column," (",(a=t.find(z=>z.name===s.levels[u].column))==null?void 0:a.type.toUpperCase(),")"]}),h.filter(z=>z.name!==s.levels[u].column).map(z=>e.jsxs(r.MenuItem,{value:z.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:R=>Re(R)}},children:[Ke(z.name)," (",z.type.toUpperCase(),")"]},z.name))]})}),e.jsxs(r.Stack,{direction:"row",spacing:1.5,children:[e.jsx(r.Button,{onClick:w,disabled:!c,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:z=>te(z,"pressedButton")}},children:"Save"}),e.jsx(r.Button,{onClick:I,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},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:S,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Stack,{spacing:1.5,children:s.levels.map((z,R)=>{const q=t.find(K=>K.name===z.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:"action.hover",borderColor:"divider",boxShadow:K=>te(K,"pressedButtonLight")}},children:[e.jsx(r.Chip,{label:`L${R+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:K=>`0 1px 2px 0 ${k(K.palette.primary.main,.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:z.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:()=>v(R,"up"),disabled:R===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(B.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>v(R,"down"),disabled:R===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(B.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>j(R),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:e.jsx(B.Edit,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>g(R),sx:{color:"text.secondary","&:hover":{bgcolor:K=>k(K.palette.error.main,.08),color:"error.main"}},children:e.jsx(B.Delete,{sx:{fontSize:18}})})]})]},R)})})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:C,variant:"contained",disabled:s.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,boxShadow:z=>te(z,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:z=>te(z,"hoverButton")},"&:active":{boxShadow:z=>te(z,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const iu={filters:B.FilterList,sorting:B.UnfoldMore,visibility:B.Visibility,order:B.ViewColumn,widths:B.Straighten,grouping:B.Layers};function su({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:i=>Me(i),boxShadow:i=>te(i,"menu")}},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(B.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 d=iu[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(d,{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:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>te(i,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:i=>te(i,"hoverButton")},"&:active":{boxShadow:i=>te(i,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})}function au({viewName:t,isDefaultView:o,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:s,onCancel:d}){const[c,l]=p.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:u=>Re(u),borderBottom:u=>`1px solid ${k(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:d,variant:"text",size:"small",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",color:"text.secondary",bgcolor:"transparent",minHeight:32,"&:hover":{bgcolor:u=>k(u.palette.common.black,.08),color:"text.primary"}},children:"Discard"}),e.jsx(r.Button,{onClick:s,variant:"contained",size:"small",sx:{fontSize:"0.875rem",px:2.5,py:.625,borderRadius:"18px",minHeight:32,boxShadow:"none","&:hover":{boxShadow:u=>te(u,"restButton")}},children:"Save as new view"})]})]})}),c&&e.jsx(su,{changes:n,onClose:()=>l(!1)})]})}function lu({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(B.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(B.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(B.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(r.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(B.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const hi=[{key:"1h",label:"Last 1 Hour",ms:3600*1e3},{key:"24h",label:"Last 24 Hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 Days",ms:10080*60*1e3},{key:"30d",label:"Last 30 Days",ms:720*60*60*1e3},{key:"all",label:"All Time",ms:null}];function cu(t,o){if(o===null)return t.length;const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()>=n).length}function du(t,o){if(o===null)return[];const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()<n)}function uu({auditHistory:t,onClose:o,onClearAuditHistory:n}){var D,g,j,w;const i=zt(),s=i.palette,[d,c]=p.useState("1h"),[l,u]=p.useState(!1),f=[...t].sort((I,v)=>new Date(v.timestamp).getTime()-new Date(I.timestamp).getTime()),m=hi.find(I=>I.key===d),h=cu(t,m.ms),x=()=>u(!0),b=()=>{n&&(n(du(t,m.ms)),u(!1))};return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{onClick:o,sx:{position:"fixed",inset:0,bgcolor:k(((D=s.common)==null?void 0:D.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:Me(i),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${k(((g=s.common)==null?void 0:g.black)??"#000",.14)}, 0 2px 8px ${k(((j=s.common)==null?void 0:j.black)??"#000",.08)}`,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,borderBottom:"1px solid",borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary"},children:"Audit History"}),e.jsx(ir,{content:sr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:[f.length," event",f.length!==1?"s":""," recorded"]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Select,{value:d,onChange:I=>c(I.target.value),size:"small",variant:"outlined",sx:{fontSize:"0.75rem",height:30,minWidth:120,"& .MuiSelect-select":{py:.375,px:1,fontSize:"0.75rem"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:k(s.text.primary,.3)}},children:hi.map(I=>e.jsx(r.MenuItem,{value:I.key,sx:{fontSize:"0.8125rem"},children:I.label},I.key))}),e.jsx(r.Button,{size:"small",variant:"outlined",color:"error",startIcon:e.jsx(B.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:x,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:k(s.error.main,.5),"&:hover":{bgcolor:k(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:17}})})]})]}),e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:k(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:k(s.text.primary,.14),borderRadius:3}},children:f.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[e.jsx(B.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",color:"text.secondary",fontWeight:500},children:"No audit events yet"}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:f.map(I=>{const v=kd(i,I.feature),{summary:S,detail:C}=va(I);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:k(s.text.primary,.18)}},children:[e.jsx(r.Chip,{label:Ca(I.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:k(v,.1),color:v,border:`1px solid ${k(v,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:S}),C&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:C}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(B.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:wa(I.timestamp)})]}),I.user&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(B.Person,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:I.user})]})]})]})]},I.id)})})})]})}),e.jsxs(r.Dialog,{open:l,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Xr(i),boxShadow:`0 8px 32px ${k(((w=s.common)==null?void 0:w.black)??"#000",.14)}`}},children:[e.jsxs(r.DialogContent,{sx:{pt:3,pb:2,px:3},children:[e.jsx(r.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:k(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),e.jsxs(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",e.jsxs(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[h," audit record",h!==1?"s":""]})," ",m.key==="all"?"from all time":`from the ${m.label.toLowerCase()}`,". This action cannot be undone."]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[e.jsx(r.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:b,variant:"contained",color:"error",startIcon:e.jsx(B.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",h," Record",h!==1?"s":""]})]})]})]})}function pu({onSave:t,onClose:o}){const[n,i]=p.useState(""),[s,d]=p.useState(""),[c,l]=p.useState(""),[u,f]=p.useState([]),[m,h]=p.useState(""),[x,b]=p.useState(""),D=C=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C),g=()=>{const C=c.trim();if(C){if(!D(C)){b("Please enter a valid email address");return}if(u.includes(C)){b("This email is already added");return}f([...u,C]),l(""),b("")}},j=C=>{f(u.filter(a=>a!==C))},w=C=>{C.key==="Enter"&&(C.preventDefault(),g())},I=()=>{if(!n.trim()){h("Preset name is required");return}t(n.trim(),s.trim(),u.length>0?u:void 0)},v=C=>{i(C),m&&h("")},S=C=>{l(C),x&&b("")};return e.jsx(r.Box,{onClick:o,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:C=>k(C.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:C=>C.zIndex.modal,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:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:C=>Me(C),bgcolor:"background.paper",outline:"none",boxShadow:C=>te(C,"menu"),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:"action.hover",color:"text.primary"}},children:e.jsx(B.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:C=>k(C.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:C=>k(C.palette.text.primary,.3)}}},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(r.Alert,{severity:"info",icon:e.jsx(B.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:C=>`1px solid ${k(C.palette.primary.main,.3)}`,bgcolor:C=>Re(C),"& .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:C=>v(C.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:"divider"},"&: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:C=>d(C.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:"divider"},"&: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:C=>S(C.target.value),onKeyPress:w,placeholder:"Enter email address",error:!!x,helperText:x,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(B.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&: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:g,variant:"outlined",startIcon:e.jsx(B.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:C=>`${C.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(C=>e.jsx(r.Chip,{label:C,onDelete:()=>j(C),deleteIcon:e.jsx(B.Delete,{sx:{fontSize:16}}),sx:{bgcolor:a=>Re(a),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},C))}),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:"action.hover"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:C=>`${C.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:I,variant:"contained",startIcon:e.jsx(B.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:C=>`${C.shape.borderRadius}px`,boxShadow:C=>te(C,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:C=>te(C,"hoverButton")},"&:active":{boxShadow:C=>te(C,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function xu({presetName:t,onClear:o}){return e.jsx(r.Chip,{icon:e.jsx(B.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(B.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>k(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 mu({presets:t,reportId:o,onOpenPreset:n,onDeletePreset:i,onClose:s}){const d=c=>new Date(c).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:c=>k(c.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:c=>c.zIndex.modal,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:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:c=>Me(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>te(c,"menu"),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:"action.hover",color:"text.primary"}},children:e.jsx(B.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:c=>k(c.palette.text.primary,.2)}}},children:t.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(B.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:"text.disabled",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(c=>e.jsxs(r.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:l=>te(l,"restButtonLight")}},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:c.name}),c.description&&e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:c.description})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(r.Chip,{label:`Created ${d(c.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),e.jsx(r.Chip,{label:`By ${c.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),e.jsx(r.Divider,{sx:{my:1.5,borderColor:"divider"}}),e.jsx(r.Box,{sx:{display:"flex",gap:1},children:e.jsx(r.Button,{onClick:()=>i(c.id,c.name),variant:"outlined",size:"small",startIcon:e.jsx(B.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:l=>k(l.palette.error.main,.04)}},children:"Delete"})})]},c.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:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:c=>`${c.shape.borderRadius}px`,boxShadow:c=>te(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>te(c,"hoverButton")},"&:active":{boxShadow:c=>te(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const Zi={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},hu=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],fu=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function gu(t,o){const n=[];for(const i of t){if(i.type!=="string")continue;const s=fu.some(l=>l.test(i.name));let d=!1;const c=o.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);c.length>0&&(d=c.filter(u=>hu.some(f=>f.test(u))).length/c.length>.6),(s||d)&&n.push(i.name)}return n}function un(t,o){if(t.length===0||o.length===0)return 0;const n=t.slice(0,Math.min(50,t.length)),s=o.map(c=>{const l=n.map(f=>String(f[c]??"")).filter(f=>f.length>0);if(l.length===0)return 5;const u=l.reduce((f,m)=>f+m.length,0);return Math.ceil(u/l.length)+1}).reduce((c,l)=>c+l,0)+1;return o.reduce((c,l)=>c+l.length+1,0)+s*t.length}function yu(t,o){const n=un(t,o);return Math.ceil(n*3.5)}function bu(t,o){const n=un(t,o);return Math.ceil(n*.7)}function vu(t,o,n){switch(t){case"csv":return un(o,n);case"excel":return bu(o,n);case"json":return yu(o,n)}}function fi(t,o){return Math.ceil(t/o)}function Su(t,o,n,i,s=Zi){const d=[],c=vu(t,o,n),l=o.length;if(l>s.maxRowsHard){const m=fi(l,s.maxRows);d.push({type:"row_count",severity:"error",message:`Export blocked: ${l.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${m} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const m=fi(l,s.maxRows);d.push({type:"row_count",severity:"warning",message:`Large export: ${l.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${m} smaller export${m>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?d.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${Yr(c)} exceeds the ${Yr(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:c,limit:s.maxFileSizeHardBytes}):c>s.maxFileSizeBytes&&d.push({type:"file_size",severity:"warning",message:`Large file: estimated ${Yr(c)}`,detail:`This exceeds the recommended ${Yr(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),t!=="excel"){const m=gu(i.filter(h=>n.includes(h.name)),o);if(m.length>0){const h=m.length>s.maxImageColumns;d.push({type:"image_columns",severity:h?"error":"warning",message:`Image column${m.length>1?"s":""} detected: ${m.map(x=>`"${x.replace(/_/g," ")}"`).join(", ")}`,detail:h?`Exporting ${m.length} image columns may produce a very large file. Consider hiding these columns before exporting.`:"Image URL columns are included in the export as plain text links — not embedded images.",value:m.length,limit:s.maxImageColumns})}}const u=d.some(m=>m.severity==="error"),f=d.some(m=>m.severity==="warning");return{violations:d,hasBlockingViolation:u,hasWarning:f,estimatedBytes:c}}function Yr(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ju({violation:t}){const n=zt().palette,i=t.severity==="error",s=i?n.error.main:n.warning.main,d=k(i?n.error.main:n.warning.main,.06),c=i?k(n.error.main,.25):k(n.warning.main,.3),l=i?B.ErrorOutline:B.WarningAmberOutlined;return e.jsxs(r.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"8px",bgcolor:d,border:"1px solid",borderColor:c},children:[e.jsx(l,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:t.message}),t.detail&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:t.detail}),t.suggestedBatches&&t.suggestedBatches>1&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[e.jsx(B.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",fontWeight:500},children:["Suggestion: split into ",t.suggestedBatches," exports"]})]})]})]})}function Cu({totalRows:t,visibleRows:o,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:d,sampleRows:c=[],allRows:l=[],processedRows:u=[],onExport:f,onClose:m}){var M,W,V;const h=zt(),x=h.palette,b=nr(),[D,g]=p.useState(b.export.allowedFormats[0]||"csv"),[j,w]=p.useState("visible"),[I,v]=p.useState("visible"),S=j==="visible"?o:t,C=I==="visible"?i:s,a=p.useMemo(()=>j==="visible"?u.length>0?u:new Array(o):l.length>0?l:new Array(t),[j,o,t,u,l]),z=p.useMemo(()=>I==="all"?d.map(Q=>Q.name):d.map(Q=>Q.name).slice(0,i),[I,d,i]),R=p.useMemo(()=>Su(D,a,z,d,Zi),[D,a,z,d]),q=()=>{R.hasBlockingViolation||(f({format:D,scope:j,columnScope:I}),m())},K={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"},ee={alignItems:"flex-start",px:1.5,py:.875,borderRadius:"8px",mx:0,transition:"background-color 0.15s","&:hover":{bgcolor:"action.hover"}},y={color:"text.secondary","&.Mui-checked":{color:"primary.main"},pt:.125};return e.jsx(r.Box,{onClick:m,sx:{position:"fixed",inset:0,bgcolor:k(((M=x.common)==null?void 0:M.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:h.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:Q=>Q.stopPropagation(),elevation:0,sx:{width:480,maxWidth:"calc(100vw - 48px)",maxHeight:"min(680px, calc(100vh - 180px))",display:"flex",flexDirection:"column",borderRadius:Me(h),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${k(((W=x.common)==null?void 0:W.black)??"#000",.14)}, 0 2px 8px ${k(((V=x.common)==null?void 0:V.black)??"#000",.08)}`,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},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",borderColor:"divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary"},children:"Export Report"}),e.jsx(ir,{content:sr.export,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:m,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.Box,{sx:{flex:1,overflowY:"auto",px:3,py:2.5,display:"flex",flexDirection:"column",gap:2.5,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:k(x.text.primary,.15),borderRadius:3}},children:[R.violations.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:R.violations.map((Q,xe)=>e.jsx(ju,{violation:Q},xe))}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Format"}),e.jsxs(r.RadioGroup,{value:D,onChange:Q=>g(Q.target.value),children:[b.export.allowedFormats.includes("csv")&&e.jsx(r.FormControlLabel,{value:"csv",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"CSV"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Comma-separated values, compatible with Excel"})]}),sx:{...ee,mb:.5}}),b.export.allowedFormats.includes("excel")&&e.jsx(r.FormControlLabel,{value:"excel",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Excel (.xlsx)"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Native Excel format with formatting support"})]}),sx:{...ee,mb:.5}}),b.export.allowedFormats.includes("json")&&e.jsx(r.FormControlLabel,{value:"json",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"JSON"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Structured data with metadata and filters"})]}),sx:ee})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Rows"}),e.jsxs(r.RadioGroup,{value:j,onChange:Q=>w(Q.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible rows"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",o.toLocaleString()," rows (filtered and searched)"]})]}),sx:{...ee,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All rows"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",t.toLocaleString()," rows (complete original dataset)"]})]}),sx:ee})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Columns"}),e.jsxs(r.RadioGroup,{value:I,onChange:Q=>v(Q.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible columns only"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",i," visible column",i!==1?"s":""]})]}),sx:{...ee,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All columns"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export all ",s," columns (including hidden)"]})]}),sx:ee})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Divider,{sx:{mb:2}}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[{label:"Format",value:K[D]},{label:"Rows to export",value:S.toLocaleString()},{label:"Columns to export",value:String(C)},{label:"Estimated file size",value:Yr(R.estimatedBytes),highlight:R.hasBlockingViolation?"error.main":R.hasWarning?"warning.main":void 0}].map(({label:Q,value:xe,highlight:de})=>e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary"},children:Q}),e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.8125rem",color:de??"text.primary"},children:xe})]},Q))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:k(x.text.primary,.015)},children:[R.hasBlockingViolation&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[e.jsx(B.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"error.main",fontWeight:500},children:"Reduce rows or columns to enable download"})]}),e.jsx(r.Button,{onClick:m,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:2.5,borderRadius:"8px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:q,disabled:R.hasBlockingViolation,variant:"contained",startIcon:e.jsx(B.Download,{sx:{fontSize:16}}),sx:{fontSize:"0.875rem",px:2.5,borderRadius:"8px"},children:["Download ",K[D]]})]})]})})}function wu({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(B.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:e.jsx(B.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 ku({error:t,onDismiss:o,autoDismiss:n=!0,autoDismissDelay:i=5e3}){p.useEffect(()=>{if(n){const l=setTimeout(()=>{o()},i);return()=>clearTimeout(l)}},[n,i,o]);const d=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(B.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(B.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(B.InfoOutlined,{sx:{fontSize:20}})}}})(),c=$a(t);return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:d.severity,icon:d.icon,action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:`${d.severity}.main`},children:e.jsx(B.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${d.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 Tu extends p.Component{constructor(n){super(n);bn(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){rr.error("urm:error-boundary","Caught unhandled component error",n,i),this.props.onError&&this.props.onError(n,i)}render(){var n,i;return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx(r.Paper,{sx:{bgcolor:s=>k(s.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(B.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:((n=this.state.error)==null?void 0:n.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:s=>k(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),e.jsx(r.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(B.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function zu({feature:t}){const[o,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),e.jsx(r.Collapse,{in:o,unmountOnExit:!0,children:e.jsxs(r.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(B.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:e.jsx(B.Close,{sx:{fontSize:16}})}),children:[e.jsxs(r.AlertTitle,{children:[t," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Lr({children:t,feature:o,onError:n}){return e.jsx(Tu,{context:o,onError:i=>{n&&n(i)},fallback:e.jsx(zu,{feature:o}),children:t})}const Bu=[{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"}],Iu=[{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 Fr({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 Du({open:t,onClose:o,config:n,onApply:i}){const[s,d]=p.useState(0),[c,l]=p.useState(n),u=()=>l(n),f=()=>l(qe),m=()=>{i(c),o()},h={sort:j=>l(w=>({...w,sort:{...w.sort,...j}})),filter:j=>l(w=>({...w,filter:{...w.filter,...j}})),columns:j=>l(w=>({...w,columns:{...w.columns,...j}})),grouping:j=>l(w=>({...w,grouping:{...w.grouping,...j}})),export:j=>l(w=>({...w,export:{...w.export,...j}}))},x=j=>{const w=c.filter.allowedOperators,I=w.includes(j)?w.filter(v=>v!==j):[...w,j];I.length!==0&&h.filter({allowedOperators:I})},b=j=>{const w=c.export.allowedFormats,I=w.includes(j)?w.filter(v=>v!==j):[...w,j];I.length!==0&&h.export({allowedFormats:I})},D=[{label:"Sort",icon:e.jsx(B.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(B.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(B.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(B.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(B.Download,{sx:{fontSize:17}})}],g=j=>JSON.stringify(c[j])===JSON.stringify(qe[j]);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:j=>Me(j),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:j=>`0 8px 32px ${k(j.palette.common.black,.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:j=>k(j.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(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(r.Tabs,{value:s,onChange:(j,w)=>d(w),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:D.map((j,w)=>e.jsx(r.Tab,{label:j.label,icon:j.icon,iconPosition:"start"},w))})}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Fr,{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"}),!g("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:(j,w)=>h.sort({maxLevels:w}),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(Fr,{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"}),!g("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:(j,w)=>h.filter({maxConditions:w}),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(j=>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:j}),e.jsx(r.FormGroup,{row:!0,sx:{gap:.5},children:Bu.filter(w=>w.group===j).map(w=>e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(w.value),onChange:()=>x(w.value)}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:w.label}),sx:{mr:1.5}},w.value))})]},j))]})]}),e.jsxs(Fr,{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"}),!g("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:(j,w)=>h.columns({maxVisible:w}),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:(j,w)=>h.columns({minColumnWidth:w}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:j=>`${j}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:(j,w)=>h.columns({maxColumnWidth:w}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:j=>`${j}px`})]})]})]})]}),e.jsxs(Fr,{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"}),!g("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(j=>e.jsxs(r.Box,{onClick:()=>h.grouping({maxLevels:j}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===j?"primary.main":"divider",bgcolor:c.grouping.maxLevels===j?w=>k(w.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:w=>k(w.palette.primary.main,.04)}},children:[e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===j?"primary.main":"text.secondary"},children:j}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][j-1]})]},j))}),e.jsxs(r.FormGroup,{row:!0,sx:{gap:2},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:c.grouping.allowNested,onChange:j=>h.grouping({allowNested:j.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:j=>h.grouping({allowCollapse:j.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(Fr,{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"}),!g("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:Iu.map(j=>e.jsxs(r.Box,{onClick:()=>b(j.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(j.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(j.value)?w=>k(w.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(r.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(j.value),onChange:()=>b(j.value),onClick:w=>w.stopPropagation()}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:j.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:j.desc})]})]},j.value))})]})})]}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:j=>k(j.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(r.Button,{startIcon:e.jsx(B.RestartAlt,{sx:{fontSize:18}}),onClick:f,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:j=>k(j.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:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(r.Button,{onClick:m,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const Eu=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ou={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 xo(t,o,n,i,s=new Date){const[d,c]=o.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(d,c,0,0),t==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(t==="weekly"){const u=n??1,f=l.getDay();let m=u-f;return m<0&&(m+=7),m===0&&l<=s&&(m=7),l.setDate(l.getDate()+m),l.toISOString()}if(t==="monthly"){const u=Math.min(i??1,28);return l.setDate(u),l<=s&&(l.setMonth(l.getMonth()+1),l.setDate(u)),l.toISOString()}return l.toISOString()}function Au(t){const o=es(t.time);return t.frequency==="daily"?`Daily at ${o}`:t.frequency==="weekly"?`Every ${Eu[t.dayOfWeek??1]} at ${o}`:t.frequency==="monthly"?`Monthly on the ${Ou[t.dayOfMonth??1]??`${t.dayOfMonth}th`} at ${o}`:o}function es(t){const[o,n]=t.split(":").map(Number),i=o>=12?"PM":"AM";return`${o%12||12}:${String(n).padStart(2,"0")} ${i}`}function $u(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),d=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${d}m`:d>0?`in ${d}m`:"in less than a minute"}function Mu(t){const o=new Date(t),n=new Date,i=o.toDateString()===n.toDateString(),s=es(`${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 ts(t){return`urm_schedules_${t}`}function rs(t){try{const o=localStorage.getItem(ts(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 os(t,o){try{localStorage.setItem(ts(t),JSON.stringify(o))}catch{}}const Ru=[{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"}],_u=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ns={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},tr={"& .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 Wu({initial:t=ns,isEditing:o=!1,onSave:n,onBack:i}){const[s,d]=p.useState(t),[c,l]=p.useState(!1),[u,f]=p.useState(!1),m=(b,D)=>d(g=>({...g,[b]:D})),h=s.email.trim().length>0&&!_u.test(s.email.trim()),x=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!h;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:b=>k(b.palette.text.primary,.06)}},children:e.jsx(B.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:b=>{m("name",b.target.value),c&&b.target.value.trim()&&l(!1)},onBlur:()=>l(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:c&&!s.name.trim(),helperText:c&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:tr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:tr,children:[e.jsx(r.InputLabel,{children:"Frequency"}),e.jsxs(r.Select,{value:s.frequency,label:"Frequency",onChange:b=>m("frequency",b.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:tr,children:[e.jsx(r.InputLabel,{children:"Day of week"}),e.jsx(r.Select,{value:s.dayOfWeek,label:"Day of week",onChange:b=>m("dayOfWeek",Number(b.target.value)),children:Ru.map(b=>e.jsx(r.MenuItem,{value:b.value,children:b.label},b.value))})]}),s.frequency==="monthly"&&e.jsx(r.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:b=>m("dayOfMonth",Number(b.target.value)),inputProps:{min:1,max:28},error:s.dayOfMonth<1||s.dayOfMonth>28,helperText:s.dayOfMonth<1||s.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:tr}),e.jsx(r.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:b=>m("time",b.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:tr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:tr,children:[e.jsx(r.InputLabel,{children:"Export format"}),e.jsxs(r.Select,{value:s.format,label:"Export format",onChange:b=>m("format",b.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:b=>m("scope",b.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:b=>m("email",b.target.value),onBlur:()=>f(!0),placeholder:"user@company.com",error:u&&h,helperText:u&&h?"Enter a valid email address":void 0,InputProps:{startAdornment:e.jsx(B.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:tr}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[e.jsx(B.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:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:b=>k(b.palette.text.primary,.06)}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>x&&n(s),disabled:!x,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:o?"Save changes":"Create schedule"})]})]})}function Pu({scheduleName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>Xr(i),boxShadow:i=>{var s;return`0 8px 32px ${k(((s=i.palette.common)==null?void 0:s.black)??"#000",.14)}`}}},children:[e.jsxs(r.DialogContent,{sx:{pt:3,pb:2,px:3},children:[e.jsx(r.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>k(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Delete Schedule"}),e.jsxs(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",e.jsxs(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',t,'"']}),"? This action cannot be undone."]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Nu({schedule:t,tick:o,onToggle:n,onRunNow:i,onEdit:s,onDelete:d}){const c=t.isActive;return e.jsxs(r.Box,{sx:{border:"1px solid",borderColor:c?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:c?l=>k(l.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:c?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(r.Chip,{label:c?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:c?l=>k(l.palette.success.main,.1):l=>k(l.palette.text.primary,.06),color:c?"success.dark":"text.secondary"}})]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Au(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:l=>k(l.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:l=>k(l.palette.text.primary,.06),color:"text.secondary"}}),t.email&&e.jsx(r.Chip,{icon:e.jsx(B.Email,{sx:{fontSize:11}}),label:t.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>k(l.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:[c&&e.jsxs(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",$u(t.nextRunAt)]}),t.lastRunAt?e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Mu(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:()=>s(t),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:l=>k(l.palette.primary.main,.08)}},children:e.jsx(B.Edit,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:c?"Pause":"Resume",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>n(t.id),sx:{color:c?"warning.main":"success.main","&:hover":{bgcolor:c?l=>k(l.palette.warning.main,.08):l=>k(l.palette.success.main,.08)}},children:c?e.jsx(B.Pause,{sx:{fontSize:15}}):e.jsx(B.PlayArrow,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Export now",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>i(t),sx:{color:"primary.main","&:hover":{bgcolor:l=>k(l.palette.primary.main,.08)}},children:e.jsx(B.Download,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Delete",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>d(t.id),sx:{color:"error.main","&:hover":{bgcolor:l=>k(l.palette.error.main,.08)}},children:e.jsx(B.Delete,{sx:{fontSize:15}})})})]})]})]})}function Lu({open:t,onClose:o,reportId:n,reportName:i,onRunNow:s}){const[d,c]=p.useState([]),[l,u]=p.useState({type:"list"}),[f,m]=p.useState(0),[h,x]=p.useState(null);p.useEffect(()=>{t&&(c(rs(n)),u({type:"list"}))},[t,n]),p.useEffect(()=>{if(!t)return;const z=setInterval(()=>m(R=>R+1),3e4);return()=>clearInterval(z)},[t]);const b=p.useCallback(z=>{c(z),os(n,z)},[n]),D=z=>{const R=xo(z.frequency,z.time,z.dayOfWeek,z.dayOfMonth),q={id:`sched-${Date.now()}`,reportId:n,name:z.name.trim(),frequency:z.frequency,dayOfWeek:z.frequency==="weekly"?z.dayOfWeek:void 0,dayOfMonth:z.frequency==="monthly"?z.dayOfMonth:void 0,time:z.time,format:z.format,scope:z.scope,email:z.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:R,runCount:0};b([...d,q]),u({type:"list"})},g=z=>{if(l.type!=="edit")return;const R=l.schedule,q=xo(z.frequency,z.time,z.dayOfWeek,z.dayOfMonth);b(d.map(K=>K.id===R.id?{...R,name:z.name.trim(),frequency:z.frequency,dayOfWeek:z.frequency==="weekly"?z.dayOfWeek:void 0,dayOfMonth:z.frequency==="monthly"?z.dayOfMonth:void 0,time:z.time,format:z.format,scope:z.scope,email:z.email.trim()||void 0,nextRunAt:q}:K)),u({type:"list"})},j=z=>{b(d.map(R=>{if(R.id!==z)return R;const q=R.isActive?R.nextRunAt:xo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth);return{...R,isActive:!R.isActive,nextRunAt:q}}))},w=z=>{s(z);const R=new Date().toISOString();b(d.map(q=>q.id===z.id?{...q,lastRunAt:R,runCount:q.runCount+1}:q))},I=z=>{const R=d.find(q=>q.id===z)??null;x(R)},v=()=>{h&&(b(d.filter(z=>z.id!==h.id)),x(null))},S=z=>({name:z.name,frequency:z.frequency,dayOfWeek:z.dayOfWeek??1,dayOfMonth:z.dayOfMonth??1,time:z.time,format:z.format,scope:z.scope,email:z.email??""}),C=l.type!=="list",a=d.filter(z=>z.isActive).length;return e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:C,PaperProps:{sx:{borderRadius:z=>Me(z),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:z=>k(z.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.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(ir,{content:sr.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:z=>k(z.palette.text.primary,.06)}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[C&&e.jsx(Wu,{initial:l.type==="edit"?S(l.schedule):ns,isEditing:l.type==="edit",onSave:l.type==="edit"?g:D,onBack:()=>u({type:"list"})}),l.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:d.length===0?"No schedules yet":`${a} of ${d.length} active`}),e.jsx(r.Button,{startIcon:e.jsx(B.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>u({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),d.length===0?e.jsxs(r.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[e.jsx(B.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:d.map(z=>e.jsx(Nu,{schedule:z,tick:f,onToggle:j,onRunNow:w,onEdit:R=>u({type:"edit",schedule:R}),onDelete:I},z.id))})]})]}),l.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:z=>k(z.palette.warning.main,.06),border:"1px solid",borderColor:z=>k(z.palette.warning.main,.2)},children:[e.jsx(B.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:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:z=>k(z.palette.text.primary,.06)}},children:"Close"})]})]}),h&&e.jsx(Pu,{scheduleName:h.name,onConfirm:v,onCancel:()=>x(null)})]})}const Fu=6e4;function Vu({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:u,sortStack:f,onFired:m}){const h=p.useRef({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:u,sortStack:f,onFired:m});p.useEffect(()=>{h.current={reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:u,sortStack:f,onFired:m}});const x=p.useCallback(b=>{var z,R;const{reportName:D,uploadedData:g,processedData:j,schema:w,activeView:I,columnVisibility:v,columnOrder:S,filters:C,sortStack:a}=h.current;try{const q=b.scope==="all"?g:j,K=mo(q,w,C,a,I,v,S),ee=`${b.name}_scheduled`;switch(b.format){case"csv":ho(K,ee,{scope:b.scope});break;case"excel":fo(K,ee,{scope:b.scope});break;case"json":go(K,ee,{scope:b.scope});break}if(b.email){const y=encodeURIComponent(`Scheduled Report: ${b.name}`),M=encodeURIComponent(`Your scheduled report "${b.name}" has been generated.
|
|
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:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:n=>`${n.shape.borderRadius}px`,boxShadow:n=>oe(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>oe(n,"hoverButton")},"&:active":{boxShadow:n=>oe(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function xd({onFileUpload:t,onError:o,isUploading:n}){const[i,s]=u.useState(!1),[d,c]=u.useState(""),[l,p]=u.useState(!1),f=u.useRef(null),m=async k=>{if(!k.name.endsWith(".json")){o("Only .json files are allowed");return}const v=10*1024*1024;if(k.size>v){o("File size exceeds 10MB limit");return}c(k.name);try{const C=await k.text();let S;try{S=JSON.parse(C)}catch{o("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(S)){o("JSON must be an array of objects");return}if(S.length===0){o("No data rows found in JSON file");return}t(S)}catch{o("Network error — please try again")}finally{c("")}},h=k=>{k.preventDefault(),s(!0)},x=k=>{k.preventDefault(),s(!1)},b=k=>{k.preventDefault(),s(!1);const v=k.dataTransfer.files[0];v&&m(v)},E=()=>{var k;(k=f.current)==null||k.click()},g=k=>{var C;const v=(C=k.target.files)==null?void 0:C[0];v&&m(v)},j=k=>{k.stopPropagation(),p(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{onDragOver:h,onDragLeave:x,onDrop:b,onPaste:k=>k.preventDefault(),onClick:E,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?k=>z(k.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:g,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..."}),d&&e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:d})]}):e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:k=>z(k.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.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:j,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(B.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(es,{isOpen:l,onClose:()=>p(!1)})]})}function md({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=>z(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(B.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 hd({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=>z(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=>z(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.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(B.Upload,{sx:{fontSize:16}}),onClick:o,sx:{fontWeight:500},children:"Try Again"})]})}function ts({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=>z(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(B.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 fd({value:t,onChange:o,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:d,disabled:c}){const[l,p]=u.useState(!1),[f,m]=u.useState(!1),[h,x]=u.useState(-1),b=u.useRef(null),E=u.useRef(null);u.useEffect(()=>{function R(G){b.current&&!b.current.contains(G.target)&&(p(!1),m(!1))}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[]);const g=u.useCallback(()=>{m(!0),x(-1),n.length>0&&p(!0)},[n.length]),j=u.useCallback(R=>{o(R),x(-1)},[o]),k=u.useCallback(R=>{var G;o(R),i(R),p(!1),(G=E.current)==null||G.blur()},[o,i]),v=u.useCallback(R=>{x(-1),k(R)},[k]),C=u.useCallback(R=>{var G;R.key==="Enter"?h>=0&&h<n.length?(R.preventDefault(),v(n[h].query)):t.trim()&&k(t.trim()):R.key==="Escape"?(p(!1),x(-1),(G=E.current)==null||G.blur()):R.key==="ArrowDown"?(R.preventDefault(),n.length>0&&(l||p(!0),x(q=>q<n.length-1?q+1:q))):R.key==="ArrowUp"&&(R.preventDefault(),x(q=>q>0?q-1:-1))},[h,n,t,l,v,k]),S=u.useCallback(()=>{var R;o(""),(R=E.current)==null||R.focus()},[o]),w=u.useMemo(()=>n.filter(R=>R.isFavourite),[n]),a=u.useMemo(()=>n.filter(R=>!R.isFavourite),[n]),I=l&&n.length>0;return e.jsxs(r.Box,{sx:{position:"relative",width:240},ref:b,children:[e.jsx(r.TextField,{inputRef:E,size:"small",fullWidth:!0,value:t,onChange:R=>j(R.target.value),onFocus:g,onKeyDown:C,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:R=>z(R.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:R=>z(R.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",sx:{ml:.5},children:e.jsx(B.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:t?e.jsx(r.InputAdornment,{position:"end",children:e.jsx(r.IconButton,{size:"small",onClick:S,edge:"end",sx:{mr:-.5},children:e.jsx(B.Close,{sx:{fontSize:16}})})}):null}}),I&&e.jsxs(r.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[w.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"}),w.map((R,G)=>e.jsx(ci,{entry:R,isSelected:h===G,onClick:()=>v(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`fav-${R.query}`))]}),a.length>0&&e.jsxs(r.Box,{sx:{py:1},children:[w.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"}),a.map((R,G)=>{const q=w.length+G;return e.jsx(ci,{entry:R,isSelected:h===q,onClick:()=>v(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`recent-${R.query}`)})]})]})]})}const ci=u.memo(function({entry:o,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:d}){const c=u.useCallback(p=>{p.stopPropagation(),s()},[s]),l=u.useCallback(p=>{p.stopPropagation(),d()},[d]);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?p=>z(p.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?p=>z(p.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(B.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(B.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(r.IconButton,{size:"small",onClick:l,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(B.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function gd({views:t,activeViewId:o,isDirty:n,onSelectView:i,onCreateView:s,onManageViews:d,onToggleDefault:c,onToggleFavorite:l,onRestoreView:p,onPermanentDelete:f,isReadOnly:m,isAdmin:h=!1}){const x=$t(),[b,E]=u.useState(!1),[g,j]=u.useState(!1),[k,v]=u.useState({top:0,left:0}),[C,S]=u.useState(null),w=u.useRef(null),a=u.useRef(null),I=t.find(O=>O.id===o),R=I==null?void 0:I.isDefault,G=t.filter(O=>O.scope==="global"&&!O.isDeleted),q=t.filter(O=>O.scope!=="global"&&!O.isDeleted),ee=t.filter(O=>O.isFavorite&&!O.isDeleted).sort((O,H)=>(H.updatedAt||0)-(O.updatedAt||0)),y=t.filter(O=>O.isDeleted);u.useEffect(()=>{if(b&&a.current){const O=a.current.getBoundingClientRect();v({top:O.bottom+window.scrollY+8,left:O.right+window.scrollX-320})}},[b]),u.useEffect(()=>{const O=H=>{w.current&&!w.current.contains(H.target)&&a.current&&!a.current.contains(H.target)&&E(!1)};return b&&document.addEventListener("mousedown",O),()=>{document.removeEventListener("mousedown",O)}},[b]);const M=O=>{if(n&&O!==o){S(O),E(!1);return}i(O),E(!1)},W=()=>{C&&(i(C),S(null))},V=()=>{S(null)},X=(O,H=!1)=>{const re=O.scope==="global",U=!m&&(!re||h);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:o===O.id?z(x.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:o===O.id?z(x.palette.primary.main,.12):x.palette.action.hover}},children:[e.jsxs(r.Button,{onClick:()=>M(O.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[o===O.id&&e.jsx(B.Check,{sx:{fontSize:16,flexShrink:0}}),o!==O.id&&e.jsx(r.Box,{sx:{width:"16px",flexShrink:0}}),e.jsx(r.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:o===O.id?x.palette.primary.dark:x.palette.text.primary,fontWeight:o===O.id?500:400},children:O.name}),H&&e.jsx(r.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:x.palette.text.secondary,backgroundColor:x.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[U&&l&&e.jsx(r.IconButton,{onClick:te=>{te.stopPropagation(),l(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:O.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(B.Star,{sx:{fontSize:16}})}),U&&c&&!O.isDefault&&e.jsx(r.IconButton,{onClick:te=>{te.stopPropagation(),c(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Set as default",children:e.jsx(B.RadioButtonUnchecked,{sx:{fontSize:16}})})]})]},O.id)},ue=O=>e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:x.palette.action.hover},children:[e.jsx(r.Typography,{sx:{color:x.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:O.name}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[p&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),p(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Restore view",children:e.jsx(B.Undo,{sx:{fontSize:16,color:"success.main"}})}),f&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),f(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Delete permanently",children:e.jsx(B.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},O.id),ce=n||!R,F=n;return e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsxs(r.Button,{ref:a,onClick:()=>E(!b),variant:"outlined",size:"small",endIcon:e.jsx(B.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:ce?"warning.main":"text.primary",borderColor:ce?"warning.main":"divider",bgcolor:ce?z(x.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:ce?"warning.dark":"primary.main",bgcolor:ce?z(x.palette.warning.main,.2):z(x.palette.text.primary,.06),color:ce?"warning.dark":"text.primary"}},title:`View: ${(I==null?void 0:I.name)||"Default View"}`,children:[e.jsx(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(I==null?void 0:I.name)||"Default View"}),F&&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"}})]}),b&&ji.createPortal(e.jsxs(r.Box,{ref:w,sx:{position:"fixed",width:"320px",backgroundColor:x.palette.background.paper,border:`1px solid ${x.palette.divider}`,borderRadius:1,boxShadow:x.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:k.top,left:k.left},children:[G.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:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),G.map(O=>X(O,O.isDefault))]}),ee.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.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:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(B.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),ee.map(O=>X(O))]})]}),q.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.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:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),q.map(O=>X(O))]})]}),y.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Button,{onClick:()=>j(!g),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:x.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsxs(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",y.length,")"]}),e.jsx(B.ChevronRight,{sx:{fontSize:16}})]}),g&&e.jsx(r.Box,{sx:{backgroundColor:x.palette.action.hover},children:y.map(O=>ue(O))})]})]}),e.jsx(r.Box,{sx:{borderTop:`1px solid ${x.palette.divider}`}}),e.jsxs(r.Button,{onClick:()=>{s(),E(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:x.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsx(B.Add,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),e.jsxs(r.Button,{onClick:()=>{d(),E(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:x.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},children:[e.jsx(B.Settings,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body),e.jsxs(r.Dialog,{open:C!==null,onClose:V,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Jr(x)}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[e.jsx(B.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),e.jsx(r.DialogContent,{children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),e.jsxs(r.DialogActions,{sx:{px:3,pb:2,gap:1},children:[e.jsx(r.Button,{onClick:V,variant:"text",children:"Stay here"}),e.jsx(r.Button,{onClick:W,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function yd({columnName:t,columnType:o="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:d=!1,hasModifications:c=!1,position:l,onSortAscending:p,onSortDescending:f,onRemoveSort:m,onFilter:h,onClearFilter:x,onGroupByColumn:b,onHideColumn:E,onManageColumns:g,onManageViews:j,onResetLayout:k,onClose:v}){var ee,y;const C=$t(),S=C.palette,w=u.useRef(null);u.useEffect(()=>{if(!w.current)return;const M=w.current,W=M.getBoundingClientRect(),V=window.innerWidth,X=window.innerHeight;W.right>V-8&&(M.style.left=`${V-W.width-8}px`),W.bottom>X-8&&(M.style.top=`${X-W.height-8}px`)},[l]),u.useEffect(()=>{const M=V=>{w.current&&!w.current.contains(V.target)&&v()},W=V=>{V.key==="Escape"&&v()};return document.addEventListener("mousedown",M),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",W)}},[v]);const a=u.useCallback(M=>()=>{M(),v()},[v]),I=(n==null?void 0:n.direction)==="asc",R=(n==null?void 0:n.direction)==="desc",G=o==="number"?"0→9":o==="boolean"?"F→T":"A→Z",q=o==="number"?"9→0":o==="boolean"?"T→F":"Z→A";return ji.createPortal(e.jsxs(r.Paper,{ref:w,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:C.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:Jr(C),overflow:"hidden",boxShadow:`0 4px 20px ${z(((ee=S.common)==null?void 0:ee.black)??"#000",.12)}, 0 1px 4px ${z(((y=S.common)==null?void 0:y.black)??"#000",.06)}`},children:[!d&&e.jsxs(r.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary"},children:"Sorting"}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[e.jsx(r.Tooltip,{title:`Sort Ascending (${G})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(()=>p(t)),sx:{p:.625,borderRadius:"6px",color:I?"primary.main":"text.secondary",bgcolor:I?z(S.primary.main,.1):"transparent","&:hover":{bgcolor:z(S.primary.main,.08),color:"primary.main"}},children:e.jsx(B.ArrowUpward,{sx:{fontSize:16}})})}),e.jsx(r.Tooltip,{title:`Sort Descending (${q})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(()=>f(t)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?z(S.primary.main,.1):"transparent","&:hover":{bgcolor:z(S.primary.main,.08),color:"primary.main"}},children:e.jsx(B.ArrowDownward,{sx:{fontSize:16}})})}),e.jsx(r.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:!s,onClick:a(()=>m(t)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:z(S.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:e.jsx(B.Close,{sx:{fontSize:16}})})})})]})]}),e.jsxs(r.MenuList,{dense:!0,sx:{py:.5},children:[e.jsxs(r.MenuItem,{onClick:a(()=>h(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!d&&e.jsxs(r.MenuItem,{onClick:a(()=>x(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:z(S.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!d&&b&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.25}}),e.jsx(r.MenuList,{dense:!0,sx:{py:.5},children:e.jsxs(r.MenuItem,{onClick:a(()=>b(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),e.jsx(r.Divider,{sx:{my:.25}}),e.jsxs(r.MenuList,{dense:!0,sx:{py:.5},children:[!d&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[e.jsxs(r.MenuItem,{onClick:a(()=>E(t)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),e.jsx(r.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(g),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:z(S.primary.main,.08),color:"primary.main"}},children:e.jsx(B.Settings,{sx:{fontSize:16}})})})]}),d&&e.jsxs(r.MenuItem,{onClick:a(g),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),j&&e.jsxs(r.MenuItem,{onClick:a(j),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.TableRows,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Views",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!d&&c&&k&&e.jsxs(r.MenuItem,{onClick:a(k),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:z(S.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(B.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const bd=176,di="COLUMN_HEADER",vd=u.memo(function({column:o,index:n,sortRule:i,hasFilters:s,isInSortStack:d,isReadOnly:c=!1,hasModifications:l=!1,width:p,onColumnClick:f,onMoveColumn:m,onColumnDragEnd:h,onResizeStart:x,onSortAscending:b,onSortDescending:E,onRemoveSort:g,onOpenFilterForColumn:j,onClearFiltersForColumn:k,onGroupByColumn:v,onHideColumn:C,onManageColumns:S,onManageViews:w,onResetLayout:a}){const I=u.useRef(null),[R,G]=u.useState(!1),[q,ee]=u.useState({x:0,y:0}),[{handlerId:y,isOver:M},W]=Dt.useDrop({accept:di,collect(U){return{handlerId:U.getHandlerId(),isOver:U.isOver()}},hover(U,te){var ge;if(!I.current)return;const se=U.index,ne=n;if(se===ne)return;const P=(ge=I.current)==null?void 0:ge.getBoundingClientRect(),ie=(P.right-P.left)/2,de=te.getClientOffset(),ae=((de==null?void 0:de.x)??0)-P.left;se<ne&&ae<ie||se>ne&&ae>ie||(m(se,ne),U.index=ne)}}),[{isDragging:V},X]=Dt.useDrag({type:di,item:()=>({index:n,columnName:o.name}),collect:U=>({isDragging:U.isDragging()}),end:()=>{h==null||h()}});X(W(I));const ue=u.useCallback(U=>{U.preventDefault(),U.stopPropagation(),ee({x:U.clientX,y:U.clientY}),G(!0)},[]),ce=u.useCallback(()=>G(!1),[]),F=u.useCallback(()=>{f(o.name)},[f,o.name]),O=u.useCallback(U=>{U.stopPropagation(),j(o.name)},[j,o.name]),H=u.useCallback(()=>i?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?e.jsx(B.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(B.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:"primary.contrastText",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),re=u.useCallback(()=>s?e.jsx(B.FilterList,{onClick:O,titleAccess:"Active filter on this column — click to edit",sx:{ml:.5,fontSize:13,color:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.15)"},transition:"transform 0.12s ease"}}):null,[s,O]);return e.jsxs(e.Fragment,{children:[e.jsxs(r.TableCell,{ref:I,"data-handler-id":y,"data-column-index":n,onClick:F,onContextMenu:ue,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:V?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:M?U=>z(U.palette.primary.main,.08):"action.hover",boxShadow:U=>`0 1px 0 ${z(U.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:"1px solid",borderColor:"divider",py:0,px:2,height:34,"&:hover":{bgcolor:U=>z(U.palette.primary.main,.1),color:"primary.dark"},width:p?`${p}px`:`${bd}px`},children:[e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[qe(o.name),H(),re()]}),e.jsx(r.Box,{draggable:!1,onDragStart:U=>U.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:U=>{U.preventDefault(),U.stopPropagation(),x(U,o.name)},onClick:U=>U.stopPropagation(),children:e.jsx(r.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),M&&e.jsx(r.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),R&&e.jsx(yd,{columnName:o.name,columnType:o.type,currentSort:i,hasFilters:s,isInSortStack:d,isReadOnly:c,hasModifications:l,position:q,onSortAscending:b,onSortDescending:E,onRemoveSort:g,onFilter:j,onClearFilter:k,onGroupByColumn:v,onHideColumn:C,onManageColumns:S,onManageViews:w,onResetLayout:a,onClose:ce})]})}),Sd={active:"success",completed:"success",approved:"success",success:"success",done:"success",contract:"info","in progress":"info","in review":"info",review:"info",pending:"info","on leave":"error","on hold":"warning",probation:"warning",cancelled:"error",rejected:"error",blocked:"error",inactive:"neutral","not started":"neutral",paused:"neutral"};function bo(t,o){const n=Sd[o.toLowerCase().trim()];if(!n||n==="neutral")return{bg:t.palette.action.selected,color:t.palette.text.secondary};const i=t.palette[n];return{bg:z(i.main,t.palette.mode==="dark"?.24:.12),color:t.palette.mode==="dark"?i.light:i.dark}}function jd(t,o){switch(o.toLowerCase().trim()){case"low":return t.palette.text.secondary;case"medium":return t.palette.warning.main;case"high":return t.palette.warning.dark;case"critical":case"urgent":return t.palette.error.main;default:return}}const Cd={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"}};function wd(t,o){const n=Cd[o];return n?t.palette[n.hue][n.shade]:t.palette.text.secondary}function Pe(t){return z(t.palette.primary.main,t.palette.mode==="dark"?.24:.12)}function kd(t){const o=t.toLowerCase().trim();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=>bo(n,o).bg,color:n=>bo(n,o).color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function Td(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 kd(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return e.jsx(r.Box,{component:"span",sx:d=>{const c=jd(d,s);return c?{color:c,fontWeight:600,fontSize:"0.8125rem"}:{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 zd(t){const o=t.find(s=>{const d=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(d)})||t[0]||null,n=t.find(s=>{const d=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(d)&&s!==o})||null,i=t.filter(s=>s!==o&&s!==n).slice(0,4);return{primaryCol:o,idCol:n,bodyColumns:i}}function Id({row:t,rowIndex:o,visibleColumns:n,isSelected:i,isReadOnly:s,onToggleSelection:d,onView:c,onEdit:l,onDuplicate:p,onDelete:f}){const[m,h]=u.useState(null),[x,b]=u.useState(!1),{primaryCol:E,idCol:g,bodyColumns:j}=u.useMemo(()=>zd(n),[n]),k=E?t[E.name]:null,v=g?t[g.name]:null,C=x||i||!!m;return e.jsxs(r.Box,{onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),onClick:()=>d(o),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":S=>z(S.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?S=>`0 0 0 3px ${z(S.palette.primary.main,.15)}, 0 2px 8px ${z(S.palette.common.black,.08)}`:x?S=>oe(S,"cardHover"):S=>oe(S,"cardRest"),transform:x&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:S=>z(S.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:k!=null&&k!==""?String(k):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:[j.map(S=>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:qe(S.name)}),e.jsx(r.Box,{sx:{flex:1,lineHeight:1},children:Td(S,t[S.name])})]},S.name)),j.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:S=>z(S.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:v?.85:0,userSelect:"none"},children:v?String(v):" "}),e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:C?1:0,transition:"opacity 0.15s ease"},onClick:S=>S.stopPropagation(),children:e.jsx(r.Tooltip,{title:"More actions",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:S=>{S.stopPropagation(),h(S.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:S=>z(S.palette.text.primary,.08)}},children:e.jsx(B.MoreVert,{sx:{fontSize:17}})})})})]}),e.jsxs(r.Popover,{open:!!m,anchorEl:m,onClose:()=>h(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:S=>oe(S,"popover")}},onClick:S=>S.stopPropagation(),children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{c(t),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(B.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),!s&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{l(t,o),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(B.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),!s&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{p(o,t),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(B.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),!s&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{f(o,t),h(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(B.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Bd({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:s=>oe(s,"flatHover"),"&:hover":{bgcolor:s=>z(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(B.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(B.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Ei(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=>z(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,d])=>Bi(d)).filter(Boolean).join(" • ")})]})}function Ed({data:t,visibleColumns:o,grouping:n,selectedRowIds:i,isReadOnly:s,isGrouped:d,sortStack:c=[],onSort:l,onToggleRowSelection:p,onToggleGroupCollapse:f,onViewRow:m,onEditRow:h,onDuplicateRow:x,onDeleteRow:b}){const E=u.useMemo(()=>{const g=new Set;return i.forEach(j=>{const k=j==null?void 0:j.__urm_row_id__;k!==void 0&&g.add(k)}),g},[i]);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.jsxs(r.Box,{sx:{fontFamily:g=>g.typography.fontFamily},children:[l&&o.length>0&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,px:2,py:1,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper",flexWrap:"wrap"},children:[e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",fontWeight:500,mr:.5,whiteSpace:"nowrap"},children:"Sort by:"}),o.map(g=>{const j=c.find(k=>k.column===g.name);return e.jsxs(r.Box,{onClick:()=>l(g.name),sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.25,py:.375,borderRadius:"6px",border:"1px solid",borderColor:j?"primary.main":"divider",bgcolor:j?k=>z(k.palette.primary.main,.07):"transparent",cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light",bgcolor:k=>z(k.palette.primary.main,.05)}},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",fontWeight:j?600:400,color:j?"primary.main":"text.secondary",whiteSpace:"nowrap"},children:qe(g.name)}),j?j.direction==="asc"?e.jsx(B.ArrowUpward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(B.ArrowDownward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(B.SwapVert,{sx:{fontSize:12,color:"text.disabled"}})]},g.name)})]}),e.jsx(r.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(272px, 1fr))",gap:1.5,alignContent:"start"},children:t.map((g,j)=>d&&g.isGroupHeader?e.jsx(Bd,{row:g,grouping:n,onToggleCollapse:f||(()=>{})},`group-${g.groupKey}`):e.jsx(Id,{row:g,rowIndex:j,visibleColumns:o,isSelected:E.has(g==null?void 0:g.__urm_row_id__),isReadOnly:s,onToggleSelection:()=>p(g),onView:m,onEdit:h,onDuplicate:x,onDelete:b},`card-${j}`))})]})}const ui=[10,15,25,50,100];function Dd(t,o){const n=t.trim();if(n==="")return"Page number is required";if(!/^-?\d+$/.test(n))return"Must be a number";const i=parseInt(n,10);return i<1?"Page number must be at least 1":i>o?"Entered page number is out of range":null}function Od({currentPage:t,pageSize:o,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:d}){var M;const l=$t().palette,p=Math.ceil(n/o),[f,m]=u.useState(String(t)),[h,x]=u.useState(null),[b,E]=u.useState(!1),g=u.useRef(null);u.useEffect(()=>{b||(m(String(t)),x(null))},[t,b]);const j=u.useCallback(()=>{const W=Dd(f,p);if(W){x(W);return}const V=parseInt(f.trim(),10);x(null),E(!1),V!==t&&s(V)},[f,p,t,s]),k=u.useCallback(W=>{var V;W.key==="Enter"?(W.preventDefault(),j()):W.key==="Escape"&&(m(String(t)),x(null),E(!1),(V=g.current)==null||V.blur())},[j,t]),v=u.useCallback(()=>{m(String(t)),x(null),E(!1)},[t]),C=u.useCallback(()=>{E(!0),x(null),setTimeout(()=>{var W;return(W=g.current)==null?void 0:W.select()},0)},[]);if(n<=Math.min(...ui))return null;const S=()=>{m(String(t)),x(null),E(!1)},w=()=>{S(),s(1)},a=()=>{S(),t>1&&s(t-1)},I=()=>{S(),t<p&&s(t+1)},R=()=>{S(),s(p)},G=(t-1)*o+1,q=Math.min(t*o,n),ee=`${Math.max(2,String(p).length+.5)}ch`,y={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};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:W=>d(Number(W.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:ui.map(W=>e.jsx(r.MenuItem,{value:W,sx:{fontSize:"0.8125rem"},children:W},W))})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[G,"–",q," of ",n]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),e.jsxs(r.Box,{sx:{position:"relative"},children:[h&&e.jsx(r.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:z(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${z(((M=l.common)==null?void 0:M.black)??"#000",.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:z(l.error.main,.4)}},children:e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:500,color:"error.main",lineHeight:1.3},children:h})}),e.jsx(r.InputBase,{inputRef:g,value:f,onChange:W=>{m(W.target.value),h&&x(null)},onKeyDown:k,onFocus:C,onBlur:v,inputProps:{"aria-label":`Page number, 1 to ${p}`,style:{textAlign:"center",padding:"2px 0",width:ee,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:h?"error.main":"text.primary",border:"1px solid",borderColor:h?"error.main":b?"primary.main":"divider",borderRadius:"4px",bgcolor:h?z(l.error.main,.04):b?z(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:h?"error.main":"text.secondary"},"&:focus-within":{boxShadow:h?`0 0 0 2px ${z(l.error.main,.2)}`:`0 0 0 2px ${z(l.primary.main,.2)}`}}})]}),e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",p]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.IconButton,{onClick:w,disabled:t===1,size:"small",title:"First page",sx:y,children:e.jsx(B.FirstPage,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:a,disabled:t===1,size:"small",title:"Previous page",sx:y,children:e.jsx(B.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:I,disabled:t===p,size:"small",title:"Next page",sx:y,children:e.jsx(B.ChevronRight,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:R,disabled:t===p,size:"small",title:"Last page",sx:y,children:e.jsx(B.LastPage,{sx:{fontSize:20}})})]})]})]})}function $d(){return e.jsx(r.Chip,{icon:e.jsx(B.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const rs="urm_hint_seen_";function Ad(t){try{return localStorage.getItem(rs+t)==="true"}catch{return!1}}function Md(t){try{localStorage.setItem(rs+t,"true")}catch{}}function pi(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 xi(t){const o={fontSize:11};switch(t){case"number":return e.jsx(B.Numbers,{sx:o});case"boolean":return e.jsx(B.CheckBox,{sx:o});case"array":return e.jsx(B.DataArray,{sx:o});case"object":return e.jsx(B.DataObject,{sx:o});default:return e.jsx(B.TextFields,{sx:o})}}function mi(t,o){var n,i;switch(t){case"number":return{bg:z(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:z(((n=o.success)==null?void 0:n.main)??"#2e7d32",.08),color:((i=o.success)==null?void 0:i.main)??"#2e7d32"};case"array":case"object":return{bg:z(o.secondary.main,.08),color:o.secondary.main};default:return{bg:z(o.text.secondary,.07),color:o.text.secondary}}}function Rd({open:t,onClose:o,row:n,schema:i,reportName:s}){var h,x;const d=$t(),c=d.palette;if(!n)return null;const l=i.filter(b=>b.name in n),p=l.filter(b=>b.type!=="object"&&b.type!=="array"),f=l.filter(b=>b.type==="object"||b.type==="array"),m=l.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:_e(d),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${z(((h=c.common)==null?void 0:h.black)??"#000",.14)}, 0 2px 8px ${z(((x=c.common)==null?void 0:x.black)??"#000",.08)}`,overflow:"hidden"}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:z(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"View Record"}),s&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",m," ",m===1?"field":"fields"]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:0,overflowY:"auto",flex:1,bgcolor:z(c.text.primary,.015)},children:[p.length>0&&e.jsx(r.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"1px",bgcolor:"divider",m:2,mb:f.length>0?1.5:2,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:p.map((b,E)=>{const g=n[b.name],j=pi(g,b.type),k=!j,v=mi(b.type,c),C=E===p.length-1&&p.length%2!==0;return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",px:2,py:1.75,gridColumn:C?"span 2":"span 1",display:"flex",flexDirection:"column",gap:.75},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,px:.75,py:.25,borderRadius:"4px",bgcolor:v.bg,color:v.color,flexShrink:0},children:xi(b.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:qe(b.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:k?400:500,color:k?"text.disabled":"text.primary",fontStyle:k?"italic":"normal",lineHeight:1.5,wordBreak:"break-word",fontFamily:b.type==="number"?'"Roboto Mono", monospace':"inherit"},children:k?"No value":j})]},b.name)})}),f.map(b=>{const E=n[b.name],g=pi(E,b.type),j=!g,k=mi(b.type,c);return e.jsxs(r.Box,{sx:{mx:2,mb:1.5,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{px:2,py:1.25,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,px:.75,py:.25,borderRadius:"4px",bgcolor:k.bg,color:k.color},children:xi(b.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:qe(b.name)}),e.jsx(r.Chip,{label:b.type,size:"small",sx:{height:18,fontSize:"0.625rem",fontWeight:600,ml:"auto",bgcolor:k.bg,color:k.color,border:"none",letterSpacing:"0.03em"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:2,py:1.5,bgcolor:z(c.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:j?"text.disabled":"text.primary",fontStyle:j?"italic":"normal",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6},children:j?"No value":g})]},b.name)}),l.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(B.VisibilityOutlined,{sx:{fontSize:40,opacity:.4}}),e.jsx(r.Typography,{variant:"body2",children:"No fields to display"})]})]}),e.jsx(r.Divider,{}),e.jsx(r.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:o,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:b=>`${b.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function _d({open:t,onClose:o,onConfirm:n,rowPreview:i}){return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:s=>_e(s),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:s=>oe(s,"menu")}},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:s=>z(s.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.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:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{sx:{px:3,pb:2},children:e.jsx(r.Box,{sx:{p:2,borderRadius:"8px",bgcolor:s=>z(s.palette.error.main,.1),border:s=>`1px solid ${z(s.palette.error.main,.5)}`},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:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,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(B.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,boxShadow:s=>oe(s,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:s=>oe(s,"hoverButton")},"&:active":{boxShadow:s=>oe(s,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function tn(t){const o={fontSize:11};switch(t){case"number":return e.jsx(B.Numbers,{sx:o});case"boolean":return e.jsx(B.CheckBox,{sx:o});case"array":return e.jsx(B.DataArray,{sx:o});case"object":return e.jsx(B.DataObject,{sx:o});default:return e.jsx(B.TextFields,{sx:o})}}function hi(t,o){var n,i;switch(t){case"number":return{bg:z(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:z(((n=o.success)==null?void 0:n.main)??"#2e7d32",.08),color:((i=o.success)==null?void 0:i.main)??"#2e7d32"};case"array":case"object":return{bg:z(o.secondary.main,.08),color:o.secondary.main};default:return{bg:z(o.text.secondary,.07),color:o.text.secondary}}}function Wd({open:t,onClose:o,onSave:n,row:i,schema:s,reportName:d}){var j,k,v;const c=$t(),l=c.palette,[p,f]=u.useState({});if(u.useEffect(()=>{t&&i&&f({...i})},[t,i]),!i)return null;const m=s.filter(C=>C.name in i),h=m.filter(C=>C.type!=="object"&&C.type!=="array"),x=m.filter(C=>C.type==="object"||C.type==="array"),b=(C,S)=>{f(w=>({...w,[C]:S}))},E=()=>{const C={...p};m.forEach(S=>{const w=p[S.name];if(S.type==="number"){const a=Number(w);C[S.name]=isNaN(a)?i[S.name]:a}else S.type==="boolean"&&(C[S.name]=!!w)}),n(C),o()},g=m.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:_e(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${z(((j=l.common)==null?void 0:j.black)??"#000",.14)}, 0 2px 8px ${z(((k=l.common)==null?void 0:k.black)??"#000",.08)}`,overflow:"hidden"}},children:[e.jsxs(r.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[e.jsx(r.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:z(((v=l.warning)==null?void 0:v.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),d&&e.jsxs(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[d," · ",g," ",g===1?"field":"fields"]})]})]}),e.jsx(r.IconButton,{size:"small",onClick:o,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:z(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[h.length>0&&e.jsxs(r.Box,{children:[h.length>1&&e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.08em",mb:1.25},children:"Fields"}),e.jsx(r.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:1.5},children:h.map((C,S)=>{const w=p[C.name],a=hi(C.type,l),I=C.type==="boolean",R=!I&&S===h.filter(q=>q.type!=="boolean").length-1&&h.filter(q=>q.type!=="boolean").length%2!==0,G=I||R;return C.type==="boolean"?e.jsxs(r.Box,{sx:{gridColumn:"span 2",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",px:2,py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,transition:"border-color 0.15s","&:hover":{borderColor:"primary.main"}},children:[e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.25},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:tn(C.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:qe(C.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",ml:.25},children:w?"Enabled":"Disabled"})]}),e.jsx(r.Switch,{checked:!!w,onChange:q=>b(C.name,q.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}})]},C.name):e.jsxs(r.Box,{sx:{gridColumn:G?"span 2":"span 1",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",overflow:"hidden",transition:"border-color 0.15s","&:focus-within":{borderColor:"primary.main",boxShadow:`0 0 0 2px ${z(l.primary.main,.12)}`}},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:z(l.text.primary,.02),display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:tn(C.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:qe(C.name)})]}),e.jsx(r.TextField,{value:w??"",onChange:q=>b(C.name,q.target.value),type:C.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"standard",placeholder:`Enter ${C.type==="number"?"number":"value"}…`,InputProps:{disableUnderline:!0},sx:{"& .MuiInputBase-root":{px:1.5,py:1,fontSize:"0.875rem",fontWeight:500,color:"text.primary",fontFamily:C.type==="number"?'"Roboto Mono", monospace':"inherit"},"& .MuiInputBase-input":{p:0,"&::placeholder":{color:"text.disabled",opacity:1,fontWeight:400}}}})]},C.name)})})]}),x.length>0&&e.jsxs(r.Box,{children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Read-only Fields"}),e.jsx(r.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:e.jsx(B.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:x.map(C=>{const S=i[C.name];let w="";try{w=S==null?"":JSON.stringify(S,null,2)}catch{w=String(S)}const a=hi(C.type,l);return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"10px",overflow:"hidden",opacity:.8},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:z(l.text.primary,.02),display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",px:.75,py:.25,borderRadius:"4px",bgcolor:a.bg,color:a.color},children:tn(C.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1},children:qe(C.name)}),e.jsx(r.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:z(l.text.secondary,.07),color:"text.secondary",border:"none"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:w?"text.primary":"text.disabled",fontStyle:w?"normal":"italic",bgcolor:z(l.text.primary,.015),overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:120,overflowY:"auto"},children:w||"No value"})]},C.name)})})]}),m.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(B.EditOutlined,{sx:{fontSize:40,opacity:.4}}),e.jsx(r.Typography,{variant:"body2",children:"No editable fields"})]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:C=>`${C.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:E,variant:"contained",startIcon:e.jsx(B.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:C=>`${C.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Pd=176,Ld=170,Nd=40;function os(t){return t.type==="date"?180:Pd}function Fd(t,o){return o!=null&&o!==Ld&&o!==os(t)}function Vd(t,o,n){return u.useMemo(()=>{const i=t.map(h=>({name:h.name,width:o[h.name]??os(h),explicit:Fd(h,o[h.name])})),s={};i.forEach(h=>{s[h.name]=h.width});const d=i.reduce((h,x)=>h+x.width,0),l=Math.max(0,n-Nd)-d;if(l<=0)return{widths:s,fillerWidth:0};const p=i.filter(h=>!h.explicit);if(p.length===0)return{widths:s,fillerWidth:l};const f=p.reduce((h,x)=>h+x.width,0)||1;let m=0;return p.forEach((h,x)=>{const E=x===p.length-1?h.width+l-m:Math.round(h.width+l*h.width/f);s[h.name]=E,m+=E-h.width}),{widths:s,fillerWidth:0}},[t,o,n])}const fi=176,Hd={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Ud(t){const o=t.toLowerCase().trim();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=>bo(n,o).bg,color:n=>bo(n,o).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function Gd(t){const o=t.toLowerCase().trim(),n=Hd[o];return n?e.jsx(r.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function Yd(t,o){const n=o.trim();if(!n)return t;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=t.split(new RegExp(`(${i})`,"gi"));return s.length===1?t:s.map((d,c)=>d.toLowerCase()===n.toLowerCase()?e.jsx(r.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:d},c):d)}function qd(t,o,n,i=""){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(o);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase()))return Ud(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase()))return Gd(s);if(t.type==="date"){const l=t.dateFormat??"iso",p=qs(o,l,n??null);return e.jsx(r.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:p})}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:"text.disabled"},children:"[ ]"});const l=o.slice(0,3).map(p=>typeof p=="object"?JSON.stringify(p):String(p)).join(", ");return e.jsxs(r.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[l,o.length>3?` +${o.length-3} more`:""]})}if(typeof o=="object"){const l=JSON.stringify(o);return e.jsx(r.Box,{component:"span",title:l,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:l.length>40?l.slice(0,40)+"…":l})}return Yd(s,i)}function Jd({schema:t,data:o,sortStack:n=[],filters:i=[],views:s=[],activeViewId:d="",isDirty:c=!1,isExporting:l=!1,columnVisibility:p={},columnOrder:f=[],columnWidths:m={},grouping:h=null,onSort:x,onSortAscending:b,onSortDescending:E,onOpenFilters:g,onOpenSort:j,onOpenFilterForColumn:k,onSelectView:v,onCreateView:C,onManageViews:S,onUpdateCurrentView:w,onSaveAsNewView:a,onDiscardChanges:I,onToggleDefault:R,onToggleFavorite:G,onRestoreView:q,onPermanentDelete:ee,isAdmin:y=!1,onExport:M,onOpenColumns:W,onUpdateColumnWidth:V,onUpdateColumnOrder:X,onUpdateColumnVisibility:ue,onClearFiltersForColumn:ce,onResetLayout:F,onOpenGroup:O,onGroupByColumn:H,onToggleGroupCollapse:re,onOpenAuditHistory:U,onOpenScheduledReports:te,searchQuery:se,highlightQuery:ne="",searchHistory:P=[],onAddToSearchHistory:ie,onToggleSearchFavourite:de,onDeleteSearchHistory:ae,selectedRowIds:ge=new Set,onSearchChange:K,onToggleRowSelection:Ee,onToggleAllRows:Ue,onRangeSelection:it,onClearSelection:St,onExportSelected:et,currentPage:xr=1,pageSize:jt=15,totalRowsBeforePagination:mr=o.length,onPageChange:st,onPageSizeChange:qt,isReadOnly:Me=!1,userRole:at,reportName:lt,onEditRow:tt,onDuplicateRow:Ve,onDeleteRow:At,showDevPanel:Er=!1,onOpenDevConfig:hr}){var eo;const[Jt,Kt]=u.useState(null),[fr,gr]=u.useState(0),[ct,Xt]=u.useState(0),[Ct,dt]=u.useState(null),Dr=((eo=dr().dates)==null?void 0:eo.displayFormat)??null,[Ke,yr]=u.useState(null),[Mt,Te]=u.useState(null),[Or,Rt]=u.useState(null),[ut,N]=u.useState(!1),[rt,be]=u.useState(!1),[Fe,Qt]=u.useState(null),[_t,br]=u.useState(""),[Wt,Pt]=u.useState(!1),[$r,Zt]=u.useState(null),[ze,Q]=u.useState(null),[fe,me]=u.useState(null),[vr,Xe]=u.useState(null),Lt=u.useRef(null),pt=u.useCallback(()=>{Lt.current&&(clearTimeout(Lt.current),Lt.current=null)},[]),er=u.useCallback(()=>{pt(),Lt.current=setTimeout(()=>Xe(null),200)},[pt]);u.useEffect(()=>pt,[pt]);const[Sr,ot]=u.useState(null),[He,xt]=u.useState("list"),[mt,tr]=u.useState(!1),[Nt,jr]=u.useState(()=>!Ad("toolbar_search")),Ft=u.useRef(null),rr=u.useRef(null),[Ar,wt]=u.useState(0);u.useLayoutEffect(()=>{const D=Ft.current;if(!D)return;wt(D.clientWidth);const Y=new ResizeObserver(pe=>{wt(pe[0].contentRect.width)});return Y.observe(D),()=>Y.disconnect()},[]);const ht=u.useCallback(()=>{Md("toolbar_search"),jr(!1)},[]);u.useEffect(()=>{if(!Nt)return;const D=setTimeout(ht,2e3);return()=>clearTimeout(D)},[Nt,ht]);const Cr=u.useMemo(()=>{const D=Ct??f;return D.length>0?D.map(Y=>t.find(pe=>pe.name===Y)).filter(Y=>Y!==void 0):t},[Ct,f,t]),Le=u.useMemo(()=>Cr.filter(D=>p[D.name]!==!1),[Cr,p]),{widths:kt,fillerWidth:Tt}=Vd(Le,m,Ar),nt=u.useMemo(()=>t.filter(D=>p[D.name]===!1).length,[t,p]),or=u.useMemo(()=>t.map(D=>D.name),[t]),zt=u.useMemo(()=>f.length===0?!1:JSON.stringify(f)!==JSON.stringify(or),[f,or]),le=u.useCallback((D,Y)=>{D.preventDefault(),D.stopPropagation(),Kt(Y),gr(D.clientX),Xt(m[Y]||150)},[m]);u.useEffect(()=>{if(!Jt)return;const D=pe=>{const Ne=pe.clientX-fr,xe=Math.max(100,Math.min(600,ct+Ne));V==null||V(Jt,xe)},Y=()=>{Kt(null)};return document.addEventListener("mousemove",D),document.addEventListener("mouseup",Y),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",Y)}},[Jt,fr,ct,V]);const ye=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(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[Y.direction==="asc"?e.jsx(B.ArrowUpward,{sx:{fontSize:14}}):e.jsx(B.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:Y.priority})]}):null},[n]),u.useCallback(D=>i.some(pe=>pe.column===D)?e.jsx(r.IconButton,{size:"small",onClick:pe=>{pe.stopPropagation(),k==null||k(D)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(B.FilterList,{sx:{fontSize:14}})}):null,[i,k]);const Re=u.useCallback(D=>{x&&x(D)},[x]),Vt=u.useCallback((D,Y)=>{dt(pe=>{const xe=[...pe??(f.length>0?f:t.map(ir=>ir.name))],[nr]=xe.splice(D,1);return xe.splice(Y,0,nr),xe})},[f,t]),Ht=u.useCallback(()=>{Ct&&X&&X(Ct),dt(null)},[Ct,X]),_o=u.useCallback(D=>{if(!x)return;const Y=n.find(pe=>pe.column===D);(!Y||Y.direction!=="asc")&&x(D)},[x,n]),Wo=u.useCallback(D=>{if(!x)return;const Y=n.find(pe=>pe.column===D);Y?Y.direction==="asc"&&x(D):(x(D),setTimeout(()=>x(D),0))},[x,n]),Po=u.useCallback(D=>{if(!x)return;const Y=n.find(pe=>pe.column===D);Y&&(Y.direction==="asc"?(x(D),setTimeout(()=>x(D),0)):Y.direction==="desc"&&x(D))},[x,n]),Lo=u.useCallback(D=>{ue&&ue(D,!1)},[ue]),Xr=(h==null?void 0:h.enabled)&&o.length>0&&o[0]&&"isGroupHeader"in o[0],No=n.length>0||i.length>0||((h==null?void 0:h.enabled)??!1)||Object.values(p).some(D=>D===!1),Fo=(xr-1)*jt,We=o,It=u.useMemo(()=>{const D=new Set;return ge.forEach(Y=>{const pe=Y==null?void 0:Y.__urm_row_id__;pe!==void 0&&D.add(pe)}),D},[ge]);u.useEffect(()=>{const D=Y=>{!Ue||!St||Y.target instanceof HTMLInputElement||Y.target instanceof HTMLTextAreaElement||((Y.ctrlKey||Y.metaKey)&&Y.key==="a"&&(Y.preventDefault(),Ue(!0,We)),Y.key==="Escape"&&(Y.preventDefault(),St()))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[Ue,St,We]);const Qr=u.useCallback((D,Y)=>{Ee&&(Y.shiftKey&&Ke!==null?(Y.preventDefault(),it&&it(Ke,D,We)):(Ee(We[D]),yr(D)))},[Ee,Ke,it,We]);!u.useMemo(()=>We.length>0&&It.size>0&&We.every(D=>It.has(D==null?void 0:D.__urm_row_id__)),[We,It])&&We.some(D=>It.has(D==null?void 0:D.__urm_row_id__));const Mr=Ee&&Ue,Vo=u.useCallback(D=>{var Ne;const Y=D.groupLevel,pe=Y*24;return e.jsx(r.TableRow,{onClick:()=>re==null?void 0:re(D.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(r.TableCell,{colSpan:Le.length+(Mr?1:0),sx:{pl:`${pe+24}px`},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[D.isCollapsed?e.jsx(B.ChevronRight,{sx:{fontSize:16}}):e.jsx(B.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:Ei(Y,((Ne=h==null?void 0:h.levels[Y])==null?void 0:Ne.column)||"",D.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:xe=>z(xe.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(([xe,nr])=>Bi(nr)).filter(Boolean).join(" • ")})]})})},D.groupKey)},[Le,Mr,h,re]),Zr=u.useCallback((D,Y)=>{const pe=It.has(D==null?void 0:D.__urm_row_id__),Ne=Mt===Y;return e.jsxs(r.TableRow,{"data-row-index":Y,onMouseEnter:()=>Te(Y),onMouseLeave:()=>Te(null),onClick:xe=>{!Ee||xe.target.closest("[data-row-action-btn]")||Qr(Y,xe)},onContextMenu:xe=>{xe.preventDefault(),xe.stopPropagation(),Xe(null),me({mouseX:xe.clientX,mouseY:xe.clientY,row:D,rowIndex:Y})},sx:{height:34,cursor:"pointer",bgcolor:pe?xe=>z(xe.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:pe?xe=>z(xe.palette.warning.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[Le.map(xe=>e.jsx(r.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,textAlign:"left",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"1px solid",borderColor:"divider",minWidth:m[xe.name]?`${m[xe.name]}px`:`${xe.type==="date"?Math.max(fi,180):fi}px`},children:qd(xe,D[xe.name],Dr,ne)},xe.name)),e.jsx(r.TableCell,{sx:{p:0,border:"none",borderBottom:"1px solid",borderColor:"divider"}}),e.jsx(r.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:40,minWidth:40,maxWidth:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",background:Ne?xe=>`linear-gradient(to right, transparent, ${pe?z(xe.palette.warning.main,.12):xe.palette.background.paper} 32px)`:"transparent",opacity:Ne?1:0,transition:"opacity 0.12s ease, background 0.12s ease",zIndex:10,verticalAlign:"middle"},children:e.jsx(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",height:"100%",px:1,gap:.25},children:e.jsx(r.IconButton,{"data-row-action-btn":"true",size:"small",onClick:xe=>{xe.stopPropagation(),xe.preventDefault(),Xe(null),me({anchorEl:xe.currentTarget,row:D,rowIndex:Y})},sx:{color:"text.secondary",opacity:Ne?1:0,transition:"opacity 0.12s ease",pointerEvents:Ne?"auto":"none","&:hover":{bgcolor:xe=>z(xe.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(B.MoreVert,{sx:{fontSize:18}})})})})]},Y)},[ge,Fo,Mt,Qr,Le,m,ne,ye,tt,Ve,At,Ee,Rt,N,me]);return e.jsxs(Dt.DndProvider,{backend:an.HTML5Backend,children:[e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[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:[Me&&e.jsx($d,{}),K&&ie&&de&&ae&&e.jsx(r.Tooltip,{open:Nt,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:ht},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(fd,{value:se||"",onChange:D=>{Nt&&ht(),K(D)},searchHistory:P,onAddToHistory:ie,onToggleFavourite:de,onDeleteHistory:ae,disabled:Me})})}),e.jsx(r.Tooltip,{title:"JSON format guide",children:e.jsx(r.IconButton,{size:"small",onClick:()=>tr(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:D=>z(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(B.InfoOutlined,{sx:{fontSize:20}})})}),v&&C&&S&&w&&s.length>0&&e.jsx(gd,{views:s||[],activeViewId:d||"",isDirty:c,onSelectView:v,onCreateView:C,onManageViews:S,onToggleDefault:R,onToggleFavorite:G,onRestoreView:q,onPermanentDelete:ee,isAdmin:y,isReadOnly:Me}),c&&!Me&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,ml:1},children:[I&&e.jsx(r.Button,{onClick:I,size:"small",variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",minWidth:0,px:1},children:"Discard"}),a&&e.jsx(r.Button,{onClick:a,size:"small",variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",minWidth:0,px:1},children:"Save as new view"}),w&&e.jsx(r.Button,{onClick:w,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",px:2,boxShadow:"none"},children:"Save"})]}),Er&&hr&&e.jsx(r.Tooltip,{title:"Developer configuration",children:e.jsx(r.IconButton,{size:"small",onClick:hr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:D=>z(D.palette.text.secondary,.3),"&:hover":{bgcolor:D=>z(D.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(B.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(r.Box,{sx:{flexGrow:1}}),!Me&&j&&e.jsx(r.Tooltip,{title:"Sort",children:e.jsxs(r.IconButton,{onClick:j,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?D=>Pe(D):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?D=>z(D.palette.primary.main,.2):D=>z(D.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(B.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Me&&g&&e.jsx(r.Tooltip,{title:"Filter",children:e.jsxs(r.IconButton,{onClick:g,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?D=>Pe(D):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?D=>z(D.palette.primary.main,.2):D=>z(D.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(B.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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:i.length})]})}),!Me&&W&&e.jsx(r.Tooltip,{title:"Show/Hide Columns",children:e.jsxs(r.IconButton,{onClick:W,size:"small",sx:{position:"relative",color:nt>0||zt?"primary.main":"text.secondary",bgcolor:nt>0||zt?D=>Pe(D):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:nt>0||zt?D=>z(D.palette.primary.main,.2):D=>z(D.palette.text.primary,.06),color:nt>0||zt?"primary.main":"text.primary"}},children:[e.jsx(B.ViewColumn,{sx:{fontSize:20}}),nt>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:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:nt})]})}),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:He==="list"?"primary.main":"text.secondary",bgcolor:He==="list"?D=>Pe(D):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:He==="list"?D=>z(D.palette.primary.main,.2):D=>z(D.palette.text.primary,.06),color:He==="list"?"primary.main":"text.primary"}},children:e.jsx(B.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:He==="grid"?"primary.main":"text.secondary",bgcolor:He==="grid"?D=>Pe(D):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:He==="grid"?D=>z(D.palette.primary.main,.2):D=>z(D.palette.text.primary,.06),color:He==="grid"?"primary.main":"text.primary"}},children:e.jsx(B.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=>ot(D.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:D=>z(D.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(B.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(r.Popover,{open:!!Sr,anchorEl:Sr,onClose:()=>ot(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:[M&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{M(),ot(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Export"})]}),!Me&&O&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{O(),ot(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Grouping"})]}),U&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{U(),ot(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Audit History"})]}),te&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{te(),ot(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Scheduled Reports"})]})]}),e.jsxs(r.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[He==="grid"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:e.jsx(Ed,{data:We,visibleColumns:Le,grouping:h,selectedRowIds:ge,isReadOnly:Me,isGrouped:!!Xr,sortStack:n,onSort:x,onToggleRowSelection:Ee||(()=>{}),onToggleGroupCollapse:re,onViewRow:D=>{Rt(D),N(!0)},onEditRow:(D,Y)=>{Zt(D),Q(Y),Pt(!0)},onDuplicateRow:(D,Y)=>Ve==null?void 0:Ve(D,Y),onDeleteRow:(D,Y)=>{Qt(Y);const pe=Object.values(Y).find(Ne=>Ne!=null&&Ne!=="");br(pe?String(pe):""),be(!0)}})}),He==="list"&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[e.jsx(r.Box,{ref:Ft,onScroll:D=>{rr.current&&(rr.current.scrollLeft=D.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e.jsxs(r.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(kt).reduce((D,Y)=>D+Y,0)+Tt+40}px`},children:[e.jsxs("colgroup",{children:[Le.map(D=>e.jsx("col",{style:{width:`${kt[D.name]}px`}},D.name)),e.jsx("col",{style:{width:`${Tt}px`}}),e.jsx("col",{style:{width:"40px"}})]}),e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[Le.map((D,Y)=>e.jsx(vd,{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),isReadOnly:Me,hasModifications:No,width:m[D.name],onColumnClick:Re,onMoveColumn:Vt,onColumnDragEnd:Ht,onResizeStart:le,onSortAscending:b||_o,onSortDescending:E||Wo,onRemoveSort:Po,onOpenFilterForColumn:k||(()=>{}),onClearFiltersForColumn:ce||(()=>{}),onGroupByColumn:H,onHideColumn:Lo,onManageColumns:W||(()=>{}),onManageViews:S,onResetLayout:F},D.name)),e.jsx(r.TableCell,{sx:{p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}}),e.jsx(r.TableCell,{sx:{width:40,minWidth:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}})]})})]})}),e.jsx(r.Box,{ref:rr,onScroll:D=>{Ft.current&&(Ft.current.scrollLeft=D.target.scrollLeft)},sx:{flex:1,overflowY:"auto",overflowX:"auto",minHeight:0,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",borderSpacing:0,width:"100%",minWidth:`${Object.values(kt).reduce((D,Y)=>D+Y,0)+Tt+40}px`},children:[e.jsxs("colgroup",{children:[Le.map(D=>e.jsx("col",{style:{width:`${kt[D.name]}px`}},D.name)),e.jsx("col",{style:{width:`${Tt}px`}}),e.jsx("col",{style:{width:"40px"}})]}),e.jsx(r.TableBody,{children:We.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:Le.length+(Mr?1:0),align:"center",sx:{py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Xr?We.map((D,Y)=>D.isGroupHeader?Vo(D):Zr(D,Y)):We.map((D,Y)=>Zr(D,Y))})]})})]}),st&&qt&&e.jsx(Od,{currentPage:xr,pageSize:jt,totalRows:mr,totalFields:t.length,onPageChange:st,onPageSizeChange:qt}),!(st&&qt)&&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:!!fe,onClose:()=>{me(null),Xe(null)},anchorEl:(fe==null?void 0:fe.anchorEl)||null,anchorReference:fe!=null&&fe.anchorEl?"anchorEl":"anchorPosition",anchorPosition:fe&&!fe.anchorEl?{top:fe.mouseY,left:fe.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:fe!=null&&fe.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:()=>{fe&&(Rt(fe.row),N(!0)),me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{fe&&(Zt(fe.row),Q(fe.rowIndex),Pt(!0)),me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{fe&&(Ve==null||Ve(fe.rowIndex,fe.row)),me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),It.size>0&&et&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5}}),e.jsxs(r.MenuItem,{dense:!0,onMouseEnter:D=>{pt(),Xe(D.currentTarget)},onMouseLeave:er,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(B.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsxs(r.Typography,{variant:"body2",children:["Export Selected (",It.size,")"]})]}),e.jsx(B.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),e.jsx(r.Popper,{open:!!vr,anchorEl:vr,placement:"right-start",transition:!0,sx:{zIndex:D=>D.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:D})=>e.jsx(r.Grow,{...D,timeout:150,children:e.jsx(r.Paper,{onMouseEnter:pt,onMouseLeave:er,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:e.jsxs(r.MenuList,{dense:!0,autoFocusItem:!1,children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{et("csv"),Xe(null),me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"CSV"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{et("excel"),Xe(null),me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.TableChart,{sx:{fontSize:18,color:"success.main"}}),e.jsx(r.Typography,{variant:"body2",children:"Excel"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{et("json"),Xe(null),me(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(B.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"JSON"})]})]})})})})]}),e.jsx(r.Divider,{sx:{my:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{if(fe){Qt(fe.row);const D=Object.values(fe.row).find(Y=>Y!=null&&Y!=="");br(D?String(D):""),be(!0)}me(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(B.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Rd,{open:ut,onClose:()=>{N(!1),Rt(null)},row:Or,schema:t,reportName:lt}),e.jsx(Wd,{open:Wt,onClose:()=>{Pt(!1),Zt(null),Q(null)},onSave:D=>{ze!==null&&(tt==null||tt(ze,D))},row:$r,schema:t,reportName:lt}),e.jsx(_d,{open:rt,onClose:()=>{be(!1),Qt(null)},onConfirm:()=>{Fe!==null&&(At==null||At(Fe))},rowPreview:_t}),e.jsx(es,{isOpen:mt,onClose:()=>tr(!1)})]})}function ur({content:t,isDev:o=!1}){const[n,i]=u.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=>z(s.palette.primary.main,.08)}},children:e.jsx(B.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=>z(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,d)=>e.jsx(r.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},d))}),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=>z(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>z(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 pr={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 Kd({schema:t,filters:o,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:s,onClearAll:d,onReplaceFilters:c,onClose:l,focusColumn:p}){const[f,m]=u.useState(""),[h,x]=u.useState(""),[b,E]=u.useState(""),[g,j]=u.useState([]),k=dr();u.useEffect(()=>{j([...o])},[o]),u.useEffect(()=>{p&&m(p)},[p]);const v=u.useCallback(()=>{m(""),x(""),E("")},[]),C=u.useMemo(()=>t.filter(M=>M.type!=="mixed"&&M.type!=="null"&&M.type!=="array"&&M.type!=="object"),[t]),S=t.find(M=>M.name===f),w=u.useMemo(()=>{const M=S?Mn(S.type):[],W=k.filter.allowedOperators;return W.length>0?M.filter(V=>W.includes(V.value)):M},[S]),a=u.useCallback(()=>!(!f||!h||oo(h)&&!b.trim()||g.length>=k.filter.maxConditions),[f,h,b,g,k]),I=u.useCallback(()=>{if(!a())return;const M={column:f,operator:h};if(oo(h)){const V=S==null?void 0:S.type;M.value=V==="number"?Number(b):b}if(g.some(V=>V.column===M.column&&V.operator===M.operator&&V.value===M.value)){v();return}j([...g,M]),v()},[a,f,h,S,b,g,v]),R=u.useCallback(M=>{j(g.filter((W,V)=>V!==M))},[g]),G=u.useMemo(()=>g.length!==o.length?!0:JSON.stringify(g)!==JSON.stringify(o),[g,o]),q=u.useCallback(()=>{c(g),l()},[g,c,l]),ee=u.useCallback(()=>{j([...o]),v(),l()},[o,v,l]),y=u.useCallback(M=>{var ue;const W=t.find(ce=>ce.name===M.column);if(!W)return"";const X=((ue=Mn(W.type).find(ce=>ce.value===M.operator))==null?void 0:ue.label)||M.operator;return oo(M.operator)?`${M.column} ${X.toLowerCase()} "${M.value}"`:`${M.column} ${X.toLowerCase()}`},[t]);return e.jsx(r.Box,{onClick:ee,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:M=>z(M.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:M=>M.zIndex.modal,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:M=>M.stopPropagation(),elevation:0,sx:{position:"relative",width:520,maxWidth:"calc(100vw - 120px)",maxHeight:"min(520px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:M=>_e(M),bgcolor:"background.paper",outline:"none",boxShadow:M=>oe(M,"menu"),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(ur,{content:pr.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:"action.hover",color:"text.primary"}},children:e.jsx(B.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:M=>z(M.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:M=>z(M.palette.text.primary,.3)}}},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,disabled:g.length>=k.filter.maxConditions,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Column"}),e.jsx(r.Select,{value:f,onChange:M=>{m(M.target.value),x(""),E("")},label:"Column",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:C.map(M=>e.jsxs(r.MenuItem,{value:M.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:W=>Pe(W),"&:hover":{bgcolor:W=>z(W.palette.primary.main,.2)}}},children:[qe(M.name)," (",M.type,")"]},M.name))})]}),f&&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:h,onChange:M=>{x(M.target.value),E("")},label:"Operator",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:w.map(M=>e.jsx(r.MenuItem,{value:M.value,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:W=>Pe(W),"&:hover":{bgcolor:W=>z(W.palette.primary.main,.2)}}},children:M.label},M.value))})]}),h&&oo(h)&&e.jsx(r.TextField,{size:"small",fullWidth:!0,type:(S==null?void 0:S.type)==="number"?"number":"text",value:b,onChange:M=>E(M.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:"divider",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:I,disabled:!a(),sx:{mt:1.5,fontSize:"0.875rem",color:"primary.main",p:0,justifyContent:"flex-start",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"primary.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"+ Add another filter"}),g.length>=k.filter.maxConditions&&e.jsxs(r.Typography,{variant:"caption",sx:{display:"block",mt:.75,color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Filter limit reached — maximum ",k.filter.maxConditions," filters allowed. Remove an existing filter to add a new one."]})]}),g.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 (",g.length,")"]}),e.jsx(r.Button,{onClick:()=>{d(),l()},sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:g.map((M,W)=>e.jsx(r.Chip,{label:y(M),onDelete:()=>R(W),sx:{bgcolor:V=>Pe(V),color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:V=>`1px solid ${z(V.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:V=>z(V.palette.primary.main,.2),borderColor:V=>z(V.palette.primary.main,.5)},"& .MuiChip-label":{px:1.5,color:"primary.main"},"& .MuiChip-deleteIcon":{color:"primary.main",fontSize:18,transition:"all 0.2s ease","&:hover":{color:"primary.dark"}}}},W))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:ee,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:M=>`${M.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:q,disabled:!G,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:M=>`${M.shape.borderRadius}px`,boxShadow:M=>oe(M,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:M=>oe(M,"hoverButton")},"&:active":{boxShadow:M=>oe(M,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})})}const gi="SORT_RULE";function Xd({rule:t,index:o,onToggleDirection:n,onRemove:i,onMove:s}){const d=u.useRef(null),[{handlerId:c},l]=Dt.useDrop({accept:gi,collect(m){return{handlerId:m.getHandlerId()}},hover(m,h){var v;if(!d.current)return;const x=m.index,b=o;if(x===b)return;const E=(v=d.current)==null?void 0:v.getBoundingClientRect(),g=(E.bottom-E.top)/2,j=h.getClientOffset(),k=((j==null?void 0:j.y)??0)-E.top;x<b&&k<g||x>b&&k>g||(s(x,b),m.index=b)}}),[{isDragging:p},f]=Dt.useDrag({type:gi,item:()=>({index:o}),collect:m=>({isDragging:m.isDragging()})});return f(l(d)),e.jsxs(r.Box,{ref:d,"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:p?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:m=>oe(m,"restButtonLight"),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:m=>`0 1px 2px 0 ${z(m.palette.primary.main,.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:m=>n(o,m.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",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:"action.hover"},"&.Mui-selected":{bgcolor:m=>Pe(m),"&:hover":{bgcolor:m=>z(m.palette.primary.main,.2)}}},children:"Ascending"}),e.jsx(r.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:m=>Pe(m),"&:hover":{bgcolor:m=>z(m.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:m=>z(m.palette.error.main,.08),transform:"scale(1.1)"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]})}function Qd({schema:t,sortStack:o,onUpdateSortStack:n,onClose:i}){const[s,d]=u.useState(""),[c,l]=u.useState([]);u.useEffect(()=>{l([...o])},[o]);const p=u.useMemo(()=>JSON.stringify(c)!==JSON.stringify(o),[c,o]),f=dr(),m=u.useCallback(v=>{if(!v||c.length>=f.sort.maxLevels)return;const C={column:v,direction:"asc",priority:c.length+1};l([...c,C]),d("")},[c,f.sort.maxLevels]),h=u.useCallback(v=>{const S=c.filter((w,a)=>a!==v).map((w,a)=>({...w,priority:a+1}));l(S)},[c]),x=u.useCallback((v,C)=>{const S=[...c];S[v]={...S[v],direction:C},l(S)},[c]),b=u.useCallback((v,C)=>{const S=[...c],[w]=S.splice(v,1);S.splice(C,0,w);const a=S.map((I,R)=>({...I,priority:R+1}));l(a)},[c]),E=u.useCallback(()=>{n([]),i()},[n,i]),g=u.useCallback(()=>{n(c),i()},[c,n,i]),j=u.useCallback(()=>{l([...o]),d(""),i()},[o,i]),k=t.filter(v=>!c.some(C=>C.column===v.name));return e.jsx(Dt.DndProvider,{backend:an.HTML5Backend,children:e.jsx(r.Box,{onClick:j,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:v=>z(v.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:v=>v.zIndex.modal,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:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:v=>_e(v),bgcolor:"background.paper",outline:"none",boxShadow:v=>oe(v,"menu"),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(ur,{content:pr.sort,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:j,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.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:v=>z(v.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:v=>z(v.palette.text.primary,.3)}}},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>=f.sort.maxLevels,children:[e.jsx(r.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),e.jsx(r.Select,{value:s,onChange:v=>m(v.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:k.map(v=>e.jsx(r.MenuItem,{value:v.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:C=>Pe(C),"&:hover":{bgcolor:C=>z(C.palette.primary.main,.2)}}},children:qe(v.name)},v.name))})]}),c.length>=f.sort.maxLevels&&e.jsxs(r.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",f.sort.maxLevels," sort levels allowed"]})]}),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,"/",f.sort.maxLevels,")"]}),e.jsx(r.Button,{onClick:E,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:c.map((v,C)=>e.jsx(Xd,{rule:v,index:C,onToggleDirection:x,onRemove:h,onMove:b},`${v.column}-${C}`))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:j,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:v=>`${v.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:g,variant:"contained",disabled:!p||c.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:v=>`${v.shape.borderRadius}px`,boxShadow:v=>oe(v,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:v=>oe(v,"hoverButton")},"&:active":{boxShadow:v=>oe(v,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function Zd({views:t,activeViewId:o,onSelectView:n,onCreateView:i,onEditView:s,onDeleteView:d,onRestoreView:c,onPermanentDelete:l,onPromoteToGlobal:p,isAdmin:f=!1,onClose:m}){var C,S;const h=$t(),x=h.palette,b=t.filter(w=>!w.isDeleted),E=t.filter(w=>w.isDeleted),g=b.filter(w=>w.scope==="global"),j=b.filter(w=>w.scope!=="global"),k=w=>{var q,ee,y,M,W;const a=w.scope==="global",I=w.id===o,R=f||!a,G=f&&!a;return e.jsx(r.Paper,{variant:"outlined",sx:{p:0,overflow:"hidden",borderRadius:"8px",borderColor:I?"primary.main":"divider",bgcolor:I?z(x.primary.main,.03):"background.paper",transition:"border-color 0.15s","&:hover":{borderColor:I?"primary.main":z(x.text.primary,.22)}},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.75,py:1.25,gap:1},children:[e.jsxs(r.Box,{sx:{flex:1,minWidth:0,cursor:"pointer",display:"flex",alignItems:"center",gap:1},onClick:()=>{n(w.id),m()},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:I?600:500,color:I?"primary.main":"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.name}),w.description&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.description})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[a&&e.jsx(r.Chip,{label:"Global",size:"small",icon:e.jsx(B.Language,{sx:{fontSize:"11px !important"}}),sx:{height:20,fontSize:"0.625rem",fontWeight:700,letterSpacing:"0.04em",bgcolor:z(((q=x.info)==null?void 0:q.main)??x.primary.main,.1),color:((ee=x.info)==null?void 0:ee.main)??x.primary.main,border:`1px solid ${z(((y=x.info)==null?void 0:y.main)??x.primary.main,.25)}`,"& .MuiChip-label":{px:.625},"& .MuiChip-icon":{ml:.5}}}),w.isDefault&&e.jsx(r.Chip,{label:"Default",size:"small",sx:{height:20,fontSize:"0.625rem",fontWeight:600,bgcolor:z(x.text.secondary,.08),color:"text.secondary","& .MuiChip-label":{px:.75}}})]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[G&&p&&e.jsx(r.Tooltip,{title:"Promote to Global View",arrow:!0,placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:V=>{V.stopPropagation(),p(w.id)},sx:{p:.625,color:"text.secondary",borderRadius:"6px","&:hover":{color:((M=x.info)==null?void 0:M.main)??x.primary.main,bgcolor:z(((W=x.info)==null?void 0:W.main)??x.primary.main,.08)}},children:e.jsx(B.Language,{sx:{fontSize:16}})})}),R&&e.jsx(r.Tooltip,{title:a&&!f?"Global Views are read-only":"Edit view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!f,onClick:V=>{V.stopPropagation(),s(w.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"primary.main",bgcolor:z(x.primary.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(B.Edit,{sx:{fontSize:15}})})})}),e.jsx(r.Tooltip,{title:a&&!f?"Only admins can delete Global Views":"Delete view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!f,onClick:V=>{V.stopPropagation(),d(w.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:z(x.error.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(B.Delete,{sx:{fontSize:15}})})})})]})]})},w.id)},v=w=>{var a;return e.jsxs(r.Paper,{variant:"outlined",sx:{px:1.75,py:1.25,borderRadius:"8px",borderColor:"divider",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:z(x.text.primary,.02)},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",color:"text.disabled",textDecoration:"line-through",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.name}),e.jsxs(r.Box,{sx:{display:"flex",gap:.25,flexShrink:0,ml:1},children:[c&&e.jsx(r.Tooltip,{title:"Restore view",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:I=>{I.stopPropagation(),c(w.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"success.main",bgcolor:z(((a=x.success)==null?void 0:a.main)??"#2e7d32",.08)}},children:e.jsx(B.Undo,{sx:{fontSize:15}})})}),l&&e.jsx(r.Tooltip,{title:"Delete permanently",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:I=>{I.stopPropagation(),l(w.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:z(x.error.main,.08)}},children:e.jsx(B.Delete,{sx:{fontSize:15}})})})]})]},w.id)};return e.jsxs(r.Dialog,{open:!0,onClose:m,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:_e(h),maxHeight:"min(640px, calc(100vh - 80px))",boxShadow:`0 8px 32px ${z(((C=x.common)==null?void 0:C.black)??"#000",.14)}`}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600},children:"Manage Views"}),f&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:"Admin mode — you can promote Personal Views to Global"})]}),e.jsx(r.IconButton,{onClick:m,size:"small",sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:19}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",pb:2},children:[e.jsx(r.Box,{sx:{mb:2},children:e.jsx(r.Button,{onClick:i,variant:"contained",startIcon:e.jsx(B.Add,{sx:{fontSize:16}}),size:"small",sx:{borderRadius:w=>`${w.shape.borderRadius}px`},children:"Create New View"})}),g.length>0&&e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1},children:[e.jsx(B.Language,{sx:{fontSize:14,color:((S=x.info)==null?void 0:S.main)??x.primary.main}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Global Views"}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:"— visible to all users"})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:g.map(k)})]}),j.length>0&&e.jsxs(r.Box,{sx:{mb:2.5},children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.07em",mb:1},children:"Personal Views"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:j.map(k)})]}),E.length>0&&e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.disabled",textTransform:"uppercase",letterSpacing:"0.07em",mb:1},children:"Recently Deleted"}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:E.map(v)})]}),b.length===0&&E.length===0&&e.jsx(r.Box,{sx:{py:4,textAlign:"center",color:"text.disabled"},children:e.jsx(r.Typography,{variant:"body2",children:"No views created yet"})})]}),e.jsx(r.DialogActions,{sx:{px:3,py:1.5,borderTop:"1px solid",borderColor:"divider",justifyContent:"flex-end"},children:e.jsx(r.Button,{onClick:m,variant:"contained",sx:{fontSize:"0.875rem",borderRadius:w=>`${w.shape.borderRadius}px`,px:3},children:"Close"})})]})}const lo=50;function yi({currentSnapshot:t,onSave:o,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:d="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:p=10}){const[f,m]=u.useState(s),[h,x]=u.useState(!1),[b,E]=u.useState(d),[g,j]=u.useState(c),k=()=>{if(!f.trim()){x(!0);return}if(f.trim().length>lo){x(!0);return}o(f.trim(),b.trim(),g),n()},v=S=>{S.key==="Enter"&&!S.shiftKey?k():S.key==="Escape"&&n()},C=()=>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:S=>_e(S),boxShadow:S=>oe(S,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[C(),e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[l&&!i&&e.jsxs(r.Alert,{severity:"warning",sx:{borderRadius:"8px"},children:["You have reached the maximum of ",p," saved views. Delete an existing view before creating a new one."]}),e.jsx(r.TextField,{label:"View Name",required:!0,value:f,onChange:S=>{S.target.value.length<=lo&&m(S.target.value),h&&S.target.value.trim()&&x(!1)},onKeyDown:v,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:lo},error:h&&!f.trim(),helperText:h&&!f.trim()?"View name is required":`${f.length} / ${lo}`}),e.jsx(r.TextField,{label:"Description (optional)",value:b,onChange:S=>E(S.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: ",aa(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:g,onChange:S=>j(S.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:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:k,variant:"contained",disabled:l&&!i,startIcon:e.jsx(B.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,boxShadow:S=>oe(S,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:S=>oe(S,"hoverButton")},"&:active":{boxShadow:S=>oe(S,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function eu({viewName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>_e(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:i=>oe(i,"menu")}},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(B.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(B.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:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"action.selected",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>oe(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>oe(i,"hoverButton")},"&:active":{boxShadow:i=>oe(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const uo=100,po=600,bi="COLUMN";function tu({column:t,index:o,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:d,moveColumn:c}){const l=u.useRef(null),[p,f]=u.useState(i.toString());u.useEffect(()=>{f(i.toString())},[i]);const[{handlerId:m},h]=Dt.useDrop({accept:bi,collect(v){return{handlerId:v.getHandlerId()}},hover(v,C){var q;if(!l.current)return;const S=v.index,w=o;if(S===w)return;const a=(q=l.current)==null?void 0:q.getBoundingClientRect(),I=(a.bottom-a.top)/2,R=C.getClientOffset(),G=((R==null?void 0:R.y)??0)-a.top;S<w&&G<I||S>w&&G>I||(c(S,w),v.index=w)}}),[{isDragging:x},b]=Dt.useDrag({type:bi,item:()=>({index:o}),collect:v=>({isDragging:v.isDragging()})});b(h(l));const E=()=>{const v=parseInt(p);if(isNaN(v)){f(i.toString()),d(t.name,i);return}const C=Math.max(uo,Math.min(po,v));f(C.toString()),d(t.name,C)},g=v=>{if(v===""||/^\d+$/.test(v)){f(v);const C=parseInt(v);if(!isNaN(C)&&C>=uo){const S=Math.min(po,C);d(t.name,S)}}},j=v=>{v.key==="Enter"&&(v.preventDefault(),E(),v.target.blur())},k=v=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[v]||"text.secondary";return e.jsxs(r.TableRow,{ref:l,"data-handler-id":m,sx:{opacity:x?.4:1,bgcolor:n?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:n?"action.hover":"action.selected"},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(B.DragIndicator,{sx:{fontSize:20}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:qe(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:`${k(t.type)}15`,color:k(t.type),border:`1px solid ${k(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:"number",value:p,onChange:v=>g(v.target.value),onBlur:E,onKeyDown:j,placeholder:"150",size:"small",inputProps:{min:uo,max:po,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),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:"action.hover",color:n?"primary.dark":"primary.main"}},children:n?e.jsx(B.Visibility,{sx:{fontSize:20}}):e.jsx(B.VisibilityOff,{sx:{fontSize:20}})}),e.jsx(r.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?v=>z(v.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function ru({schema:t,columnVisibility:o,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:d="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:p,onResetLayout:f,onSaveToCurrentView:m,onSaveToAllViews:h,onSelectView:x,onClose:b}){const[E,g]=u.useState(!1),[j,k]=u.useState(n),[v,C]=u.useState(i),[S,w]=u.useState("all"),[a,I]=u.useState(null);u.useEffect(()=>{k(n)},[n]),u.useEffect(()=>{C(i)},[i]);const R=(F,O)=>{C(H=>({...H,[F]:O})),p==null||p(F,O)},G=(F,O)=>{const H=[...j],[re]=H.splice(F,1);H.splice(O,0,re),k(H),l(H)},q=()=>{f(),g(!1)},y=j.map(F=>t.find(O=>O.name===F)).filter(F=>F!==void 0).filter(F=>{const O=o[F.name]??!0;return S==="active"?O:S==="hidden"?!O:!0}),M=Object.values(o).filter(F=>F).length,W=t.length,V=s.find(F=>F.id===d),X=s.filter(F=>!F.isDeleted),ue=X.length>1,ce=u.useMemo(()=>{if(!V)return!1;const F=V.snapshot,O=F.columnVisibility??{},H=JSON.stringify(o)!==JSON.stringify(O),re=F.columnOrder??[],U=n??[],te=JSON.stringify(U)!==JSON.stringify(re)&&!(U.length===0&&re.length===0),se=F.columnWidths??{},ne=JSON.stringify(v)!==JSON.stringify(se);return H||te||ne},[V,o,n,v]);return e.jsx(Dt.DndProvider,{backend:an.HTML5Backend,children:e.jsx(r.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:F=>z(F.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:F=>F.zIndex.modal,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: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:F=>_e(F),bgcolor:"background.paper",outline:"none",boxShadow:F=>oe(F,"menu"),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.jsx(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(ur,{content:pr.columns,isDev:process.env.NODE_ENV==="development"})]})}),X.length>0&&x&&e.jsxs(r.Box,{sx:{ml:2},children:[e.jsx(r.Button,{onClick:F=>I(F.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(B.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",fontSize:"0.875rem",color:"text.primary",borderColor:"divider",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:e.jsx(r.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(V==null?void 0:V.name)||"Select View"})}),e.jsx(r.Menu,{anchorEl:a,open:!!a,onClose:()=>I(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:F=>oe(F,"small")}},children:X.map(F=>e.jsx(r.MenuItem,{onClick:()=>{x(F.id),I(null)},selected:F.id===d,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:O=>Pe(O),"&:hover":{bgcolor:O=>z(O.palette.primary.main,.2)}}},children:F.name},F.id))})]}),e.jsx(r.IconButton,{onClick:b,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Tabs,{value:S,onChange:(F,O)=>w(O),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:F=>z(F.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:F=>z(F.palette.text.primary,.3)}}},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:"background.paper",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:"background.paper",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:"background.paper",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: ${uo}px, max: ${po}px)`,arrow:!0,placement:"top",children:e.jsx(B.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:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Visibility"})]})}),e.jsx(r.TableBody,{children:y.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"})})}):y.map((F,O)=>e.jsx(tu,{column:F,index:O,isVisible:o[F.name]??!0,width:v[F.name]||170,onToggleVisibility:c,onWidthChange:R,moveColumn:G},F.name))})]})}),e.jsx(r.Box,{sx:{px:3,py:1,borderTop:"1px solid divider",bgcolor:"background.default",flexShrink:0},children:e.jsxs(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:[M," of ",W," columns visible • Drag to reorder"]})}),e.jsxs(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:()=>g(!0),disabled:!ce,variant:"outlined",startIcon:e.jsx(B.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:F=>`${F.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"}),e.jsxs(r.Stack,{direction:"row",spacing:1.25,children:[m&&e.jsx(r.Button,{onClick:()=>{m(v),b()},disabled:!ce,variant:"contained",startIcon:e.jsx(B.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:F=>`${F.shape.borderRadius}px`,boxShadow:F=>oe(F,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:F=>oe(F,"hoverButton")},"&:active":{boxShadow:F=>oe(F,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to current view"}),h&&ue&&e.jsx(r.Button,{onClick:()=>{h(v),b()},disabled:!ce||!ue,variant:"contained",startIcon:e.jsx(B.GridView,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"success.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:F=>`${F.shape.borderRadius}px`,boxShadow:F=>oe(F,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"success.dark",boxShadow:F=>oe(F,"hoverButton")},"&:active":{boxShadow:F=>oe(F,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to all views"})]})]}),E&&e.jsx(r.Box,{onClick:()=>g(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:F=>z(F.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:F=>F.zIndex.tooltip},children:e.jsxs(r.Paper,{onClick:F=>F.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:F=>Jr(F),bgcolor:"background.paper",boxShadow:F=>oe(F,"menu")},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:"action.hover"},children:[e.jsx(r.Button,{onClick:()=>g(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:F=>`${F.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:q,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:F=>`${F.shape.borderRadius}px`,boxShadow:F=>oe(F,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:F=>oe(F,"hoverButton")},"&:active":{boxShadow:F=>oe(F,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function ou({schema:t,grouping:o,onApply:n,onClose:i}){var a;const[s,d]=u.useState(o||{enabled:!1,levels:[],collapsedGroups:[]}),[c,l]=u.useState(""),[p,f]=u.useState(null),m=u.useMemo(()=>ta(t),[t]),h=u.useMemo(()=>m.filter(I=>!s.levels.some((R,G)=>R.column===I.name&&G!==p)),[m,s.levels,p]),x=dr(),b=s.levels.length<x.grouping.maxLevels&&h.length>0,E=u.useCallback(()=>{!b||!c||(d({...s,levels:[...s.levels,{column:c}],enabled:!0}),l(""))},[b,c,s]),g=u.useCallback(I=>{const R=s.levels.filter((G,q)=>q!==I);if(R.length===0){n(null),i();return}d({...s,levels:R,enabled:R.length>0})},[s,n,i]),j=u.useCallback(I=>{f(I),l(s.levels[I].column)},[s.levels]),k=u.useCallback(()=>{if(p===null||!c)return;const I=[...s.levels];I[p]={column:c},d({...s,levels:I}),f(null),l("")},[p,c,s]),v=u.useCallback(()=>{f(null),l("")},[]),C=u.useCallback((I,R)=>{const G=R==="up"?I-1:I+1;if(G<0||G>=s.levels.length)return;const q=[...s.levels],[ee]=q.splice(I,1);q.splice(G,0,ee),d({...s,levels:q})},[s]),S=u.useCallback(()=>{n(null),i()},[n,i]),w=u.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:I=>z(I.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:I=>I.zIndex.modal,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(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:I=>_e(I),bgcolor:"background.paper",outline:"none",boxShadow:I=>oe(I,"menu"),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(ur,{content:pr.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:"action.hover",color:"text.primary"}},children:e.jsx(B.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:I=>z(I.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:I=>z(I.palette.text.primary,.3)}}},children:e.jsxs(r.Stack,{spacing:2.5,children:[p===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:I=>l(I.target.value),disabled:!b,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[e.jsx(r.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),h.map(I=>e.jsxs(r.MenuItem,{value:I.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:R=>Pe(R),"&:hover":{bgcolor:R=>z(R.palette.primary.main,.2)}}},children:[qe(I.name)," (",I.type.toUpperCase(),")"]},I.name))]})}),e.jsx(r.Button,{onClick:E,disabled:!b||!c,variant:"outlined",startIcon:e.jsx(B.Add,{sx:{fontSize:18}}),fullWidth:!0,sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",py:1,transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",bgcolor:"action.hover"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Add group level"}),s.levels.length>=x.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"}),m.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."})]}),p!==null&&e.jsxs(r.Alert,{severity:"warning",sx:{borderRadius:"8px",border:I=>`1px solid ${z(I.palette.warning.main,.5)}`,bgcolor:I=>z(I.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[e.jsxs(r.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"text.primary"},children:["Edit Group Level ",p+1]}),e.jsx(r.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:e.jsxs(r.Select,{value:c,onChange:I=>l(I.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&: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[p].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:I=>Pe(I)}},children:[s.levels[p].column," (",(a=t.find(I=>I.name===s.levels[p].column))==null?void 0:a.type.toUpperCase(),")"]}),h.filter(I=>I.name!==s.levels[p].column).map(I=>e.jsxs(r.MenuItem,{value:I.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:R=>Pe(R)}},children:[qe(I.name)," (",I.type.toUpperCase(),")"]},I.name))]})}),e.jsxs(r.Stack,{direction:"row",spacing:1.5,children:[e.jsx(r.Button,{onClick:k,disabled:!c,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:I=>oe(I,"pressedButton")}},children:"Save"}),e.jsx(r.Button,{onClick:v,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),s.levels.length>0&&p===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:S,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),e.jsx(r.Stack,{spacing:1.5,children:s.levels.map((I,R)=>{const G=t.find(q=>q.name===I.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:"action.hover",borderColor:"divider",boxShadow:q=>oe(q,"pressedButtonLight")}},children:[e.jsx(r.Chip,{label:`L${R+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:q=>`0 1px 2px 0 ${z(q.palette.primary.main,.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:I.column}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:G==null?void 0:G.type.toUpperCase()})]}),e.jsxs(r.Stack,{direction:"row",spacing:.5,children:[e.jsx(r.IconButton,{size:"small",onClick:()=>C(R,"up"),disabled:R===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(B.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>C(R,"down"),disabled:R===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(B.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>j(R),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:e.jsx(B.Edit,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>g(R),sx:{color:"text.secondary","&:hover":{bgcolor:q=>z(q.palette.error.main,.08),color:"error.main"}},children:e.jsx(B.Delete,{sx:{fontSize:18}})})]})]},R)})})]})]})}),e.jsxs(r.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[e.jsx(r.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:w,variant:"contained",disabled:s.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,boxShadow:I=>oe(I,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:I=>oe(I,"hoverButton")},"&:active":{boxShadow:I=>oe(I,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function nu({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(B.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(B.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(B.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(r.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(B.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const vi=[{key:"1h",label:"Last 1 Hour",ms:3600*1e3},{key:"24h",label:"Last 24 Hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 Days",ms:10080*60*1e3},{key:"30d",label:"Last 30 Days",ms:720*60*60*1e3},{key:"all",label:"All Time",ms:null}];function iu(t,o){if(o===null)return t.length;const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()>=n).length}function su(t,o){if(o===null)return[];const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()<n)}function au({auditHistory:t,onClose:o,onClearAuditHistory:n}){var E,g,j,k;const i=$t(),s=i.palette,[d,c]=u.useState("1h"),[l,p]=u.useState(!1),f=[...t].sort((v,C)=>new Date(C.timestamp).getTime()-new Date(v.timestamp).getTime()),m=vi.find(v=>v.key===d),h=iu(t,m.ms),x=()=>p(!0),b=()=>{n&&(n(su(t,m.ms)),p(!1))};return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{onClick:o,sx:{position:"fixed",inset:0,bgcolor:z(((E=s.common)==null?void 0:E.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:v=>v.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:_e(i),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${z(((g=s.common)==null?void 0:g.black)??"#000",.14)}, 0 2px 8px ${z(((j=s.common)==null?void 0:j.black)??"#000",.08)}`,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[e.jsxs(r.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,borderBottom:"1px solid",borderColor:"divider"},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary"},children:"Audit History"}),e.jsx(ur,{content:pr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:[f.length," event",f.length!==1?"s":""," recorded"]})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Select,{value:d,onChange:v=>c(v.target.value),size:"small",variant:"outlined",sx:{fontSize:"0.75rem",height:30,minWidth:120,"& .MuiSelect-select":{py:.375,px:1,fontSize:"0.75rem"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:z(s.text.primary,.3)}},children:vi.map(v=>e.jsx(r.MenuItem,{value:v.key,sx:{fontSize:"0.8125rem"},children:v.label},v.key))}),e.jsx(r.Button,{size:"small",variant:"outlined",color:"error",startIcon:e.jsx(B.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:x,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:z(s.error.main,.5),"&:hover":{bgcolor:z(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),e.jsx(r.IconButton,{onClick:o,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:17}})})]})]}),e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:z(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:z(s.text.primary,.14),borderRadius:3}},children:f.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[e.jsx(B.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",color:"text.secondary",fontWeight:500},children:"No audit events yet"}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:f.map(v=>{const C=wd(i,v.feature),{summary:S,detail:w}=va(v);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:z(s.text.primary,.18)}},children:[e.jsx(r.Chip,{label:Ca(v.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:z(C,.1),color:C,border:`1px solid ${z(C,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),e.jsxs(r.Box,{sx:{flex:1,minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:S}),w&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:w}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(B.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:wa(v.timestamp)})]}),v.user&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(B.Person,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:v.user})]})]})]})]},v.id)})})})]})}),e.jsxs(r.Dialog,{open:l,onClose:()=>p(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Jr(i),boxShadow:`0 8px 32px ${z(((k=s.common)==null?void 0:k.black)??"#000",.14)}`}},children:[e.jsxs(r.DialogContent,{sx:{pt:3,pb:2,px:3},children:[e.jsx(r.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:z(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),e.jsxs(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",e.jsxs(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[h," audit record",h!==1?"s":""]})," ",m.key==="all"?"from all time":`from the ${m.label.toLowerCase()}`,". This action cannot be undone."]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[e.jsx(r.Button,{onClick:()=>p(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:b,variant:"contained",color:"error",startIcon:e.jsx(B.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",h," Record",h!==1?"s":""]})]})]})]})}function lu({onSave:t,onClose:o}){const[n,i]=u.useState(""),[s,d]=u.useState(""),[c,l]=u.useState(""),[p,f]=u.useState([]),[m,h]=u.useState(""),[x,b]=u.useState(""),E=w=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w),g=()=>{const w=c.trim();if(w){if(!E(w)){b("Please enter a valid email address");return}if(p.includes(w)){b("This email is already added");return}f([...p,w]),l(""),b("")}},j=w=>{f(p.filter(a=>a!==w))},k=w=>{w.key==="Enter"&&(w.preventDefault(),g())},v=()=>{if(!n.trim()){h("Preset name is required");return}t(n.trim(),s.trim(),p.length>0?p:void 0)},C=w=>{i(w),m&&h("")},S=w=>{l(w),x&&b("")};return e.jsx(r.Box,{onClick:o,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:w=>z(w.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:w=>w.zIndex.modal,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:w=>w.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:w=>_e(w),bgcolor:"background.paper",outline:"none",boxShadow:w=>oe(w,"menu"),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:"action.hover",color:"text.primary"}},children:e.jsx(B.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:w=>z(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>z(w.palette.text.primary,.3)}}},children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[e.jsx(r.Alert,{severity:"info",icon:e.jsx(B.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:w=>`1px solid ${z(w.palette.primary.main,.3)}`,bgcolor:w=>Pe(w),"& .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:w=>C(w.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:"divider"},"&: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:w=>d(w.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:"divider"},"&: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:w=>S(w.target.value),onKeyPress:k,placeholder:"Enter email address",error:!!x,helperText:x,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(B.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&: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:g,variant:"outlined",startIcon:e.jsx(B.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:w=>`${w.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),p.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:p.map(w=>e.jsx(r.Chip,{label:w,onDelete:()=>j(w),deleteIcon:e.jsx(B.Delete,{sx:{fontSize:16}}),sx:{bgcolor:a=>Pe(a),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},w))}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:p.length>0?`An email with the shareable link will be sent to ${p.length} recipient${p.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:"action.hover"},children:[e.jsx(r.Button,{onClick:o,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:w=>`${w.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:v,variant:"contained",startIcon:e.jsx(B.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:w=>`${w.shape.borderRadius}px`,boxShadow:w=>oe(w,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:w=>oe(w,"hoverButton")},"&:active":{boxShadow:w=>oe(w,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function cu({presetName:t,onClear:o}){return e.jsx(r.Chip,{icon:e.jsx(B.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(B.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>z(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 du({presets:t,reportId:o,onOpenPreset:n,onDeletePreset:i,onClose:s}){const d=c=>new Date(c).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:c=>z(c.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:c=>c.zIndex.modal,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:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:c=>_e(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>oe(c,"menu"),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:"action.hover",color:"text.primary"}},children:e.jsx(B.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:c=>z(c.palette.text.primary,.2)}}},children:t.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[e.jsx(B.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:"text.disabled",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(c=>e.jsxs(r.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:l=>oe(l,"restButtonLight")}},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:c.name}),c.description&&e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:c.description})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(r.Chip,{label:`Created ${d(c.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),e.jsx(r.Chip,{label:`By ${c.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),e.jsx(r.Divider,{sx:{my:1.5,borderColor:"divider"}}),e.jsx(r.Box,{sx:{display:"flex",gap:1},children:e.jsx(r.Button,{onClick:()=>i(c.id,c.name),variant:"outlined",size:"small",startIcon:e.jsx(B.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:l=>z(l.palette.error.main,.04)}},children:"Delete"})})]},c.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:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:c=>`${c.shape.borderRadius}px`,boxShadow:c=>oe(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>oe(c,"hoverButton")},"&:active":{boxShadow:c=>oe(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const ns={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},uu=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],pu=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function xu(t,o){const n=[];for(const i of t){if(i.type!=="string")continue;const s=pu.some(l=>l.test(i.name));let d=!1;const c=o.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);c.length>0&&(d=c.filter(p=>uu.some(f=>f.test(p))).length/c.length>.6),(s||d)&&n.push(i.name)}return n}function fn(t,o){if(t.length===0||o.length===0)return 0;const n=t.slice(0,Math.min(50,t.length)),s=o.map(c=>{const l=n.map(f=>String(f[c]??"")).filter(f=>f.length>0);if(l.length===0)return 5;const p=l.reduce((f,m)=>f+m.length,0);return Math.ceil(p/l.length)+1}).reduce((c,l)=>c+l,0)+1;return o.reduce((c,l)=>c+l.length+1,0)+s*t.length}function mu(t,o){const n=fn(t,o);return Math.ceil(n*3.5)}function hu(t,o){const n=fn(t,o);return Math.ceil(n*.7)}function fu(t,o,n){switch(t){case"csv":return fn(o,n);case"excel":return hu(o,n);case"json":return mu(o,n)}}function Si(t,o){return Math.ceil(t/o)}function gu(t,o,n,i,s=ns){const d=[],c=fu(t,o,n),l=o.length;if(l>s.maxRowsHard){const m=Si(l,s.maxRows);d.push({type:"row_count",severity:"error",message:`Export blocked: ${l.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${m} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const m=Si(l,s.maxRows);d.push({type:"row_count",severity:"warning",message:`Large export: ${l.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${m} smaller export${m>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:m,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?d.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${Hr(c)} exceeds the ${Hr(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:c,limit:s.maxFileSizeHardBytes}):c>s.maxFileSizeBytes&&d.push({type:"file_size",severity:"warning",message:`Large file: estimated ${Hr(c)}`,detail:`This exceeds the recommended ${Hr(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),t!=="excel"){const m=xu(i.filter(h=>n.includes(h.name)),o);if(m.length>0){const h=m.length>s.maxImageColumns;d.push({type:"image_columns",severity:h?"error":"warning",message:`Image column${m.length>1?"s":""} detected: ${m.map(x=>`"${x.replace(/_/g," ")}"`).join(", ")}`,detail:h?`Exporting ${m.length} image columns may produce a very large file. Consider hiding these columns before exporting.`:"Image URL columns are included in the export as plain text links — not embedded images.",value:m.length,limit:s.maxImageColumns})}}const p=d.some(m=>m.severity==="error"),f=d.some(m=>m.severity==="warning");return{violations:d,hasBlockingViolation:p,hasWarning:f,estimatedBytes:c}}function Hr(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function yu({violation:t}){const n=$t().palette,i=t.severity==="error",s=i?n.error.main:n.warning.main,d=z(i?n.error.main:n.warning.main,.06),c=i?z(n.error.main,.25):z(n.warning.main,.3),l=i?B.ErrorOutline:B.WarningAmberOutlined;return e.jsxs(r.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"8px",bgcolor:d,border:"1px solid",borderColor:c},children:[e.jsx(l,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",fontWeight:600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:t.message}),t.detail&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:t.detail}),t.suggestedBatches&&t.suggestedBatches>1&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[e.jsx(B.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",fontWeight:500},children:["Suggestion: split into ",t.suggestedBatches," exports"]})]})]})]})}function bu({totalRows:t,visibleRows:o,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:d,sampleRows:c=[],allRows:l=[],processedRows:p=[],onExport:f,onClose:m}){var M,W,V;const h=$t(),x=h.palette,b=dr(),[E,g]=u.useState(b.export.allowedFormats[0]||"csv"),[j,k]=u.useState("visible"),[v,C]=u.useState("visible"),S=j==="visible"?o:t,w=v==="visible"?i:s,a=u.useMemo(()=>j==="visible"?p.length>0?p:new Array(o):l.length>0?l:new Array(t),[j,o,t,p,l]),I=u.useMemo(()=>v==="all"?d.map(X=>X.name):d.map(X=>X.name).slice(0,i),[v,d,i]),R=u.useMemo(()=>gu(E,a,I,d,ns),[E,a,I,d]),G=()=>{R.hasBlockingViolation||(f({format:E,scope:j,columnScope:v}),m())},q={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"},ee={alignItems:"flex-start",px:1.5,py:.875,borderRadius:"8px",mx:0,transition:"background-color 0.15s","&:hover":{bgcolor:"action.hover"}},y={color:"text.secondary","&.Mui-checked":{color:"primary.main"},pt:.125};return e.jsx(r.Box,{onClick:m,sx:{position:"fixed",inset:0,bgcolor:z(((M=x.common)==null?void 0:M.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:h.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:X=>X.stopPropagation(),elevation:0,sx:{width:480,maxWidth:"calc(100vw - 48px)",maxHeight:"min(680px, calc(100vh - 180px))",display:"flex",flexDirection:"column",borderRadius:_e(h),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${z(((W=x.common)==null?void 0:W.black)??"#000",.14)}, 0 2px 8px ${z(((V=x.common)==null?void 0:V.black)??"#000",.08)}`,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},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",borderColor:"divider",flexShrink:0},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(r.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary"},children:"Export Report"}),e.jsx(ur,{content:pr.export,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:m,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.Box,{sx:{flex:1,overflowY:"auto",px:3,py:2.5,display:"flex",flexDirection:"column",gap:2.5,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:z(x.text.primary,.15),borderRadius:3}},children:[R.violations.length>0&&e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:R.violations.map((X,ue)=>e.jsx(yu,{violation:X},ue))}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Format"}),e.jsxs(r.RadioGroup,{value:E,onChange:X=>g(X.target.value),children:[b.export.allowedFormats.includes("csv")&&e.jsx(r.FormControlLabel,{value:"csv",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"CSV"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Comma-separated values, compatible with Excel"})]}),sx:{...ee,mb:.5}}),b.export.allowedFormats.includes("excel")&&e.jsx(r.FormControlLabel,{value:"excel",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Excel (.xlsx)"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Native Excel format with formatting support"})]}),sx:{...ee,mb:.5}}),b.export.allowedFormats.includes("json")&&e.jsx(r.FormControlLabel,{value:"json",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"JSON"}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:"Structured data with metadata and filters"})]}),sx:ee})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Rows"}),e.jsxs(r.RadioGroup,{value:j,onChange:X=>k(X.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible rows"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",o.toLocaleString()," rows (filtered and searched)"]})]}),sx:{...ee,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All rows"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",t.toLocaleString()," rows (complete original dataset)"]})]}),sx:ee})]})]}),e.jsxs(r.FormControl,{component:"fieldset",children:[e.jsx(r.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Columns"}),e.jsxs(r.RadioGroup,{value:v,onChange:X=>C(X.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible columns only"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export ",i," visible column",i!==1?"s":""]})]}),sx:{...ee,mb:.5}}),e.jsx(r.FormControlLabel,{value:"all",control:e.jsx(r.Radio,{size:"small",sx:y}),label:e.jsxs(r.Box,{children:[e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All columns"}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Export all ",s," columns (including hidden)"]})]}),sx:ee})]})]}),e.jsxs(r.Box,{children:[e.jsx(r.Divider,{sx:{mb:2}}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[{label:"Format",value:q[E]},{label:"Rows to export",value:S.toLocaleString()},{label:"Columns to export",value:String(w)},{label:"Estimated file size",value:Hr(R.estimatedBytes),highlight:R.hasBlockingViolation?"error.main":R.hasWarning?"warning.main":void 0}].map(({label:X,value:ue,highlight:ce})=>e.jsxs(r.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary"},children:X}),e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.8125rem",color:ce??"text.primary"},children:ue})]},X))})]})]}),e.jsxs(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:z(x.text.primary,.015)},children:[R.hasBlockingViolation&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[e.jsx(B.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"error.main",fontWeight:500},children:"Reduce rows or columns to enable download"})]}),e.jsx(r.Button,{onClick:m,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:2.5,borderRadius:"8px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsxs(r.Button,{onClick:G,disabled:R.hasBlockingViolation,variant:"contained",startIcon:e.jsx(B.Download,{sx:{fontSize:16}}),sx:{fontSize:"0.875rem",px:2.5,borderRadius:"8px"},children:["Download ",q[E]]})]})]})})}function vu({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(B.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:e.jsx(B.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 Su({error:t,onDismiss:o,autoDismiss:n=!0,autoDismissDelay:i=5e3}){u.useEffect(()=>{if(n){const l=setTimeout(()=>{o()},i);return()=>clearTimeout(l)}},[n,i,o]);const d=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(B.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(B.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(B.InfoOutlined,{sx:{fontSize:20}})}}})(),c=Aa(t);return e.jsx(r.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:e.jsxs(r.Alert,{severity:d.severity,icon:d.icon,action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:`${d.severity}.main`},children:e.jsx(B.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${d.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 ju extends u.Component{constructor(n){super(n);wn(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){lr.error("urm:error-boundary","Caught unhandled component error",n,i),this.props.onError&&this.props.onError(n,i)}render(){var n,i;return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx(r.Paper,{sx:{bgcolor:s=>z(s.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(B.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:((n=this.state.error)==null?void 0:n.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:s=>z(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),e.jsx(r.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:e.jsx(B.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Cu({feature:t}){const[o,n]=u.useState(!0);return u.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),e.jsx(r.Collapse,{in:o,unmountOnExit:!0,children:e.jsxs(r.Alert,{severity:"warning",sx:{m:1},icon:e.jsx(B.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:e.jsx(B.Close,{sx:{fontSize:16}})}),children:[e.jsxs(r.AlertTitle,{children:[t," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Pr({children:t,feature:o,onError:n}){return e.jsx(ju,{context:o,onError:i=>{n&&n(i)},fallback:e.jsx(Cu,{feature:o}),children:t})}const wu=[{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"}],ku=[{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 Lr({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 Tu({open:t,onClose:o,config:n,onApply:i}){const[s,d]=u.useState(0),[c,l]=u.useState(n),p=()=>l(n),f=()=>l(Ge),m=()=>{i(c),o()},h={sort:j=>l(k=>({...k,sort:{...k.sort,...j}})),filter:j=>l(k=>({...k,filter:{...k.filter,...j}})),columns:j=>l(k=>({...k,columns:{...k.columns,...j}})),grouping:j=>l(k=>({...k,grouping:{...k.grouping,...j}})),export:j=>l(k=>({...k,export:{...k.export,...j}}))},x=j=>{const k=c.filter.allowedOperators,v=k.includes(j)?k.filter(C=>C!==j):[...k,j];v.length!==0&&h.filter({allowedOperators:v})},b=j=>{const k=c.export.allowedFormats,v=k.includes(j)?k.filter(C=>C!==j):[...k,j];v.length!==0&&h.export({allowedFormats:v})},E=[{label:"Sort",icon:e.jsx(B.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(B.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(B.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(B.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(B.Download,{sx:{fontSize:17}})}],g=j=>JSON.stringify(c[j])===JSON.stringify(Ge[j]);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:p},PaperProps:{sx:{borderRadius:j=>_e(j),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:j=>`0 8px 32px ${z(j.palette.common.black,.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:j=>z(j.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(B.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(r.Tabs,{value:s,onChange:(j,k)=>d(k),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:E.map((j,k)=>e.jsx(r.Tab,{label:j.label,icon:j.icon,iconPosition:"start"},k))})}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Lr,{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"}),!g("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:(j,k)=>h.sort({maxLevels:k}),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(Lr,{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"}),!g("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:(j,k)=>h.filter({maxConditions:k}),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(j=>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:j}),e.jsx(r.FormGroup,{row:!0,sx:{gap:.5},children:wu.filter(k=>k.group===j).map(k=>e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(k.value),onChange:()=>x(k.value)}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:k.label}),sx:{mr:1.5}},k.value))})]},j))]})]}),e.jsxs(Lr,{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"}),!g("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:(j,k)=>h.columns({maxVisible:k}),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:(j,k)=>h.columns({minColumnWidth:k}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:j=>`${j}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:(j,k)=>h.columns({maxColumnWidth:k}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:j=>`${j}px`})]})]})]})]}),e.jsxs(Lr,{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"}),!g("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(j=>e.jsxs(r.Box,{onClick:()=>h.grouping({maxLevels:j}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===j?"primary.main":"divider",bgcolor:c.grouping.maxLevels===j?k=>z(k.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:k=>z(k.palette.primary.main,.04)}},children:[e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===j?"primary.main":"text.secondary"},children:j}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][j-1]})]},j))}),e.jsxs(r.FormGroup,{row:!0,sx:{gap:2},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:c.grouping.allowNested,onChange:j=>h.grouping({allowNested:j.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:j=>h.grouping({allowCollapse:j.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(Lr,{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"}),!g("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:ku.map(j=>e.jsxs(r.Box,{onClick:()=>b(j.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(j.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(j.value)?k=>z(k.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(r.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(j.value),onChange:()=>b(j.value),onClick:k=>k.stopPropagation()}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:j.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:j.desc})]})]},j.value))})]})})]}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:j=>z(j.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(r.Button,{startIcon:e.jsx(B.RestartAlt,{sx:{fontSize:18}}),onClick:f,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:j=>z(j.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:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),e.jsx(r.Button,{onClick:m,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const zu=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Iu={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 xo(t,o,n,i,s=new Date){const[d,c]=o.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(d,c,0,0),t==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(t==="weekly"){const p=n??1,f=l.getDay();let m=p-f;return m<0&&(m+=7),m===0&&l<=s&&(m=7),l.setDate(l.getDate()+m),l.toISOString()}if(t==="monthly"){const p=Math.min(i??1,28);return l.setDate(p),l<=s&&(l.setMonth(l.getMonth()+1),l.setDate(p)),l.toISOString()}return l.toISOString()}function Bu(t){const o=is(t.time);return t.frequency==="daily"?`Daily at ${o}`:t.frequency==="weekly"?`Every ${zu[t.dayOfWeek??1]} at ${o}`:t.frequency==="monthly"?`Monthly on the ${Iu[t.dayOfMonth??1]??`${t.dayOfMonth}th`} at ${o}`:o}function is(t){const[o,n]=t.split(":").map(Number),i=o>=12?"PM":"AM";return`${o%12||12}:${String(n).padStart(2,"0")} ${i}`}function Eu(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),d=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${d}m`:d>0?`in ${d}m`:"in less than a minute"}function Du(t){const o=new Date(t),n=new Date,i=o.toDateString()===n.toDateString(),s=is(`${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 ss(t){return`urm_schedules_${t}`}function as(t){try{const o=localStorage.getItem(ss(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 ls(t,o){try{localStorage.setItem(ss(t),JSON.stringify(o))}catch{}}const Ou=[{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"}],$u=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,cs={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},ar={"& .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 Au({initial:t=cs,isEditing:o=!1,onSave:n,onBack:i}){const[s,d]=u.useState(t),[c,l]=u.useState(!1),[p,f]=u.useState(!1),m=(b,E)=>d(g=>({...g,[b]:E})),h=s.email.trim().length>0&&!$u.test(s.email.trim()),x=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!h;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:b=>z(b.palette.text.primary,.06)}},children:e.jsx(B.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:b=>{m("name",b.target.value),c&&b.target.value.trim()&&l(!1)},onBlur:()=>l(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:c&&!s.name.trim(),helperText:c&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:ar}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:ar,children:[e.jsx(r.InputLabel,{children:"Frequency"}),e.jsxs(r.Select,{value:s.frequency,label:"Frequency",onChange:b=>m("frequency",b.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:ar,children:[e.jsx(r.InputLabel,{children:"Day of week"}),e.jsx(r.Select,{value:s.dayOfWeek,label:"Day of week",onChange:b=>m("dayOfWeek",Number(b.target.value)),children:Ou.map(b=>e.jsx(r.MenuItem,{value:b.value,children:b.label},b.value))})]}),s.frequency==="monthly"&&e.jsx(r.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:b=>m("dayOfMonth",Number(b.target.value)),inputProps:{min:1,max:28},error:s.dayOfMonth<1||s.dayOfMonth>28,helperText:s.dayOfMonth<1||s.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:ar}),e.jsx(r.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:b=>m("time",b.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:ar}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:ar,children:[e.jsx(r.InputLabel,{children:"Export format"}),e.jsxs(r.Select,{value:s.format,label:"Export format",onChange:b=>m("format",b.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:b=>m("scope",b.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:b=>m("email",b.target.value),onBlur:()=>f(!0),placeholder:"user@company.com",error:p&&h,helperText:p&&h?"Enter a valid email address":void 0,InputProps:{startAdornment:e.jsx(B.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:ar}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[e.jsx(B.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:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:b=>z(b.palette.text.primary,.06)}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>x&&n(s),disabled:!x,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:o?"Save changes":"Create schedule"})]})]})}function Mu({scheduleName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>Jr(i),boxShadow:i=>{var s;return`0 8px 32px ${z(((s=i.palette.common)==null?void 0:s.black)??"#000",.14)}`}}},children:[e.jsxs(r.DialogContent,{sx:{pt:3,pb:2,px:3},children:[e.jsx(r.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>z(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(B.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),e.jsx(r.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Delete Schedule"}),e.jsxs(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",e.jsxs(r.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',t,'"']}),"? This action cannot be undone."]})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[e.jsx(r.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),e.jsx(r.Button,{onClick:o,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Ru({schedule:t,tick:o,onToggle:n,onRunNow:i,onEdit:s,onDelete:d}){const c=t.isActive;return e.jsxs(r.Box,{sx:{border:"1px solid",borderColor:c?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:c?l=>z(l.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:c?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(r.Chip,{label:c?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:c?l=>z(l.palette.success.main,.1):l=>z(l.palette.text.primary,.06),color:c?"success.dark":"text.secondary"}})]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Bu(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:l=>z(l.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:l=>z(l.palette.text.primary,.06),color:"text.secondary"}}),t.email&&e.jsx(r.Chip,{icon:e.jsx(B.Email,{sx:{fontSize:11}}),label:t.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>z(l.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:[c&&e.jsxs(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",Eu(t.nextRunAt)]}),t.lastRunAt?e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Du(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:()=>s(t),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:l=>z(l.palette.primary.main,.08)}},children:e.jsx(B.Edit,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:c?"Pause":"Resume",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>n(t.id),sx:{color:c?"warning.main":"success.main","&:hover":{bgcolor:c?l=>z(l.palette.warning.main,.08):l=>z(l.palette.success.main,.08)}},children:c?e.jsx(B.Pause,{sx:{fontSize:15}}):e.jsx(B.PlayArrow,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Export now",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>i(t),sx:{color:"primary.main","&:hover":{bgcolor:l=>z(l.palette.primary.main,.08)}},children:e.jsx(B.Download,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:"Delete",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>d(t.id),sx:{color:"error.main","&:hover":{bgcolor:l=>z(l.palette.error.main,.08)}},children:e.jsx(B.Delete,{sx:{fontSize:15}})})})]})]})]})}function _u({open:t,onClose:o,reportId:n,reportName:i,onRunNow:s}){const[d,c]=u.useState([]),[l,p]=u.useState({type:"list"}),[f,m]=u.useState(0),[h,x]=u.useState(null);u.useEffect(()=>{t&&(c(as(n)),p({type:"list"}))},[t,n]),u.useEffect(()=>{if(!t)return;const I=setInterval(()=>m(R=>R+1),3e4);return()=>clearInterval(I)},[t]);const b=u.useCallback(I=>{c(I),ls(n,I)},[n]),E=I=>{const R=xo(I.frequency,I.time,I.dayOfWeek,I.dayOfMonth),G={id:`sched-${Date.now()}`,reportId:n,name:I.name.trim(),frequency:I.frequency,dayOfWeek:I.frequency==="weekly"?I.dayOfWeek:void 0,dayOfMonth:I.frequency==="monthly"?I.dayOfMonth:void 0,time:I.time,format:I.format,scope:I.scope,email:I.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:R,runCount:0};b([...d,G]),p({type:"list"})},g=I=>{if(l.type!=="edit")return;const R=l.schedule,G=xo(I.frequency,I.time,I.dayOfWeek,I.dayOfMonth);b(d.map(q=>q.id===R.id?{...R,name:I.name.trim(),frequency:I.frequency,dayOfWeek:I.frequency==="weekly"?I.dayOfWeek:void 0,dayOfMonth:I.frequency==="monthly"?I.dayOfMonth:void 0,time:I.time,format:I.format,scope:I.scope,email:I.email.trim()||void 0,nextRunAt:G}:q)),p({type:"list"})},j=I=>{b(d.map(R=>{if(R.id!==I)return R;const G=R.isActive?R.nextRunAt:xo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth);return{...R,isActive:!R.isActive,nextRunAt:G}}))},k=I=>{s(I);const R=new Date().toISOString();b(d.map(G=>G.id===I.id?{...G,lastRunAt:R,runCount:G.runCount+1}:G))},v=I=>{const R=d.find(G=>G.id===I)??null;x(R)},C=()=>{h&&(b(d.filter(I=>I.id!==h.id)),x(null))},S=I=>({name:I.name,frequency:I.frequency,dayOfWeek:I.dayOfWeek??1,dayOfMonth:I.dayOfMonth??1,time:I.time,format:I.format,scope:I.scope,email:I.email??""}),w=l.type!=="list",a=d.filter(I=>I.isActive).length;return e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:w,PaperProps:{sx:{borderRadius:I=>_e(I),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:I=>z(I.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(B.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(ur,{content:pr.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:I=>z(I.palette.text.primary,.06)}},children:e.jsx(B.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[w&&e.jsx(Au,{initial:l.type==="edit"?S(l.schedule):cs,isEditing:l.type==="edit",onSave:l.type==="edit"?g:E,onBack:()=>p({type:"list"})}),l.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:d.length===0?"No schedules yet":`${a} of ${d.length} active`}),e.jsx(r.Button,{startIcon:e.jsx(B.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>p({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),d.length===0?e.jsxs(r.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[e.jsx(B.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:d.map(I=>e.jsx(Ru,{schedule:I,tick:f,onToggle:j,onRunNow:k,onEdit:R=>p({type:"edit",schedule:R}),onDelete:v},I.id))})]})]}),l.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:I=>z(I.palette.warning.main,.06),border:"1px solid",borderColor:I=>z(I.palette.warning.main,.2)},children:[e.jsx(B.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:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:I=>z(I.palette.text.primary,.06)}},children:"Close"})]})]}),h&&e.jsx(Mu,{scheduleName:h.name,onConfirm:C,onCancel:()=>x(null)})]})}const Wu=6e4;function Pu({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:p,sortStack:f,onFired:m}){const h=u.useRef({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:p,sortStack:f,onFired:m});u.useEffect(()=>{h.current={reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:p,sortStack:f,onFired:m}});const x=u.useCallback(b=>{var I,R;const{reportName:E,uploadedData:g,processedData:j,schema:k,activeView:v,columnVisibility:C,columnOrder:S,filters:w,sortStack:a}=h.current;try{const G=b.scope==="all"?g:j,q=mo(G,k,w,a,v,C,S),ee=`${b.name}_scheduled`;switch(b.format){case"csv":ho(q,ee,{scope:b.scope});break;case"excel":fo(q,ee,{scope:b.scope});break;case"json":go(q,ee,{scope:b.scope});break}if(b.email){const y=encodeURIComponent(`Scheduled Report: ${b.name}`),M=encodeURIComponent(`Your scheduled report "${b.name}" has been generated.
|
|
90
90
|
|
|
91
|
-
Report: ${
|
|
91
|
+
Report: ${E}
|
|
92
92
|
Format: ${b.format.toUpperCase()}
|
|
93
93
|
Generated: ${new Date().toLocaleString()}
|
|
94
94
|
|
|
95
|
-
The file has been downloaded to your device.`);window.open(`mailto:${b.email}?subject=${y}&body=${M}`,"_blank")}(R=(z=h.current).onFired)==null||R.call(z,b)}catch(q){rr.error("urm:scheduler",`Export failed for schedule: ${b.name}`,q)}},[]);p.useEffect(()=>{if(!t)return;const b=()=>{const{reportId:g}=h.current;if(!g)return;const j=rs(g),w=new Date;let I=!1;const v=j.map(S=>{if(!S.isActive)return S;if(new Date(S.nextRunAt)<=w){x(S);const a=xo(S.frequency,S.time,S.dayOfWeek,S.dayOfMonth,w);return I=!0,{...S,lastRunAt:w.toISOString(),nextRunAt:a,runCount:S.runCount+1}}return S});I&&os(g,v)};b();const D=setInterval(b,Fu);return()=>clearInterval(D)},[t,x])}function is({reportEngine:t}){var gr,yr,br,vr,Sr;const{activeReport:o,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:d,activeView:c,isDirty:l,currentTableState:u,viewChanges:f,showFilterPanel:m,setShowFilterPanel:h,filterFocusColumn:x,handleAddFilter:b,handleUpdateFilter:D,handleRemoveFilter:g,handleClearAllFilters:j,handleReplaceFilters:w,handleOpenFilterForColumn:I,handleCloseFilterPanel:v,handleClearFiltersForColumn:S,showSortPanel:C,setShowSortPanel:a,handleSort:z,handleUpdateSortStack:R,handleSortAscending:q,handleSortDescending:K,showManageViews:ee,setShowManageViews:y,showCreateViewModal:M,setShowCreateViewModal:W,showEditViewModal:V,setShowEditViewModal:Q,showDeleteConfirmation:xe,setShowDeleteConfirmation:de,editingView:L,deletingView:A,handleSelectView:H,handleCreateView:ie,handleUpdateCurrentView:Y,handleSaveColumnConfigToCurrentView:re,handleSaveColumnConfigToAllViews:se,handleSaveAsNewView:oe,handleRevertChanges:P,handleToggleDefault:ne,handleToggleFavorite:ce,handleSoftDelete:ae,handleRestoreView:fe,handlePermanentDelete:G,handleEditView:Ae,handleSaveEditView:Qe,handleConfirmDelete:Ze,handlePromoteToGlobal:Bt,showManageColumns:ar,setShowManageColumns:It,handleUpdateColumnVisibility:Dt,handleUpdateColumnOrder:Et,handleUpdateColumnWidth:lt,handleResetColumnLayout:Ve,showGroupPanel:Vt,setShowGroupPanel:et,handleGroup:Ue,handleToggleGroupCollapse:He,searchQuery:nt,debouncedSearchQuery:Ir,searchHistory:lr,handleSearchChange:Ht,handleAddToSearchHistory:cr,handleToggleSearchFavourite:Ut,handleDeleteSearchHistory:Dr,selectedRowIds:Yt,handleToggleRowSelection:ft,handleToggleAllRows:it,handleRangeSelection:dr,handleClearSelection:Gt,handleUpdateSelectionAfterDelete:ur,currentPage:qt,pageSize:Er,paginationEngine:tt,handlePageChange:Ot,handlePageSizeChange:ke,isExporting:At,showExportModal:Or,setShowExportModal:Ye,showDirtyExportWarning:F,handleExport:Ge,handleExportWithConfig:be,handleExportSelected:Pe,handleExportAnyway:Ar,handleSaveAndExport:gt,handleCancelExport:$r,showAuditHistory:yt,setShowAuditHistory:Jt,showCreatePreset:Kt,setShowCreatePreset:pr,showManagePresets:Te,setShowManagePresets:U,activePreset:_e,handleCreatePreset:we,handleClearActivePreset:ct,handleOpenPresetById:Le,handleDeletePresetById:xr,isViewerRole:mr,userRole:hr,featureLimitWarning:bt,setFeatureLimitWarning:Mr,reportError:vt,setReportError:Xt,handleError:St,updateReport:st,showSnack:jt}=t,[fr,Fe]=p.useState(!1);Vu({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)||((gr=c==null?void 0:c.snapshot)==null?void 0:gr.columnVisibility)||{},columnOrder:(o==null?void 0:o.columnOrder)||((yr=c==null?void 0:c.snapshot)==null?void 0:yr.columnOrder)||[],filters:(o==null?void 0:o.filters)||[],sortStack:(o==null?void 0:o.sortStack)||[],onFired:le=>{jt(`Scheduled export "${le.name}" completed`,"success")}});const $t=p.useCallback((le,he)=>{if(!(o!=null&&o.uploadedData))return;const $e=[...o.uploadedData];$e[le]=he,st(o.id,{uploadedData:$e})},[o,st]),Mt=p.useCallback(le=>{if(!(o!=null&&o.uploadedData))return;const he=o.uploadedData.indexOf(le);if(he===-1)return;const $e=o.uploadedData.filter((_t,Wt)=>Wt!==he);st(o.id,{uploadedData:$e}),ur(le)},[o,st,ur]),dt=p.useCallback((le,he)=>{if(!(o!=null&&o.uploadedData))return;const $e=o.uploadedData.indexOf(he),_t=$e!==-1?$e+1:le+1,Wt=[...o.uploadedData];Wt.splice(_t,0,{...he}),st(o.id,{uploadedData:Wt})},[o,st]),at=nr(),{handleDevConfigChange:Rt}=jo(),[Rr,Qt]=p.useState(!1);return p.useEffect(()=>{const le=he=>{he.ctrlKey&&he.shiftKey&&he.key==="D"&&(he.preventDefault(),Qt(!0))};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},[]),!o||!o.schemaLocked||!o.schema||!o.uploadedData||!o.views?null:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[!mr&&l&&c&&e.jsx(au,{viewName:c.name,isDefaultView:c.isDefault,changes:f,onSaveToCurrentView:c.isDefault?void 0:Y,onSaveAsNewView:oe,onCancel:P}),e.jsxs(r.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[bt&&e.jsx(wu,{warning:bt,onDismiss:()=>Mr(null)}),vt&&e.jsx(ku,{error:vt,onDismiss:()=>Xt(null)}),F&&e.jsx(lu,{onExportAnyway:Ar,onSaveAndExport:gt,onCancel:$r}),e.jsx(Kd,{schema:o.schema,data:n,sortStack:o.sortStack,filters:o.filters,views:o.views,activeViewId:o.activeViewId,isDirty:l,isExporting:At,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:z,onSortAscending:q,onSortDescending:K,onOpenFilters:()=>h(!0),onOpenSort:()=>a(!0),onOpenFilterForColumn:I,onSelectView:H,onCreateView:()=>W(!0),onManageViews:()=>y(!0),onUpdateCurrentView:Y,onSaveAsNewView:oe,onToggleDefault:ne,onToggleFavorite:ce,onRestoreView:fe,onPermanentDelete:G,onExport:Ge,onOpenColumns:()=>It(!0),onUpdateColumnWidth:lt,onUpdateColumnOrder:Et,onUpdateColumnVisibility:Dt,onClearFiltersForColumn:S,onResetLayout:Ve,onOpenGroup:()=>et(!0),onGroupByColumn:le=>{Ue({enabled:!0,levels:[{column:le}],collapsedGroups:[]})},onToggleGroupCollapse:He,onOpenAuditHistory:()=>Jt(!0),onOpenScheduledReports:()=>Fe(!0),searchQuery:nt,highlightQuery:Ir,searchHistory:lr,onAddToSearchHistory:cr,onToggleSearchFavourite:Ut,onDeleteSearchHistory:Dr,selectedRowIds:Yt,onSearchChange:Ht,onToggleRowSelection:ft,onToggleAllRows:it,onRangeSelection:dr,onClearSelection:Gt,onExportSelected:Pe,currentPage:(tt==null?void 0:tt.currentPage)||qt,pageSize:(tt==null?void 0:tt.pageSize)||Er,onPageChange:Ot,onPageSizeChange:ke,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:mr,userRole:hr,reportName:o.name,onEditRow:$t,onDeleteRow:Mt,onDuplicateRow:dt,showDevPanel:at.display.showDevPanel,onOpenDevConfig:()=>Qt(!0)})]}),m&&e.jsx(Lr,{feature:"Filters",onError:le=>{const he=wt("ui","filters",le);St(he)},children:e.jsx(Xd,{schema:o.schema,filters:o.filters??[],onAddFilter:b,onUpdateFilter:D,onRemoveFilter:g,onClearAll:j,onReplaceFilters:w,onClose:v,focusColumn:x})}),C&&e.jsx(Lr,{feature:"Sorting",onError:le=>{const he=wt("ui","sorting",le);St(he)},children:e.jsx(Zd,{schema:o.schema,sortStack:o.sortStack??[],onUpdateSortStack:R,onClose:()=>a(!1)})}),ee&&e.jsx(Lr,{feature:"Views",onError:le=>{const he=wt("ui","views",le);St(he)},children:e.jsx(eu,{views:o.views,activeViewId:o.activeViewId??"",onSelectView:H,onCreateView:()=>{y(!1),W(!0)},onEditView:Ae,onDeleteView:ae,onRestoreView:fe,onPermanentDelete:G,onPromoteToGlobal:Bt,isAdmin:((br=at.views)==null?void 0:br.isAdmin)??!1,onClose:()=>y(!1)})}),M&&u&&(()=>{var $e;const le=(o.views??[]).filter(_t=>!_t.isDeleted).length,he=(($e=at.views)==null?void 0:$e.maxViews)??10;return e.jsx(xi,{currentSnapshot:u,onSave:ie,onClose:()=>W(!1),atViewLimit:le>=he,maxViews:he})})(),V&&L&&e.jsx(xi,{currentSnapshot:L.snapshot,onSave:Qe,onClose:()=>{Q(!1)},isEditMode:!0,initialName:L.name,initialDescription:L.description,initialIsDefault:L.isDefault}),xe&&A&&e.jsx(tu,{viewName:A.name,onConfirm:Ze,onCancel:()=>{de(!1)}}),ar&&c&&e.jsx(ou,{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:Dt,onUpdateColumnOrder:Et,onUpdateColumnWidth:lt,onResetLayout:Ve,onSelectView:le=>{H(le)},onSaveToCurrentView:le=>{re(le),It(!1)},onSaveToAllViews:le=>{se(le),It(!1)},onClose:()=>It(!1)}),Vt&&e.jsx(Lr,{feature:"Grouping",onError:le=>{const he=wt("ui","grouping",le);St(he)},children:e.jsx(nu,{schema:o.schema,grouping:o.grouping||null,onApply:Ue,onClose:()=>et(!1)})}),yt&&e.jsx(uu,{auditHistory:o.auditHistory||[],onClose:()=>Jt(!1)}),Kt&&e.jsx(pu,{onSave:we,onClose:()=>pr(!1)}),Te&&e.jsx(mu,{presets:o.presets||[],reportId:o.id,onOpenPreset:Le,onDeletePreset:xr,onClose:()=>U(!1)}),_e&&e.jsx(r.Box,{sx:{mt:2},children:e.jsx(xu,{presetName:_e.name,onClear:ct})}),Or&&e.jsx(Lr,{feature:"Export",onError:le=>{const he=wt("ui","export",le);St(he)},children:e.jsx(Cu,{totalRows:(s==null?void 0:s.totalRows)||((vr=o.uploadedData)==null?void 0:vr.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((Sr=d==null?void 0:d.columnEngine)==null?void 0:Sr.visibleColumns.length)||o.schema.length,totalColumnsCount:o.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:o.schema,allRows:o.uploadedData||[],processedRows:i||[],onExport:be,onClose:()=>{Ye(!1)}})}),o&&e.jsx(Lu,{open:fr,onClose:()=>Fe(!1),reportId:o.id,reportName:o.name,onRunNow:le=>{const he=le.scope==="all"?o.uploadedData||[]:i||[],$e=mo(he,o.schema||[],o.filters||[],o.sortStack||[],c,o.columnVisibility,o.columnOrder);le.format==="csv"&&ho($e,le.name),le.format==="excel"&&fo($e,le.name),le.format==="json"&&go($e,le.name),jt(`"${le.name}" exported successfully`,"success")}}),e.jsx(Du,{open:Rr,onClose:()=>Qt(!1),config:at,onApply:Rt})]})}const Hu={error:"err",warning:"warn",info:"info",success:"suc"};function ss({open:t,message:o,severity:n,onClose:i,autoHideDurationMs:s}){var I,v;const d=r.useTheme(),c=d.tokens,l=(c==null?void 0:c.notifPosition)??"top-right",u=(c==null?void 0:c.notifStyle)??"toast",f=(c==null?void 0:c.notifAccent)??"severity",m=(c==null?void 0:c.notifAutoDismiss)??!0,h=(c==null?void 0:c.toastW)??252,x=l.startsWith("top")?"top":"bottom",b=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",D=Hu[n],g=((I=c==null?void 0:c.status)==null?void 0:I[`${D}Soft`])??d.palette[n].light,j=((v=c==null?void 0:c.status)==null?void 0:v[`${D}Txt`])??d.palette[n].dark,w=f==="primary"?d.palette.primary.main:f==="mono"?d.palette.text.secondary:j;return e.jsx(r.Snackbar,{open:t,autoHideDuration:m?s??2e3:void 0,onClose:(S,C)=>{C!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:x,horizontal:b},children:e.jsx(r.Alert,{severity:n,icon:!1,onClose:m?void 0:i,sx:{width:h,alignItems:"flex-start",bgcolor:g,color:j,boxShadow:u==="inline"?"none":(c==null?void 0:c.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(c==null?void 0:c.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${w}`:void 0,borderRadius:`${d.shape.borderRadius}px`},children:o})})}function as({hasExternalData:t=!1}){const o=jo(),{reports:n,activeReportId:i,activeReport:s,uploadState:d,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:u,setActiveReportId:f,createReport:m,handleFileUpload:h,handleUploadError:x,handleRetry:b,handleConfirm:D,snack:g,handleSnackClose:j,snackDurationMs:w}=o,I=t&&d==="uploading"&&n.length===0;return e.jsxs(r.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(tl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:f}),e.jsx(r.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:I?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(Ki,{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(is,{reportEngine:o}):e.jsx(r.Box,{sx:{p:3},children:d==="preview"&&s.schema&&s.uploadedData?e.jsx(md,{schema:s.schema,onConfirm:D,hasConflicts:c}):s.uploadError?e.jsx(hd,{error:s.uploadError,onRetry:b}):e.jsx(xd,{onFileUpload:h,onError:x,isUploading:d==="uploading"})})}):null}),!t&&e.jsx(pd,{isOpen:l,onClose:()=>u(!1),onCreate:m}),e.jsx(ss,{open:g.open,message:g.message,severity:g.severity,onClose:j,autoHideDurationMs:w})]})}function Uu({data:t,dataSource:o,reportName:n,autoLoad:i=!0,config:s}={}){return e.jsx(nn,{mode:"builder",data:t,dataSource:o,reportName:n,autoLoad:i,config:s,children:e.jsx(as,{hasExternalData:!!(t||o)})})}function ls(){const t=jo(),{snack:o,handleSnackClose:n,snackDurationMs:i}=t;return e.jsxs(r.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[e.jsx(r.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:t.activeReport?e.jsx(is,{reportEngine:t}):e.jsx(Ki,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(ss,{open:o.open,message:o.message,severity:o.severity,onClose:n,autoHideDurationMs:i})]})}function Yu({data:t,autoLoad:o=!0,config:n}){return e.jsx(nn,{data:t,mode:"viewer",autoLoad:o,config:n,children:e.jsx(ls,{})})}exports.URMBuilder=Uu;exports.URMBuilderRaw=as;exports.URMProvider=nn;exports.URMViewer=Yu;exports.URMViewerRaw=ls;exports.useURMContext=jo;
|
|
95
|
+
The file has been downloaded to your device.`);window.open(`mailto:${b.email}?subject=${y}&body=${M}`,"_blank")}(R=(I=h.current).onFired)==null||R.call(I,b)}catch(G){lr.error("urm:scheduler",`Export failed for schedule: ${b.name}`,G)}},[]);u.useEffect(()=>{if(!t)return;const b=()=>{const{reportId:g}=h.current;if(!g)return;const j=as(g),k=new Date;let v=!1;const C=j.map(S=>{if(!S.isActive)return S;if(new Date(S.nextRunAt)<=k){x(S);const a=xo(S.frequency,S.time,S.dayOfWeek,S.dayOfMonth,k);return v=!0,{...S,lastRunAt:k.toISOString(),nextRunAt:a,runCount:S.runCount+1}}return S});v&&ls(g,C)};b();const E=setInterval(b,Wu);return()=>clearInterval(E)},[t,x])}function ds({reportEngine:t}){var kt,Tt,nt,or,zt;const{activeReport:o,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:d,activeView:c,isDirty:l,currentTableState:p,showFilterPanel:f,setShowFilterPanel:m,filterFocusColumn:h,handleAddFilter:x,handleUpdateFilter:b,handleRemoveFilter:E,handleClearAllFilters:g,handleReplaceFilters:j,handleOpenFilterForColumn:k,handleCloseFilterPanel:v,handleClearFiltersForColumn:C,showSortPanel:S,setShowSortPanel:w,handleSort:a,handleUpdateSortStack:I,handleSortAscending:R,handleSortDescending:G,showManageViews:q,setShowManageViews:ee,showCreateViewModal:y,setShowCreateViewModal:M,showEditViewModal:W,setShowEditViewModal:V,showDeleteConfirmation:X,setShowDeleteConfirmation:ue,editingView:ce,deletingView:F,handleSelectView:O,handleCreateView:H,handleUpdateCurrentView:re,handleSaveColumnConfigToCurrentView:U,handleSaveColumnConfigToAllViews:te,handleSaveAsNewView:se,handleRevertChanges:ne,handleToggleDefault:P,handleToggleFavorite:ie,handleSoftDelete:de,handleRestoreView:ae,handlePermanentDelete:ge,handleEditView:K,handleSaveEditView:Ee,handleConfirmDelete:Ue,handlePromoteToGlobal:it,showManageColumns:St,setShowManageColumns:et,handleUpdateColumnVisibility:xr,handleUpdateColumnOrder:jt,handleUpdateColumnWidth:mr,handleResetColumnLayout:st,showGroupPanel:qt,setShowGroupPanel:Me,handleGroup:at,handleToggleGroupCollapse:lt,searchQuery:tt,debouncedSearchQuery:Ve,searchHistory:At,handleSearchChange:Er,handleAddToSearchHistory:hr,handleToggleSearchFavourite:Jt,handleDeleteSearchHistory:Kt,selectedRowIds:fr,handleToggleRowSelection:gr,handleToggleAllRows:ct,handleRangeSelection:Xt,handleClearSelection:Ct,handleUpdateSelectionAfterDelete:dt,currentPage:Kr,pageSize:Dr,paginationEngine:Ke,handlePageChange:yr,handlePageSizeChange:Mt,isExporting:Te,showExportModal:Or,setShowExportModal:Rt,showDirtyExportWarning:ut,handleExport:N,handleExportWithConfig:rt,handleExportSelected:be,handleExportAnyway:Fe,handleSaveAndExport:Qt,handleCancelExport:_t,showAuditHistory:br,setShowAuditHistory:Wt,showCreatePreset:Pt,setShowCreatePreset:$r,showManagePresets:Zt,setShowManagePresets:ze,activePreset:Q,handleCreatePreset:fe,handleClearActivePreset:me,handleOpenPresetById:vr,handleDeletePresetById:Xe,isViewerRole:Lt,userRole:pt,featureLimitWarning:er,setFeatureLimitWarning:Sr,reportError:ot,setReportError:He,handleError:xt,updateReport:mt,showSnack:tr}=t,[Nt,jr]=u.useState(!1);Pu({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)||((kt=c==null?void 0:c.snapshot)==null?void 0:kt.columnVisibility)||{},columnOrder:(o==null?void 0:o.columnOrder)||((Tt=c==null?void 0:c.snapshot)==null?void 0:Tt.columnOrder)||[],filters:(o==null?void 0:o.filters)||[],sortStack:(o==null?void 0:o.sortStack)||[],onFired:le=>{tr(`Scheduled export "${le.name}" completed`,"success")}});const Ft=u.useCallback((le,ye)=>{if(!(o!=null&&o.uploadedData))return;const Re=[...o.uploadedData];Re[le]=ye,mt(o.id,{uploadedData:Re})},[o,mt]),rr=u.useCallback(le=>{if(!(o!=null&&o.uploadedData))return;const ye=o.uploadedData.indexOf(le);if(ye===-1)return;const Re=o.uploadedData.filter((Vt,Ht)=>Ht!==ye);mt(o.id,{uploadedData:Re}),dt(le)},[o,mt,dt]),Ar=u.useCallback((le,ye)=>{if(!(o!=null&&o.uploadedData))return;const Re=o.uploadedData.indexOf(ye),Vt=Re!==-1?Re+1:le+1,Ht=[...o.uploadedData];Ht.splice(Vt,0,{...ye}),mt(o.id,{uploadedData:Ht})},[o,mt]),wt=dr(),{handleDevConfigChange:ht}=jo(),[Cr,Le]=u.useState(!1);return u.useEffect(()=>{const le=ye=>{ye.ctrlKey&&ye.shiftKey&&ye.key==="D"&&(ye.preventDefault(),Le(!0))};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},[]),!o||!o.schemaLocked||!o.schema||!o.uploadedData||!o.views?null:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[e.jsxs(r.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[er&&e.jsx(vu,{warning:er,onDismiss:()=>Sr(null)}),ot&&e.jsx(Su,{error:ot,onDismiss:()=>He(null)}),ut&&e.jsx(nu,{onExportAnyway:Fe,onSaveAndExport:Qt,onCancel:_t}),e.jsx(Jd,{schema:o.schema,data:n,sortStack:o.sortStack,filters:o.filters,views:o.views,activeViewId:o.activeViewId,isDirty:l,isExporting:Te,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:a,onSortAscending:R,onSortDescending:G,onOpenFilters:()=>m(!0),onOpenSort:()=>w(!0),onOpenFilterForColumn:k,onSelectView:O,onCreateView:()=>M(!0),onManageViews:()=>ee(!0),onUpdateCurrentView:re,onSaveAsNewView:se,onDiscardChanges:ne,onToggleDefault:P,onToggleFavorite:ie,onRestoreView:ae,onPermanentDelete:ge,onExport:N,onOpenColumns:()=>et(!0),onUpdateColumnWidth:mr,onUpdateColumnOrder:jt,onUpdateColumnVisibility:xr,onClearFiltersForColumn:C,onResetLayout:st,onOpenGroup:()=>Me(!0),onGroupByColumn:le=>{at({enabled:!0,levels:[{column:le}],collapsedGroups:[]})},onToggleGroupCollapse:lt,onOpenAuditHistory:()=>Wt(!0),onOpenScheduledReports:()=>jr(!0),searchQuery:tt,highlightQuery:Ve,searchHistory:At,onAddToSearchHistory:hr,onToggleSearchFavourite:Jt,onDeleteSearchHistory:Kt,selectedRowIds:fr,onSearchChange:Er,onToggleRowSelection:gr,onToggleAllRows:ct,onRangeSelection:Xt,onClearSelection:Ct,onExportSelected:be,currentPage:(Ke==null?void 0:Ke.currentPage)||Kr,pageSize:(Ke==null?void 0:Ke.pageSize)||Dr,onPageChange:yr,onPageSizeChange:Mt,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:Lt,userRole:pt,reportName:o.name,onEditRow:Ft,onDeleteRow:rr,onDuplicateRow:Ar,showDevPanel:wt.display.showDevPanel,onOpenDevConfig:()=>Le(!0)})]}),f&&e.jsx(Pr,{feature:"Filters",onError:le=>{const ye=Et("ui","filters",le);xt(ye)},children:e.jsx(Kd,{schema:o.schema,filters:o.filters??[],onAddFilter:x,onUpdateFilter:b,onRemoveFilter:E,onClearAll:g,onReplaceFilters:j,onClose:v,focusColumn:h})}),S&&e.jsx(Pr,{feature:"Sorting",onError:le=>{const ye=Et("ui","sorting",le);xt(ye)},children:e.jsx(Qd,{schema:o.schema,sortStack:o.sortStack??[],onUpdateSortStack:I,onClose:()=>w(!1)})}),q&&e.jsx(Pr,{feature:"Views",onError:le=>{const ye=Et("ui","views",le);xt(ye)},children:e.jsx(Zd,{views:o.views,activeViewId:o.activeViewId??"",onSelectView:O,onCreateView:()=>{ee(!1),M(!0)},onEditView:K,onDeleteView:de,onRestoreView:ae,onPermanentDelete:ge,onPromoteToGlobal:it,isAdmin:((nt=wt.views)==null?void 0:nt.isAdmin)??!1,onClose:()=>ee(!1)})}),y&&p&&(()=>{var Re;const le=(o.views??[]).filter(Vt=>!Vt.isDeleted).length,ye=((Re=wt.views)==null?void 0:Re.maxViews)??10;return e.jsx(yi,{currentSnapshot:p,onSave:H,onClose:()=>M(!1),atViewLimit:le>=ye,maxViews:ye})})(),W&&ce&&e.jsx(yi,{currentSnapshot:ce.snapshot,onSave:Ee,onClose:()=>{V(!1)},isEditMode:!0,initialName:ce.name,initialDescription:ce.description,initialIsDefault:ce.isDefault}),X&&F&&e.jsx(eu,{viewName:F.name,onConfirm:Ue,onCancel:()=>{ue(!1)}}),St&&c&&e.jsx(ru,{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:xr,onUpdateColumnOrder:jt,onUpdateColumnWidth:mr,onResetLayout:st,onSelectView:le=>{O(le)},onSaveToCurrentView:le=>{U(le),et(!1)},onSaveToAllViews:le=>{te(le),et(!1)},onClose:()=>et(!1)}),qt&&e.jsx(Pr,{feature:"Grouping",onError:le=>{const ye=Et("ui","grouping",le);xt(ye)},children:e.jsx(ou,{schema:o.schema,grouping:o.grouping||null,onApply:at,onClose:()=>Me(!1)})}),br&&e.jsx(au,{auditHistory:o.auditHistory||[],onClose:()=>Wt(!1)}),Pt&&e.jsx(lu,{onSave:fe,onClose:()=>$r(!1)}),Zt&&e.jsx(du,{presets:o.presets||[],reportId:o.id,onOpenPreset:vr,onDeletePreset:Xe,onClose:()=>ze(!1)}),Q&&e.jsx(r.Box,{sx:{mt:2},children:e.jsx(cu,{presetName:Q.name,onClear:me})}),Or&&e.jsx(Pr,{feature:"Export",onError:le=>{const ye=Et("ui","export",le);xt(ye)},children:e.jsx(bu,{totalRows:(s==null?void 0:s.totalRows)||((or=o.uploadedData)==null?void 0:or.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((zt=d==null?void 0:d.columnEngine)==null?void 0:zt.visibleColumns.length)||o.schema.length,totalColumnsCount:o.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:o.schema,allRows:o.uploadedData||[],processedRows:i||[],onExport:rt,onClose:()=>{Rt(!1)}})}),o&&e.jsx(_u,{open:Nt,onClose:()=>jr(!1),reportId:o.id,reportName:o.name,onRunNow:le=>{const ye=le.scope==="all"?o.uploadedData||[]:i||[],Re=mo(ye,o.schema||[],o.filters||[],o.sortStack||[],c,o.columnVisibility,o.columnOrder);le.format==="csv"&&ho(Re,le.name),le.format==="excel"&&fo(Re,le.name),le.format==="json"&&go(Re,le.name),tr(`"${le.name}" exported successfully`,"success")}}),e.jsx(Tu,{open:Cr,onClose:()=>Le(!1),config:wt,onApply:ht})]})}const Lu={error:"err",warning:"warn",info:"info",success:"suc"};function us({open:t,message:o,severity:n,onClose:i,autoHideDurationMs:s}){var v,C;const d=r.useTheme(),c=d.tokens,l=(c==null?void 0:c.notifPosition)??"top-right",p=(c==null?void 0:c.notifStyle)??"toast",f=(c==null?void 0:c.notifAccent)??"severity",m=(c==null?void 0:c.notifAutoDismiss)??!0,h=(c==null?void 0:c.toastW)??252,x=l.startsWith("top")?"top":"bottom",b=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",E=Lu[n],g=((v=c==null?void 0:c.status)==null?void 0:v[`${E}Soft`])??d.palette[n].light,j=((C=c==null?void 0:c.status)==null?void 0:C[`${E}Txt`])??d.palette[n].dark,k=f==="primary"?d.palette.primary.main:f==="mono"?d.palette.text.secondary:j;return e.jsx(r.Snackbar,{open:t,autoHideDuration:m?s??2e3:void 0,onClose:(S,w)=>{w!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:x,horizontal:b},children:e.jsx(r.Alert,{severity:n,icon:!1,onClose:m?void 0:i,sx:{width:h,alignItems:"flex-start",bgcolor:g,color:j,boxShadow:p==="inline"?"none":(c==null?void 0:c.cardShadow)??3,border:p==="inline"?"1px solid":p==="toast"?(c==null?void 0:c.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:p==="banner"?`4px solid ${k}`:void 0,borderRadius:`${d.shape.borderRadius}px`},children:o})})}function ps({hasExternalData:t=!1}){const o=jo(),{reports:n,activeReportId:i,activeReport:s,uploadState:d,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:p,setActiveReportId:f,createReport:m,handleFileUpload:h,handleUploadError:x,handleRetry:b,handleConfirm:E,snack:g,handleSnackClose:j,snackDurationMs:k}=o,v=t&&d==="uploading"&&n.length===0;return e.jsxs(r.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(tl,{onCreateReport:()=>p(!0),reports:n,activeReportId:i,onReportClick:f}),e.jsx(r.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:v?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(ts,{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(ds,{reportEngine:o}):e.jsx(r.Box,{sx:{p:3},children:d==="preview"&&s.schema&&s.uploadedData?e.jsx(md,{schema:s.schema,onConfirm:E,hasConflicts:c}):s.uploadError?e.jsx(hd,{error:s.uploadError,onRetry:b}):e.jsx(xd,{onFileUpload:h,onError:x,isUploading:d==="uploading"})})}):null}),!t&&e.jsx(pd,{isOpen:l,onClose:()=>p(!1),onCreate:m}),e.jsx(us,{open:g.open,message:g.message,severity:g.severity,onClose:j,autoHideDurationMs:k})]})}function Nu({data:t,dataSource:o,reportName:n,autoLoad:i=!0,config:s}={}){return e.jsx(dn,{mode:"builder",data:t,dataSource:o,reportName:n,autoLoad:i,config:s,children:e.jsx(ps,{hasExternalData:!!(t||o)})})}function xs(){const t=jo(),{snack:o,handleSnackClose:n,snackDurationMs:i}=t;return e.jsxs(r.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[e.jsx(r.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:t.activeReport?e.jsx(ds,{reportEngine:t}):e.jsx(ts,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(us,{open:o.open,message:o.message,severity:o.severity,onClose:n,autoHideDurationMs:i})]})}function Fu({data:t,autoLoad:o=!0,config:n}){return e.jsx(dn,{data:t,mode:"viewer",autoLoad:o,config:n,children:e.jsx(xs,{})})}exports.URMBuilder=Nu;exports.URMBuilderRaw=ps;exports.URMProvider=dn;exports.URMViewer=Fu;exports.URMViewerRaw=xs;exports.useURMContext=jo;
|