dts-universal-report-module 1.0.16 → 1.0.17

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.
Files changed (3) hide show
  1. package/dist/index.esm.js +4518 -4417
  2. package/dist/index.js +23 -23
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
- "use strict";var Os=Object.defineProperty;var $s=(t,o,n)=>o in t?Os(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n;var Sn=(t,o,n)=>$s(t,typeof o!="symbol"?o+"":o,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),As=require("xlsx"),z=require("@mui/icons-material"),r=require("@mui/material"),yi=require("react-dom"),_s=require("@emotion/react"),$t=require("react-dnd"),sn=require("react-dnd-html5-backend");function bi(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 To=bi(p),lo=bi(As),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}},vi="urm_dev_config";function Ms(){try{const t=localStorage.getItem(vi);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 Rs(t){try{localStorage.setItem(vi,JSON.stringify(t))}catch{}}function Ws(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 Si=p.createContext(Ge);function cr(){return p.useContext(Si)}const Ps=/^\d{4}-\d{2}-\d{2}$/,Ns=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Ls=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Fs=9783072e5,Vs=41024448e5,Hs=978307200,Us=4102444800;function Ys(t){return t==null||t===""?"unknown":typeof t=="number"?Number.isInteger(t)&&t>=Fs&&t<=Vs?"timestamp_ms":Number.isInteger(t)&&t>=Hs&&t<=Us?"timestamp_s":"unknown":typeof t!="string"?"unknown":Ns.test(t)||Ps.test(t)?"iso":Ls.test(t.trim())?"locale_string":"unknown"}function Gs(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=Ys(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 qs(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 jn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Js=["January","February","March","April","May","June","July","August","September","October","November","December"];function _e(t){return String(t).padStart(2,"0")}function Ks(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),x=Math.floor(l/30),h=Math.floor(l/365);let b;return s<60?b="just now":d<60?b=`${d} minute${d!==1?"s":""}`:c<24?b=`${c} hour${c!==1?"s":""}`:l<7?b=`${l} day${l!==1?"s":""}`:u<5?b=`${u} week${u!==1?"s":""}`:x<12?b=`${x} month${x!==1?"s":""}`:b=`${h} year${h!==1?"s":""}`,s<60?b:i?`${b} ago`:`in ${b}`}function Xs(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}-${_e(i+1)}-${_e(s)}`;case"DD/MM/YYYY":return`${_e(s)}/${_e(i+1)}/${n}`;case"MM/DD/YYYY":return`${_e(i+1)}/${_e(s)}/${n}`;case"MMM DD, YYYY":return`${jn[i]} ${_e(s)}, ${n}`;case"DD MMM YYYY":return`${_e(s)} ${jn[i]} ${n}`;case"MMMM D, YYYY":return`${Js[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${_e(i+1)}-${_e(s)} ${_e(d)}:${_e(c)}`;case"DD/MM/YYYY HH:mm":return`${_e(s)}/${_e(i+1)}/${n} ${_e(d)}:${_e(c)}`;case"MM/DD/YYYY HH:mm":return`${_e(i+1)}/${_e(s)}/${n} ${_e(d)}:${_e(c)}`;case"relative":return Ks(t);case"locale":return t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return t.toLocaleDateString()}}function Zs(t,o,n){if(!n||o==="unknown")return String(t);const i=qs(t,o);return!i||isNaN(i.getTime())?String(t):Xs(i,n)}function Qs(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 ji(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,ji(c,d,n+1)):i[d]=c}return i}function fo(t){return t.map(o=>typeof o!="object"||o===null||Array.isArray(o)?o:ji(o))}function Yr(t){if(!Array.isArray(t)||t.length===0)return[];const o=fo(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(m=>{typeof m=="object"&&m!==null&&c in m&&(u++,l.add(Qs(m[c])))});const x=u===o.length,h=l.size>1&&!l.has("null");let b="mixed";if(l.size===1)b=Array.from(l)[0];else if(l.size===2&&l.has("null")){const m=Array.from(l).filter(y=>y!=="null");m.length===1&&(b=m[0])}i.push({name:c,type:b,required:x,hasConflict:h})});const d=o.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=Gs(c.name,d);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function ea(t){return t.some(o=>o.hasConflict)}function Je(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 Cn(t){return t==null}function ta(t){return(o,n,i)=>{const s=Cn(o),d=Cn(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 ra(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(h=>h.name===c.column);if(!l)continue;const x=ta(l.type)(s[c.column],d[c.column],c.direction);if(x!==0)return x}return 0})}function oa(t){return t===null?"asc":t==="asc"?"desc":null}function na(t){return t==="string"||t==="boolean"}function ia(t){return t.filter(o=>na(o.type))}function sa(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 aa(t,o,n){if(!n.enabled||n.levels.length===0)return t;const i=Ci(t,n.levels,o);return wi(i,n.collapsedGroups||[])}function Ci(t,o,n,i="",s=0){if(s>=o.length)return t;const d=o[s].column,c=new Map;t.forEach(x=>{const h=x[d],b=h==null?"(empty)":String(h);c.has(b)||c.set(b,[]),c.get(b).push(x)});const l=[];return Array.from(c.keys()).sort().forEach(x=>{const h=c.get(x),b=`${d}:${x}`,m=i?`${i}|${b}`:b,y=sa(h,n),D=s<o.length-1?Ci(h,o,n,m,s+1):h,v={key:m,level:s,column:d,value:x,rowCount:h.length,aggregates:y,children:D};l.push(v)}),l}function wi(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&&wi(i.children,o,n)}else n.push(i);return n}function la(t,o){const n=t.collapsedGroups||[],i=n.includes(o)?n.filter(s=>s!==o):[...n,o];return{...t,collapsedGroups:i}}function ki(t,o){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function Ti(t,o,n){return`${o}: ${n}`}function Xr(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 Ii(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 x of n)c.has(x)?d.push(x):l.has(x)&&u<s.length?(d.push(s[u]),u++):l.has(x)||d.push(x);for(let x=u;x<s.length;x++)d.includes(s[x])||d.push(s[x]);return d}return[...t]}function Ho(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 ca(t,o,n,i,s,d,c,l){const u={},x=[],h={};n.forEach(y=>{u[y.name]=!0,x.push(y.name),h[y.name]=170});const m=Ii(s||x,c||null,l||x);return{filters:t||[],sortStack:o||[],columnVisibility:i||u,columnOrder:m,columnWidths:d||h,grouping:c||null}}function da(t,o){const n=m=>{if(m==null)return m;if(Array.isArray(m))return m.map(y=>n(y));if(typeof m=="object"){const y={};return Object.keys(m).sort().forEach(D=>{y[D]=n(m[D])}),y}return m},i=m=>JSON.stringify(n(m));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 m=[...t.columnOrder||[]].sort().join(",");if((t.columnOrder||[]).join(",")!==m)return!0}const h=t.columnWidths??{},b=o.columnWidths??{};return i(h)!==i(b)||i(t.grouping)!==i(o.grouping)}function ua(t){return!t||t.length===0?"None":t.sort((o,n)=>o.priority-n.priority).map(o=>`${o.column} ${o.direction==="asc"?"↑":"↓"}`).join(", ")}function pa(t,o){var v,C,S;const n=[],i=JSON.stringify(t.filters),s=JSON.stringify(o.filters);if(i!==s){const I=t.filters.length,f=o.filters.length;I>f?n.push({category:"filters",label:"Filters Added",description:`${I-f} new filter${I-f>1?"s":""} added`}):I<f?n.push({category:"filters",label:"Filters Removed",description:`${f-I} filter${f-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,f=o.sortStack.length;I>f?n.push({category:"sorting",label:"Sorting Added",description:`${I-f} new sort rule${I-f>1?"s":""} added`}):I<f?n.push({category:"sorting",label:"Sorting Removed",description:`${f-I} sort rule${f-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(k=>k).length,f=Object.values(o.columnVisibility).filter(k=>k).length;I>f?n.push({category:"visibility",label:"Columns Shown",description:`${I-f} column${I-f>1?"s":""} made visible`}):I<f?n.push({category:"visibility",label:"Columns Hidden",description:`${f-I} column${f-I>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const x=JSON.stringify(t.columnOrder),h=JSON.stringify(o.columnOrder);x!==h&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const b=JSON.stringify(t.columnWidths),m=JSON.stringify(o.columnWidths);if(b!==m){const I=Object.keys(t.columnWidths).filter(f=>t.columnWidths[f]!==o.columnWidths[f]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${I} column width${I>1?"s":""} modified`})}const y=JSON.stringify(t.grouping),D=JSON.stringify(o.grouping);if(y!==D){const I=(v=t.grouping)==null?void 0:v.enabled,f=(C=o.grouping)==null?void 0:C.enabled;if(I&&!f){const k=((S=t.grouping)==null?void 0:S.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${k} grouping level${k>1?"s":""} added`})}else!I&&f?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 wn(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function kn(t){return`[${t}]`}const ar={warn(t,o,...n){wn()&&console.warn(kn(t),o,...n)},error(t,o,...n){wn()&&console.error(kn(t),o,...n)}},zi="urm_report_";function xa(t,o){try{const n=`${zi}${t}`;localStorage.setItem(n,JSON.stringify(o))}catch(n){ar.error("urm:persistence","Failed to save report state",n)}}function ma(t){try{const o=`${zi}${t}`,n=localStorage.getItem(o);return n?JSON.parse(n):null}catch(o){return ar.error("urm:persistence","Failed to load report state",o),null}}function Io(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(ha(c)){const l=s.children,u=Io(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 ha(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 an(t){return t.filter(o=>o.type==="row").map(o=>o.type==="row"?o.data:null).filter(o=>o!==null)}function ln(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 vo(t,o,n,i,s,d,c){let l,u;d?(l={...d},u=c||o.map(h=>h.name)):s?(l={...s.snapshot.columnVisibility},u=c||[...s.snapshot.columnOrder]):(l={},u=[],o.forEach(h=>{l[h.name]=!0,u.push(h.name)}));const x=Object.entries(l).filter(([h,b])=>!b).map(([h,b])=>h);return{data:t,schema:o,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:x,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function So(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,c=s.filter(b=>t.columnVisibility[b]);let l;if(d&&d.enabled){const b=d.collapsedGroups??[],m=Io(i,b);l=an(m)}else l=i;const u=c.join(","),x=l.map(b=>c.map(m=>{const y=b[m];if(y==null)return"";const D=String(y);return D.includes(",")||D.includes('"')||D.includes(`
2
- `)?`"${D.replace(/"/g,'""')}"`:D}).join(",")),h=[u,...x].join(`
3
- `);Bi(h,ln(o,"csv"),"text/csv;charset=utf-8;")}function jo(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,c=s.filter(b=>t.columnVisibility[b]);let l;if(d&&d.enabled){const b=d.collapsedGroups??[],m=Io(i,b);l=an(m)}else l=i;const u=[c,...l.map(b=>c.map(m=>b[m]??""))],x=lo.utils.aoa_to_sheet(u),h=lo.utils.book_new();lo.utils.book_append_sheet(h,x,"Data"),lo.writeFile(h,ln(o,"xlsx"))}function Co(t,o="export",n){const{data:i,appliedFilters:s,appliedSortStack:d,viewMeta:c,hiddenColumns:l,columnOrder:u,grouping:x}=t;let h;if(x&&x.enabled){const y=x.collapsedGroups??[],D=Io(i,y);h=an(D)}else h=i;const b={meta:{exportedAt:new Date().toISOString(),reportName:o,view:(c==null?void 0:c.name)||"Default View",filters:s.map(y=>({field:y.column,operator:y.operator,value:y.value})),sortStack:d.map(y=>({field:y.column,direction:y.direction,priority:y.priority})),grouping:x||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:h},m=JSON.stringify(b,null,2);Bi(m,ln(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 Tn=10;function fa(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>Tn&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Tn)),s}function ga(t,o){return t.map(n=>n.query===o?{...n,isFavourite:!n.isFavourite}:n)}function ya(t,o){return t.filter(n=>n.query!==o)}function ba(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 va={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 Sa(t,o){return!t||t.owner===o?"owner":t.editors.includes(o)?"editor":(t.viewers.includes(o),"viewer")}function ft(t,o){return va[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 ja(t){return t==="viewer"}const In=1e3;function tn(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 tn(n)}const Ca={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 Uo(t){if(!t||!t.column)return"a filter";const o=vt(t.column),n=Ca[t.operator]??t.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(t.operator)?`"${o}" ${n}`:`"${o}" ${n} "${t.value}"`}function zn(t){return!t||!t.enabled||t.levels.length===0?"grouping removed":`grouped by ${t.levels.map(n=>`"${vt(n.column)}"`).join(", ")}`}function wa(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: ${Uo(l)}`}}case"filter_removed":return{summary:`Filter removed: ${Uo(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 "${vt(u==null?void 0:u.column)}"`,detail:`Previously filtered "${vt(l==null?void 0:l.column)}"`}:{summary:`Filter updated: ${Uo(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?vt(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?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: ${zn(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?vt(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${zn(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:[],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: "${vt(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,x=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",h=(i==null?void 0:i.viewName)??"",b=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${b}`,detail:h?`${tn(x)} · View: "${h}"`:tn(x)}}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:Ta(o)}}}function ka(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Di(t,o,n,i,s,d){return{id:ka(),user:o,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:d}}function Ei(t,o){const n=[o,...t];return n.length>In?n.slice(0,In):n}function Ta(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 Ia(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function za(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 Bn=100;function Ba(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Da(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=Ii(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 Ea(t,o,n,i){return{id:Ba(),name:t,description:o,createdBy:n,createdAt:Date.now(),config:i}}function Oa(t,o){const n=t||[];if(n.length>=Bn)throw new Error(`Maximum of ${Bn} presets reached. Please delete old presets first.`);return[...n,o]}function $a(t,o){return(t||[]).filter(i=>i.id!==o)}function Dn(t,o){if(t)return t.find(n=>n.id===o)}function Aa(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function _a(t){const o=t.columnOrder,n=Xr(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 Ma(t,o){return{totalRows:t.length,totalColumns:o.length}}function Ra(t,o){let n=null;return function(...s){const d=()=>{n=null,t(...s)};n&&clearTimeout(n),n=setTimeout(d,o)}}function Ot(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:Wa(t,o)};return process.env.NODE_ENV==="development"&&ar.error("urm:error-handling","[Report Error]",{type:t,context:o,message:s,details:i}),d}function Wa(t,o){return t==="ui"?!0:o==="export"?!1:t==="processing"&&["filters","sorting","grouping","columns"].includes(o)?!0:t!=="system"}function Pa(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 Na(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 La(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 Fa(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 Oi(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 Va(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}=Oi(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 Ha(t,o){return Ot("processing","export",t,{retryAvailable:!!(o!=null&&o.onRetry)})}function En(t,o,n,i){const s=Di(t,o,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Ei(i||[],s)}function Ua(t){return t==null}function Ya(t,o){const{operator:n,value:i}=o;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(Ua(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 Ga(t,o){return!o||o.length===0?t:t.filter(n=>o.every(i=>Ya(n[i.column],i)))}function On(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 co(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function qa({data:t,filters:o}){return{filteredData:p.useMemo(()=>!o||o.length===0?t:Ga(t,o),[t,o])}}function Ja(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 Ka({data:t,searchQuery:o,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!o||o.trim()===""?t:Ja(t,n,o,i),[t,o,n,i])}}function Xa({data:t,sortStack:o,schema:n}){return{sortedData:p.useMemo(()=>!o||o.length===0?t:ra(t,n,o),[t,o,n])}}function Za({data:t,grouping:o,schema:n}){const i=p.useMemo(()=>!o||!o.enabled||o.levels.length===0?t:aa(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(x=>x.name===l)||{name:l,type:"string"}),[n,t]),c=p.useMemo(()=>i.map(l=>t.find(x=>x.name===l)||{name:l,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:s,allColumns:d,visibleColumnSchemas:c,hiddenCount:s.length}}function el({views:t,activeViewId:o,currentState:n}){const i=p.useMemo(()=>t.find(x=>x.id===o),[t,o]),s=p.useMemo(()=>i?da(n,i.snapshot):!1,[i,n]),d=p.useMemo(()=>t.find(x=>x.isDefault),[t]),c=p.useMemo(()=>t.filter(x=>!x.isDefault&&!x.isDeleted),[t]),l=p.useMemo(()=>t.filter(x=>x.isFavorite&&!x.isDeleted),[t]),u=p.useMemo(()=>t.filter(x=>x.isDeleted),[t]);return{activeView:i,isDirty:s,defaultView:d,customViews:c,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function tl({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 y=(s-1)*n,D=y+n;return t.slice(y,D)},[t,o,s,n]),x=p.useCallback(y=>{const D=Math.max(1,Math.min(y,l));d(D)},[l]),h=p.useCallback(()=>{s<l&&d(s+1)},[s,l]),b=p.useCallback(()=>{s>1&&d(s-1)},[s]),m=p.useCallback(()=>{d(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:x,nextPage:h,prevPage:b,resetPage:m,hasNextPage:s<l,hasPrevPage:s>1}}function rl(t){const{rawData:o,schema:n,filters:i,sortStack:s,grouping:d,searchQuery:c,columnVisibility:l,columnOrder:u,columnWidths:x,views:h,activeViewId:b,pagination:m}=t,y=p.useMemo(()=>({filters:i,sortStack:s,grouping:d,columnVisibility:l,columnOrder:u,columnWidths:x}),[i,s,d,l,u,x]),D=el({views:h,activeViewId:b,currentState:y}),v=Qa({schema:n,columnVisibility:l,columnOrder:u}),{filteredData:C}=qa({data:o,filters:i}),{sortedData:S}=Xa({data:C,sortStack:s,schema:n}),{groupedData:I,isGrouped:f}=Za({data:S,grouping:d,schema:n}),{searchedData:k}=Ka({data:I,searchQuery:c,schema:n,visibleColumns:v.visibleColumns}),j=tl({data:k,enabled:(m==null?void 0:m.enabled)||!1,pageSize:(m==null?void 0:m.pageSize)||100,initialPage:(m==null?void 0:m.currentPage)||1}),a=m!=null&&m.enabled?j.paginatedData:k,B=p.useMemo(()=>({totalRows:o.length,filteredRows:C.length,sortedRows:S.length,groupedRows:f?I.length:S.length,searchedRows:k.length,visibleRows:a.length,hiddenColumns:v.hiddenCount,activeFilters:i.length,activeSorts:s.length,isGrouped:f}),[o.length,C.length,S.length,I.length,k.length,a.length,v.hiddenCount,i.length,s.length,f]);return{data:a,filteredData:C,sortedData:S,groupedData:I,searchedData:k,viewEngine:D,columnEngine:v,paginationEngine:j,metrics:B,isGrouped:f,isPaginated:(m==null?void 0:m.enabled)||!1}}let ol=0;function nl(t){t!==null&&t.__urm_row_id__===void 0&&Object.defineProperty(t,"__urm_row_id__",{value:ol++,writable:!1,enumerable:!1,configurable:!1})}const yt="user-demo-001";function il(t={}){var fn,gn,yn,bn,vn;const{mode:o="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:d,sharedReportId:c,config:l={}}=t,[u,x]=p.useState([]),h=cr(),[b,m]=p.useState(""),[y,D]=p.useState(!1),[v,C]=p.useState(!1),[S,I]=p.useState({message:"",severity:"info",open:!1}),f=(w,E="info")=>{I({message:w,severity:E,open:!0})},k=()=>I(w=>({...w,open:!1})),j=l.notifDurationMs??2e3,a=u.find(w=>w.id===b),[B,R]=p.useState("idle"),[q,K]=p.useState(!1),[ee,g]=p.useState(!1),[M,W]=p.useState(!1),[V,Z]=p.useState(!1),[xe,me]=p.useState(!1),[F,A]=p.useState(!1),[H,se]=p.useState(void 0),[G,re]=p.useState(null),[ae,ne]=p.useState(null),[P,ie]=p.useState(!1),[de,le]=p.useState(!1),[fe,J]=p.useState(null),[Re,He]=p.useState(!1),[St,Mt]=p.useState(!1),[pr,Gt]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[pt,Rt]=p.useState(""),[Be,Xe]=p.useState(new Set),[jt,ot]=p.useState(null),[Le,nt]=p.useState(1),[Ct,Ze]=p.useState(15),[it,We]=p.useState(!1),[$r,xr]=p.useState(!1),[mr,qt]=p.useState(!1),[st,Wt]=p.useState(null),[hr,wt]=p.useState(!1),[fr,Ar]=p.useState(null),[Ue,Jt]=p.useState(null),gr=p.useRef(null),ze=p.useMemo(()=>a?Sa(a.permissions,yt):"owner",[a]),Kt=ja(ze),_r=p.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:Ma(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),at=p.useCallback(()=>{a&&(gr.current=Na(a))},[a]),L=p.useCallback((w,E)=>{x(_=>_.map($=>$.id===w?{...$,...E}:$))},[]),lt=p.useCallback(w=>{if(!a)return;Jt(w);const E=En(a.id,yt,w,a.auditHistory||[]);L(a.id,{auditHistory:E}),f(w.message,"error"),w.recoverable&&gr.current&&setTimeout(()=>{La(a,gr.current,L),f("Previous state restored","success")},100)},[a,L]),ye=p.useCallback((w,E,_,$)=>{if(!a)return;const Y=Di(a.id,yt,w,E,_,$),U=a.auditHistory||[],oe=Ei(U,Y);setTimeout(()=>{L(a.id,{auditHistory:oe})},0)},[a,L]);p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const w=Ho(a.schema);(()=>{try{const E=localStorage.getItem("urm_dev_config");return E?JSON.parse(E):null}catch{return null}})(),L(a.id,{views:[w],activeViewId:w.id,filters:w.snapshot.filters,sortStack:w.snapshot.sortStack,columnVisibility:w.snapshot.columnVisibility,columnOrder:w.snapshot.columnOrder,columnWidths:w.snapshot.columnWidths,grouping:w.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,L]),p.useEffect(()=>{if(i&&n&&!v&&u.length===0){const w=fo(i),E={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:w,schema:Yr(w),permissions:{owner:yt,editors:[],viewers:[]}};x([E]),m(E.id),C(!0),R("confirmed")}},[i,n,v,u.length,o,d]),p.useEffect(()=>{if(!s||v)return;let w=!1,E=null;const _=async()=>{try{R("uploading");let $;if(s.type==="api"){const U=await fetch(s.url,{headers:s.headers||{}});if(!U.ok)throw new Error(`HTTP ${U.status}: ${U.statusText}`);$=await U.json()}else $=await s.fetch();if(w)return;if(!Array.isArray($))throw new Error("Data source must return an array of objects");const Y=Yr($);if(v)x(U=>U.map(oe=>oe.id===b?{...oe,uploadedData:$}:oe)),R("confirmed");else{const U={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:fo($),schema:Yr(fo($)),permissions:{owner:yt,editors:[],viewers:[]}};x([U]),m(U.id),C(!0),R("confirmed")}}catch($){w||(R("error"),a&&L(a.id,{uploadError:($==null?void 0:$.message)||"Failed to load data from source"}))}};return _(),s.refreshInterval&&s.refreshInterval>0&&(E=setInterval(_,s.refreshInterval)),()=>{w=!0,E&&clearInterval(E)}},[s,d,o]);const Ye=(fn=a==null?void 0:a.views)==null?void 0:fn.find(w=>w.id===a.activeViewId),Pt=p.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(nl),a.showFavoritesOnly?!a.favoriteRowIndices||a.favoriteRowIndices.length===0?[]:a.uploadedData.filter((w,E)=>a.favoriteRowIndices.includes(E)):a.uploadedData):[],[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),Mr=p.useMemo(()=>{var E;if(!(a!=null&&a.uploadedData)||!((E=a==null?void 0:a.favoriteRowIndices)!=null&&E.length))return new Set;const w=new Set;return a.favoriteRowIndices.forEach(_=>{const $=a.uploadedData[_];$!==void 0&&w.add($)}),w},[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),xt=rl({rawData:Pt,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:pt||"",columnVisibility:(a==null?void 0:a.columnVisibility)||(Ye==null?void 0:Ye.snapshot.columnVisibility)||{},columnOrder:(a==null?void 0:a.columnOrder)||(Ye==null?void 0:Ye.snapshot.columnOrder)||[],columnWidths:(a==null?void 0:a.columnWidths)||(Ye==null?void 0:Ye.snapshot.columnWidths)||{},views:(a==null?void 0:a.views)||[],activeViewId:(a==null?void 0:a.activeViewId)||"",pagination:{enabled:!0,pageSize:Ct,currentPage:Le}}),{data:Xt=[],searchedData:kt=[],groupedData:yr=[],metrics:br={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Rr=!1,paginationEngine:Te}=xt||{},Q=((gn=xt.viewEngine)==null?void 0:gn.activeView)||Ye,ct=((yn=xt.viewEngine)==null?void 0:yn.isDirty)||!1;p.useEffect(()=>{if(!(!Q||!a)&&!a.columnOrder){const w=Q.snapshot.columnOrder,E=Xr(w,Q.snapshot.grouping);L(a.id,{columnOrder:E})}},[a==null?void 0:a.activeViewId]);const Ie=p.useMemo(()=>!(a!=null&&a.schema)||!Q?null:ca(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]),Zt=p.useMemo(()=>!Q||!Ie||!ct?[]:pa(Ie,Q.snapshot),[Q,Ie,ct]),be=p.useCallback((w,E,_)=>{const $={id:`report-${Date.now()}`,name:w,description:E,schemaLocked:!1,permissions:{owner:yt,editors:[],viewers:[]}};if(_&&Array.isArray(_)&&_.length>0){const Y=Yr(_),U=Ho(Y);$.uploadedData=_,$.schema=Y,$.schemaLocked=!0,$.views=[U],$.activeViewId=U.id,$.sortStack=U.snapshot.sortStack,$.filters=U.snapshot.filters,$.columnVisibility=U.snapshot.columnVisibility,$.columnOrder=U.snapshot.columnOrder,$.columnWidths=U.snapshot.columnWidths,$.grouping=U.snapshot.grouping}x(Y=>[...Y,$]),m($.id),D(!1),R("confirmed")},[]),Qe=p.useCallback(w=>{a&&(R("uploading"),setTimeout(()=>{const E=Yr(w);L(a.id,{uploadedData:w,schema:E,uploadError:void 0}),R("preview")},500))},[a,L]),Qt=p.useCallback(w=>{a&&(L(a.id,{uploadError:w}),R("idle"))},[a,L]),mt=p.useCallback(()=>{a&&(L(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),R("idle"))},[a,L]),Fe=p.useCallback(()=>{a&&(L(a.id,{schemaLocked:!0}),R("confirmed"))},[a,L]),vr=p.useCallback(w=>{if(!a)return;if(!ft("edit_sorting",ze)){f(gt("edit_sorting"),"error");return}const E=a.sortStack??[],_=E.find($=>$.column===w);if(_){const $=oa(_.direction);if($===null){const Y=E.filter(U=>U.column!==w).map((U,oe)=>({...U,priority:oe+1}));L(a.id,{sortStack:Y.length>0?Y:void 0})}else{const Y=$,U=E.map(oe=>oe.column===w?{...oe,direction:Y}:oe);L(a.id,{sortStack:U})}}else{if(E.length>=h.sort.maxLevels){f(`Sort limit reached — maximum ${h.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:w,direction:"asc",priority:E.length+1};L(a.id,{sortStack:[...E,$]})}},[a,ze,L]),Tt=p.useCallback(w=>{if(a)if(a.schema){const{validRules:E,invalidColumns:_}=Oi(w,a.schema);_.length>0&&f(`Removed invalid sort columns: ${_.join(", ")}`),at();try{L(a.id,{sortStack:E.length>0?E:void 0})}catch($){const Y=Ot("processing","sorting",$);lt(Y)}}else L(a.id,{sortStack:w.length>0?w:void 0})},[a,L,at,lt]),dt=p.useCallback(w=>{if(!a)return;const E=a.sortStack??[],_=E.find($=>$.column===w);if(!(_&&_.direction==="asc"))if(_){const $=E.map(Y=>Y.column===w?{...Y,direction:"asc"}:Y);L(a.id,{sortStack:$})}else{if(E.length>=h.sort.maxLevels){f(`Sort limit reached — maximum ${h.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:w,direction:"asc",priority:E.length+1};L(a.id,{sortStack:[...E,$]})}},[a,L]),It=p.useCallback(w=>{if(!a)return;const E=a.sortStack??[],_=E.find($=>$.column===w);if(!(_&&_.direction==="desc"))if(_){const $=E.map(Y=>Y.column===w?{...Y,direction:"desc"}:Y);L(a.id,{sortStack:$})}else{if(E.length>=h.sort.maxLevels){f(`Sort limit reached — maximum ${h.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:w,direction:"desc",priority:E.length+1};L(a.id,{sortStack:[...E,$]})}},[a,L]),Wr=p.useCallback(w=>{var _;if(!a)return;if(!ft("edit_filters",ze)){f(gt("edit_filters"),"error");return}const E=(_=a.schema)==null?void 0:_.find($=>$.name===w.column);if(E&&w.value!==void 0){const $=Fa(E.type,w.operator,w.value);if(!$.isValid){f($.errorMessage||"Invalid filter value","error");return}}at();try{const $=a.filters??[];ye("filters","filter_added",$,[...$,w]),L(a.id,{filters:[...$,w]})}catch($){const Y=Ot("processing","filters",$);lt(Y)}},[a,ze,L,at,lt,ye]),er=p.useCallback((w,E)=>{if(!a)return;if(!ft("edit_filters",ze)){f(gt("edit_filters"),"error");return}const _=a.filters??[],$=[..._];ye("filters","filter_updated",_[w],E),$[w]=E,L(a.id,{filters:$})},[a,ze,L,ye]),tr=p.useCallback(w=>{if(!a)return;if(!ft("edit_filters",ze)){f(gt("edit_filters"),"error");return}const E=a.filters??[],_=E.filter(($,Y)=>Y!==w);ye("filters","filter_removed",E[w],null),L(a.id,{filters:_.length>0?_:void 0})},[a,ze,L,ye]),Nt=p.useCallback(()=>{if(!a)return;if(!ft("edit_filters",ze)){f(gt("edit_filters"),"error");return}const w=a.filters??[];ye("filters","filter_cleared",w,null),L(a.id,{filters:void 0})},[a,ze,L,ye]),Sr=p.useCallback(w=>{if(!a)return;if(!ft("edit_filters",ze)){f(gt("edit_filters"),"error");return}const E=a.filters??[];ye("filters","filter_cleared",E,w),L(a.id,{filters:w.length>0?w:void 0})},[a,ze,L,ye]),Ne=p.useCallback(w=>{var Y;if(!a)return;const E=(Y=a.views)==null?void 0:Y.find(U=>U.id===w);if(!E)return;const _=E.snapshot.columnOrder,$=Xr(_,E.snapshot.grouping);L(a.id,{filters:E.snapshot.filters.length>0?[...E.snapshot.filters]:void 0,sortStack:E.snapshot.sortStack.length>0?[...E.snapshot.sortStack]:void 0,columnVisibility:{...E.snapshot.columnVisibility},columnOrder:$,columnWidths:{...E.snapshot.columnWidths},grouping:E.snapshot.grouping,activeViewId:w}),Xe(new Set),W(!1)},[a,L]),ht=p.useCallback((w,E,_)=>{var nr;if(!(a!=null&&a.schema)||!Ie)return;const $=a.views??[],Y=$.filter(Ur=>!Ur.isDeleted).length,U=((nr=h.views)==null?void 0:nr.maxViews)??10;if(Y>=U){f(`View limit reached — you can have at most ${U} saved views. Delete an existing view to create a new one.`,"error");return}const oe={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:w,description:E||void 0,isDefault:_,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:yt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Ie}},ge=_?$.map(Ur=>({...Ur,isDefault:!1})):$;L(a.id,{views:[...ge,oe],activeViewId:oe.id}),f(`"${w}" view created`,"success")},[a,Ie,L]),zt=p.useCallback(()=>{var E;if(!Q||!Ie||Q.isDefault||!a)return;const w=(E=a.views)==null?void 0:E.map(_=>_.id===Q.id?{..._,snapshot:{...Ie}}:_);L(a.id,{views:w}),f(`"${Q.name}" view updated`,"success")},[Q,Ie,a,L]),Lt=p.useCallback(w=>{var $;if(!Q||!Ie||!a)return;const E=w??Ie.columnWidths,_=($=a.views)==null?void 0:$.map(Y=>Y.id===Q.id?{...Y,snapshot:{...Y.snapshot,columnVisibility:Ie.columnVisibility,columnOrder:Ie.columnOrder,columnWidths:E},updatedAt:Date.now()}:Y);L(a.id,{views:_,columnWidths:E}),f(`Column configuration saved to "${Q.name}"`,"success")},[Q,Ie,a,L]),Pr=p.useCallback(w=>{var U,oe;if(!Ie||!a||!Q)return;const E=w??Ie.columnWidths,_={...Q,snapshot:{...Q.snapshot,columnVisibility:Ie.columnVisibility,columnOrder:Ie.columnOrder,columnWidths:E},updatedAt:Date.now()},$=(U=a.views)==null?void 0:U.map(ge=>ge.id===Q.id?_:{...ge,snapshot:{...ge.snapshot,columnVisibility:Ie.columnVisibility,columnOrder:Ie.columnOrder,columnWidths:E},updatedAt:Date.now()});L(a.id,{views:$,columnWidths:E});const Y=(((oe=a.views)==null?void 0:oe.length)||0)-1;f(`Column configuration saved to current view and ${Y} other view${Y===1?"":"s"}`,"success")},[Ie,a,Q,L]),Nr=p.useCallback(()=>{Z(!0)},[]),Ft=p.useCallback(()=>{if(!Q||!a)return;const w=Q.snapshot.columnOrder,E=Xr(w,Q.snapshot.grouping);L(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:E,columnWidths:{...Q.snapshot.columnWidths},grouping:Q.snapshot.grouping}),f("Changes reverted to last saved state","success")},[Q,a,L]),Lr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map($=>({...$,isDefault:$.id===w}));L(a.id,{views:E});const _=a.views.find($=>$.id===w);_&&f(`"${_.name}" set as default view`,"success")},[a,L]),Fr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map($=>$.id===w?{...$,isFavorite:!$.isFavorite,updatedAt:Date.now()}:$);L(a.id,{views:E});const _=a.views.find($=>$.id===w);_&&!_.isFavorite?f(`"${_.name}" added to favorites`,"success"):_&&f(`"${_.name}" removed from favorites`,"info")},[a,L]),rr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map(U=>U.id===w?{...U,isDeleted:!0,updatedAt:Date.now()}:U),_=a.activeViewId===w,$=E.find(U=>U.isDefault&&!U.isDeleted);L(a.id,{views:E,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 Y=a.views.find(U=>U.id===w);Y&&f(`"${Y.name}" moved to Recently Deleted`,"info")},[a,L]),jr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map($=>$.id===w?{...$,isDeleted:!1,updatedAt:Date.now()}:$);L(a.id,{views:E});const _=a.views.find($=>$.id===w);_&&f(`"${_.name}" restored`,"success")},[a,L]),Cr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.find(ge=>ge.id===w),_=a.views.filter(ge=>!ge.isDeleted||ge.id===w);if((E==null?void 0:E.isDefault)&&_.filter(ge=>ge.isDefault).length===1){f("Cannot delete the last default view","error");return}const Y=a.views.filter(ge=>ge.id!==w),U=a.activeViewId===w,oe=Y.find(ge=>ge.isDefault&&!ge.isDeleted);L(a.id,{views:Y,activeViewId:U&&oe?oe.id:a.activeViewId,filters:U&&oe?oe.snapshot.filters.length>0?oe.snapshot.filters:void 0:a.filters,sortStack:U&&oe?oe.snapshot.sortStack.length>0?oe.snapshot.sortStack:void 0:a.sortStack}),E&&f(`"${E.name}" permanently deleted`,"success")},[a,L]),wr=p.useCallback(w=>{re(w),me(!0),W(!1)},[]),or=p.useCallback((w,E)=>{if(!G||!(a!=null&&a.views))return;const _=a.views.map($=>$.id===G?{...$,name:w,description:E||void 0}:$);L(a.id,{views:_}),re(null)},[G,a,L]),kr=p.useCallback(w=>{ne(w),A(!0),W(!1)},[]),ue=p.useCallback(()=>{if(!ae||!(a!=null&&a.views))return;const w=a.views.filter($=>$.id!==ae),E=a.activeViewId===ae,_=w.find($=>$.isDefault);L(a.id,{views:w,activeViewId:E&&_?_.id:a.activeViewId,filters:E&&_?_.snapshot.filters.length>0?_.snapshot.filters:void 0:a.filters,sortStack:E&&_?_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0:a.sortStack}),ne(null),A(!1)},[ae,a,L]),ce=p.useCallback(w=>{var Y;if(!(a!=null&&a.views))return;if(!(((Y=h.views)==null?void 0:Y.isAdmin)??!1)){f("Only administrators can promote views to Global.","error");return}const _=a.views.find(U=>U.id===w);if(!_)return;if(_.scope==="global"){f(`"${_.name}" is already a Global View.`,"info");return}const $=a.views.map(U=>U.id===w?{...U,scope:"global",isDefault:!0,updatedAt:Date.now()}:U.scope==="global"&&U.isDefault?{...U,isDefault:!1}:U);L(a.id,{views:$}),f(`"${_.name}" promoted to Global View and set as default.`,"success")},[a,h,L]);p.useEffect(()=>{Te!=null&&Te.resetPage?Te.resetPage():nt(1)},[a==null?void 0:a.filters,pt,a==null?void 0:a.activeViewId]),p.useEffect(()=>{Te&&Te.currentPage!==Le&&nt(Te.currentPage)},[Te==null?void 0:Te.currentPage]);const Ee=p.useCallback(w=>{Te!=null&&Te.goToPage&&Te.goToPage(w),nt(w)},[Te]),ut=p.useCallback(w=>{const E=(Le-1)*Ct,_=Math.floor(E/w)+1;Ze(w),nt(_),Te==null||Te.goToPage(_)},[Le,Ct,Te]),et=p.useCallback((w,E)=>{if(!a)return;if(!ft("edit_columns",ze)){f(gt("edit_columns"),"error");return}const $={...a.columnVisibility||(Q==null?void 0:Q.snapshot.columnVisibility)||{},[w]:E};L(a.id,{columnVisibility:$})},[a,Q,ze,L]),Bt=p.useCallback(w=>{if(a){if(!ft("edit_columns",ze)){f(gt("edit_columns"),"error");return}L(a.id,{columnOrder:w})}},[a,ze,L]),Vr=p.useCallback((w,E)=>{if(!a)return;if(!ft("edit_columns",ze)){f(gt("edit_columns"),"error");return}const $={...a.columnWidths||(Q==null?void 0:Q.snapshot.columnWidths)||{},[w]:E};L(a.id,{columnWidths:$})},[a,Q,ze,L]),Vt=p.useCallback(w=>{if(!a)return;const _=(a.filters??[]).filter($=>$.column!==w);L(a.id,{filters:_.length>0?_:void 0})},[a,L]),so=p.useCallback(()=>{if(!Q||!(a!=null&&a.schema))return;const w={},E=[],_={};a.schema.forEach($=>{w[$.name]=!0,E.push($.name),_[$.name]=170}),L(a.id,{columnVisibility:w,columnOrder:E,columnWidths:_,filters:void 0,sortStack:void 0}),f("Reset to default layout - all filters and sorts cleared","success")},[Q,a,L]),O=p.useCallback(Ra(w=>{Rt(w)},300),[]),X=p.useCallback(w=>{O(w)},[O]),he=p.useCallback(w=>{if(!w.trim()||!a)return;const E=a.searchHistory||[],_=fa(E,w);L(a.id,{searchHistory:_})},[a,L]),Ve=p.useCallback(w=>{if(!a)return;const E=a.searchHistory||[],_=ga(E,w);L(a.id,{searchHistory:_})},[a,L]),pe=p.useCallback(w=>{if(!a)return;const E=a.searchHistory||[],_=ya(E,w);L(a.id,{searchHistory:_})},[a,L]),Dt=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;Xe(_=>{const $=new Set(_);if(E!==void 0){const Y=Array.from($).find(U=>(U==null?void 0:U.__urm_row_id__)===E);Y!==void 0?$.delete(Y):$.add(w)}else{const Y=JSON.stringify(w),U=Array.from($).find(oe=>JSON.stringify(oe)===Y);U!==void 0?$.delete(U):$.add(w)}return $})},[]),Vo=p.useCallback((w,E)=>{Xe(_=>{const $=new Set(_);for(const Y of E)w?$.add(Y):$.delete(Y);return $})},[]),cs=p.useCallback((w,E,_)=>{Xe($=>{const Y=new Set($),U=Math.min(w,E),oe=Math.max(w,E);for(let ge=U;ge<=oe;ge++)_[ge]!==void 0&&Y.add(_[ge]);return Y})},[]),ds=p.useCallback(()=>{Xe(new Set),ot(null)},[]),us=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;Xe(_=>{const $=new Set(_);if(E!==void 0){const Y=Array.from($).find(U=>(U==null?void 0:U.__urm_row_id__)===E);Y!==void 0&&$.delete(Y)}else $.delete(w);return $})},[]),ps=p.useCallback(w=>{if(!(a!=null&&a.uploadedData))return;const E=a.uploadedData.indexOf(w);if(E===-1)return;const _=a.favoriteRowIndices||[],Y=_.includes(E)?_.filter(U=>U!==E):[..._,E];L(a.id,{favoriteRowIndices:Y})},[a,L]),xs=p.useCallback((w,E)=>{if(!(a!=null&&a.uploadedData))return;const _=a.favoriteRowIndices||[],$=w.map(U=>a.uploadedData.indexOf(U)).filter(U=>U!==-1),Y=E?[..._,...$.filter(U=>!_.includes(U))]:_.filter(U=>!$.includes(U));L(a.id,{favoriteRowIndices:Y})},[a,L]),ms=p.useCallback(()=>{if(!a)return;const w=a.favoriteRowIndices||[],E=!a.showFavoritesOnly;if(E&&w.length===0){f("No rows marked as favorite","warning");return}if(L(a.id,{showFavoritesOnly:E}),E){if(ot(new Set(Be)),Be.size>0){const _=new Set(w.map(Y=>{var U,oe;return(oe=(U=a.uploadedData)==null?void 0:U[Y])==null?void 0:oe.__urm_row_id__}).filter(Y=>Y!==void 0)),$=new Set(Array.from(Be).filter(Y=>(Y==null?void 0:Y.__urm_row_id__)!==void 0&&_.has(Y.__urm_row_id__)));Xe($)}f(`Showing ${w.length} favorite row${w.length===1?"":"s"}`,"info")}else{if(jt!==null){const _=new Set(Array.from(Be).map(oe=>oe==null?void 0:oe.__urm_row_id__).filter(Boolean)),$=new Set(Array.from(jt).map(oe=>oe==null?void 0:oe.__urm_row_id__).filter(Boolean)),Y=new Set(w.map(oe=>{var ge,nr;return(nr=(ge=a.uploadedData)==null?void 0:ge[oe])==null?void 0:nr.__urm_row_id__}).filter(oe=>oe!==void 0)),U=new Set;Array.from(jt).forEach(oe=>{const ge=oe==null?void 0:oe.__urm_row_id__;if(ge===void 0)return;const nr=Y.has(ge),Ur=_.has(ge);nr&&!Ur||U.add(oe)}),Array.from(Be).forEach(oe=>{const ge=oe==null?void 0:oe.__urm_row_id__;ge!==void 0&&($.has(ge)||U.add(oe))}),Xe(U),ot(null)}f("Showing all data","info")}},[a,L,Be,jt]),hs=p.useCallback(w=>{if(a){if(!ft("edit_columns",ze)){f(gt("edit_columns"),"error");return}if(w&&a.schema){const{validGrouping:E,invalidColumns:_}=$i(w,a.schema);_.length>0&&f(`Removed invalid grouping columns: ${_.join(", ")}`,"warning"),at();try{const $=a.grouping;E===null?ye("grouping","group_cleared",$,null):$?ye("grouping","group_reordered",$,E):ye("grouping","group_level_added",null,E);const Y=(Q==null?void 0:Q.snapshot.columnOrder)||a.columnOrder||[],U=Xr(Y,E);L(a.id,{grouping:E,columnOrder:U}),JSON.stringify(U)!==JSON.stringify(a.columnOrder)&&ye("columns","column_reordered",a.columnOrder,U),Mt(!1)}catch($){const Y=Ot("processing","grouping",$);lt(Y)}}else{const E=a.grouping;ye("grouping","group_cleared",E,null);const _=(Q==null?void 0:Q.snapshot.columnOrder)||a.columnOrder||[];L(a.id,{grouping:w,columnOrder:[..._]}),JSON.stringify(_)!==JSON.stringify(a.columnOrder)&&ye("columns","column_reordered",a.columnOrder,_),Mt(!1)}}},[a,Q,ze,L,at,lt,ye]),fs=p.useCallback(w=>{if(!a)return;const E=a.grouping;if(!E)return;const _=la(E,w);L(a.id,{grouping:_})},[a,L]),gs=p.useCallback(()=>{wt(!0)},[]),Hr=p.useCallback(w=>{a!=null&&a.schema&&(ie(!0),setTimeout(()=>{try{let E;w.scope==="visible"?E=kt:E=a.uploadedData||[];let _;w.columnScope==="all"?(_={},(a.schema??[]).forEach(ge=>{_[ge.name]=!0})):_=a.columnVisibility||(Q==null?void 0:Q.snapshot.columnVisibility)||{};const $=a.columnOrder||(Q==null?void 0:Q.snapshot.columnOrder),Y=vo(E,a.schema,a.filters??[],a.sortStack??[],Q,_,$),U=a.name;let oe;switch(w.format){case"csv":So(Y,U,w),oe="export_csv";break;case"excel":jo(Y,U,w),oe="export_excel";break;case"json":Co(Y,U,w),oe="export_json";break}ye("export",oe,null,{format:w.format,scope:w.scope,columnScope:w.columnScope,rowCount:E.length,viewName:(Q==null?void 0:Q.name)||"Default View"}),f(`Export completed successfully (${w.format.toUpperCase()})`,"success")}catch(E){const _=Ha(E,{onRetry:()=>Hr(w)});f(`Export failed: ${_.message}. Click Export to retry.`,"error");const $=En(a.id,yt,_,a.auditHistory||[]);L(a.id,{auditHistory:$}),ar.error("urm:report-engine","Export failed",E)}finally{ie(!1)}},500))},[a,Q,kt,L,ye]),ys=p.useCallback(w=>{if(a!=null&&a.schema){if(ct&&Q&&!Q.isDefault){J(w.format),le(!0),wt(!1);return}Hr(w),wt(!1)}},[a,Q,ct,Hr]),ao=p.useCallback(w=>{Hr({format:w,scope:"visible",columnScope:"visible"})},[Hr]),bs=p.useCallback(()=>{fe&&ao(fe),le(!1),J(null)},[fe,ao]),vs=p.useCallback(()=>{zt(),fe&&ao(fe),le(!1),J(null)},[zt,fe,ao]),Ss=p.useCallback(()=>{le(!1),J(null)},[]),js=p.useCallback(w=>{!(a!=null&&a.schema)||Be.size===0||(ie(!0),setTimeout(()=>{try{const E=Array.from(Be),_=vo(E,a.schema,a.filters??[],a.sortStack??[],Q),$=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(w){case"csv":So(_,$);break;case"excel":jo(_,$);break;case"json":Co(_,$);break}f(`Exported ${E.length} selected rows`,"info")}catch(E){f("Export failed. Please try again.","error"),ar.error("urm:report-engine","Bulk export failed",E)}finally{ie(!1)}},500))},[a,Q,Be,yr]),Cs=p.useCallback((w,E)=>{if(a)try{const _=Da(a),$=Ea(w,E,yt,_),Y=Oa(a.presets,$);L(a.id,{presets:Y}),ye("presets","preset_created",null,{presetId:$.id,name:$.name}),xr(!1),f(`Preset "${w}" saved successfully`,"success")}catch(_){f(_ instanceof Error?_.message:"Failed to create preset","error")}},[a,L,ye]),ws=p.useCallback(()=>{Wt(null),f("Exited preset view","info")},[]),ks=p.useCallback(()=>{qt(!0)},[]),Ts=p.useCallback((w,E)=>{if(!a)return;const _=$a(a.presets,w);L(a.id,{presets:_}),ye("presets","preset_deleted",{presetId:w,name:E},null),st===w&&Wt(null),f(`Preset "${E}" deleted`,"success")},[a,st,L,ye]);p.useEffect(()=>{if(!c||u.length===0)return;const w=u.find(E=>E.id===c);w&&w.id!==b&&m(w.id)},[c,u,b]),p.useEffect(()=>{if(!a)return;const w=Aa();if(w&&a.presets&&a.schemaLocked&&a.schema){const E=Dn(a.presets,w);if(E){const{sanitizedConfig:_,warnings:$}=Va(E.config,a.schema);$.length>0&&$.forEach(U=>f(U,"warning"));const Y=_a(_);L(a.id,Y),Wt(w),ye("presets","preset_applied",null,{presetId:E.id,name:E.name}),f(`Loaded preset: ${E.name}`,"info")}else f("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const Is=st?Dn(a==null?void 0:a.presets,st):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&xa(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 w=ma(a.id);if(w&&w.views.length>0){const E=w.views.find(_=>_.id===w.activeViewId);if(E)L(a.id,{views:w.views,activeViewId:w.activeViewId,filters:E.snapshot.filters.length>0?E.snapshot.filters:void 0,sortStack:E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0});else{const _=w.views.find($=>$.isDefault)||Ho(a.schema);L(a.id,{views:w.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 zs=p.useCallback(w=>{var $;const E=(a==null?void 0:a.filters)??[],_=(($=h.filter)==null?void 0:$.maxConditions)??3;if(E.length>=_){f(`Filter limit reached — maximum ${_} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}se(w),K(!0)},[a,h,f]),Bs=p.useCallback(()=>{K(!1),se(void 0)},[]),Ds=(bn=a==null?void 0:a.views)==null?void 0:bn.find(w=>w.id===G),Es=(vn=a==null?void 0:a.views)==null?void 0:vn.find(w=>w.id===ae);return{reports:u,activeReport:a,activeReportId:b,setActiveReportId:m,isModalOpen:y,setIsModalOpen:D,createReport:be,updateReport:L,uploadState:B,handleFileUpload:Qe,handleUploadError:Qt,handleRetry:mt,handleConfirm:Fe,paginatedData:Xt,processedData:kt,displayData:yr,tableMetrics:br,isGrouped:Rr,tableEngine:xt,activeView:Q,isDirty:ct,currentTableState:Ie,viewChanges:Zt,filters:a==null?void 0:a.filters,showFilterPanel:q,setShowFilterPanel:K,filterFocusColumn:H,handleAddFilter:Wr,handleUpdateFilter:er,handleRemoveFilter:tr,handleClearAllFilters:Nt,handleReplaceFilters:Sr,handleOpenFilterForColumn:zs,handleCloseFilterPanel:Bs,handleClearFiltersForColumn:Vt,sortStack:a==null?void 0:a.sortStack,showSortPanel:ee,setShowSortPanel:g,handleSort:vr,handleUpdateSortStack:Tt,handleSortAscending:dt,handleSortDescending:It,views:a==null?void 0:a.views,showManageViews:M,setShowManageViews:W,showCreateViewModal:V,setShowCreateViewModal:Z,showEditViewModal:xe,setShowEditViewModal:me,showDeleteConfirmation:F,setShowDeleteConfirmation:A,editingView:Ds,deletingView:Es,editingViewId:G,deletingViewId:ae,handleSelectView:Ne,handleCreateView:ht,handleUpdateCurrentView:zt,handleSaveColumnConfigToCurrentView:Lt,handleSaveColumnConfigToAllViews:Pr,handleSaveAsNewView:Nr,handleRevertChanges:Ft,handleToggleDefault:Lr,handleToggleFavorite:Fr,handleSoftDelete:rr,handleRestoreView:jr,handlePermanentDelete:Cr,handleEditView:wr,handleSaveEditView:or,handleDeleteView:kr,handleConfirmDelete:ue,handlePromoteToGlobal:ce,showManageColumns:Re,setShowManageColumns:He,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:et,handleUpdateColumnOrder:Bt,handleUpdateColumnWidth:Vr,handleResetColumnLayout:so,showGroupPanel:St,setShowGroupPanel:Mt,grouping:a==null?void 0:a.grouping,groupingState:pr,handleGroup:hs,handleToggleGroupCollapse:fs,searchQuery:pt,searchHistory:ba((a==null?void 0:a.searchHistory)||[]),handleSearchChange:X,handleAddToSearchHistory:he,handleToggleSearchFavourite:Ve,handleDeleteSearchHistory:pe,selectedRowIds:Be,handleToggleRowSelection:Dt,handleToggleAllRows:Vo,handleRangeSelection:cs,handleClearSelection:ds,handleUpdateSelectionAfterDelete:us,favoriteRowIndices:(a==null?void 0:a.favoriteRowIndices)||[],resolvedFavoritesSet:Mr,showFavoritesOnly:(a==null?void 0:a.showFavoritesOnly)||!1,handleToggleRowFavorite:ps,handleBulkSetFavorites:xs,handleToggleFavoritesFilter:ms,currentPage:Le,pageSize:Ct,paginationEngine:Te,handlePageChange:Ee,handlePageSizeChange:ut,isExporting:P,showExportModal:hr,setShowExportModal:wt,showDirtyExportWarning:de,handleExport:gs,handleExportWithConfig:ys,handleExportSelected:js,handleExportAnyway:bs,handleSaveAndExport:vs,handleCancelExport:Ss,showAuditHistory:it,setShowAuditHistory:We,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:$r,setShowCreatePreset:xr,showManagePresets:mr,setShowManagePresets:qt,activePreset:Is,activePresetId:st,handleOpenManagePresets:ks,handleCreatePreset:Cs,handleClearActivePreset:ws,handleDeletePresetById:Ts,userRole:ze,isViewerRole:Kt,currentUserId:yt,featureLimitWarning:fr,setFeatureLimitWarning:Ar,datasetMeta:_r,reportError:Ue,setReportError:Jt,handleError:lt,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?ea(a.schema):!1,snack:S,handleSnackClose:k,showSnack:f,snackDurationMs:j}}const Ai=p.createContext(void 0);function cn(t){const{children:o,initialData:n,data:i,reportName:s,dataSource:d,mode:c="builder",autoLoad:l=!0,config:u,devConfig:x,showDevPanel:h=!1,sharedReportId:b}=t,y=il({mode:c,autoLoad:l,initialData:i||n,dataSource:d,reportName:s,sharedReportId:b,config:u}),[D,v]=p.useState(()=>Ms()),C=(()=>{const k=Ws(D,x,!!x);return{...k,display:{...k.display,showDevPanel:h||k.display.showDevPanel}}})(),S=p.useCallback(f=>{v(f),Rs(f)},[]),I={...y,activeDevConfig:C,handleDevConfigChange:S};return e.jsx(Si.Provider,{value:C,children:e.jsx(Ai.Provider,{value:I,children:o})})}function zo(){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 sl({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(z.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(z.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(z.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function lr(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 al="$$material";function ll(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var uo={exports:{}},po={exports:{}},ve={};/** @license React v16.13.1
1
+ "use strict";var As=Object.defineProperty;var _s=(t,o,n)=>o in t?As(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n;var jn=(t,o,n)=>_s(t,typeof o!="symbol"?o+"":o,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),Ms=require("xlsx"),z=require("@mui/icons-material"),r=require("@mui/material"),bi=require("react-dom"),Rs=require("@emotion/react"),Ot=require("react-dnd"),an=require("react-dnd-html5-backend");function vi(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 Io=vi(p),co=vi(Ms),Ke={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}},Si="urm_dev_config";function Ws(){try{const t=localStorage.getItem(Si);if(!t)return Ke;const o=JSON.parse(t),n={sort:{...Ke.sort,...o.sort},filter:{...Ke.filter,...o.filter},columns:{...Ke.columns,...o.columns},grouping:{...Ke.grouping,...o.grouping},export:{...Ke.export,...o.export},views:{...Ke.views,...o.views},dates:{...Ke.dates,...o.dates},display:{...Ke.display,...o.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return Ke}}function Ps(t){try{localStorage.setItem(Si,JSON.stringify(t))}catch{}}function Ns(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 ji=p.createContext(Ke);function ur(){return p.useContext(ji)}const Ls=/^\d{4}-\d{2}-\d{2}$/,Fs=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Vs=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Hs=9783072e5,Us=41024448e5,Ys=978307200,Gs=4102444800;function qs(t){return t==null||t===""?"unknown":typeof t=="number"?Number.isInteger(t)&&t>=Hs&&t<=Us?"timestamp_ms":Number.isInteger(t)&&t>=Ys&&t<=Gs?"timestamp_s":"unknown":typeof t!="string"?"unknown":Fs.test(t)||Ls.test(t)?"iso":Vs.test(t.trim())?"locale_string":"unknown"}function Js(t,o){const n=o.map(l=>l[t]).filter(l=>l!=null&&l!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const l of n){const c=qs(l);i[c]++}const s=n.length,d=.7;for(const l of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[l]/s>=d)return l;return"unknown"}function Ks(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 Cn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Xs=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ae(t){return String(t).padStart(2,"0")}function Qs(t){const o=Date.now()-t.getTime(),n=Math.abs(o),i=o>0,s=Math.floor(n/1e3),d=Math.floor(s/60),l=Math.floor(d/60),c=Math.floor(l/24),u=Math.floor(c/7),h=Math.floor(c/30),m=Math.floor(c/365);let b;return s<60?b="just now":d<60?b=`${d} minute${d!==1?"s":""}`:l<24?b=`${l} hour${l!==1?"s":""}`:c<7?b=`${c} day${c!==1?"s":""}`:u<5?b=`${u} week${u!==1?"s":""}`:h<12?b=`${h} month${h!==1?"s":""}`:b=`${m} year${m!==1?"s":""}`,s<60?b:i?`${b} ago`:`in ${b}`}function Zs(t,o){const n=t.getFullYear(),i=t.getMonth(),s=t.getDate(),d=t.getHours(),l=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`${Cn[i]} ${Ae(s)}, ${n}`;case"DD MMM YYYY":return`${Ae(s)} ${Cn[i]} ${n}`;case"MMMM D, YYYY":return`${Xs[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ae(i+1)}-${Ae(s)} ${Ae(d)}:${Ae(l)}`;case"DD/MM/YYYY HH:mm":return`${Ae(s)}/${Ae(i+1)}/${n} ${Ae(d)}:${Ae(l)}`;case"MM/DD/YYYY HH:mm":return`${Ae(i+1)}/${Ae(s)}/${n} ${Ae(d)}:${Ae(l)}`;case"relative":return Qs(t);case"locale":return t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return t.toLocaleDateString()}}function ea(t,o,n){if(!n||o==="unknown")return String(t);const i=Ks(t,o);return!i||isNaN(i.getTime())?String(t):Zs(i,n)}function ta(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 Ci(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,l=t[s];l!==null&&typeof l=="object"&&!Array.isArray(l)&&n<2?Object.assign(i,Ci(l,d,n+1)):i[d]=l}return i}function go(t){return t.map(o=>typeof o!="object"||o===null||Array.isArray(o)?o:Ci(o))}function Gr(t){if(!Array.isArray(t)||t.length===0)return[];const o=go(t),n=new Set;o.forEach(l=>{typeof l=="object"&&l!==null&&Object.keys(l).forEach(c=>n.add(c))});const i=[];n.forEach(l=>{const c=new Set;let u=0;o.forEach(x=>{typeof x=="object"&&x!==null&&l in x&&(u++,c.add(ta(x[l])))});const h=u===o.length,m=c.size>1&&!c.has("null");let b="mixed";if(c.size===1)b=Array.from(c)[0];else if(c.size===2&&c.has("null")){const x=Array.from(c).filter(y=>y!=="null");x.length===1&&(b=x[0])}i.push({name:l,type:b,required:h,hasConflict:m})});const d=o.slice(0,50);for(const l of i){if(l.type!=="string"&&l.type!=="number")continue;const c=Js(l.name,d);c!=="unknown"&&(l.type="date",l.dateFormat=c)}return i}function ra(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 wn(t){return t==null}function oa(t){return(o,n,i)=>{const s=wn(o),d=wn(n);if(s&&d)return 0;if(s)return 1;if(d)return-1;let l=0;switch(t){case"number":const c=Number(o),u=Number(n);l=c-u;break;case"boolean":l=(o?1:0)-(n?1:0);break;case"string":l=String(o).localeCompare(String(n));break;case"array":case"object":l=JSON.stringify(o).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:l=String(o).localeCompare(String(n));break}return i==="asc"?l:-l}}function na(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 l of i){const c=o.find(m=>m.name===l.column);if(!c)continue;const h=oa(c.type)(s[l.column],d[l.column],l.direction);if(h!==0)return h}return 0})}function ia(t){return t===null?"asc":t==="asc"?"desc":null}function sa(t){return t==="string"||t==="boolean"}function aa(t){return t.filter(o=>sa(o.type))}function la(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,l)=>d+l,0))}}),n}function ca(t,o,n){if(!n.enabled||n.levels.length===0)return t;const i=wi(t,n.levels,o);return ki(i,n.collapsedGroups||[])}function wi(t,o,n,i="",s=0){if(s>=o.length)return t;const d=o[s].column,l=new Map;t.forEach(h=>{const m=h[d],b=m==null?"(empty)":String(m);l.has(b)||l.set(b,[]),l.get(b).push(h)});const c=[];return Array.from(l.keys()).sort().forEach(h=>{const m=l.get(h),b=`${d}:${h}`,x=i?`${i}|${b}`:b,y=la(m,n),D=s<o.length-1?wi(m,o,n,x,s+1):m,v={key:x,level:s,column:d,value:h,rowCount:m.length,aggregates:y,children:D};c.push(v)}),c}function ki(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&&ki(i.children,o,n)}else n.push(i);return n}function da(t,o){const n=t.collapsedGroups||[],i=n.includes(o)?n.filter(s=>s!==o):[...n,o];return{...t,collapsedGroups:i}}function Ti(t,o){return t==null?"":typeof t=="number"?`Σ ${t.toLocaleString()}`:String(t)}function Ii(t,o,n){return`${o}: ${n}`}function Qr(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 zi(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=[],l=new Set(i),c=new Set(s);let u=0;for(const h of n)l.has(h)?d.push(h):c.has(h)&&u<s.length?(d.push(s[u]),u++):c.has(h)||d.push(h);for(let h=u;h<s.length;h++)d.includes(s[h])||d.push(s[h]);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 ua(t,o,n,i,s,d,l,c){const u={},h=[],m={};n.forEach(y=>{u[y.name]=!0,h.push(y.name),m[y.name]=170});const x=zi(s||h,l||null,c||h);return{filters:t||[],sortStack:o||[],columnVisibility:i||u,columnOrder:x,columnWidths:d||m,grouping:l||null}}function pa(t,o){const n=x=>{if(x==null)return x;if(Array.isArray(x))return x.map(y=>n(y));if(typeof x=="object"){const y={};return Object.keys(x).sort().forEach(D=>{y[D]=n(x[D])}),y}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 l=[...t.columnOrder||[]].sort().join(","),c=[...o.columnOrder||[]].sort().join(",");if(l!==c)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??{},b=o.columnWidths??{};return i(m)!==i(b)||i(t.grouping)!==i(o.grouping)}function xa(t){return!t||t.length===0?"None":t.sort((o,n)=>o.priority-n.priority).map(o=>`${o.column} ${o.direction==="asc"?"↑":"↓"}`).join(", ")}function ma(t,o){var v,C,S;const n=[],i=JSON.stringify(t.filters),s=JSON.stringify(o.filters);if(i!==s){const I=t.filters.length,f=o.filters.length;I>f?n.push({category:"filters",label:"Filters Added",description:`${I-f} new filter${I-f>1?"s":""} added`}):I<f?n.push({category:"filters",label:"Filters Removed",description:`${f-I} filter${f-I>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const d=JSON.stringify(t.sortStack),l=JSON.stringify(o.sortStack);if(d!==l){const I=t.sortStack.length,f=o.sortStack.length;I>f?n.push({category:"sorting",label:"Sorting Added",description:`${I-f} new sort rule${I-f>1?"s":""} added`}):I<f?n.push({category:"sorting",label:"Sorting Removed",description:`${f-I} sort rule${f-I>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const c=JSON.stringify(t.columnVisibility),u=JSON.stringify(o.columnVisibility);if(c!==u){const I=Object.values(t.columnVisibility).filter(k=>k).length,f=Object.values(o.columnVisibility).filter(k=>k).length;I>f?n.push({category:"visibility",label:"Columns Shown",description:`${I-f} column${I-f>1?"s":""} made visible`}):I<f?n.push({category:"visibility",label:"Columns Hidden",description:`${f-I} column${f-I>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const h=JSON.stringify(t.columnOrder),m=JSON.stringify(o.columnOrder);h!==m&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const b=JSON.stringify(t.columnWidths),x=JSON.stringify(o.columnWidths);if(b!==x){const I=Object.keys(t.columnWidths).filter(f=>t.columnWidths[f]!==o.columnWidths[f]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${I} column width${I>1?"s":""} modified`})}const y=JSON.stringify(t.grouping),D=JSON.stringify(o.grouping);if(y!==D){const I=(v=t.grouping)==null?void 0:v.enabled,f=(C=o.grouping)==null?void 0:C.enabled;if(I&&!f){const k=((S=t.grouping)==null?void 0:S.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${k} grouping level${k>1?"s":""} added`})}else!I&&f?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 kn(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Tn(t){return`[${t}]`}const cr={warn(t,o,...n){kn()&&console.warn(Tn(t),o,...n)},error(t,o,...n){kn()&&console.error(Tn(t),o,...n)}},Bi="urm_report_";function ha(t,o){try{const n=`${Bi}${t}`;localStorage.setItem(n,JSON.stringify(o))}catch(n){cr.error("urm:persistence","Failed to save report state",n)}}function fa(t){try{const o=`${Bi}${t}`,n=localStorage.getItem(o);return n?JSON.parse(n):null}catch(o){return cr.error("urm:persistence","Failed to load report state",o),null}}function zo(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 l=s.children[0];if(ga(l)){const c=s.children,u=zo(c,o,n+1);i.push(...u)}else{const c=s.children;for(const u of c)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function ga(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"),l=`${i}-${s}-${d}`;return`${t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${l}.${o}`}function So(t,o,n,i,s,d,l){let c,u;d?(c={...d},u=l||o.map(m=>m.name)):s?(c={...s.snapshot.columnVisibility},u=l||[...s.snapshot.columnOrder]):(c={},u=[],o.forEach(m=>{c[m.name]=!0,u.push(m.name)}));const h=Object.entries(c).filter(([m,b])=>!b).map(([m,b])=>m);return{data:t,schema:o,appliedFilters:n,appliedSortStack:i,columnVisibility:c,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:h,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function jo(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,l=s.filter(b=>t.columnVisibility[b]);let c;if(d&&d.enabled){const b=d.collapsedGroups??[],x=zo(i,b);c=ln(x)}else c=i;const u=l.join(","),h=c.map(b=>l.map(x=>{const y=b[x];if(y==null)return"";const D=String(y);return D.includes(",")||D.includes('"')||D.includes(`
2
+ `)?`"${D.replace(/"/g,'""')}"`:D}).join(",")),m=[u,...h].join(`
3
+ `);Di(m,cn(o,"csv"),"text/csv;charset=utf-8;")}function Co(t,o="export",n){const{data:i,columnOrder:s,grouping:d}=t,l=s.filter(b=>t.columnVisibility[b]);let c;if(d&&d.enabled){const b=d.collapsedGroups??[],x=zo(i,b);c=ln(x)}else c=i;const u=[l,...c.map(b=>l.map(x=>b[x]??""))],h=co.utils.aoa_to_sheet(u),m=co.utils.book_new();co.utils.book_append_sheet(m,h,"Data"),co.writeFile(m,cn(o,"xlsx"))}function wo(t,o="export",n){const{data:i,appliedFilters:s,appliedSortStack:d,viewMeta:l,hiddenColumns:c,columnOrder:u,grouping:h}=t;let m;if(h&&h.enabled){const y=h.collapsedGroups??[],D=zo(i,y);m=ln(D)}else m=i;const b={meta:{exportedAt:new Date().toISOString(),reportName:o,view:(l==null?void 0:l.name)||"Default View",filters:s.map(y=>({field:y.column,operator:y.operator,value:y.value})),sortStack:d.map(y=>({field:y.column,direction:y.direction,priority:y.priority})),grouping:h||{},hiddenColumns:c,columnOrder:u,exportConfig:n||{scope:"visible"}},data:m},x=JSON.stringify(b,null,2);Di(x,cn(o,"json"),"application/json;charset=utf-8;")}function Di(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 In=10;function ya(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>In&&(s=[...s].sort((l,c)=>l.isFavourite&&!c.isFavourite?-1:!l.isFavourite&&c.isFavourite?1:c.lastUsed-l.lastUsed).slice(0,In)),s}function ba(t,o){return t.map(n=>n.query===o?{...n,isFavourite:!n.isFavourite}:n)}function va(t,o){return t.filter(n=>n.query!==o)}function Sa(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 ja={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 Ca(t,o){return!t||t.owner===o?"owner":t.editors.includes(o)?"editor":(t.viewers.includes(o),"viewer")}function bt(t,o){return ja[o].includes(t)}function vt(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 wa(t){return t==="viewer"}const zn=1e3;function rn(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)}function Ct(t){if(!t)return"";const n=t.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return rn(n)}const ka={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 Yo(t){if(!t||!t.column)return"a filter";const o=Ct(t.column),n=ka[t.operator]??t.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(t.operator)?`"${o}" ${n}`:`"${o}" ${n} "${t.value}"`}function Bn(t){return!t||!t.enabled||t.levels.length===0?"grouping removed":`grouped by ${t.levels.map(n=>`"${Ct(n.column)}"`).join(", ")}`}function Ta(t){var s,d,l;const{action:o,previousState:n,newState:i}=t;switch(o){case"filter_added":{const c=i&&Array.isArray(i)?i[i.length-1]:i;return{summary:`Filter added: ${Yo(c)}`}}case"filter_removed":return{summary:`Filter removed: ${Yo(n)}`};case"filter_updated":{const c=n,u=i;return(c==null?void 0:c.column)!==(u==null?void 0:u.column)?{summary:`Filter changed on "${Ct(u==null?void 0:u.column)}"`,detail:`Previously filtered "${Ct(c==null?void 0:c.column)}"`}:{summary:`Filter updated: ${Yo(u)}`}}case"filter_cleared":{const c=Array.isArray(n)?n.length:0;return{summary:c>0?`All filters cleared (${c} filter${c!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const c=i!=null&&i.column?Ct(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:c?`Sort added: "${c}" ${u}`:"Sort level added"}}case"sort_level_removed":{const c=n!=null&&n.column?Ct(n.column):"";return{summary:c?`Sort removed: "${c}"`:"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: ${Bn(i)}`};case"group_level_removed":{const c=n,u=(d=(s=c==null?void 0:c.levels)==null?void 0:s[0])!=null&&d.column?Ct(c.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Bn(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column hidden: "${Ct(c)}"`:"Column hidden"}}case"column_shown":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column shown: "${Ct(c)}"`:"Column made visible"}}case"column_reordered":{const c=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return c.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 c=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:c?`Column resized: "${Ct(c)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const c=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:c?`View created: "${c}"`:"New view created"}}case"view_updated":{const c=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:c?`View updated: "${c}"`:"View updated"}}case"view_deleted":{const c=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:c?`View deleted: "${c}"`:"View deleted"}}case"view_set_default":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Default view set to "${c}"`:"Default view changed"}}case"view_switched":{const c=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return c&&u?{summary:`Switched to view "${u}"`,detail:`From "${c}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":{const c=o==="export_csv"?"CSV":o==="export_excel"?"Excel":"JSON",u=i==null?void 0:i.rowCount,h=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",m=(i==null?void 0:i.viewName)??"",b=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${c}${b}`,detail:m?`${rn(h)} · View: "${m}"`:rn(h)}}case"export_triggered":{const c=((l=i==null?void 0:i.format)==null?void 0:l.toUpperCase())??"";return{summary:c?`Export triggered: ${c}`:"Export triggered"}}case"preset_created":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset created: "${c}"`:"New preset created"}}case"preset_applied":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset applied: "${c}"`:"Preset applied"}}case"preset_deleted":{const c=(n==null?void 0:n.name)??"";return{summary:c?`Preset deleted: "${c}"`:"Preset deleted"}}case"preset_link_copied":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset link copied: "${c}"`:"Preset link copied to clipboard"}}case"theme_changed":{const c=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return c&&u?{summary:`Theme changed from "${c}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const c=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:c?`Details: ${String(c).slice(0,120)}`:void 0}}default:return{summary:za(o)}}}function Ia(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ei(t,o,n,i,s,d){return{id:Ia(),user:o,reportId:t,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:d}}function Oi(t,o){const n=[o,...t];return n.length>zn?n.slice(0,zn):n}function za(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 Ba(t){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[t]||t}function Da(t){const o=new Date(t),i=new Date().getTime()-o.getTime(),s=Math.floor(i/6e4),d=Math.floor(i/36e5),l=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`:l<7?`${l} day${l>1?"s":""} ago`:o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Dn=100;function Ea(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Oa(t){var d;const o=(d=t.views)==null?void 0:d.find(l=>l.id===t.activeViewId),n=o==null?void 0:o.snapshot.columnOrder,i=t.columnOrder||[],s=zi(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 $a(t,o,n,i){return{id:Ea(),name:t,description:o,createdBy:n,createdAt:Date.now(),config:i}}function Aa(t,o){const n=t||[];if(n.length>=Dn)throw new Error(`Maximum of ${Dn} presets reached. Please delete old presets first.`);return[...n,o]}function _a(t,o){return(t||[]).filter(i=>i.id!==o)}function En(t,o){if(t)return t.find(n=>n.id===o)}function Ma(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Ra(t){const o=t.columnOrder,n=Qr(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 Wa(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:Pa(t,o)};return process.env.NODE_ENV==="development"&&cr.error("urm:error-handling","[Report Error]",{type:t,context:o,message:s,details:i}),d}function Pa(t,o){return t==="ui"?!0:o==="export"?!1:t==="processing"&&["filters","sorting","grouping","columns"].includes(o)?!0:t!=="system"}function Na(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 La(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 Fa(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 Va(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 $i(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 Ai(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 Ha(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(l=>{const c=i.has(l.column);return c||n.push(`Filter for column "${l.column}" ignored (column not found)`),c});s.filters=d.length>0?d:void 0}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:d,invalidColumns:l}=$i(s.sortStack,o);l.length>0&&n.push(`Sort rules for columns ignored: ${l.join(", ")}`),s.sortStack=d.length>0?d:void 0}if(s.grouping){const{validGrouping:d,invalidColumns:l}=Ai(s.grouping,o);l.length>0&&n.push(`Grouping for columns ignored: ${l.join(", ")}`),s.grouping=d}if(s.columnVisibility){const d={};Object.entries(s.columnVisibility).forEach(([l,c])=>{i.has(l)?d[l]=c:n.push(`Column visibility for "${l}" 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(l=>{const c=i.has(l);return c||n.push(`Column "${l}" in order ignored (column not found)`),c});s.columnOrder=d.length>0?d:void 0}if(s.columnWidths){const d={};Object.entries(s.columnWidths).forEach(([l,c])=>{i.has(l)?d[l]=c:n.push(`Column width for "${l}" ignored (column not found)`)}),s.columnWidths=Object.keys(d).length>0?d:void 0}return{sanitizedConfig:s,warnings:n}}function Ua(t,o){return Et("processing","export",t,{retryAvailable:!!(o!=null&&o.onRetry)})}function On(t,o,n,i){const s=Ei(t,o,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Oi(i||[],s)}function Ya(t){return t==null}function Ga(t,o){const{operator:n,value:i}=o;if(n==="NULL")return t==null;if(n==="NOT_NULL")return t!=null;if(Ya(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 qa(t,o){return!o||o.length===0?t:t.filter(n=>o.every(i=>Ga(n[i.column],i)))}function $n(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 uo(t){return t!=="isTrue"&&t!=="isFalse"&&t!=="NULL"&&t!=="NOT_NULL"}function Ja({data:t,filters:o}){return{filteredData:p.useMemo(()=>!o||o.length===0?t:qa(t,o),[t,o])}}function Ka(t,o,n,i){if(!n||n.trim()==="")return t;const s=n.toLowerCase().trim(),d=o.filter(l=>i.includes(l.name));return t.filter(l=>d.some(c=>{const u=l[c.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function Xa({data:t,searchQuery:o,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!o||o.trim()===""?t:Ka(t,n,o,i),[t,o,n,i])}}function Qa({data:t,sortStack:o,schema:n}){return{sortedData:p.useMemo(()=>!o||o.length===0?t:na(t,n,o),[t,o,n])}}function Za({data:t,grouping:o,schema:n}){const i=p.useMemo(()=>!o||!o.enabled||o.levels.length===0?t:ca(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 el({schema:t,columnVisibility:o,columnOrder:n}){const i=p.useMemo(()=>n.filter(c=>o[c]!==!1),[n,o]),s=p.useMemo(()=>Object.entries(o).filter(([c,u])=>!u).map(([c,u])=>c),[o]),d=p.useMemo(()=>n.map(c=>t.find(h=>h.name===c)||{name:c,type:"string"}),[n,t]),l=p.useMemo(()=>i.map(c=>t.find(h=>h.name===c)||{name:c,type:"string"}),[i,t]);return{visibleColumns:i,hiddenColumns:s,allColumns:d,visibleColumnSchemas:l,hiddenCount:s.length}}function tl({views:t,activeViewId:o,currentState:n}){const i=p.useMemo(()=>t.find(h=>h.id===o),[t,o]),s=p.useMemo(()=>i?pa(n,i.snapshot):!1,[i,n]),d=p.useMemo(()=>t.find(h=>h.isDefault),[t]),l=p.useMemo(()=>t.filter(h=>!h.isDefault&&!h.isDeleted),[t]),c=p.useMemo(()=>t.filter(h=>h.isFavorite&&!h.isDeleted),[t]),u=p.useMemo(()=>t.filter(h=>h.isDeleted),[t]);return{activeView:i,isDirty:s,defaultView:d,customViews:l,favoriteViews:c,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function rl({data:t,enabled:o=!1,pageSize:n=100,initialPage:i=1}){const[s,d]=p.useState(i),l=t.length,c=Math.ceil(l/n),u=p.useMemo(()=>{if(!o)return t;const y=(s-1)*n,D=y+n;return t.slice(y,D)},[t,o,s,n]),h=p.useCallback(y=>{const D=Math.max(1,Math.min(y,c));d(D)},[c]),m=p.useCallback(()=>{s<c&&d(s+1)},[s,c]),b=p.useCallback(()=>{s>1&&d(s-1)},[s]),x=p.useCallback(()=>{d(1)},[]);return{paginatedData:u,currentPage:s,totalPages:c,pageSize:n,totalRows:l,goToPage:h,nextPage:m,prevPage:b,resetPage:x,hasNextPage:s<c,hasPrevPage:s>1}}function ol(t){const{rawData:o,schema:n,filters:i,sortStack:s,grouping:d,searchQuery:l,columnVisibility:c,columnOrder:u,columnWidths:h,views:m,activeViewId:b,pagination:x}=t,y=p.useMemo(()=>({filters:i,sortStack:s,grouping:d,columnVisibility:c,columnOrder:u,columnWidths:h}),[i,s,d,c,u,h]),D=tl({views:m,activeViewId:b,currentState:y}),v=el({schema:n,columnVisibility:c,columnOrder:u}),{filteredData:C}=Ja({data:o,filters:i}),{sortedData:S}=Qa({data:C,sortStack:s,schema:n}),{groupedData:I,isGrouped:f}=Za({data:S,grouping:d,schema:n}),{searchedData:k}=Xa({data:I,searchQuery:l,schema:n,visibleColumns:v.visibleColumns}),j=rl({data:k,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?j.paginatedData:k,B=p.useMemo(()=>({totalRows:o.length,filteredRows:C.length,sortedRows:S.length,groupedRows:f?I.length:S.length,searchedRows:k.length,visibleRows:a.length,hiddenColumns:v.hiddenCount,activeFilters:i.length,activeSorts:s.length,isGrouped:f}),[o.length,C.length,S.length,I.length,k.length,a.length,v.hiddenCount,i.length,s.length,f]);return{data:a,filteredData:C,sortedData:S,groupedData:I,searchedData:k,viewEngine:D,columnEngine:v,paginationEngine:j,metrics:B,isGrouped:f,isPaginated:(x==null?void 0:x.enabled)||!1}}let nl=0;function il(t){t!==null&&t.__urm_row_id__===void 0&&Object.defineProperty(t,"__urm_row_id__",{value:nl++,writable:!1,enumerable:!1,configurable:!1})}const St="user-demo-001";function sl(t={}){var gn,yn,bn,vn,Sn;const{mode:o="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:d,sharedReportId:l,config:c={}}=t,[u,h]=p.useState([]),m=ur(),[b,x]=p.useState(""),[y,D]=p.useState(!1),[v,C]=p.useState(!1),[S,I]=p.useState({message:"",severity:"info",open:!1}),f=(w,E="info")=>{I({message:w,severity:E,open:!0})},k=()=>I(w=>({...w,open:!1})),j=c.notifDurationMs??2e3,a=u.find(w=>w.id===b),[B,R]=p.useState("idle"),[J,K]=p.useState(!1),[ee,g]=p.useState(!1),[M,W]=p.useState(!1),[V,Q]=p.useState(!1),[xe,me]=p.useState(!1),[L,A]=p.useState(!1),[H,se]=p.useState(void 0),[G,re]=p.useState(null),[ae,ne]=p.useState(null),[P,ie]=p.useState(!1),[pe,le]=p.useState(!1),[ge,q]=p.useState(null),[_e,et]=p.useState(!1),[tt,_t]=p.useState(!1),[mr,Mt]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Rt,Wt]=p.useState(""),[pt,Ve]=p.useState(""),[qe,Ue]=p.useState(new Set),[rt,Je]=p.useState(null),[ot,wt]=p.useState(1),[He,lt]=p.useState(15),[Re,Or]=p.useState(!1),[$r,qt]=p.useState(!1),[hr,Pt]=p.useState(!1),[xt,Nt]=p.useState(null),[fr,kt]=p.useState(!1),[Ar,Ye]=p.useState(null),[gr,_r]=p.useState(null),Jt=p.useRef(null),Ce=p.useMemo(()=>a?Ca(a.permissions,St):"owner",[a]),Mr=wa(Ce),yr=p.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:Wa(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),ct=p.useCallback(()=>{a&&(Jt.current=La(a))},[a]),F=p.useCallback((w,E)=>{h(_=>_.map($=>$.id===w?{...$,...E}:$))},[]),Ge=p.useCallback(w=>{if(!a)return;_r(w);const E=On(a.id,St,w,a.auditHistory||[]);F(a.id,{auditHistory:E}),f(w.message,"error"),w.recoverable&&Jt.current&&setTimeout(()=>{Fa(a,Jt.current,F),f("Previous state restored","success")},100)},[a,F]),we=p.useCallback((w,E,_,$)=>{if(!a)return;const Y=Ei(a.id,St,w,E,_,$),U=a.auditHistory||[],oe=Oi(U,Y);setTimeout(()=>{F(a.id,{auditHistory:oe})},0)},[a,F]);p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const w=Uo(a.schema);(()=>{try{const E=localStorage.getItem("urm_dev_config");return E?JSON.parse(E):null}catch{return null}})(),F(a.id,{views:[w],activeViewId:w.id,filters:w.snapshot.filters,sortStack:w.snapshot.sortStack,columnVisibility:w.snapshot.columnVisibility,columnOrder:w.snapshot.columnOrder,columnWidths:w.snapshot.columnWidths,grouping:w.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&&!v&&u.length===0){const w=go(i),E={id:`auto-report-${Date.now()}`,name:d||(o==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:w,schema:Gr(w),permissions:{owner:St,editors:[],viewers:[]}};h([E]),x(E.id),C(!0),R("confirmed")}},[i,n,v,u.length,o,d]),p.useEffect(()=>{if(!s||v)return;let w=!1,E=null;const _=async()=>{try{R("uploading");let $;if(s.type==="api"){const U=await fetch(s.url,{headers:s.headers||{}});if(!U.ok)throw new Error(`HTTP ${U.status}: ${U.statusText}`);$=await U.json()}else $=await s.fetch();if(w)return;if(!Array.isArray($))throw new Error("Data source must return an array of objects");const Y=Gr($);if(v)h(U=>U.map(oe=>oe.id===b?{...oe,uploadedData:$}:oe)),R("confirmed");else{const U={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:go($),schema:Gr(go($)),permissions:{owner:St,editors:[],viewers:[]}};h([U]),x(U.id),C(!0),R("confirmed")}}catch($){w||(R("error"),a&&F(a.id,{uploadError:($==null?void 0:$.message)||"Failed to load data from source"}))}};return _(),s.refreshInterval&&s.refreshInterval>0&&(E=setInterval(_,s.refreshInterval)),()=>{w=!0,E&&clearInterval(E)}},[s,d,o]);const Pe=(gn=a==null?void 0:a.views)==null?void 0:gn.find(w=>w.id===a.activeViewId),Rr=p.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(il),a.showFavoritesOnly?!a.favoriteRowIndices||a.favoriteRowIndices.length===0?[]:a.uploadedData.filter((w,E)=>a.favoriteRowIndices.includes(E)):a.uploadedData):[],[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),Kt=p.useMemo(()=>{var E;if(!(a!=null&&a.uploadedData)||!((E=a==null?void 0:a.favoriteRowIndices)!=null&&E.length))return new Set;const w=new Set;return a.favoriteRowIndices.forEach(_=>{const $=a.uploadedData[_];$!==void 0&&w.add($)}),w},[a==null?void 0:a.uploadedData,a==null?void 0:a.showFavoritesOnly,a==null?void 0:a.favoriteRowIndices]),mt=ol({rawData:Rr,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:pt||"",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:He,currentPage:ot}}),{data:Xt=[],searchedData:Qt=[],groupedData:Zt=[],metrics:Wr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Lt=!1,paginationEngine:ze}=mt||{},Z=((yn=mt.viewEngine)==null?void 0:yn.activeView)||Pe,ht=((bn=mt.viewEngine)==null?void 0:bn.isDirty)||!1;p.useEffect(()=>{if(!(!Z||!a)&&!a.columnOrder){const w=Z.snapshot.columnOrder,E=Qr(w,Z.snapshot.grouping);F(a.id,{columnOrder:E})}},[a==null?void 0:a.activeViewId]);const ke=p.useMemo(()=>!(a!=null&&a.schema)||!Z?null:ua(a.filters||[],a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,Z.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,Z]),ye=p.useMemo(()=>!Z||!ke||!ht?[]:ma(ke,Z.snapshot),[Z,ke,ht]),nt=p.useCallback((w,E,_)=>{const $={id:`report-${Date.now()}`,name:w,description:E,schemaLocked:!1,permissions:{owner:St,editors:[],viewers:[]}};if(_&&Array.isArray(_)&&_.length>0){const Y=Gr(_),U=Uo(Y);$.uploadedData=_,$.schema=Y,$.schemaLocked=!0,$.views=[U],$.activeViewId=U.id,$.sortStack=U.snapshot.sortStack,$.filters=U.snapshot.filters,$.columnVisibility=U.snapshot.columnVisibility,$.columnOrder=U.snapshot.columnOrder,$.columnWidths=U.snapshot.columnWidths,$.grouping=U.snapshot.grouping}h(Y=>[...Y,$]),x($.id),D(!1),R("confirmed")},[]),er=p.useCallback(w=>{a&&(R("uploading"),setTimeout(()=>{const E=Gr(w);F(a.id,{uploadedData:w,schema:E,uploadError:void 0}),R("preview")},500))},[a,F]),ft=p.useCallback(w=>{a&&(F(a.id,{uploadError:w}),R("idle"))},[a,F]),Le=p.useCallback(()=>{a&&(F(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),R("idle"))},[a,F]),br=p.useCallback(()=>{a&&(F(a.id,{schemaLocked:!0}),R("confirmed"))},[a,F]),Tt=p.useCallback(w=>{if(!a)return;if(!bt("edit_sorting",Ce)){f(vt("edit_sorting"),"error");return}const E=a.sortStack??[],_=E.find($=>$.column===w);if(_){const $=ia(_.direction);if($===null){const Y=E.filter(U=>U.column!==w).map((U,oe)=>({...U,priority:oe+1}));F(a.id,{sortStack:Y.length>0?Y:void 0})}else{const Y=$,U=E.map(oe=>oe.column===w?{...oe,direction:Y}:oe);F(a.id,{sortStack:U})}}else{if(E.length>=m.sort.maxLevels){f(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:w,direction:"asc",priority:E.length+1};F(a.id,{sortStack:[...E,$]})}},[a,Ce,F]),dt=p.useCallback(w=>{if(a)if(a.schema){const{validRules:E,invalidColumns:_}=$i(w,a.schema);_.length>0&&f(`Removed invalid sort columns: ${_.join(", ")}`),ct();try{F(a.id,{sortStack:E.length>0?E:void 0})}catch($){const Y=Et("processing","sorting",$);Ge(Y)}}else F(a.id,{sortStack:w.length>0?w:void 0})},[a,F,ct,Ge]),It=p.useCallback(w=>{if(!a)return;const E=a.sortStack??[],_=E.find($=>$.column===w);if(!(_&&_.direction==="asc"))if(_){const $=E.map(Y=>Y.column===w?{...Y,direction:"asc"}:Y);F(a.id,{sortStack:$})}else{if(E.length>=m.sort.maxLevels){f(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:w,direction:"asc",priority:E.length+1};F(a.id,{sortStack:[...E,$]})}},[a,F]),Pr=p.useCallback(w=>{if(!a)return;const E=a.sortStack??[],_=E.find($=>$.column===w);if(!(_&&_.direction==="desc"))if(_){const $=E.map(Y=>Y.column===w?{...Y,direction:"desc"}:Y);F(a.id,{sortStack:$})}else{if(E.length>=m.sort.maxLevels){f(`Sort limit reached — maximum ${m.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:w,direction:"desc",priority:E.length+1};F(a.id,{sortStack:[...E,$]})}},[a,F]),tr=p.useCallback(w=>{var _;if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const E=(_=a.schema)==null?void 0:_.find($=>$.name===w.column);if(E&&w.value!==void 0){const $=Va(E.type,w.operator,w.value);if(!$.isValid){f($.errorMessage||"Invalid filter value","error");return}}ct();try{const $=a.filters??[];we("filters","filter_added",$,[...$,w]),F(a.id,{filters:[...$,w]})}catch($){const Y=Et("processing","filters",$);Ge(Y)}},[a,Ce,F,ct,Ge,we]),rr=p.useCallback((w,E)=>{if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const _=a.filters??[],$=[..._];we("filters","filter_updated",_[w],E),$[w]=E,F(a.id,{filters:$})},[a,Ce,F,we]),Ft=p.useCallback(w=>{if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const E=a.filters??[],_=E.filter(($,Y)=>Y!==w);we("filters","filter_removed",E[w],null),F(a.id,{filters:_.length>0?_:void 0})},[a,Ce,F,we]),vr=p.useCallback(()=>{if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const w=a.filters??[];we("filters","filter_cleared",w,null),F(a.id,{filters:void 0})},[a,Ce,F,we]),Ne=p.useCallback(w=>{if(!a)return;if(!bt("edit_filters",Ce)){f(vt("edit_filters"),"error");return}const E=a.filters??[];we("filters","filter_cleared",E,w),F(a.id,{filters:w.length>0?w:void 0})},[a,Ce,F,we]),gt=p.useCallback(w=>{var Y;if(!a)return;const E=(Y=a.views)==null?void 0:Y.find(U=>U.id===w);if(!E)return;const _=E.snapshot.columnOrder,$=Qr(_,E.snapshot.grouping);F(a.id,{filters:E.snapshot.filters.length>0?[...E.snapshot.filters]:void 0,sortStack:E.snapshot.sortStack.length>0?[...E.snapshot.sortStack]:void 0,columnVisibility:{...E.snapshot.columnVisibility},columnOrder:$,columnWidths:{...E.snapshot.columnWidths},grouping:E.snapshot.grouping,activeViewId:w}),Ue(new Set),W(!1)},[a,F]),or=p.useCallback((w,E,_)=>{var sr;if(!(a!=null&&a.schema)||!ke)return;const $=a.views??[],Y=$.filter(Yr=>!Yr.isDeleted).length,U=((sr=m.views)==null?void 0:sr.maxViews)??10;if(Y>=U){f(`View limit reached — you can have at most ${U} saved views. Delete an existing view to create a new one.`,"error");return}const oe={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:w,description:E||void 0,isDefault:_,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:St,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...ke}},fe=_?$.map(Yr=>({...Yr,isDefault:!1})):$;F(a.id,{views:[...fe,oe],activeViewId:oe.id}),f(`"${w}" view created`,"success")},[a,ke,F]),yt=p.useCallback(()=>{var E;if(!Z||!ke||Z.isDefault||!a)return;const w=(E=a.views)==null?void 0:E.map(_=>_.id===Z.id?{..._,snapshot:{...ke}}:_);F(a.id,{views:w}),f(`"${Z.name}" view updated`,"success")},[Z,ke,a,F]),Nr=p.useCallback(w=>{var $;if(!Z||!ke||!a)return;const E=w??ke.columnWidths,_=($=a.views)==null?void 0:$.map(Y=>Y.id===Z.id?{...Y,snapshot:{...Y.snapshot,columnVisibility:ke.columnVisibility,columnOrder:ke.columnOrder,columnWidths:E},updatedAt:Date.now()}:Y);F(a.id,{views:_,columnWidths:E}),f(`Column configuration saved to "${Z.name}"`,"success")},[Z,ke,a,F]),Lr=p.useCallback(w=>{var U,oe;if(!ke||!a||!Z)return;const E=w??ke.columnWidths,_={...Z,snapshot:{...Z.snapshot,columnVisibility:ke.columnVisibility,columnOrder:ke.columnOrder,columnWidths:E},updatedAt:Date.now()},$=(U=a.views)==null?void 0:U.map(fe=>fe.id===Z.id?_:{...fe,snapshot:{...fe.snapshot,columnVisibility:ke.columnVisibility,columnOrder:ke.columnOrder,columnWidths:E},updatedAt:Date.now()});F(a.id,{views:$,columnWidths:E});const Y=(((oe=a.views)==null?void 0:oe.length)||0)-1;f(`Column configuration saved to current view and ${Y} other view${Y===1?"":"s"}`,"success")},[ke,a,Z,F]),Vt=p.useCallback(()=>{Q(!0)},[]),Fr=p.useCallback(()=>{if(!Z||!a)return;const w=Z.snapshot.columnOrder,E=Qr(w,Z.snapshot.grouping);F(a.id,{filters:Z.snapshot.filters.length>0?[...Z.snapshot.filters]:void 0,sortStack:Z.snapshot.sortStack.length>0?[...Z.snapshot.sortStack]:void 0,columnVisibility:{...Z.snapshot.columnVisibility},columnOrder:E,columnWidths:{...Z.snapshot.columnWidths},grouping:Z.snapshot.grouping}),f("Changes reverted to last saved state","success")},[Z,a,F]),Vr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map($=>({...$,isDefault:$.id===w}));F(a.id,{views:E});const _=a.views.find($=>$.id===w);_&&f(`"${_.name}" set as default view`,"success")},[a,F]),nr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map($=>$.id===w?{...$,isFavorite:!$.isFavorite,updatedAt:Date.now()}:$);F(a.id,{views:E});const _=a.views.find($=>$.id===w);_&&!_.isFavorite?f(`"${_.name}" added to favorites`,"success"):_&&f(`"${_.name}" removed from favorites`,"info")},[a,F]),Sr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map(U=>U.id===w?{...U,isDeleted:!0,updatedAt:Date.now()}:U),_=a.activeViewId===w,$=E.find(U=>U.isDefault&&!U.isDeleted);F(a.id,{views:E,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 Y=a.views.find(U=>U.id===w);Y&&f(`"${Y.name}" moved to Recently Deleted`,"info")},[a,F]),jr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map($=>$.id===w?{...$,isDeleted:!1,updatedAt:Date.now()}:$);F(a.id,{views:E});const _=a.views.find($=>$.id===w);_&&f(`"${_.name}" restored`,"success")},[a,F]),Cr=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.find(fe=>fe.id===w),_=a.views.filter(fe=>!fe.isDeleted||fe.id===w);if((E==null?void 0:E.isDefault)&&_.filter(fe=>fe.isDefault).length===1){f("Cannot delete the last default view","error");return}const Y=a.views.filter(fe=>fe.id!==w),U=a.activeViewId===w,oe=Y.find(fe=>fe.isDefault&&!fe.isDeleted);F(a.id,{views:Y,activeViewId:U&&oe?oe.id:a.activeViewId,filters:U&&oe?oe.snapshot.filters.length>0?oe.snapshot.filters:void 0:a.filters,sortStack:U&&oe?oe.snapshot.sortStack.length>0?oe.snapshot.sortStack:void 0:a.sortStack}),E&&f(`"${E.name}" permanently deleted`,"success")},[a,F]),ir=p.useCallback(w=>{re(w),me(!0),W(!1)},[]),wr=p.useCallback((w,E)=>{if(!G||!(a!=null&&a.views))return;const _=a.views.map($=>$.id===G?{...$,name:w,description:E||void 0}:$);F(a.id,{views:_}),re(null)},[G,a,F]),de=p.useCallback(w=>{ne(w),A(!0),W(!1)},[]),ce=p.useCallback(()=>{if(!ae||!(a!=null&&a.views))return;const w=a.views.filter($=>$.id!==ae),E=a.activeViewId===ae,_=w.find($=>$.isDefault);F(a.id,{views:w,activeViewId:E&&_?_.id:a.activeViewId,filters:E&&_?_.snapshot.filters.length>0?_.snapshot.filters:void 0:a.filters,sortStack:E&&_?_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0:a.sortStack}),ne(null),A(!1)},[ae,a,F]),De=p.useCallback(w=>{var Y;if(!(a!=null&&a.views))return;if(!(((Y=m.views)==null?void 0:Y.isAdmin)??!1)){f("Only administrators can promote views to Global.","error");return}const _=a.views.find(U=>U.id===w);if(!_)return;if(_.scope==="global"){f(`"${_.name}" is already a Global View.`,"info");return}const $=a.views.map(U=>U.id===w?{...U,scope:"global",isDefault:!0,updatedAt:Date.now()}:U.scope==="global"&&U.isDefault?{...U,isDefault:!1}:U);F(a.id,{views:$}),f(`"${_.name}" promoted to Global View and set as default.`,"success")},[a,m,F]);p.useEffect(()=>{ze!=null&&ze.resetPage?ze.resetPage():wt(1)},[a==null?void 0:a.filters,pt,a==null?void 0:a.activeViewId]),p.useEffect(()=>{ze&&ze.currentPage!==ot&&wt(ze.currentPage)},[ze==null?void 0:ze.currentPage]);const ut=p.useCallback(w=>{ze!=null&&ze.goToPage&&ze.goToPage(w),wt(w)},[ze]),it=p.useCallback(w=>{const E=(ot-1)*He,_=Math.floor(E/w)+1;lt(w),wt(_),ze==null||ze.goToPage(_)},[ot,He,ze]),zt=p.useCallback((w,E)=>{if(!a)return;if(!bt("edit_columns",Ce)){f(vt("edit_columns"),"error");return}const $={...a.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{},[w]:E};F(a.id,{columnVisibility:$})},[a,Z,Ce,F]),Hr=p.useCallback(w=>{if(a){if(!bt("edit_columns",Ce)){f(vt("edit_columns"),"error");return}F(a.id,{columnOrder:w})}},[a,Ce,F]),Ht=p.useCallback((w,E)=>{if(!a)return;if(!bt("edit_columns",Ce)){f(vt("edit_columns"),"error");return}const $={...a.columnWidths||(Z==null?void 0:Z.snapshot.columnWidths)||{},[w]:E};F(a.id,{columnWidths:$})},[a,Z,Ce,F]),ao=p.useCallback(w=>{if(!a)return;const _=(a.filters??[]).filter($=>$.column!==w);F(a.id,{filters:_.length>0?_:void 0})},[a,F]),O=p.useCallback(()=>{if(!Z||!(a!=null&&a.schema))return;const w={},E=[],_={};a.schema.forEach($=>{w[$.name]=!0,E.push($.name),_[$.name]=170}),F(a.id,{columnVisibility:w,columnOrder:E,columnWidths:_,filters:void 0,sortStack:void 0}),f("Reset to default layout - all filters and sorts cleared","success")},[Z,a,F]);p.useEffect(()=>{const w=setTimeout(()=>Ve(Rt),300);return()=>clearTimeout(w)},[Rt]);const X=p.useCallback(w=>{Wt(w)},[]),he=p.useCallback(w=>{if(!w.trim()||!a)return;const E=a.searchHistory||[],_=ya(E,w);F(a.id,{searchHistory:_})},[a,F]),Fe=p.useCallback(w=>{if(!a)return;const E=a.searchHistory||[],_=ba(E,w);F(a.id,{searchHistory:_})},[a,F]),ue=p.useCallback(w=>{if(!a)return;const E=a.searchHistory||[],_=va(E,w);F(a.id,{searchHistory:_})},[a,F]),Bt=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;Ue(_=>{const $=new Set(_);if(E!==void 0){const Y=Array.from($).find(U=>(U==null?void 0:U.__urm_row_id__)===E);Y!==void 0?$.delete(Y):$.add(w)}else{const Y=JSON.stringify(w),U=Array.from($).find(oe=>JSON.stringify(oe)===Y);U!==void 0?$.delete(U):$.add(w)}return $})},[]),Ho=p.useCallback((w,E)=>{Ue(_=>{const $=new Set(_);for(const Y of E)w?$.add(Y):$.delete(Y);return $})},[]),us=p.useCallback((w,E,_)=>{Ue($=>{const Y=new Set($),U=Math.min(w,E),oe=Math.max(w,E);for(let fe=U;fe<=oe;fe++)_[fe]!==void 0&&Y.add(_[fe]);return Y})},[]),ps=p.useCallback(()=>{Ue(new Set),Je(null)},[]),xs=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;Ue(_=>{const $=new Set(_);if(E!==void 0){const Y=Array.from($).find(U=>(U==null?void 0:U.__urm_row_id__)===E);Y!==void 0&&$.delete(Y)}else $.delete(w);return $})},[]),ms=p.useCallback(w=>{if(!(a!=null&&a.uploadedData))return;const E=a.uploadedData.indexOf(w);if(E===-1)return;const _=a.favoriteRowIndices||[],Y=_.includes(E)?_.filter(U=>U!==E):[..._,E];F(a.id,{favoriteRowIndices:Y})},[a,F]),hs=p.useCallback((w,E)=>{if(!(a!=null&&a.uploadedData))return;const _=a.favoriteRowIndices||[],$=w.map(U=>a.uploadedData.indexOf(U)).filter(U=>U!==-1),Y=E?[..._,...$.filter(U=>!_.includes(U))]:_.filter(U=>!$.includes(U));F(a.id,{favoriteRowIndices:Y})},[a,F]),fs=p.useCallback(()=>{if(!a)return;const w=a.favoriteRowIndices||[],E=!a.showFavoritesOnly;if(E&&w.length===0){f("No rows marked as favorite","warning");return}if(F(a.id,{showFavoritesOnly:E}),E){if(Je(new Set(qe)),qe.size>0){const _=new Set(w.map(Y=>{var U,oe;return(oe=(U=a.uploadedData)==null?void 0:U[Y])==null?void 0:oe.__urm_row_id__}).filter(Y=>Y!==void 0)),$=new Set(Array.from(qe).filter(Y=>(Y==null?void 0:Y.__urm_row_id__)!==void 0&&_.has(Y.__urm_row_id__)));Ue($)}f(`Showing ${w.length} favorite row${w.length===1?"":"s"}`,"info")}else{if(rt!==null){const _=new Set(Array.from(qe).map(oe=>oe==null?void 0:oe.__urm_row_id__).filter(Boolean)),$=new Set(Array.from(rt).map(oe=>oe==null?void 0:oe.__urm_row_id__).filter(Boolean)),Y=new Set(w.map(oe=>{var fe,sr;return(sr=(fe=a.uploadedData)==null?void 0:fe[oe])==null?void 0:sr.__urm_row_id__}).filter(oe=>oe!==void 0)),U=new Set;Array.from(rt).forEach(oe=>{const fe=oe==null?void 0:oe.__urm_row_id__;if(fe===void 0)return;const sr=Y.has(fe),Yr=_.has(fe);sr&&!Yr||U.add(oe)}),Array.from(qe).forEach(oe=>{const fe=oe==null?void 0:oe.__urm_row_id__;fe!==void 0&&($.has(fe)||U.add(oe))}),Ue(U),Je(null)}f("Showing all data","info")}},[a,F,qe,rt]),gs=p.useCallback(w=>{if(a){if(!bt("edit_columns",Ce)){f(vt("edit_columns"),"error");return}if(w&&a.schema){const{validGrouping:E,invalidColumns:_}=Ai(w,a.schema);_.length>0&&f(`Removed invalid grouping columns: ${_.join(", ")}`,"warning"),ct();try{const $=a.grouping;E===null?we("grouping","group_cleared",$,null):$?we("grouping","group_reordered",$,E):we("grouping","group_level_added",null,E);const Y=(Z==null?void 0:Z.snapshot.columnOrder)||a.columnOrder||[],U=Qr(Y,E);F(a.id,{grouping:E,columnOrder:U}),JSON.stringify(U)!==JSON.stringify(a.columnOrder)&&we("columns","column_reordered",a.columnOrder,U),_t(!1)}catch($){const Y=Et("processing","grouping",$);Ge(Y)}}else{const E=a.grouping;we("grouping","group_cleared",E,null);const _=(Z==null?void 0:Z.snapshot.columnOrder)||a.columnOrder||[];F(a.id,{grouping:w,columnOrder:[..._]}),JSON.stringify(_)!==JSON.stringify(a.columnOrder)&&we("columns","column_reordered",a.columnOrder,_),_t(!1)}}},[a,Z,Ce,F,ct,Ge,we]),ys=p.useCallback(w=>{if(!a)return;const E=a.grouping;if(!E)return;const _=da(E,w);F(a.id,{grouping:_})},[a,F]),bs=p.useCallback(()=>{kt(!0)},[]),Ur=p.useCallback(w=>{a!=null&&a.schema&&(ie(!0),setTimeout(()=>{try{let E;w.scope==="visible"?E=Qt:E=a.uploadedData||[];let _;w.columnScope==="all"?(_={},(a.schema??[]).forEach(fe=>{_[fe.name]=!0})):_=a.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{};const $=a.columnOrder||(Z==null?void 0:Z.snapshot.columnOrder),Y=So(E,a.schema,a.filters??[],a.sortStack??[],Z,_,$),U=a.name;let oe;switch(w.format){case"csv":jo(Y,U,w),oe="export_csv";break;case"excel":Co(Y,U,w),oe="export_excel";break;case"json":wo(Y,U,w),oe="export_json";break}we("export",oe,null,{format:w.format,scope:w.scope,columnScope:w.columnScope,rowCount:E.length,viewName:(Z==null?void 0:Z.name)||"Default View"}),f(`Export completed successfully (${w.format.toUpperCase()})`,"success")}catch(E){const _=Ua(E,{onRetry:()=>Ur(w)});f(`Export failed: ${_.message}. Click Export to retry.`,"error");const $=On(a.id,St,_,a.auditHistory||[]);F(a.id,{auditHistory:$}),cr.error("urm:report-engine","Export failed",E)}finally{ie(!1)}},500))},[a,Z,Qt,F,we]),vs=p.useCallback(w=>{if(a!=null&&a.schema){if(ht&&Z&&!Z.isDefault){q(w.format),le(!0),kt(!1);return}Ur(w),kt(!1)}},[a,Z,ht,Ur]),lo=p.useCallback(w=>{Ur({format:w,scope:"visible",columnScope:"visible"})},[Ur]),Ss=p.useCallback(()=>{ge&&lo(ge),le(!1),q(null)},[ge,lo]),js=p.useCallback(()=>{yt(),ge&&lo(ge),le(!1),q(null)},[yt,ge,lo]),Cs=p.useCallback(()=>{le(!1),q(null)},[]),ws=p.useCallback(w=>{!(a!=null&&a.schema)||qe.size===0||(ie(!0),setTimeout(()=>{try{const E=Array.from(qe),_=So(E,a.schema,a.filters??[],a.sortStack??[],Z),$=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(w){case"csv":jo(_,$);break;case"excel":Co(_,$);break;case"json":wo(_,$);break}f(`Exported ${E.length} selected rows`,"info")}catch(E){f("Export failed. Please try again.","error"),cr.error("urm:report-engine","Bulk export failed",E)}finally{ie(!1)}},500))},[a,Z,qe,Zt]),ks=p.useCallback((w,E)=>{if(a)try{const _=Oa(a),$=$a(w,E,St,_),Y=Aa(a.presets,$);F(a.id,{presets:Y}),we("presets","preset_created",null,{presetId:$.id,name:$.name}),qt(!1),f(`Preset "${w}" saved successfully`,"success")}catch(_){f(_ instanceof Error?_.message:"Failed to create preset","error")}},[a,F,we]),Ts=p.useCallback(()=>{Nt(null),f("Exited preset view","info")},[]),Is=p.useCallback(()=>{Pt(!0)},[]),zs=p.useCallback((w,E)=>{if(!a)return;const _=_a(a.presets,w);F(a.id,{presets:_}),we("presets","preset_deleted",{presetId:w,name:E},null),xt===w&&Nt(null),f(`Preset "${E}" deleted`,"success")},[a,xt,F,we]);p.useEffect(()=>{if(!l||u.length===0)return;const w=u.find(E=>E.id===l);w&&w.id!==b&&x(w.id)},[l,u,b]),p.useEffect(()=>{if(!a)return;const w=Ma();if(w&&a.presets&&a.schemaLocked&&a.schema){const E=En(a.presets,w);if(E){const{sanitizedConfig:_,warnings:$}=Ha(E.config,a.schema);$.length>0&&$.forEach(U=>f(U,"warning"));const Y=Ra(_);F(a.id,Y),Nt(w),we("presets","preset_applied",null,{presetId:E.id,name:E.name}),f(`Loaded preset: ${E.name}`,"info")}else f("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const Bs=xt?En(a==null?void 0:a.presets,xt):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&ha(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 w=fa(a.id);if(w&&w.views.length>0){const E=w.views.find(_=>_.id===w.activeViewId);if(E)F(a.id,{views:w.views,activeViewId:w.activeViewId,filters:E.snapshot.filters.length>0?E.snapshot.filters:void 0,sortStack:E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0});else{const _=w.views.find($=>$.isDefault)||Uo(a.schema);F(a.id,{views:w.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 Ds=p.useCallback(w=>{var $;const E=(a==null?void 0:a.filters)??[],_=(($=m.filter)==null?void 0:$.maxConditions)??3;if(E.length>=_){f(`Filter limit reached — maximum ${_} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}se(w),K(!0)},[a,m,f]),Es=p.useCallback(()=>{K(!1),se(void 0)},[]),Os=(vn=a==null?void 0:a.views)==null?void 0:vn.find(w=>w.id===G),$s=(Sn=a==null?void 0:a.views)==null?void 0:Sn.find(w=>w.id===ae);return{reports:u,activeReport:a,activeReportId:b,setActiveReportId:x,isModalOpen:y,setIsModalOpen:D,createReport:nt,updateReport:F,uploadState:B,handleFileUpload:er,handleUploadError:ft,handleRetry:Le,handleConfirm:br,paginatedData:Xt,processedData:Qt,displayData:Zt,tableMetrics:Wr,isGrouped:Lt,tableEngine:mt,activeView:Z,isDirty:ht,currentTableState:ke,viewChanges:ye,filters:a==null?void 0:a.filters,showFilterPanel:J,setShowFilterPanel:K,filterFocusColumn:H,handleAddFilter:tr,handleUpdateFilter:rr,handleRemoveFilter:Ft,handleClearAllFilters:vr,handleReplaceFilters:Ne,handleOpenFilterForColumn:Ds,handleCloseFilterPanel:Es,handleClearFiltersForColumn:ao,sortStack:a==null?void 0:a.sortStack,showSortPanel:ee,setShowSortPanel:g,handleSort:Tt,handleUpdateSortStack:dt,handleSortAscending:It,handleSortDescending:Pr,views:a==null?void 0:a.views,showManageViews:M,setShowManageViews:W,showCreateViewModal:V,setShowCreateViewModal:Q,showEditViewModal:xe,setShowEditViewModal:me,showDeleteConfirmation:L,setShowDeleteConfirmation:A,editingView:Os,deletingView:$s,editingViewId:G,deletingViewId:ae,handleSelectView:gt,handleCreateView:or,handleUpdateCurrentView:yt,handleSaveColumnConfigToCurrentView:Nr,handleSaveColumnConfigToAllViews:Lr,handleSaveAsNewView:Vt,handleRevertChanges:Fr,handleToggleDefault:Vr,handleToggleFavorite:nr,handleSoftDelete:Sr,handleRestoreView:jr,handlePermanentDelete:Cr,handleEditView:ir,handleSaveEditView:wr,handleDeleteView:de,handleConfirmDelete:ce,handlePromoteToGlobal:De,showManageColumns:_e,setShowManageColumns:et,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:zt,handleUpdateColumnOrder:Hr,handleUpdateColumnWidth:Ht,handleResetColumnLayout:O,showGroupPanel:tt,setShowGroupPanel:_t,grouping:a==null?void 0:a.grouping,groupingState:mr,handleGroup:gs,handleToggleGroupCollapse:ys,searchQuery:Rt,debouncedSearchQuery:pt,searchHistory:Sa((a==null?void 0:a.searchHistory)||[]),handleSearchChange:X,handleAddToSearchHistory:he,handleToggleSearchFavourite:Fe,handleDeleteSearchHistory:ue,selectedRowIds:qe,handleToggleRowSelection:Bt,handleToggleAllRows:Ho,handleRangeSelection:us,handleClearSelection:ps,handleUpdateSelectionAfterDelete:xs,favoriteRowIndices:(a==null?void 0:a.favoriteRowIndices)||[],resolvedFavoritesSet:Kt,showFavoritesOnly:(a==null?void 0:a.showFavoritesOnly)||!1,handleToggleRowFavorite:ms,handleBulkSetFavorites:hs,handleToggleFavoritesFilter:fs,currentPage:ot,pageSize:He,paginationEngine:ze,handlePageChange:ut,handlePageSizeChange:it,isExporting:P,showExportModal:fr,setShowExportModal:kt,showDirtyExportWarning:pe,handleExport:bs,handleExportWithConfig:vs,handleExportSelected:ws,handleExportAnyway:Ss,handleSaveAndExport:js,handleCancelExport:Cs,showAuditHistory:Re,setShowAuditHistory:Or,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:$r,setShowCreatePreset:qt,showManagePresets:hr,setShowManagePresets:Pt,activePreset:Bs,activePresetId:xt,handleOpenManagePresets:Is,handleCreatePreset:ks,handleClearActivePreset:Ts,handleDeletePresetById:zs,userRole:Ce,isViewerRole:Mr,currentUserId:St,featureLimitWarning:Ar,setFeatureLimitWarning:Ye,datasetMeta:yr,reportError:gr,setReportError:_r,handleError:Ge,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?ra(a.schema):!1,snack:S,handleSnackClose:k,showSnack:f,snackDurationMs:j}}const _i=p.createContext(void 0);function dn(t){const{children:o,initialData:n,data:i,reportName:s,dataSource:d,mode:l="builder",autoLoad:c=!0,config:u,devConfig:h,showDevPanel:m=!1,sharedReportId:b}=t,y=sl({mode:l,autoLoad:c,initialData:i||n,dataSource:d,reportName:s,sharedReportId:b,config:u}),[D,v]=p.useState(()=>Ws()),C=(()=>{const k=Ns(D,h,!!h);return{...k,display:{...k.display,showDevPanel:m||k.display.showDevPanel}}})(),S=p.useCallback(f=>{v(f),Ps(f)},[]),I={...y,activeDevConfig:C,handleDevConfigChange:S};return e.jsx(ji.Provider,{value:C,children:e.jsx(_i.Provider,{value:I,children:o})})}function Bo(){const t=p.useContext(_i);if(t===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return t}function al({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(z.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(z.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(z.Add,{sx:{fontSize:18}}),onClick:t,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function dr(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 ll="$$material";function cl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var po={exports:{}},xo={exports:{}},be={};/** @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 $n;function cl(){if($n)return ve;$n=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,u=t?Symbol.for("react.async_mode"):60111,x=t?Symbol.for("react.concurrent_mode"):60111,h=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,m=t?Symbol.for("react.suspense_list"):60120,y=t?Symbol.for("react.memo"):60115,D=t?Symbol.for("react.lazy"):60116,v=t?Symbol.for("react.block"):60121,C=t?Symbol.for("react.fundamental"):60117,S=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function f(j){if(typeof j=="object"&&j!==null){var a=j.$$typeof;switch(a){case o:switch(j=j.type,j){case u:case x:case i:case d:case s:case b:return j;default:switch(j=j&&j.$$typeof,j){case l:case h:case D:case y:case c:return j;default:return a}}case n:return a}}}function k(j){return f(j)===x}return ve.AsyncMode=u,ve.ConcurrentMode=x,ve.ContextConsumer=l,ve.ContextProvider=c,ve.Element=o,ve.ForwardRef=h,ve.Fragment=i,ve.Lazy=D,ve.Memo=y,ve.Portal=n,ve.Profiler=d,ve.StrictMode=s,ve.Suspense=b,ve.isAsyncMode=function(j){return k(j)||f(j)===u},ve.isConcurrentMode=k,ve.isContextConsumer=function(j){return f(j)===l},ve.isContextProvider=function(j){return f(j)===c},ve.isElement=function(j){return typeof j=="object"&&j!==null&&j.$$typeof===o},ve.isForwardRef=function(j){return f(j)===h},ve.isFragment=function(j){return f(j)===i},ve.isLazy=function(j){return f(j)===D},ve.isMemo=function(j){return f(j)===y},ve.isPortal=function(j){return f(j)===n},ve.isProfiler=function(j){return f(j)===d},ve.isStrictMode=function(j){return f(j)===s},ve.isSuspense=function(j){return f(j)===b},ve.isValidElementType=function(j){return typeof j=="string"||typeof j=="function"||j===i||j===x||j===d||j===s||j===b||j===m||typeof j=="object"&&j!==null&&(j.$$typeof===D||j.$$typeof===y||j.$$typeof===c||j.$$typeof===l||j.$$typeof===h||j.$$typeof===C||j.$$typeof===S||j.$$typeof===I||j.$$typeof===v)},ve.typeOf=f,ve}var Se={};/** @license React v16.13.1
10
+ */var An;function dl(){if(An)return be;An=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,l=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,y=t?Symbol.for("react.memo"):60115,D=t?Symbol.for("react.lazy"):60116,v=t?Symbol.for("react.block"):60121,C=t?Symbol.for("react.fundamental"):60117,S=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function f(j){if(typeof j=="object"&&j!==null){var a=j.$$typeof;switch(a){case o:switch(j=j.type,j){case u:case h:case i:case d:case s:case b:return j;default:switch(j=j&&j.$$typeof,j){case c:case m:case D:case y:case l:return j;default:return a}}case n:return a}}}function k(j){return f(j)===h}return be.AsyncMode=u,be.ConcurrentMode=h,be.ContextConsumer=c,be.ContextProvider=l,be.Element=o,be.ForwardRef=m,be.Fragment=i,be.Lazy=D,be.Memo=y,be.Portal=n,be.Profiler=d,be.StrictMode=s,be.Suspense=b,be.isAsyncMode=function(j){return k(j)||f(j)===u},be.isConcurrentMode=k,be.isContextConsumer=function(j){return f(j)===c},be.isContextProvider=function(j){return f(j)===l},be.isElement=function(j){return typeof j=="object"&&j!==null&&j.$$typeof===o},be.isForwardRef=function(j){return f(j)===m},be.isFragment=function(j){return f(j)===i},be.isLazy=function(j){return f(j)===D},be.isMemo=function(j){return f(j)===y},be.isPortal=function(j){return f(j)===n},be.isProfiler=function(j){return f(j)===d},be.isStrictMode=function(j){return f(j)===s},be.isSuspense=function(j){return f(j)===b},be.isValidElementType=function(j){return typeof j=="string"||typeof j=="function"||j===i||j===h||j===d||j===s||j===b||j===x||typeof j=="object"&&j!==null&&(j.$$typeof===D||j.$$typeof===y||j.$$typeof===l||j.$$typeof===c||j.$$typeof===m||j.$$typeof===C||j.$$typeof===S||j.$$typeof===I||j.$$typeof===v)},be.typeOf=f,be}var ve={};/** @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 An;function dl(){return An||(An=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,u=t?Symbol.for("react.async_mode"):60111,x=t?Symbol.for("react.concurrent_mode"):60111,h=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,m=t?Symbol.for("react.suspense_list"):60120,y=t?Symbol.for("react.memo"):60115,D=t?Symbol.for("react.lazy"):60116,v=t?Symbol.for("react.block"):60121,C=t?Symbol.for("react.fundamental"):60117,S=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function f(J){return typeof J=="string"||typeof J=="function"||J===i||J===x||J===d||J===s||J===b||J===m||typeof J=="object"&&J!==null&&(J.$$typeof===D||J.$$typeof===y||J.$$typeof===c||J.$$typeof===l||J.$$typeof===h||J.$$typeof===C||J.$$typeof===S||J.$$typeof===I||J.$$typeof===v)}function k(J){if(typeof J=="object"&&J!==null){var Re=J.$$typeof;switch(Re){case o:var He=J.type;switch(He){case u:case x:case i:case d:case s:case b:return He;default:var St=He&&He.$$typeof;switch(St){case l:case h:case D:case y:case c:return St;default:return Re}}case n:return Re}}}var j=u,a=x,B=l,R=c,q=o,K=h,ee=i,g=D,M=y,W=n,V=d,Z=s,xe=b,me=!1;function F(J){return me||(me=!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.")),A(J)||k(J)===u}function A(J){return k(J)===x}function H(J){return k(J)===l}function se(J){return k(J)===c}function G(J){return typeof J=="object"&&J!==null&&J.$$typeof===o}function re(J){return k(J)===h}function ae(J){return k(J)===i}function ne(J){return k(J)===D}function P(J){return k(J)===y}function ie(J){return k(J)===n}function de(J){return k(J)===d}function le(J){return k(J)===s}function fe(J){return k(J)===b}Se.AsyncMode=j,Se.ConcurrentMode=a,Se.ContextConsumer=B,Se.ContextProvider=R,Se.Element=q,Se.ForwardRef=K,Se.Fragment=ee,Se.Lazy=g,Se.Memo=M,Se.Portal=W,Se.Profiler=V,Se.StrictMode=Z,Se.Suspense=xe,Se.isAsyncMode=F,Se.isConcurrentMode=A,Se.isContextConsumer=H,Se.isContextProvider=se,Se.isElement=G,Se.isForwardRef=re,Se.isFragment=ae,Se.isLazy=ne,Se.isMemo=P,Se.isPortal=ie,Se.isProfiler=de,Se.isStrictMode=le,Se.isSuspense=fe,Se.isValidElementType=f,Se.typeOf=k})()),Se}var _n;function _i(){return _n||(_n=1,process.env.NODE_ENV==="production"?po.exports=cl():po.exports=dl()),po.exports}/*
17
+ */var _n;function ul(){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,l=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,y=t?Symbol.for("react.memo"):60115,D=t?Symbol.for("react.lazy"):60116,v=t?Symbol.for("react.block"):60121,C=t?Symbol.for("react.fundamental"):60117,S=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function f(q){return typeof q=="string"||typeof q=="function"||q===i||q===h||q===d||q===s||q===b||q===x||typeof q=="object"&&q!==null&&(q.$$typeof===D||q.$$typeof===y||q.$$typeof===l||q.$$typeof===c||q.$$typeof===m||q.$$typeof===C||q.$$typeof===S||q.$$typeof===I||q.$$typeof===v)}function k(q){if(typeof q=="object"&&q!==null){var _e=q.$$typeof;switch(_e){case o:var et=q.type;switch(et){case u:case h:case i:case d:case s:case b:return et;default:var tt=et&&et.$$typeof;switch(tt){case c:case m:case D:case y:case l:return tt;default:return _e}}case n:return _e}}}var j=u,a=h,B=c,R=l,J=o,K=m,ee=i,g=D,M=y,W=n,V=d,Q=s,xe=b,me=!1;function L(q){return me||(me=!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.")),A(q)||k(q)===u}function A(q){return k(q)===h}function H(q){return k(q)===c}function se(q){return k(q)===l}function G(q){return typeof q=="object"&&q!==null&&q.$$typeof===o}function re(q){return k(q)===m}function ae(q){return k(q)===i}function ne(q){return k(q)===D}function P(q){return k(q)===y}function ie(q){return k(q)===n}function pe(q){return k(q)===d}function le(q){return k(q)===s}function ge(q){return k(q)===b}ve.AsyncMode=j,ve.ConcurrentMode=a,ve.ContextConsumer=B,ve.ContextProvider=R,ve.Element=J,ve.ForwardRef=K,ve.Fragment=ee,ve.Lazy=g,ve.Memo=M,ve.Portal=W,ve.Profiler=V,ve.StrictMode=Q,ve.Suspense=xe,ve.isAsyncMode=L,ve.isConcurrentMode=A,ve.isContextConsumer=H,ve.isContextProvider=se,ve.isElement=G,ve.isForwardRef=re,ve.isFragment=ae,ve.isLazy=ne,ve.isMemo=P,ve.isPortal=ie,ve.isProfiler=pe,ve.isStrictMode=le,ve.isSuspense=ge,ve.isValidElementType=f,ve.typeOf=k})()),ve}var Mn;function Mi(){return Mn||(Mn=1,process.env.NODE_ENV==="production"?xo.exports=dl():xo.exports=ul()),xo.exports}/*
18
18
  object-assign
19
19
  (c) Sindre Sorhus
20
20
  @license MIT
21
- */var Yo,Mn;function ul(){if(Mn)return Yo;Mn=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 u=Object.getOwnPropertyNames(c).map(function(h){return c[h]});if(u.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(h){x[h]=h}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Yo=s()?Object.assign:function(d,c){for(var l,u=i(d),x,h=1;h<arguments.length;h++){l=Object(arguments[h]);for(var b in l)o.call(l,b)&&(u[b]=l[b]);if(t){x=t(l);for(var m=0;m<x.length;m++)n.call(l,x[m])&&(u[x[m]]=l[x[m]])}}return u},Yo}var Go,Rn;function dn(){if(Rn)return Go;Rn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Go=t,Go}var qo,Wn;function Mi(){return Wn||(Wn=1,qo=Function.call.bind(Object.prototype.hasOwnProperty)),qo}var Jo,Pn;function pl(){if(Pn)return Jo;Pn=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var o=dn(),n={},i=Mi();t=function(d){var c="Warning: "+d;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(d,c,l,u,x){if(process.env.NODE_ENV!=="production"){for(var h in d)if(i(d,h)){var b;try{if(typeof d[h]!="function"){var m=Error((u||"React class")+": "+l+" type `"+h+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[h]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw m.name="Invariant Violation",m}b=d[h](c,h,u,l,null,o)}catch(D){b=D}if(b&&!(b instanceof Error)&&t((u||"React class")+": type specification of "+l+" `"+h+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof b+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),b instanceof Error&&!(b.message in n)){n[b.message]=!0;var y=x?x():"";t("Failed "+l+" type: "+b.message+(y??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Jo=s,Jo}var Ko,Nn;function xl(){if(Nn)return Ko;Nn=1;var t=_i(),o=ul(),n=dn(),i=Mi(),s=pl(),d=function(){};process.env.NODE_ENV!=="production"&&(d=function(l){var u="Warning: "+l;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return Ko=function(l,u){var x=typeof Symbol=="function"&&Symbol.iterator,h="@@iterator";function b(A){var H=A&&(x&&A[x]||A[h]);if(typeof H=="function")return H}var m="<<anonymous>>",y={array:S("array"),bigint:S("bigint"),bool:S("boolean"),func:S("function"),number:S("number"),object:S("object"),string:S("string"),symbol:S("symbol"),any:I(),arrayOf:f,element:k(),elementType:j(),instanceOf:a,node:K(),objectOf:R,oneOf:B,oneOfType:q,shape:g,exact:M};function D(A,H){return A===H?A!==0||1/A===1/H:A!==A&&H!==H}function v(A,H){this.message=A,this.data=H&&typeof H=="object"?H:{},this.stack=""}v.prototype=Error.prototype;function C(A){if(process.env.NODE_ENV!=="production")var H={},se=0;function G(ae,ne,P,ie,de,le,fe){if(ie=ie||m,le=le||P,fe!==n){if(u){var J=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 J.name="Invariant Violation",J}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Re=ie+":"+P;!H[Re]&&se<3&&(d("You are manually calling a React.PropTypes validation function for the `"+le+"` 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[Re]=!0,se++)}}return ne[P]==null?ae?ne[P]===null?new v("The "+de+" `"+le+"` is marked as required "+("in `"+ie+"`, but its value is `null`.")):new v("The "+de+" `"+le+"` is marked as required in "+("`"+ie+"`, but its value is `undefined`.")):null:A(ne,P,ie,de,le)}var re=G.bind(null,!1);return re.isRequired=G.bind(null,!0),re}function S(A){function H(se,G,re,ae,ne,P){var ie=se[G],de=Z(ie);if(de!==A){var le=xe(ie);return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+le+"` supplied to `"+re+"`, expected ")+("`"+A+"`."),{expectedType:A})}return null}return C(H)}function I(){return C(c)}function f(A){function H(se,G,re,ae,ne){if(typeof A!="function")return new v("Property `"+ne+"` of component `"+re+"` has invalid PropType notation inside arrayOf.");var P=se[G];if(!Array.isArray(P)){var ie=Z(P);return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+re+"`, expected an array."))}for(var de=0;de<P.length;de++){var le=A(P,de,re,ae,ne+"["+de+"]",n);if(le instanceof Error)return le}return null}return C(H)}function k(){function A(H,se,G,re,ae){var ne=H[se];if(!l(ne)){var P=Z(ne);return new v("Invalid "+re+" `"+ae+"` of type "+("`"+P+"` supplied to `"+G+"`, expected a single ReactElement."))}return null}return C(A)}function j(){function A(H,se,G,re,ae){var ne=H[se];if(!t.isValidElementType(ne)){var P=Z(ne);return new v("Invalid "+re+" `"+ae+"` of type "+("`"+P+"` supplied to `"+G+"`, expected a single ReactElement type."))}return null}return C(A)}function a(A){function H(se,G,re,ae,ne){if(!(se[G]instanceof A)){var P=A.name||m,ie=F(se[G]);return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+re+"`, expected ")+("instance of `"+P+"`."))}return null}return C(H)}function B(A){if(!Array.isArray(A))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(se,G,re,ae,ne){for(var P=se[G],ie=0;ie<A.length;ie++)if(D(P,A[ie]))return null;var de=JSON.stringify(A,function(fe,J){var Re=xe(J);return Re==="symbol"?String(J):J});return new v("Invalid "+ae+" `"+ne+"` of value `"+String(P)+"` "+("supplied to `"+re+"`, expected one of "+de+"."))}return C(H)}function R(A){function H(se,G,re,ae,ne){if(typeof A!="function")return new v("Property `"+ne+"` of component `"+re+"` has invalid PropType notation inside objectOf.");var P=se[G],ie=Z(P);if(ie!=="object")return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+re+"`, expected an object."));for(var de in P)if(i(P,de)){var le=A(P,de,re,ae,ne+"."+de,n);if(le instanceof Error)return le}return null}return C(H)}function q(A){if(!Array.isArray(A))return process.env.NODE_ENV!=="production"&&d("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var H=0;H<A.length;H++){var se=A[H];if(typeof se!="function")return d("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+me(se)+" at index "+H+"."),c}function G(re,ae,ne,P,ie){for(var de=[],le=0;le<A.length;le++){var fe=A[le],J=fe(re,ae,ne,P,ie,n);if(J==null)return null;J.data&&i(J.data,"expectedType")&&de.push(J.data.expectedType)}var Re=de.length>0?", expected one of type ["+de.join(", ")+"]":"";return new v("Invalid "+P+" `"+ie+"` supplied to "+("`"+ne+"`"+Re+"."))}return C(G)}function K(){function A(H,se,G,re,ae){return W(H[se])?null:new v("Invalid "+re+" `"+ae+"` supplied to "+("`"+G+"`, expected a ReactNode."))}return C(A)}function ee(A,H,se,G,re){return new v((A||"React class")+": "+H+" type `"+se+"."+G+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+re+"`.")}function g(A){function H(se,G,re,ae,ne){var P=se[G],ie=Z(P);if(ie!=="object")return new v("Invalid "+ae+" `"+ne+"` of type `"+ie+"` "+("supplied to `"+re+"`, expected `object`."));for(var de in A){var le=A[de];if(typeof le!="function")return ee(re,ae,ne,de,xe(le));var fe=le(P,de,re,ae,ne+"."+de,n);if(fe)return fe}return null}return C(H)}function M(A){function H(se,G,re,ae,ne){var P=se[G],ie=Z(P);if(ie!=="object")return new v("Invalid "+ae+" `"+ne+"` of type `"+ie+"` "+("supplied to `"+re+"`, expected `object`."));var de=o({},se[G],A);for(var le in de){var fe=A[le];if(i(A,le)&&typeof fe!="function")return ee(re,ae,ne,le,xe(fe));if(!fe)return new v("Invalid "+ae+" `"+ne+"` key `"+le+"` supplied to `"+re+"`.\nBad object: "+JSON.stringify(se[G],null," ")+`
22
- Valid keys: `+JSON.stringify(Object.keys(A),null," "));var J=fe(P,le,re,ae,ne+"."+le,n);if(J)return J}return null}return C(H)}function W(A){switch(typeof A){case"number":case"string":case"undefined":return!0;case"boolean":return!A;case"object":if(Array.isArray(A))return A.every(W);if(A===null||l(A))return!0;var H=b(A);if(H){var se=H.call(A),G;if(H!==A.entries){for(;!(G=se.next()).done;)if(!W(G.value))return!1}else for(;!(G=se.next()).done;){var re=G.value;if(re&&!W(re[1]))return!1}}else return!1;return!0;default:return!1}}function V(A,H){return A==="symbol"?!0:H?H["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&H instanceof Symbol:!1}function Z(A){var H=typeof A;return Array.isArray(A)?"array":A instanceof RegExp?"object":V(H,A)?"symbol":H}function xe(A){if(typeof A>"u"||A===null)return""+A;var H=Z(A);if(H==="object"){if(A instanceof Date)return"date";if(A instanceof RegExp)return"regexp"}return H}function me(A){var H=xe(A);switch(H){case"array":case"object":return"an "+H;case"boolean":case"date":case"regexp":return"a "+H;default:return H}}function F(A){return!A.constructor||!A.constructor.name?m:A.constructor.name}return y.checkPropTypes=s,y.resetWarningCache=s.resetWarningCache,y.PropTypes=y,y},Ko}var Xo,Ln;function ml(){if(Ln)return Xo;Ln=1;var t=dn();function o(){}function n(){}return n.resetWarningCache=o,Xo=function(){function i(c,l,u,x,h,b){if(b!==t){var m=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 m.name="Invariant Violation",m}}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},Xo}var Fn;function hl(){if(Fn)return uo.exports;if(Fn=1,process.env.NODE_ENV!=="production"){var t=_i(),o=!0;uo.exports=xl()(t.isElement,o)}else uo.exports=ml()();return uo.exports}var fl=hl();const Gr=ll(fl);var xo={exports:{}},we={};/**
21
+ */var Go,Rn;function pl(){if(Rn)return Go;Rn=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 l={},c=0;c<10;c++)l["_"+String.fromCharCode(c)]=c;var u=Object.getOwnPropertyNames(l).map(function(m){return l[m]});if(u.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(m){h[m]=m}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Go=s()?Object.assign:function(d,l){for(var c,u=i(d),h,m=1;m<arguments.length;m++){c=Object(arguments[m]);for(var b in c)o.call(c,b)&&(u[b]=c[b]);if(t){h=t(c);for(var x=0;x<h.length;x++)n.call(c,h[x])&&(u[h[x]]=c[h[x]])}}return u},Go}var qo,Wn;function un(){if(Wn)return qo;Wn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return qo=t,qo}var Jo,Pn;function Ri(){return Pn||(Pn=1,Jo=Function.call.bind(Object.prototype.hasOwnProperty)),Jo}var Ko,Nn;function xl(){if(Nn)return Ko;Nn=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var o=un(),n={},i=Ri();t=function(d){var l="Warning: "+d;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}}}function s(d,l,c,u,h){if(process.env.NODE_ENV!=="production"){for(var m in d)if(i(d,m)){var b;try{if(typeof d[m]!="function"){var x=Error((u||"React class")+": "+c+" 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}b=d[m](l,m,u,c,null,o)}catch(D){b=D}if(b&&!(b instanceof Error)&&t((u||"React class")+": type specification of "+c+" `"+m+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof b+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),b instanceof Error&&!(b.message in n)){n[b.message]=!0;var y=h?h():"";t("Failed "+c+" type: "+b.message+(y??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Ko=s,Ko}var Xo,Ln;function ml(){if(Ln)return Xo;Ln=1;var t=Mi(),o=pl(),n=un(),i=Ri(),s=xl(),d=function(){};process.env.NODE_ENV!=="production"&&(d=function(c){var u="Warning: "+c;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function l(){return null}return Xo=function(c,u){var h=typeof Symbol=="function"&&Symbol.iterator,m="@@iterator";function b(A){var H=A&&(h&&A[h]||A[m]);if(typeof H=="function")return H}var x="<<anonymous>>",y={array:S("array"),bigint:S("bigint"),bool:S("boolean"),func:S("function"),number:S("number"),object:S("object"),string:S("string"),symbol:S("symbol"),any:I(),arrayOf:f,element:k(),elementType:j(),instanceOf:a,node:K(),objectOf:R,oneOf:B,oneOfType:J,shape:g,exact:M};function D(A,H){return A===H?A!==0||1/A===1/H:A!==A&&H!==H}function v(A,H){this.message=A,this.data=H&&typeof H=="object"?H:{},this.stack=""}v.prototype=Error.prototype;function C(A){if(process.env.NODE_ENV!=="production")var H={},se=0;function G(ae,ne,P,ie,pe,le,ge){if(ie=ie||x,le=le||P,ge!==n){if(u){var q=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 q.name="Invariant Violation",q}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var _e=ie+":"+P;!H[_e]&&se<3&&(d("You are manually calling a React.PropTypes validation function for the `"+le+"` 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[_e]=!0,se++)}}return ne[P]==null?ae?ne[P]===null?new v("The "+pe+" `"+le+"` is marked as required "+("in `"+ie+"`, but its value is `null`.")):new v("The "+pe+" `"+le+"` is marked as required in "+("`"+ie+"`, but its value is `undefined`.")):null:A(ne,P,ie,pe,le)}var re=G.bind(null,!1);return re.isRequired=G.bind(null,!0),re}function S(A){function H(se,G,re,ae,ne,P){var ie=se[G],pe=Q(ie);if(pe!==A){var le=xe(ie);return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+le+"` supplied to `"+re+"`, expected ")+("`"+A+"`."),{expectedType:A})}return null}return C(H)}function I(){return C(l)}function f(A){function H(se,G,re,ae,ne){if(typeof A!="function")return new v("Property `"+ne+"` of component `"+re+"` has invalid PropType notation inside arrayOf.");var P=se[G];if(!Array.isArray(P)){var ie=Q(P);return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+re+"`, expected an array."))}for(var pe=0;pe<P.length;pe++){var le=A(P,pe,re,ae,ne+"["+pe+"]",n);if(le instanceof Error)return le}return null}return C(H)}function k(){function A(H,se,G,re,ae){var ne=H[se];if(!c(ne)){var P=Q(ne);return new v("Invalid "+re+" `"+ae+"` of type "+("`"+P+"` supplied to `"+G+"`, expected a single ReactElement."))}return null}return C(A)}function j(){function A(H,se,G,re,ae){var ne=H[se];if(!t.isValidElementType(ne)){var P=Q(ne);return new v("Invalid "+re+" `"+ae+"` of type "+("`"+P+"` supplied to `"+G+"`, expected a single ReactElement type."))}return null}return C(A)}function a(A){function H(se,G,re,ae,ne){if(!(se[G]instanceof A)){var P=A.name||x,ie=L(se[G]);return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+re+"`, expected ")+("instance of `"+P+"`."))}return null}return C(H)}function B(A){if(!Array.isArray(A))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.")),l;function H(se,G,re,ae,ne){for(var P=se[G],ie=0;ie<A.length;ie++)if(D(P,A[ie]))return null;var pe=JSON.stringify(A,function(ge,q){var _e=xe(q);return _e==="symbol"?String(q):q});return new v("Invalid "+ae+" `"+ne+"` of value `"+String(P)+"` "+("supplied to `"+re+"`, expected one of "+pe+"."))}return C(H)}function R(A){function H(se,G,re,ae,ne){if(typeof A!="function")return new v("Property `"+ne+"` of component `"+re+"` has invalid PropType notation inside objectOf.");var P=se[G],ie=Q(P);if(ie!=="object")return new v("Invalid "+ae+" `"+ne+"` of type "+("`"+ie+"` supplied to `"+re+"`, expected an object."));for(var pe in P)if(i(P,pe)){var le=A(P,pe,re,ae,ne+"."+pe,n);if(le instanceof Error)return le}return null}return C(H)}function J(A){if(!Array.isArray(A))return process.env.NODE_ENV!=="production"&&d("Invalid argument supplied to oneOfType, expected an instance of array."),l;for(var H=0;H<A.length;H++){var se=A[H];if(typeof se!="function")return d("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+me(se)+" at index "+H+"."),l}function G(re,ae,ne,P,ie){for(var pe=[],le=0;le<A.length;le++){var ge=A[le],q=ge(re,ae,ne,P,ie,n);if(q==null)return null;q.data&&i(q.data,"expectedType")&&pe.push(q.data.expectedType)}var _e=pe.length>0?", expected one of type ["+pe.join(", ")+"]":"";return new v("Invalid "+P+" `"+ie+"` supplied to "+("`"+ne+"`"+_e+"."))}return C(G)}function K(){function A(H,se,G,re,ae){return W(H[se])?null:new v("Invalid "+re+" `"+ae+"` supplied to "+("`"+G+"`, expected a ReactNode."))}return C(A)}function ee(A,H,se,G,re){return new v((A||"React class")+": "+H+" type `"+se+"."+G+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+re+"`.")}function g(A){function H(se,G,re,ae,ne){var P=se[G],ie=Q(P);if(ie!=="object")return new v("Invalid "+ae+" `"+ne+"` of type `"+ie+"` "+("supplied to `"+re+"`, expected `object`."));for(var pe in A){var le=A[pe];if(typeof le!="function")return ee(re,ae,ne,pe,xe(le));var ge=le(P,pe,re,ae,ne+"."+pe,n);if(ge)return ge}return null}return C(H)}function M(A){function H(se,G,re,ae,ne){var P=se[G],ie=Q(P);if(ie!=="object")return new v("Invalid "+ae+" `"+ne+"` of type `"+ie+"` "+("supplied to `"+re+"`, expected `object`."));var pe=o({},se[G],A);for(var le in pe){var ge=A[le];if(i(A,le)&&typeof ge!="function")return ee(re,ae,ne,le,xe(ge));if(!ge)return new v("Invalid "+ae+" `"+ne+"` key `"+le+"` supplied to `"+re+"`.\nBad object: "+JSON.stringify(se[G],null," ")+`
22
+ Valid keys: `+JSON.stringify(Object.keys(A),null," "));var q=ge(P,le,re,ae,ne+"."+le,n);if(q)return q}return null}return C(H)}function W(A){switch(typeof A){case"number":case"string":case"undefined":return!0;case"boolean":return!A;case"object":if(Array.isArray(A))return A.every(W);if(A===null||c(A))return!0;var H=b(A);if(H){var se=H.call(A),G;if(H!==A.entries){for(;!(G=se.next()).done;)if(!W(G.value))return!1}else for(;!(G=se.next()).done;){var re=G.value;if(re&&!W(re[1]))return!1}}else return!1;return!0;default:return!1}}function V(A,H){return A==="symbol"?!0:H?H["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&H instanceof Symbol:!1}function Q(A){var H=typeof A;return Array.isArray(A)?"array":A instanceof RegExp?"object":V(H,A)?"symbol":H}function xe(A){if(typeof A>"u"||A===null)return""+A;var H=Q(A);if(H==="object"){if(A instanceof Date)return"date";if(A instanceof RegExp)return"regexp"}return H}function me(A){var H=xe(A);switch(H){case"array":case"object":return"an "+H;case"boolean":case"date":case"regexp":return"a "+H;default:return H}}function L(A){return!A.constructor||!A.constructor.name?x:A.constructor.name}return y.checkPropTypes=s,y.resetWarningCache=s.resetWarningCache,y.PropTypes=y,y},Xo}var Qo,Fn;function hl(){if(Fn)return Qo;Fn=1;var t=un();function o(){}function n(){}return n.resetWarningCache=o,Qo=function(){function i(l,c,u,h,m,b){if(b!==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 Vn;function fl(){if(Vn)return po.exports;if(Vn=1,process.env.NODE_ENV!=="production"){var t=Mi(),o=!0;po.exports=ml()(t.isElement,o)}else po.exports=hl()();return po.exports}var gl=fl();const qr=cl(gl);var mo={exports:{}},Te={};/**
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 J=fe(P,le,re,ae,ne+"
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 Vn;function gl(){if(Vn)return we;Vn=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"),u=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),m=Symbol.for("react.view_transition"),y=Symbol.for("react.client.reference");function D(v){if(typeof v=="object"&&v!==null){var C=v.$$typeof;switch(C){case t:switch(v=v.type,v){case n:case s:case i:case u:case x:case m:return v;default:switch(v=v&&v.$$typeof,v){case c:case l:case b:case h:return v;case d:return v;default:return C}}case o:return C}}}return we.ContextConsumer=d,we.ContextProvider=c,we.Element=t,we.ForwardRef=l,we.Fragment=n,we.Lazy=b,we.Memo=h,we.Portal=o,we.Profiler=s,we.StrictMode=i,we.Suspense=u,we.SuspenseList=x,we.isContextConsumer=function(v){return D(v)===d},we.isContextProvider=function(v){return D(v)===c},we.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},we.isForwardRef=function(v){return D(v)===l},we.isFragment=function(v){return D(v)===n},we.isLazy=function(v){return D(v)===b},we.isMemo=function(v){return D(v)===h},we.isPortal=function(v){return D(v)===o},we.isProfiler=function(v){return D(v)===s},we.isStrictMode=function(v){return D(v)===i},we.isSuspense=function(v){return D(v)===u},we.isSuspenseList=function(v){return D(v)===x},we.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===s||v===i||v===u||v===x||typeof v=="object"&&v!==null&&(v.$$typeof===b||v.$$typeof===h||v.$$typeof===c||v.$$typeof===d||v.$$typeof===l||v.$$typeof===y||v.getModuleId!==void 0)},we.typeOf=D,we}var ke={};/**
30
+ */var Hn;function yl(){if(Hn)return Te;Hn=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"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),x=Symbol.for("react.view_transition"),y=Symbol.for("react.client.reference");function D(v){if(typeof v=="object"&&v!==null){var C=v.$$typeof;switch(C){case t:switch(v=v.type,v){case n:case s:case i:case u:case h:case x:return v;default:switch(v=v&&v.$$typeof,v){case l:case c:case b:case m:return v;case d:return v;default:return C}}case o:return C}}}return Te.ContextConsumer=d,Te.ContextProvider=l,Te.Element=t,Te.ForwardRef=c,Te.Fragment=n,Te.Lazy=b,Te.Memo=m,Te.Portal=o,Te.Profiler=s,Te.StrictMode=i,Te.Suspense=u,Te.SuspenseList=h,Te.isContextConsumer=function(v){return D(v)===d},Te.isContextProvider=function(v){return D(v)===l},Te.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},Te.isForwardRef=function(v){return D(v)===c},Te.isFragment=function(v){return D(v)===n},Te.isLazy=function(v){return D(v)===b},Te.isMemo=function(v){return D(v)===m},Te.isPortal=function(v){return D(v)===o},Te.isProfiler=function(v){return D(v)===s},Te.isStrictMode=function(v){return D(v)===i},Te.isSuspense=function(v){return D(v)===u},Te.isSuspenseList=function(v){return D(v)===h},Te.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===s||v===i||v===u||v===h||typeof v=="object"&&v!==null&&(v.$$typeof===b||v.$$typeof===m||v.$$typeof===l||v.$$typeof===d||v.$$typeof===c||v.$$typeof===y||v.getModuleId!==void 0)},Te.typeOf=D,Te}var Ie={};/**
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 J=fe(P,le,re,ae,ne+"
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 Hn;function yl(){return Hn||(Hn=1,process.env.NODE_ENV!=="production"&&(function(){function t(v){if(typeof v=="object"&&v!==null){var C=v.$$typeof;switch(C){case o:switch(v=v.type,v){case i:case d:case s:case x:case h:case y:return v;default:switch(v=v&&v.$$typeof,v){case l:case u:case m:case b:return v;case c:return v;default:return C}}case n:return C}}}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"),u=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.view_transition"),D=Symbol.for("react.client.reference");ke.ContextConsumer=c,ke.ContextProvider=l,ke.Element=o,ke.ForwardRef=u,ke.Fragment=i,ke.Lazy=m,ke.Memo=b,ke.Portal=n,ke.Profiler=d,ke.StrictMode=s,ke.Suspense=x,ke.SuspenseList=h,ke.isContextConsumer=function(v){return t(v)===c},ke.isContextProvider=function(v){return t(v)===l},ke.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===o},ke.isForwardRef=function(v){return t(v)===u},ke.isFragment=function(v){return t(v)===i},ke.isLazy=function(v){return t(v)===m},ke.isMemo=function(v){return t(v)===b},ke.isPortal=function(v){return t(v)===n},ke.isProfiler=function(v){return t(v)===d},ke.isStrictMode=function(v){return t(v)===s},ke.isSuspense=function(v){return t(v)===x},ke.isSuspenseList=function(v){return t(v)===h},ke.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===i||v===d||v===s||v===x||v===h||typeof v=="object"&&v!==null&&(v.$$typeof===m||v.$$typeof===b||v.$$typeof===l||v.$$typeof===c||v.$$typeof===u||v.$$typeof===D||v.getModuleId!==void 0)},ke.typeOf=t})()),ke}var Un;function bl(){return Un||(Un=1,process.env.NODE_ENV==="production"?xo.exports=gl():xo.exports=yl()),xo.exports}var Ri=bl();function Ht(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 Wi(t){if(To.isValidElement(t)||Ri.isValidElementType(t)||!Ht(t))return t;const o={};return Object.keys(t).forEach(n=>{o[n]=Wi(t[n])}),o}function Ke(t,o,n={clone:!0}){const i=n.clone?{...t}:t;return Ht(t)&&Ht(o)&&Object.keys(o).forEach(s=>{To.isValidElement(o[s])||Ri.isValidElementType(o[s])?i[s]=o[s]:Ht(o[s])&&Object.prototype.hasOwnProperty.call(t,s)&&Ht(t[s])?i[s]=Ke(t[s],o[s],n):n.clone?i[s]=Ht(o[s])?Wi(o[s]):o[s]:i[s]=o[s]}),i}const vl=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 Sl(t){const{values:o={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=t,d=vl(o),c=Object.keys(d);function l(m){return`@media (min-width:${typeof o[m]=="number"?o[m]:m}${n})`}function u(m){return`@media (max-width:${(typeof o[m]=="number"?o[m]:m)-i/100}${n})`}function x(m,y){const D=c.indexOf(y);return`@media (min-width:${typeof o[m]=="number"?o[m]:m}${n}) and (max-width:${(D!==-1&&typeof o[c[D]]=="number"?o[c[D]]:y)-i/100}${n})`}function h(m){return c.indexOf(m)+1<c.length?x(m,c[c.indexOf(m)+1]):l(m)}function b(m){const y=c.indexOf(m);return y===0?l(c[1]):y===c.length-1?u(c[y]):x(m,c[c.indexOf(m)+1]).replace("@media","@media not all and")}return{keys:c,values:d,up:l,down:u,between:x,only:h,not:b,unit:n,...s}}function Yn(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 jl(t,o){return o==="@"||o.startsWith("@")&&(t.some(n=>o.startsWith(`@${n}`))||!!o.match(/^@\d/))}function Cl(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 wl(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 u=o(t.breakpoints.not(...l),c);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=d=>(n(i,d),i);return n(s),{...t,containerQueries:s}}const kl={borderRadius:4},Yt=process.env.NODE_ENV!=="production"?Gr.oneOfType([Gr.number,Gr.string,Gr.object,Gr.array]):{};function to(t,o){return o?Ke(t,o,{clone:!1}):t}const Bo={xs:0,sm:600,md:900,lg:1200,xl:1536},Gn={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${Bo[t]}px)`},Tl={containerQueries:t=>({up:o=>{let n=typeof o=="number"?o:Bo[o]||o;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function At(t,o,n){const i=t.theme||{};if(Array.isArray(o)){const d=i.breakpoints||Gn;return o.reduce((c,l,u)=>(c[d.up(d.keys[u])]=n(o[u]),c),{})}if(typeof o=="object"){const d=i.breakpoints||Gn;return Object.keys(o).reduce((c,l)=>{if(jl(d.keys,l)){const u=Cl(i.containerQueries?i:Tl,l);u&&(c[u]=n(o[l],l))}else if(Object.keys(d.values||Bo).includes(l)){const u=d.up(l);c[u]=n(o[l],l)}else{const u=l;c[u]=o[u]}return c},{})}return n(o)}function Il(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,s)=>{const d=t.up(s);return i[d]={},i},{}))||{}}function qn(t,o){return t.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},o)}function Pi(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":lr(7));return t.charAt(0).toUpperCase()+t.slice(1)}function Do(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 wo(t,o,n,i=n){let s;return typeof t=="function"?s=t(n):Array.isArray(t)?s=t[n]||i:s=Do(t,n)||i,o&&(s=o(s,i,t)),s}function Ae(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],u=c.theme,x=Do(u,i)||{};return At(c,l,b=>{let m=wo(x,s,b);return b===m&&typeof b=="string"&&(m=wo(x,s,`${o}${b==="default"?"":Pi(b)}`,b)),n===!1?m:{[n]:m}})};return d.propTypes=process.env.NODE_ENV!=="production"?{[o]:Yt}:{},d.filterProps=[o],d}function zl(t){const o={};return n=>(o[n]===void 0&&(o[n]=t(n)),o[n])}const Bl={m:"margin",p:"padding"},Dl={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Jn={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},El=zl(t=>{if(t.length>2)if(Jn[t])t=Jn[t];else return[t];const[o,n]=t.split(""),i=Bl[o],s=Dl[n]||"";return Array.isArray(s)?s.map(d=>i+d):[i+s]}),Eo=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],Oo=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],Ol=[...Eo,...Oo];function oo(t,o,n,i){const s=Do(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(`
38
+ */var Un;function bl(){return Un||(Un=1,process.env.NODE_ENV!=="production"&&(function(){function t(v){if(typeof v=="object"&&v!==null){var C=v.$$typeof;switch(C){case o:switch(v=v.type,v){case i:case d:case s:case h:case m:case y:return v;default:switch(v=v&&v.$$typeof,v){case c:case u:case x:case b:return v;case l:return v;default:return C}}case n:return C}}}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"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.for("react.view_transition"),D=Symbol.for("react.client.reference");Ie.ContextConsumer=l,Ie.ContextProvider=c,Ie.Element=o,Ie.ForwardRef=u,Ie.Fragment=i,Ie.Lazy=x,Ie.Memo=b,Ie.Portal=n,Ie.Profiler=d,Ie.StrictMode=s,Ie.Suspense=h,Ie.SuspenseList=m,Ie.isContextConsumer=function(v){return t(v)===l},Ie.isContextProvider=function(v){return t(v)===c},Ie.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===o},Ie.isForwardRef=function(v){return t(v)===u},Ie.isFragment=function(v){return t(v)===i},Ie.isLazy=function(v){return t(v)===x},Ie.isMemo=function(v){return t(v)===b},Ie.isPortal=function(v){return t(v)===n},Ie.isProfiler=function(v){return t(v)===d},Ie.isStrictMode=function(v){return t(v)===s},Ie.isSuspense=function(v){return t(v)===h},Ie.isSuspenseList=function(v){return t(v)===m},Ie.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===i||v===d||v===s||v===h||v===m||typeof v=="object"&&v!==null&&(v.$$typeof===x||v.$$typeof===b||v.$$typeof===c||v.$$typeof===l||v.$$typeof===u||v.$$typeof===D||v.getModuleId!==void 0)},Ie.typeOf=t})()),Ie}var Yn;function vl(){return Yn||(Yn=1,process.env.NODE_ENV==="production"?mo.exports=yl():mo.exports=bl()),mo.exports}var Wi=vl();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 Pi(t){if(Io.isValidElement(t)||Wi.isValidElementType(t)||!Ut(t))return t;const o={};return Object.keys(t).forEach(n=>{o[n]=Pi(t[n])}),o}function Ze(t,o,n={clone:!0}){const i=n.clone?{...t}:t;return Ut(t)&&Ut(o)&&Object.keys(o).forEach(s=>{Io.isValidElement(o[s])||Wi.isValidElementType(o[s])?i[s]=o[s]:Ut(o[s])&&Object.prototype.hasOwnProperty.call(t,s)&&Ut(t[s])?i[s]=Ze(t[s],o[s],n):n.clone?i[s]=Ut(o[s])?Pi(o[s]):o[s]:i[s]=o[s]}),i}const Sl=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 jl(t){const{values:o={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=t,d=Sl(o),l=Object.keys(d);function c(x){return`@media (min-width:${typeof o[x]=="number"?o[x]:x}${n})`}function u(x){return`@media (max-width:${(typeof o[x]=="number"?o[x]:x)-i/100}${n})`}function h(x,y){const D=l.indexOf(y);return`@media (min-width:${typeof o[x]=="number"?o[x]:x}${n}) and (max-width:${(D!==-1&&typeof o[l[D]]=="number"?o[l[D]]:y)-i/100}${n})`}function m(x){return l.indexOf(x)+1<l.length?h(x,l[l.indexOf(x)+1]):c(x)}function b(x){const y=l.indexOf(x);return y===0?c(l[1]):y===l.length-1?u(l[y]):h(x,l[l.indexOf(x)+1]).replace("@media","@media not all and")}return{keys:l,values:d,up:c,down:u,between:h,only:m,not:b,unit:n,...s}}function Gn(t,o){if(!t.containerQueries)return o;const n=Object.keys(o).filter(i=>i.startsWith("@container")).sort((i,s)=>{var l,c;const d=/min-width:\s*([0-9.]+)/;return+(((l=i.match(d))==null?void 0:l[1])||0)-+(((c=s.match(d))==null?void 0:c[1])||0)});return n.length?n.reduce((i,s)=>{const d=o[s];return delete i[s],i[s]=d,i},{...o}):o}function Cl(t,o){return o==="@"||o.startsWith("@")&&(t.some(n=>o.startsWith(`@${n}`))||!!o.match(/^@\d/))}function wl(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 kl(t){const o=(d,l)=>d.replace("@media",l?`@container ${l}`:"@container");function n(d,l){d.up=(...c)=>o(t.breakpoints.up(...c),l),d.down=(...c)=>o(t.breakpoints.down(...c),l),d.between=(...c)=>o(t.breakpoints.between(...c),l),d.only=(...c)=>o(t.breakpoints.only(...c),l),d.not=(...c)=>{const u=o(t.breakpoints.not(...c),l);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=d=>(n(i,d),i);return n(s),{...t,containerQueries:s}}const Tl={borderRadius:4},Gt=process.env.NODE_ENV!=="production"?qr.oneOfType([qr.number,qr.string,qr.object,qr.array]):{};function ro(t,o){return o?Ze(t,o,{clone:!1}):t}const Do={xs:0,sm:600,md:900,lg:1200,xl:1536},qn={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${Do[t]}px)`},Il={containerQueries:t=>({up:o=>{let n=typeof o=="number"?o:Do[o]||o;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function $t(t,o,n){const i=t.theme||{};if(Array.isArray(o)){const d=i.breakpoints||qn;return o.reduce((l,c,u)=>(l[d.up(d.keys[u])]=n(o[u]),l),{})}if(typeof o=="object"){const d=i.breakpoints||qn;return Object.keys(o).reduce((l,c)=>{if(Cl(d.keys,c)){const u=wl(i.containerQueries?i:Il,c);u&&(l[u]=n(o[c],c))}else if(Object.keys(d.values||Do).includes(c)){const u=d.up(c);l[u]=n(o[c],c)}else{const u=c;l[u]=o[u]}return l},{})}return n(o)}function zl(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,s)=>{const d=t.up(s);return i[d]={},i},{}))||{}}function Jn(t,o){return t.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},o)}function Ni(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":dr(7));return t.charAt(0).toUpperCase()+t.slice(1)}function Eo(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 ko(t,o,n,i=n){let s;return typeof t=="function"?s=t(n):Array.isArray(t)?s=t[n]||i:s=Eo(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=l=>{if(l[o]==null)return null;const c=l[o],u=l.theme,h=Eo(u,i)||{};return $t(l,c,b=>{let x=ko(h,s,b);return b===x&&typeof b=="string"&&(x=ko(h,s,`${o}${b==="default"?"":Ni(b)}`,b)),n===!1?x:{[n]:x}})};return d.propTypes=process.env.NODE_ENV!=="production"?{[o]:Gt}:{},d.filterProps=[o],d}function Bl(t){const o={};return n=>(o[n]===void 0&&(o[n]=t(n)),o[n])}const Dl={m:"margin",p:"padding"},El={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Kn={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Ol=Bl(t=>{if(t.length>2)if(Kn[t])t=Kn[t];else return[t];const[o,n]=t.split(""),i=Dl[o],s=El[n]||"";return Array.isArray(s)?s.map(d=>i+d):[i+s]}),Oo=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],$o=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],$l=[...Oo,...$o];function no(t,o,n,i){const s=Eo(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 l=Math.abs(d);process.env.NODE_ENV!=="production"&&(Number.isInteger(l)?l>s.length-1&&console.error([`MUI: The value provided (${l}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${l} > ${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
- `)));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 un(t){return oo(t,"spacing",8,"spacing")}function no(t,o){return typeof o=="string"||o==null?o:t(o)}function $l(t,o){return n=>t.reduce((i,s)=>(i[s]=no(o,n),i),{})}function Al(t,o,n,i){if(!o.includes(n))return null;const s=El(n),d=$l(s,i),c=t[n];return At(t,c,d)}function Ni(t,o){const n=un(t.theme);return Object.keys(t).map(i=>Al(t,o,i,n)).reduce(to,{})}function Oe(t){return Ni(t,Eo)}Oe.propTypes=process.env.NODE_ENV!=="production"?Eo.reduce((t,o)=>(t[o]=Yt,t),{}):{};Oe.filterProps=Eo;function $e(t){return Ni(t,Oo)}$e.propTypes=process.env.NODE_ENV!=="production"?Oo.reduce((t,o)=>(t[o]=Yt,t),{}):{};$e.filterProps=Oo;process.env.NODE_ENV!=="production"&&Ol.reduce((t,o)=>(t[o]=Yt,t),{});function Li(t=8,o=un({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 $o(...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]?to(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 tt(t){return typeof t!="number"?t:`${t}px solid`}function rt(t,o){return Ae({prop:t,themeKey:"borders",transform:o})}const _l=rt("border",tt),Ml=rt("borderTop",tt),Rl=rt("borderRight",tt),Wl=rt("borderBottom",tt),Pl=rt("borderLeft",tt),Nl=rt("borderColor"),Ll=rt("borderTopColor"),Fl=rt("borderRightColor"),Vl=rt("borderBottomColor"),Hl=rt("borderLeftColor"),Ul=rt("outline",tt),Yl=rt("outlineColor"),Ao=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const o=oo(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:no(o,i)});return At(t,t.borderRadius,n)}return null};Ao.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Yt}:{};Ao.filterProps=["borderRadius"];$o(_l,Ml,Rl,Wl,Pl,Nl,Ll,Fl,Vl,Hl,Ao,Ul,Yl);const _o=t=>{if(t.gap!==void 0&&t.gap!==null){const o=oo(t.theme,"spacing",8,"gap"),n=i=>({gap:no(o,i)});return At(t,t.gap,n)}return null};_o.propTypes=process.env.NODE_ENV!=="production"?{gap:Yt}:{};_o.filterProps=["gap"];const Mo=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const o=oo(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:no(o,i)});return At(t,t.columnGap,n)}return null};Mo.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Yt}:{};Mo.filterProps=["columnGap"];const Ro=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const o=oo(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:no(o,i)});return At(t,t.rowGap,n)}return null};Ro.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Yt}:{};Ro.filterProps=["rowGap"];const Gl=Ae({prop:"gridColumn"}),ql=Ae({prop:"gridRow"}),Jl=Ae({prop:"gridAutoFlow"}),Kl=Ae({prop:"gridAutoColumns"}),Xl=Ae({prop:"gridAutoRows"}),Zl=Ae({prop:"gridTemplateColumns"}),Ql=Ae({prop:"gridTemplateRows"}),ec=Ae({prop:"gridTemplateAreas"}),tc=Ae({prop:"gridArea"});$o(_o,Mo,Ro,Gl,ql,Jl,Kl,Xl,Zl,Ql,ec,tc);function Or(t,o){return o==="grey"?o:t}const rc=Ae({prop:"color",themeKey:"palette",transform:Or}),oc=Ae({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Or}),nc=Ae({prop:"backgroundColor",themeKey:"palette",transform:Or});$o(rc,oc,nc);function qe(t){return t<=1&&t!==0?`${t*100}%`:t}const ic=Ae({prop:"width",transform:qe}),pn=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])||Bo[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:qe(n)}};return At(t,t.maxWidth,o)}return null};pn.filterProps=["maxWidth"];const sc=Ae({prop:"minWidth",transform:qe}),ac=Ae({prop:"height",transform:qe}),lc=Ae({prop:"maxHeight",transform:qe}),cc=Ae({prop:"minHeight",transform:qe});Ae({prop:"size",cssProperty:"width",transform:qe});Ae({prop:"size",cssProperty:"height",transform:qe});const dc=Ae({prop:"boxSizing"});$o(ic,pn,sc,ac,lc,cc,dc);const Wo={border:{themeKey:"borders",transform:tt},borderTop:{themeKey:"borders",transform:tt},borderRight:{themeKey:"borders",transform:tt},borderBottom:{themeKey:"borders",transform:tt},borderLeft:{themeKey:"borders",transform:tt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:tt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Ao},color:{themeKey:"palette",transform:Or},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Or},backgroundColor:{themeKey:"palette",transform:Or},p:{style:$e},pt:{style:$e},pr:{style:$e},pb:{style:$e},pl:{style:$e},px:{style:$e},py:{style:$e},padding:{style:$e},paddingTop:{style:$e},paddingRight:{style:$e},paddingBottom:{style:$e},paddingLeft:{style:$e},paddingX:{style:$e},paddingY:{style:$e},paddingInline:{style:$e},paddingInlineStart:{style:$e},paddingInlineEnd:{style:$e},paddingBlock:{style:$e},paddingBlockStart:{style:$e},paddingBlockEnd:{style:$e},m:{style:Oe},mt:{style:Oe},mr:{style:Oe},mb:{style:Oe},ml:{style:Oe},mx:{style:Oe},my:{style:Oe},margin:{style:Oe},marginTop:{style:Oe},marginRight:{style:Oe},marginBottom:{style:Oe},marginLeft:{style:Oe},marginX:{style:Oe},marginY:{style:Oe},marginInline:{style:Oe},marginInlineStart:{style:Oe},marginInlineEnd:{style:Oe},marginBlock:{style:Oe},marginBlockStart:{style:Oe},marginBlockEnd:{style:Oe},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:_o},rowGap:{style:Ro},columnGap:{style:Mo},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:qe},maxWidth:{style:pn},minWidth:{transform:qe},height:{transform:qe},maxHeight:{transform:qe},minHeight:{transform:qe},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 uc(...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 pc(t,o){return typeof t=="function"?t(o):t}function xc(){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:x,transform:h,style:b}=l;if(i==null)return null;if(x==="typography"&&i==="inherit")return{[n]:i};const m=Do(s,x)||{};return b?b(c):At(c,i,D=>{let v=wo(m,h,D);return D===v&&typeof D=="string"&&(v=wo(m,h,`${n}${D==="default"?"":Pi(D)}`,D)),u===!1?v:{[u]:v}})}function o(n){const{sx:i,theme:s={},nested:d}=n||{};if(!i)return null;const c=s.unstable_sxConfig??Wo;function l(u){let x=u;if(typeof u=="function")x=u(s);else if(typeof u!="object")return u;if(!x)return null;const h=Il(s.breakpoints),b=Object.keys(h);let m=h;return Object.keys(x).forEach(y=>{const D=pc(x[y],s);if(D!=null)if(typeof D=="object")if(c[y])m=to(m,t(y,D,s,c));else{const v=At({theme:s},D,C=>({[y]:C}));uc(v,D)?m[y]=o({sx:D,theme:s,nested:!0}):m=to(m,v)}else m=to(m,t(y,D,s,c))}),!d&&s.modularCssLayers?{"@layer sx":Yn(s,qn(b,m))}:Yn(s,qn(b,m))}return Array.isArray(i)?i.map(l):l(i)}return o}const Po=xc();Po.filterProps=["sx"];function mc(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 Fi(t={},...o){const{breakpoints:n={},palette:i={},spacing:s,shape:d={},...c}=t,l=Sl(n),u=Li(s);let x=Ke({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...kl,...d}},c);return x=wl(x),x.applyStyles=mc,x=o.reduce((h,b)=>Ke(h,b),x),x.unstable_sxConfig={...Wo,...c==null?void 0:c.unstable_sxConfig},x.unstable_sx=function(b){return Po({sx:b,theme:this})},x}function hc(t){return Object.keys(t).length===0}function fc(t=null){const o=To.useContext(_s.ThemeContext);return!o||hc(o)?t:o}const gc=Fi();function yc(t=gc){return fc(t)}const Kn=t=>t,bc=()=>{let t=Kn;return{configure(o){t=o},generate(o){return t(o)},reset(){t=Kn}}},vc=bc(),Sc={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 jc(t,o,n="Mui"){const i=Sc[o];return i?`${n}-${i}`:`${vc.generate(t)}-${o}`}function Cc(t,o=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(o,Math.min(t,n))}function xn(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}].`),Cc(t,o,n)}function wc(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 Ut(t){if(t.type)return t;if(t.charAt(0)==="#")return Ut(wc(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().`:lr(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.`:lr(10,s))}else i=i.split(",");return i=i.map(d=>parseFloat(d)),{type:n,values:i,colorSpace:s}}const kc=t=>{const o=Ut(t);return o.values.slice(0,3).map((n,i)=>o.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Zr=(t,o)=>{try{return kc(t)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),t}};function No(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 Vi(t){t=Ut(t);const{values:o}=t,n=o[0],i=o[1]/100,s=o[2]/100,d=i*Math.min(s,1-s),c=(x,h=(x+n/30)%12)=>s-d*Math.max(Math.min(h-3,9-h,1),-1);let l="rgb";const u=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return t.type==="hsla"&&(l+="a",u.push(o[3])),No({type:l,values:u})}function rn(t){t=Ut(t);let o=t.type==="hsl"||t.type==="hsla"?Ut(Vi(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 Xn(t,o){const n=rn(t),i=rn(o);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function T(t,o){return t=Ut(t),o=xn(o),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${o}`:t.values[3]=o,No(t)}function ir(t,o,n){try{return T(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Lo(t,o){if(t=Ut(t),o=xn(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 No(t)}function je(t,o,n){try{return Lo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Fo(t,o){if(t=Ut(t),o=xn(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 No(t)}function Ce(t,o,n){try{return Fo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Tc(t,o=.15){return rn(t)>.5?Lo(t,o):Fo(t,o)}function mo(t,o,n){try{return Tc(t,o)}catch{return t}}function Ic(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 Zn=(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])})},zc=(t,o,n)=>{function i(s,d=[],c=[]){Object.entries(s).forEach(([l,u])=>{(!n||n&&!n([...d,l]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...d,l],Array.isArray(u)?[...c,l]:c):o([...d,l],u,c))})}i(t)},Bc=(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 zc(t,(l,u,x)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(l,u))){const h=`--${n?`${n}-`:""}${l.join("-")}`,b=Bc(l,u);Object.assign(s,{[h]:b}),Zn(d,l,`var(${h})`,x),Zn(c,l,`var(${h}, ${b})`,x)}},l=>l[0]==="vars"),{css:s,vars:d,varsWithDefaults:c}}function Dc(t,o={}){const{getSelector:n=S,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:d}=o,{colorSchemes:c={},components:l,defaultColorScheme:u="light",...x}=t,{vars:h,css:b,varsWithDefaults:m}=Zo(x,o);let y=m;const D={},{[u]:v,...C}=c;if(Object.entries(C||{}).forEach(([k,j])=>{const{vars:a,css:B,varsWithDefaults:R}=Zo(j,o);y=Ke(y,R),D[k]={css:B,vars:a}}),v){const{css:k,vars:j,varsWithDefaults:a}=Zo(v,o);y=Ke(y,a),D[u]={css:k,vars:j}}function S(k,j){var B,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"]`),k){if(a==="media")return t.defaultColorScheme===k?":root":{[`@media (prefers-color-scheme: ${((R=(B=c[k])==null?void 0:B.palette)==null?void 0:R.mode)||k})`]:{":root":j}};if(a)return t.defaultColorScheme===k?`:root, ${a.replace("%s",String(k))}`:a.replace("%s",String(k))}return":root"}return{vars:y,generateThemeVars:()=>{let k={...h};return Object.entries(D).forEach(([,{vars:j}])=>{k=Ke(k,j)}),k},generateStyleSheets:()=>{var q,K;const k=[],j=t.defaultColorScheme||"light";function a(ee,g){Object.keys(g).length&&k.push(typeof ee=="string"?{[ee]:{...g}}:ee)}a(n(void 0,{...b}),b);const{[j]:B,...R}=D;if(B){const{css:ee}=B,g=(K=(q=c[j])==null?void 0:q.palette)==null?void 0:K.mode,M=!i&&g?{colorScheme:g,...ee}:{...ee};a(n(j,{...M}),M)}return Object.entries(R).forEach(([ee,{css:g}])=>{var V,Z;const M=(Z=(V=c[ee])==null?void 0:V.palette)==null?void 0:Z.mode,W=!i&&M?{colorScheme:M,...g}:{...g};a(n(ee,{...W}),W)}),d&&k.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)"}}),k}}}function Ec(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 ro={black:"#000",white:"#fff"},Oc={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"},Tr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},Ir={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},qr={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},zr={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},Br={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},Dr={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Hi(){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:ro.white,default:ro.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}}}const Ui=Hi();function Yi(){return{text:{primary:ro.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:ro.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 on=Yi();function Qn(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=Fo(t.main,s):o==="dark"&&(t.dark=Lo(t.main,d)))}function ei(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 $c(t="light"){return t==="dark"?{main:zr[200],light:zr[50],dark:zr[400]}:{main:zr[700],light:zr[400],dark:zr[800]}}function Ac(t="light"){return t==="dark"?{main:Tr[200],light:Tr[50],dark:Tr[400]}:{main:Tr[500],light:Tr[300],dark:Tr[700]}}function _c(t="light"){return t==="dark"?{main:Ir[500],light:Ir[300],dark:Ir[700]}:{main:Ir[700],light:Ir[400],dark:Ir[800]}}function Mc(t="light"){return t==="dark"?{main:Br[400],light:Br[300],dark:Br[700]}:{main:Br[700],light:Br[500],dark:Br[900]}}function Rc(t="light"){return t==="dark"?{main:Dr[400],light:Dr[300],dark:Dr[700]}:{main:Dr[800],light:Dr[500],dark:Dr[900]}}function Wc(t="light"){return t==="dark"?{main:qr[400],light:qr[300],dark:qr[700]}:{main:"#ed6c02",light:qr[500],dark:qr[900]}}function Pc(t){return`oklch(from ${t} var(--__l) 0 h / var(--__a))`}function mn(t){const{mode:o="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...d}=t,c=t.primary||$c(o),l=t.secondary||Ac(o),u=t.error||_c(o),x=t.info||Mc(o),h=t.success||Rc(o),b=t.warning||Wc(o);function m(C){if(s)return Pc(C);const S=Xn(C,on.text.primary)>=n?on.text.primary:Ui.text.primary;if(process.env.NODE_ENV!=="production"){const I=Xn(C,S);I<3&&console.error([`MUI: The contrast ratio of ${I}:1 for ${S} on ${C}`,"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(`
41
+ `)));const c=s[l];return d>=0?c:typeof c=="number"?-c:typeof c=="string"&&c.startsWith("var(")?`calc(-1 * ${c})`:`-${c}`}: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 pn(t){return no(t,"spacing",8,"spacing")}function io(t,o){return typeof o=="string"||o==null?o:t(o)}function Al(t,o){return n=>t.reduce((i,s)=>(i[s]=io(o,n),i),{})}function _l(t,o,n,i){if(!o.includes(n))return null;const s=Ol(n),d=Al(s,i),l=t[n];return $t(t,l,d)}function Li(t,o){const n=pn(t.theme);return Object.keys(t).map(i=>_l(t,o,i,n)).reduce(ro,{})}function Ee(t){return Li(t,Oo)}Ee.propTypes=process.env.NODE_ENV!=="production"?Oo.reduce((t,o)=>(t[o]=Gt,t),{}):{};Ee.filterProps=Oo;function Oe(t){return Li(t,$o)}Oe.propTypes=process.env.NODE_ENV!=="production"?$o.reduce((t,o)=>(t[o]=Gt,t),{}):{};Oe.filterProps=$o;process.env.NODE_ENV!=="production"&&$l.reduce((t,o)=>(t[o]=Gt,t),{});function Fi(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 l=o(d);return typeof l=="number"?`${l}px`:l}).join(" "));return n.mui=!0,n}function Ao(...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]?ro(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 st(t){return typeof t!="number"?t:`${t}px solid`}function at(t,o){return $e({prop:t,themeKey:"borders",transform:o})}const Ml=at("border",st),Rl=at("borderTop",st),Wl=at("borderRight",st),Pl=at("borderBottom",st),Nl=at("borderLeft",st),Ll=at("borderColor"),Fl=at("borderTopColor"),Vl=at("borderRightColor"),Hl=at("borderBottomColor"),Ul=at("borderLeftColor"),Yl=at("outline",st),Gl=at("outlineColor"),_o=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const o=no(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:io(o,i)});return $t(t,t.borderRadius,n)}return null};_o.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Gt}:{};_o.filterProps=["borderRadius"];Ao(Ml,Rl,Wl,Pl,Nl,Ll,Fl,Vl,Hl,Ul,_o,Yl,Gl);const Mo=t=>{if(t.gap!==void 0&&t.gap!==null){const o=no(t.theme,"spacing",8,"gap"),n=i=>({gap:io(o,i)});return $t(t,t.gap,n)}return null};Mo.propTypes=process.env.NODE_ENV!=="production"?{gap:Gt}:{};Mo.filterProps=["gap"];const Ro=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const o=no(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:io(o,i)});return $t(t,t.columnGap,n)}return null};Ro.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Gt}:{};Ro.filterProps=["columnGap"];const Wo=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const o=no(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:io(o,i)});return $t(t,t.rowGap,n)}return null};Wo.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Gt}:{};Wo.filterProps=["rowGap"];const ql=$e({prop:"gridColumn"}),Jl=$e({prop:"gridRow"}),Kl=$e({prop:"gridAutoFlow"}),Xl=$e({prop:"gridAutoColumns"}),Ql=$e({prop:"gridAutoRows"}),Zl=$e({prop:"gridTemplateColumns"}),ec=$e({prop:"gridTemplateRows"}),tc=$e({prop:"gridTemplateAreas"}),rc=$e({prop:"gridArea"});Ao(Mo,Ro,Wo,ql,Jl,Kl,Xl,Ql,Zl,ec,tc,rc);function Er(t,o){return o==="grey"?o:t}const oc=$e({prop:"color",themeKey:"palette",transform:Er}),nc=$e({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Er}),ic=$e({prop:"backgroundColor",themeKey:"palette",transform:Er});Ao(oc,nc,ic);function Xe(t){return t<=1&&t!==0?`${t*100}%`:t}const sc=$e({prop:"width",transform:Xe}),xn=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const o=n=>{var s,d,l,c,u;const i=((l=(d=(s=t.theme)==null?void 0:s.breakpoints)==null?void 0:d.values)==null?void 0:l[n])||Do[n];return i?((u=(c=t.theme)==null?void 0:c.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Xe(n)}};return $t(t,t.maxWidth,o)}return null};xn.filterProps=["maxWidth"];const ac=$e({prop:"minWidth",transform:Xe}),lc=$e({prop:"height",transform:Xe}),cc=$e({prop:"maxHeight",transform:Xe}),dc=$e({prop:"minHeight",transform:Xe});$e({prop:"size",cssProperty:"width",transform:Xe});$e({prop:"size",cssProperty:"height",transform:Xe});const uc=$e({prop:"boxSizing"});Ao(sc,xn,ac,lc,cc,dc,uc);const Po={border:{themeKey:"borders",transform:st},borderTop:{themeKey:"borders",transform:st},borderRight:{themeKey:"borders",transform:st},borderBottom:{themeKey:"borders",transform:st},borderLeft:{themeKey:"borders",transform:st},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:st},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:_o},color:{themeKey:"palette",transform:Er},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Er},backgroundColor:{themeKey:"palette",transform:Er},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:Ee},mt:{style:Ee},mr:{style:Ee},mb:{style:Ee},ml:{style:Ee},mx:{style:Ee},my:{style:Ee},margin:{style:Ee},marginTop:{style:Ee},marginRight:{style:Ee},marginBottom:{style:Ee},marginLeft:{style:Ee},marginX:{style:Ee},marginY:{style:Ee},marginInline:{style:Ee},marginInlineStart:{style:Ee},marginInlineEnd:{style:Ee},marginBlock:{style:Ee},marginBlockStart:{style:Ee},marginBlockEnd:{style:Ee},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:Mo},rowGap:{style:Wo},columnGap:{style:Ro},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Xe},maxWidth:{style:xn},minWidth:{transform:Xe},height:{transform:Xe},maxHeight:{transform:Xe},minHeight:{transform:Xe},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 pc(...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 xc(t,o){return typeof t=="function"?t(o):t}function mc(){function t(n,i,s,d){const l={[n]:i,theme:s},c=d[n];if(!c)return{[n]:i};const{cssProperty:u=n,themeKey:h,transform:m,style:b}=c;if(i==null)return null;if(h==="typography"&&i==="inherit")return{[n]:i};const x=Eo(s,h)||{};return b?b(l):$t(l,i,D=>{let v=ko(x,m,D);return D===v&&typeof D=="string"&&(v=ko(x,m,`${n}${D==="default"?"":Ni(D)}`,D)),u===!1?v:{[u]:v}})}function o(n){const{sx:i,theme:s={},nested:d}=n||{};if(!i)return null;const l=s.unstable_sxConfig??Po;function c(u){let h=u;if(typeof u=="function")h=u(s);else if(typeof u!="object")return u;if(!h)return null;const m=zl(s.breakpoints),b=Object.keys(m);let x=m;return Object.keys(h).forEach(y=>{const D=xc(h[y],s);if(D!=null)if(typeof D=="object")if(l[y])x=ro(x,t(y,D,s,l));else{const v=$t({theme:s},D,C=>({[y]:C}));pc(v,D)?x[y]=o({sx:D,theme:s,nested:!0}):x=ro(x,v)}else x=ro(x,t(y,D,s,l))}),!d&&s.modularCssLayers?{"@layer sx":Gn(s,Jn(b,x))}:Gn(s,Jn(b,x))}return Array.isArray(i)?i.map(c):c(i)}return o}const No=mc();No.filterProps=["sx"];function hc(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 Vi(t={},...o){const{breakpoints:n={},palette:i={},spacing:s,shape:d={},...l}=t,c=jl(n),u=Fi(s);let h=Ze({breakpoints:c,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...Tl,...d}},l);return h=kl(h),h.applyStyles=hc,h=o.reduce((m,b)=>Ze(m,b),h),h.unstable_sxConfig={...Po,...l==null?void 0:l.unstable_sxConfig},h.unstable_sx=function(b){return No({sx:b,theme:this})},h}function fc(t){return Object.keys(t).length===0}function gc(t=null){const o=Io.useContext(Rs.ThemeContext);return!o||fc(o)?t:o}const yc=Vi();function bc(t=yc){return gc(t)}const Xn=t=>t,vc=()=>{let t=Xn;return{configure(o){t=o},generate(o){return t(o)},reset(){t=Xn}}},Sc=vc(),jc={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 Cc(t,o,n="Mui"){const i=jc[o];return i?`${n}-${i}`:`${Sc.generate(t)}-${o}`}function wc(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}].`),wc(t,o,n)}function kc(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 Yt(t){if(t.type)return t;if(t.charAt(0)==="#")return Yt(kc(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().`:dr(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.`:dr(10,s))}else i=i.split(",");return i=i.map(d=>parseFloat(d)),{type:n,values:i,colorSpace:s}}const Tc=t=>{const o=Yt(t);return o.values.slice(0,3).map((n,i)=>o.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Zr=(t,o)=>{try{return Tc(t)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),t}};function Lo(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 Hi(t){t=Yt(t);const{values:o}=t,n=o[0],i=o[1]/100,s=o[2]/100,d=i*Math.min(s,1-s),l=(h,m=(h+n/30)%12)=>s-d*Math.max(Math.min(m-3,9-m,1),-1);let c="rgb";const u=[Math.round(l(0)*255),Math.round(l(8)*255),Math.round(l(4)*255)];return t.type==="hsla"&&(c+="a",u.push(o[3])),Lo({type:c,values:u})}function on(t){t=Yt(t);let o=t.type==="hsl"||t.type==="hsla"?Yt(Hi(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 Qn(t,o){const n=on(t),i=on(o);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function T(t,o){return t=Yt(t),o=mn(o),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${o}`:t.values[3]=o,Lo(t)}function ar(t,o,n){try{return T(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Fo(t,o){if(t=Yt(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 Lo(t)}function Se(t,o,n){try{return Fo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Vo(t,o){if(t=Yt(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 Lo(t)}function je(t,o,n){try{return Vo(t,o)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),t}}function Ic(t,o=.15){return on(t)>.5?Fo(t,o):Vo(t,o)}function ho(t,o,n){try{return Ic(t,o)}catch{return t}}function zc(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 Zn=(t,o,n,i=[])=>{let s=t;o.forEach((d,l)=>{l===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])})},Bc=(t,o,n)=>{function i(s,d=[],l=[]){Object.entries(s).forEach(([c,u])=>{(!n||n&&!n([...d,c]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...d,c],Array.isArray(u)?[...l,c]:l):o([...d,c],u,l))})}i(t)},Dc=(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={},l={};return Bc(t,(c,u,h)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(c,u))){const m=`--${n?`${n}-`:""}${c.join("-")}`,b=Dc(c,u);Object.assign(s,{[m]:b}),Zn(d,c,`var(${m})`,h),Zn(l,c,`var(${m}, ${b})`,h)}},c=>c[0]==="vars"),{css:s,vars:d,varsWithDefaults:l}}function Ec(t,o={}){const{getSelector:n=S,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:d}=o,{colorSchemes:l={},components:c,defaultColorScheme:u="light",...h}=t,{vars:m,css:b,varsWithDefaults:x}=Zo(h,o);let y=x;const D={},{[u]:v,...C}=l;if(Object.entries(C||{}).forEach(([k,j])=>{const{vars:a,css:B,varsWithDefaults:R}=Zo(j,o);y=Ze(y,R),D[k]={css:B,vars:a}}),v){const{css:k,vars:j,varsWithDefaults:a}=Zo(v,o);y=Ze(y,a),D[u]={css:k,vars:j}}function S(k,j){var B,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"]`),k){if(a==="media")return t.defaultColorScheme===k?":root":{[`@media (prefers-color-scheme: ${((R=(B=l[k])==null?void 0:B.palette)==null?void 0:R.mode)||k})`]:{":root":j}};if(a)return t.defaultColorScheme===k?`:root, ${a.replace("%s",String(k))}`:a.replace("%s",String(k))}return":root"}return{vars:y,generateThemeVars:()=>{let k={...m};return Object.entries(D).forEach(([,{vars:j}])=>{k=Ze(k,j)}),k},generateStyleSheets:()=>{var J,K;const k=[],j=t.defaultColorScheme||"light";function a(ee,g){Object.keys(g).length&&k.push(typeof ee=="string"?{[ee]:{...g}}:ee)}a(n(void 0,{...b}),b);const{[j]:B,...R}=D;if(B){const{css:ee}=B,g=(K=(J=l[j])==null?void 0:J.palette)==null?void 0:K.mode,M=!i&&g?{colorScheme:g,...ee}:{...ee};a(n(j,{...M}),M)}return Object.entries(R).forEach(([ee,{css:g}])=>{var V,Q;const M=(Q=(V=l[ee])==null?void 0:V.palette)==null?void 0:Q.mode,W=!i&&M?{colorScheme:M,...g}:{...g};a(n(ee,{...W}),W)}),d&&k.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)"}}),k}}}function Oc(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 oo={black:"#000",white:"#fff"},$c={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"},kr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},Tr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Jr={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},Ir={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},zr={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},Br={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Ui(){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:oo.white,default:oo.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 Yi=Ui();function Gi(){return{text:{primary:oo.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:oo.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=Gi();function ei(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=Vo(t.main,s):o==="dark"&&(t.dark=Fo(t.main,d)))}function ti(t,o,n,i,s){const d=s.light||s,l=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 ${(l*100).toFixed(0)}%)`))}function Ac(t="light"){return t==="dark"?{main:Ir[200],light:Ir[50],dark:Ir[400]}:{main:Ir[700],light:Ir[400],dark:Ir[800]}}function _c(t="light"){return t==="dark"?{main:kr[200],light:kr[50],dark:kr[400]}:{main:kr[500],light:kr[300],dark:kr[700]}}function Mc(t="light"){return t==="dark"?{main:Tr[500],light:Tr[300],dark:Tr[700]}:{main:Tr[700],light:Tr[400],dark:Tr[800]}}function Rc(t="light"){return t==="dark"?{main:zr[400],light:zr[300],dark:zr[700]}:{main:zr[700],light:zr[500],dark:zr[900]}}function Wc(t="light"){return t==="dark"?{main:Br[400],light:Br[300],dark:Br[700]}:{main:Br[800],light:Br[500],dark:Br[900]}}function Pc(t="light"){return t==="dark"?{main:Jr[400],light:Jr[300],dark:Jr[700]}:{main:"#ed6c02",light:Jr[500],dark:Jr[900]}}function Nc(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,l=t.primary||Ac(o),c=t.secondary||_c(o),u=t.error||Mc(o),h=t.info||Rc(o),m=t.success||Wc(o),b=t.warning||Pc(o);function x(C){if(s)return Nc(C);const S=Qn(C,nn.text.primary)>=n?nn.text.primary:Yi.text.primary;if(process.env.NODE_ENV!=="production"){const I=Qn(C,S);I<3&&console.error([`MUI: The contrast ratio of ${I}:1 for ${S} on ${C}`,"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
45
  `))}return S}const y=({color:C,name:S,mainShade:I=500,lightShade:f=300,darkShade:k=700})=>{if(C={...C},!C.main&&C[I]&&(C.main=C[I]),!C.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${S?` (${S})`:""} provided to augmentColor(color) is invalid.
46
- The color object needs to have a \`main\` property or a \`${I}\` property.`:lr(11,S?` (${S})`:"",I));if(typeof C.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${S?` (${S})`:""} provided to augmentColor(color) is invalid.
46
+ The color object needs to have a \`main\` property or a \`${I}\` property.`:dr(11,S?` (${S})`:"",I));if(typeof C.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${S?` (${S})`:""} provided to augmentColor(color) is invalid.
47
47
  \`color.main\` should be a string, but \`${JSON.stringify(C.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
- } });`:lr(12,S?` (${S})`:"",JSON.stringify(C.main)));return s?(ei(s,C,"light",f,i),ei(s,C,"dark",k,i)):(Qn(C,"light",f,i),Qn(C,"dark",k,i)),C.contrastText||(C.contrastText=m(C.main)),C};let D;return o==="light"?D=Hi():o==="dark"&&(D=Yi()),process.env.NODE_ENV!=="production"&&(D||console.error(`MUI: The palette mode \`${o}\` is not supported.`)),Ke({common:{...ro},mode:o,primary:y({color:c,name:"primary"}),secondary:y({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:y({color:u,name:"error"}),warning:y({color:b,name:"warning"}),info:y({color:x,name:"info"}),success:y({color:h,name:"success"}),grey:Oc,contrastThreshold:n,getContrastText:m,augmentColor:y,tonalOffset:i,...D},d)}function Nc(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 Lc(t,o){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...o}}function Fc(t){return Math.round(t*1e5)/1e5}const ti={textTransform:"uppercase"},ri='"Roboto", "Helvetica", "Arial", sans-serif';function Vc(t,o){const{fontFamily:n=ri,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:d=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:u=16,allVariants:x,pxToRem:h,...b}=typeof o=="function"?o(t):o;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const m=i/14,y=h||(C=>`${C/u*m}rem`),D=(C,S,I,f,k)=>({fontFamily:n,fontWeight:C,fontSize:y(S),lineHeight:I,...n===ri?{letterSpacing:`${Fc(f/S)}em`}:{},...k,...x}),v={h1:D(s,96,1.167,-1.5),h2:D(s,60,1.2,-.5),h3:D(d,48,1.167,0),h4:D(d,34,1.235,.25),h5:D(d,24,1.334,0),h6:D(c,20,1.6,.15),subtitle1:D(d,16,1.75,.15),subtitle2:D(c,14,1.57,.1),body1:D(d,16,1.5,.15),body2:D(d,14,1.43,.15),button:D(c,14,1.75,.4,ti),caption:D(d,12,1.66,.4),overline:D(d,12,2.66,1,ti),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Ke({htmlFontSize:u,pxToRem:y,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:d,fontWeightMedium:c,fontWeightBold:l,...v},b,{clone:!1})}const Hc=.2,Uc=.14,Yc=.12;function De(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${Hc})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${Uc})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${Yc})`].join(",")}const Gc=["none",De(0,2,1,-1,0,1,1,0,0,1,3,0),De(0,3,1,-2,0,2,2,0,0,1,5,0),De(0,3,3,-2,0,3,4,0,0,1,8,0),De(0,2,4,-1,0,4,5,0,0,1,10,0),De(0,3,5,-1,0,5,8,0,0,1,14,0),De(0,3,5,-1,0,6,10,0,0,1,18,0),De(0,4,5,-2,0,7,10,1,0,2,16,1),De(0,5,5,-3,0,8,10,1,0,3,14,2),De(0,5,6,-3,0,9,12,1,0,3,16,2),De(0,6,6,-3,0,10,14,1,0,4,18,3),De(0,6,7,-4,0,11,15,1,0,4,20,3),De(0,7,8,-4,0,12,17,2,0,5,22,4),De(0,7,8,-4,0,13,19,2,0,5,24,4),De(0,7,9,-4,0,14,21,2,0,5,26,4),De(0,8,9,-5,0,15,22,2,0,6,28,5),De(0,8,10,-5,0,16,24,2,0,6,30,5),De(0,8,11,-5,0,17,26,2,0,6,32,5),De(0,9,11,-5,0,18,28,2,0,7,34,6),De(0,9,12,-6,0,19,29,2,0,7,36,6),De(0,10,13,-6,0,20,31,3,0,8,38,7),De(0,10,13,-6,0,21,33,3,0,8,40,7),De(0,10,14,-6,0,22,35,3,0,8,42,7),De(0,11,14,-7,0,23,36,3,0,9,44,8),De(0,11,15,-7,0,24,38,3,0,9,46,8)],qc={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)"},Jc={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function oi(t){return`${Math.round(t)}ms`}function Kc(t){if(!t)return 0;const o=t/36;return Math.min(Math.round((4+15*o**.25+o/5)*10),3e3)}function Xc(t){const o={...qc,...t.easing},n={...Jc,...t.duration};return{getAutoHeightDuration:Kc,create:(s=["all"],d={})=>{const{duration:c=n.standard,easing:l=o.easeInOut,delay:u=0,...x}=d;if(process.env.NODE_ENV!=="production"){const h=m=>typeof m=="string",b=m=>!Number.isNaN(parseFloat(m));!h(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!b(c)&&!h(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),h(l)||console.error('MUI: Argument "easing" must be a string.'),!b(u)&&!h(u)&&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(x).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(x).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(h=>`${h} ${typeof c=="string"?c:oi(c)} ${l} ${typeof u=="string"?u:oi(u)}`).join(",")},...t,easing:o,duration:n}}const Zc={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Qc(t){return Ht(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function Gi(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]:Ht(l)&&(i[c]={...l},n(i[c]))}}return n(o),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
59
+ } });`:dr(12,S?` (${S})`:"",JSON.stringify(C.main)));return s?(ti(s,C,"light",f,i),ti(s,C,"dark",k,i)):(ei(C,"light",f,i),ei(C,"dark",k,i)),C.contrastText||(C.contrastText=x(C.main)),C};let D;return o==="light"?D=Ui():o==="dark"&&(D=Gi()),process.env.NODE_ENV!=="production"&&(D||console.error(`MUI: The palette mode \`${o}\` is not supported.`)),Ze({common:{...oo},mode:o,primary:y({color:l,name:"primary"}),secondary:y({color:c,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:y({color:u,name:"error"}),warning:y({color:b,name:"warning"}),info:y({color:h,name:"info"}),success:y({color:m,name:"success"}),grey:$c,contrastThreshold:n,getContrastText:x,augmentColor:y,tonalOffset:i,...D},d)}function Lc(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 Fc(t,o){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...o}}function Vc(t){return Math.round(t*1e5)/1e5}const ri={textTransform:"uppercase"},oi='"Roboto", "Helvetica", "Arial", sans-serif';function Hc(t,o){const{fontFamily:n=oi,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:d=400,fontWeightMedium:l=500,fontWeightBold:c=700,htmlFontSize:u=16,allVariants:h,pxToRem:m,...b}=typeof o=="function"?o(t):o;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const x=i/14,y=m||(C=>`${C/u*x}rem`),D=(C,S,I,f,k)=>({fontFamily:n,fontWeight:C,fontSize:y(S),lineHeight:I,...n===oi?{letterSpacing:`${Vc(f/S)}em`}:{},...k,...h}),v={h1:D(s,96,1.167,-1.5),h2:D(s,60,1.2,-.5),h3:D(d,48,1.167,0),h4:D(d,34,1.235,.25),h5:D(d,24,1.334,0),h6:D(l,20,1.6,.15),subtitle1:D(d,16,1.75,.15),subtitle2:D(l,14,1.57,.1),body1:D(d,16,1.5,.15),body2:D(d,14,1.43,.15),button:D(l,14,1.75,.4,ri),caption:D(d,12,1.66,.4),overline:D(d,12,2.66,1,ri),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Ze({htmlFontSize:u,pxToRem:y,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:d,fontWeightMedium:l,fontWeightBold:c,...v},b,{clone:!1})}const Uc=.2,Yc=.14,Gc=.12;function Be(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${Uc})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${Yc})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${Gc})`].join(",")}const qc=["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)],Jc={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)"},Kc={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function ni(t){return`${Math.round(t)}ms`}function Xc(t){if(!t)return 0;const o=t/36;return Math.min(Math.round((4+15*o**.25+o/5)*10),3e3)}function Qc(t){const o={...Jc,...t.easing},n={...Kc,...t.duration};return{getAutoHeightDuration:Xc,create:(s=["all"],d={})=>{const{duration:l=n.standard,easing:c=o.easeInOut,delay:u=0,...h}=d;if(process.env.NODE_ENV!=="production"){const m=x=>typeof x=="string",b=x=>!Number.isNaN(parseFloat(x));!m(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!b(l)&&!m(l)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${l}.`),m(c)||console.error('MUI: Argument "easing" must be a string.'),!b(u)&&!m(u)&&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(h).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(h).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(m=>`${m} ${typeof l=="string"?l:ni(l)} ${c} ${typeof u=="string"?u:ni(u)}`).join(",")},...t,easing:o,duration:n}}const Zc={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function ed(t){return Ut(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function qi(t={}){const o={...t};function n(i){const s=Object.entries(i);for(let d=0;d<s.length;d++){const[l,c]=s[d];!ed(c)||l.startsWith("unstable_")?delete i[l]:Ut(c)&&(i[l]={...c},n(i[l]))}}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 ni(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const ed=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 td(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})`:T(o,ed(n))},lighten(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #fff ${ni(n)})`:Fo(o,n)},darken(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #000 ${ni(n)})`:Lo(o,n)}})}function nn(t={},...o){const{breakpoints:n,mixins:i={},spacing:s,palette:d={},transitions:c={},typography:l={},shape:u,colorSpace:x,...h}=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.":lr(20));const b=mn({...d,colorSpace:x}),m=Fi(t);let y=Ke(m,{mixins:Lc(m.breakpoints,i),palette:b,shadows:Gc.slice(),typography:Vc(b,l),transitions:Xc(c),zIndex:{...Zc}});if(y=Ke(y,h),y=o.reduce((D,v)=>Ke(D,v),y),process.env.NODE_ENV!=="production"){const D=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],v=(C,S)=>{let I;for(I in C){const f=C[I];if(D.includes(I)&&Object.keys(f).length>0){if(process.env.NODE_ENV!=="production"){const k=jc("",I);console.error([`MUI: The \`${S}\` component increases the CSS specificity of the \`${I}\` internal state.`,"You can not override it like this: ",JSON.stringify(C,null,2),"",`Instead, you need to use the '&.${k}' syntax:`,JSON.stringify({root:{[`&.${k}`]:f}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
68
- `))}C[I]={}}}};Object.keys(y.components).forEach(C=>{const S=y.components[C].styleOverrides;S&&C.startsWith("Mui")&&v(S,C)})}return y.unstable_sxConfig={...Wo,...h==null?void 0:h.unstable_sxConfig},y.unstable_sx=function(v){return Po({sx:v,theme:this})},y.toRuntimeSource=Gi,td(y),y}function rd(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 od=[...Array(25)].map((t,o)=>{if(o===0)return"none";const n=rd(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 Ji(t){return t==="dark"?od:[]}function nd(t){const{palette:o={mode:"light"},opacity:n,overlays:i,colorSpace:s,...d}=t,c=mn({...o,colorSpace:s});return{palette:c,opacity:{...qi(c.mode),...n},overlays:i||Ji(c.mode),...d}}function id(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 sd=t=>[...[...Array(25)].map((o,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],ad=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 sd(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 ld(t,o){o.forEach(n=>{t[n]||(t[n]={})})}function N(t,o,n){!t[o]&&n&&(t[o]=n)}function Qr(t){return typeof t!="string"||!t.startsWith("hsl")?t:Vi(t)}function Et(t,o){`${o}Channel`in t||(t[`${o}Channel`]=Zr(Qr(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 cd(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{}},dd=(t="mui")=>Ic(t);function Qo(t,o,n,i,s){if(!n)return;n=n===!0?{}:n;const d=s==="dark"?"dark":"light";if(!i){o[s]=nd({...n,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:c,...l}=nn({...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)||Ji(d)},l}function ud(t={},...o){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:d="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=id,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:x=":root",...h}=t,b=Object.keys(n)[0],m=i||(n.light&&b!=="light"?"light":b),y=dd(d),{[m]:D,light:v,dark:C,...S}=n,I={...S};let f=D;if((m==="dark"&&!("dark"in n)||m==="light"&&!("light"in n))&&(f=!0),!f)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${m}\` option is either missing or invalid.`:lr(21,m));let k;c&&(k="oklch");const j=Qo(k,I,f,h,m);v&&!I.light&&Qo(k,I,v,void 0,"light"),C&&!I.dark&&Qo(k,I,C,void 0,"dark");let a={defaultColorScheme:m,...j,cssVarPrefix:d,colorSchemeSelector:u,rootSelector:x,getCssVar:y,colorSchemes:I,font:{...Nc(j.typography),...j.font},spacing:cd(h.spacing)};Object.keys(a.colorSchemes).forEach(ee=>{const g=a.colorSchemes[ee].palette,M=V=>{const Z=V.split("-"),xe=Z[1],me=Z[2];return y(V,g[xe][me])};g.mode==="light"&&(N(g.common,"background","#fff"),N(g.common,"onBackground","#000")),g.mode==="dark"&&(N(g.common,"background","#000"),N(g.common,"onBackground","#fff"));function W(V,Z,xe){if(k){let me;return V===ir&&(me=`transparent ${((1-xe)*100).toFixed(0)}%`),V===je&&(me=`#000 ${(xe*100).toFixed(0)}%`),V===Ce&&(me=`#fff ${(xe*100).toFixed(0)}%`),`color-mix(in ${k}, ${Z}, ${me})`}return V(Z,xe)}if(ld(g,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),g.mode==="light"){N(g.Alert,"errorColor",W(je,g.error.light,.6)),N(g.Alert,"infoColor",W(je,g.info.light,.6)),N(g.Alert,"successColor",W(je,g.success.light,.6)),N(g.Alert,"warningColor",W(je,g.warning.light,.6)),N(g.Alert,"errorFilledBg",M("palette-error-main")),N(g.Alert,"infoFilledBg",M("palette-info-main")),N(g.Alert,"successFilledBg",M("palette-success-main")),N(g.Alert,"warningFilledBg",M("palette-warning-main")),N(g.Alert,"errorFilledColor",bt(()=>g.getContrastText(g.error.main))),N(g.Alert,"infoFilledColor",bt(()=>g.getContrastText(g.info.main))),N(g.Alert,"successFilledColor",bt(()=>g.getContrastText(g.success.main))),N(g.Alert,"warningFilledColor",bt(()=>g.getContrastText(g.warning.main))),N(g.Alert,"errorStandardBg",W(Ce,g.error.light,.9)),N(g.Alert,"infoStandardBg",W(Ce,g.info.light,.9)),N(g.Alert,"successStandardBg",W(Ce,g.success.light,.9)),N(g.Alert,"warningStandardBg",W(Ce,g.warning.light,.9)),N(g.Alert,"errorIconColor",M("palette-error-main")),N(g.Alert,"infoIconColor",M("palette-info-main")),N(g.Alert,"successIconColor",M("palette-success-main")),N(g.Alert,"warningIconColor",M("palette-warning-main")),N(g.AppBar,"defaultBg",M("palette-grey-100")),N(g.Avatar,"defaultBg",M("palette-grey-400")),N(g.Button,"inheritContainedBg",M("palette-grey-300")),N(g.Button,"inheritContainedHoverBg",M("palette-grey-A100")),N(g.Chip,"defaultBorder",M("palette-grey-400")),N(g.Chip,"defaultAvatarColor",M("palette-grey-700")),N(g.Chip,"defaultIconColor",M("palette-grey-700")),N(g.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),N(g.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),N(g.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),N(g.LinearProgress,"primaryBg",W(Ce,g.primary.main,.62)),N(g.LinearProgress,"secondaryBg",W(Ce,g.secondary.main,.62)),N(g.LinearProgress,"errorBg",W(Ce,g.error.main,.62)),N(g.LinearProgress,"infoBg",W(Ce,g.info.main,.62)),N(g.LinearProgress,"successBg",W(Ce,g.success.main,.62)),N(g.LinearProgress,"warningBg",W(Ce,g.warning.main,.62)),N(g.Skeleton,"bg",k?W(ir,g.text.primary,.11):`rgba(${M("palette-text-primaryChannel")} / 0.11)`),N(g.Slider,"primaryTrack",W(Ce,g.primary.main,.62)),N(g.Slider,"secondaryTrack",W(Ce,g.secondary.main,.62)),N(g.Slider,"errorTrack",W(Ce,g.error.main,.62)),N(g.Slider,"infoTrack",W(Ce,g.info.main,.62)),N(g.Slider,"successTrack",W(Ce,g.success.main,.62)),N(g.Slider,"warningTrack",W(Ce,g.warning.main,.62));const V=k?W(je,g.background.default,.6825):mo(g.background.default,.8);N(g.SnackbarContent,"bg",V),N(g.SnackbarContent,"color",bt(()=>k?on.text.primary:g.getContrastText(V))),N(g.SpeedDialAction,"fabHoverBg",mo(g.background.paper,.15)),N(g.StepConnector,"border",M("palette-grey-400")),N(g.StepContent,"border",M("palette-grey-400")),N(g.Switch,"defaultColor",M("palette-common-white")),N(g.Switch,"defaultDisabledColor",M("palette-grey-100")),N(g.Switch,"primaryDisabledColor",W(Ce,g.primary.main,.62)),N(g.Switch,"secondaryDisabledColor",W(Ce,g.secondary.main,.62)),N(g.Switch,"errorDisabledColor",W(Ce,g.error.main,.62)),N(g.Switch,"infoDisabledColor",W(Ce,g.info.main,.62)),N(g.Switch,"successDisabledColor",W(Ce,g.success.main,.62)),N(g.Switch,"warningDisabledColor",W(Ce,g.warning.main,.62)),N(g.TableCell,"border",W(Ce,W(ir,g.divider,1),.88)),N(g.Tooltip,"bg",W(ir,g.grey[700],.92))}if(g.mode==="dark"){N(g.Alert,"errorColor",W(Ce,g.error.light,.6)),N(g.Alert,"infoColor",W(Ce,g.info.light,.6)),N(g.Alert,"successColor",W(Ce,g.success.light,.6)),N(g.Alert,"warningColor",W(Ce,g.warning.light,.6)),N(g.Alert,"errorFilledBg",M("palette-error-dark")),N(g.Alert,"infoFilledBg",M("palette-info-dark")),N(g.Alert,"successFilledBg",M("palette-success-dark")),N(g.Alert,"warningFilledBg",M("palette-warning-dark")),N(g.Alert,"errorFilledColor",bt(()=>g.getContrastText(g.error.dark))),N(g.Alert,"infoFilledColor",bt(()=>g.getContrastText(g.info.dark))),N(g.Alert,"successFilledColor",bt(()=>g.getContrastText(g.success.dark))),N(g.Alert,"warningFilledColor",bt(()=>g.getContrastText(g.warning.dark))),N(g.Alert,"errorStandardBg",W(je,g.error.light,.9)),N(g.Alert,"infoStandardBg",W(je,g.info.light,.9)),N(g.Alert,"successStandardBg",W(je,g.success.light,.9)),N(g.Alert,"warningStandardBg",W(je,g.warning.light,.9)),N(g.Alert,"errorIconColor",M("palette-error-main")),N(g.Alert,"infoIconColor",M("palette-info-main")),N(g.Alert,"successIconColor",M("palette-success-main")),N(g.Alert,"warningIconColor",M("palette-warning-main")),N(g.AppBar,"defaultBg",M("palette-grey-900")),N(g.AppBar,"darkBg",M("palette-background-paper")),N(g.AppBar,"darkColor",M("palette-text-primary")),N(g.Avatar,"defaultBg",M("palette-grey-600")),N(g.Button,"inheritContainedBg",M("palette-grey-800")),N(g.Button,"inheritContainedHoverBg",M("palette-grey-700")),N(g.Chip,"defaultBorder",M("palette-grey-700")),N(g.Chip,"defaultAvatarColor",M("palette-grey-300")),N(g.Chip,"defaultIconColor",M("palette-grey-300")),N(g.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),N(g.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),N(g.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),N(g.LinearProgress,"primaryBg",W(je,g.primary.main,.5)),N(g.LinearProgress,"secondaryBg",W(je,g.secondary.main,.5)),N(g.LinearProgress,"errorBg",W(je,g.error.main,.5)),N(g.LinearProgress,"infoBg",W(je,g.info.main,.5)),N(g.LinearProgress,"successBg",W(je,g.success.main,.5)),N(g.LinearProgress,"warningBg",W(je,g.warning.main,.5)),N(g.Skeleton,"bg",k?W(ir,g.text.primary,.13):`rgba(${M("palette-text-primaryChannel")} / 0.13)`),N(g.Slider,"primaryTrack",W(je,g.primary.main,.5)),N(g.Slider,"secondaryTrack",W(je,g.secondary.main,.5)),N(g.Slider,"errorTrack",W(je,g.error.main,.5)),N(g.Slider,"infoTrack",W(je,g.info.main,.5)),N(g.Slider,"successTrack",W(je,g.success.main,.5)),N(g.Slider,"warningTrack",W(je,g.warning.main,.5));const V=k?W(Ce,g.background.default,.985):mo(g.background.default,.98);N(g.SnackbarContent,"bg",V),N(g.SnackbarContent,"color",bt(()=>k?Ui.text.primary:g.getContrastText(V))),N(g.SpeedDialAction,"fabHoverBg",mo(g.background.paper,.15)),N(g.StepConnector,"border",M("palette-grey-600")),N(g.StepContent,"border",M("palette-grey-600")),N(g.Switch,"defaultColor",M("palette-grey-300")),N(g.Switch,"defaultDisabledColor",M("palette-grey-600")),N(g.Switch,"primaryDisabledColor",W(je,g.primary.main,.55)),N(g.Switch,"secondaryDisabledColor",W(je,g.secondary.main,.55)),N(g.Switch,"errorDisabledColor",W(je,g.error.main,.55)),N(g.Switch,"infoDisabledColor",W(je,g.info.main,.55)),N(g.Switch,"successDisabledColor",W(je,g.success.main,.55)),N(g.Switch,"warningDisabledColor",W(je,g.warning.main,.55)),N(g.TableCell,"border",W(je,W(ir,g.divider,1),.68)),N(g.Tooltip,"bg",W(ir,g.grey[700],.92))}Et(g.background,"default"),Et(g.background,"paper"),Et(g.common,"background"),Et(g.common,"onBackground"),Et(g,"divider"),Object.keys(g).forEach(V=>{const Z=g[V];V!=="tonalOffset"&&Z&&typeof Z=="object"&&(Z.main&&N(g[V],"mainChannel",Zr(Qr(Z.main))),Z.light&&N(g[V],"lightChannel",Zr(Qr(Z.light))),Z.dark&&N(g[V],"darkChannel",Zr(Qr(Z.dark))),Z.contrastText&&N(g[V],"contrastTextChannel",Zr(Qr(Z.contrastText))),V==="text"&&(Et(g[V],"primary"),Et(g[V],"secondary")),V==="action"&&(Z.active&&Et(g[V],"active"),Z.selected&&Et(g[V],"selected")))})}),a=o.reduce((ee,g)=>Ke(ee,g),a);const B={prefix:d,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:ad(a),enableContrastVars:c},{vars:R,generateThemeVars:q,generateStyleSheets:K}=Dc(a,B);return a.vars=R,Object.entries(a.colorSchemes[a.defaultColorScheme]).forEach(([ee,g])=>{a[ee]=g}),a.generateThemeVars=q,a.generateStyleSheets=K,a.generateSpacing=function(){return Li(h.spacing,un(this))},a.getColorSchemeSelector=Ec(u),a.spacing=a.generateSpacing(),a.shouldSkipGeneratingVar=l,a.unstable_sxConfig={...Wo,...h==null?void 0:h.unstable_sxConfig},a.unstable_sx=function(g){return Po({sx:g,theme:this})},a.toRuntimeSource=Gi,a}function ii(t,o,n){t.colorSchemes&&n&&(t.colorSchemes[o]={...n!==!0&&n,palette:mn({...n===!0?{}:n.palette,mode:o})})}function pd(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],x={...s,...n?{[l]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return nn(t,...o);let h=n;"palette"in t||x[l]&&(x[l]!==!0?h=x[l].palette:l==="dark"&&(h={mode:"dark"}));const b=nn({...t,palette:h},...o);return b.defaultColorScheme=l,b.colorSchemes=x,b.palette.mode==="light"&&(b.colorSchemes.light={...x.light!==!0&&x.light,palette:b.palette},ii(b,"dark",x.dark)),b.palette.mode==="dark"&&(b.colorSchemes.dark={...x.dark!==!0&&x.dark,palette:b.palette},ii(b,"light",x.light)),b}return!n&&!("light"in x)&&l==="light"&&(x.light=!0),ud({...c,colorSchemes:x,defaultColorScheme:l,...typeof i!="boolean"&&i},...o)}const xd=pd();function _t(){const t=yc(xd);return process.env.NODE_ENV!=="production"&&To.useDebugValue(t),t[al]||t}async function md(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(x){throw clearTimeout(d),(x==null?void 0:x.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 h=["data","results","items","records"].find(b=>l[b]&&Array.isArray(l[b]));if(h)u=l[h];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 hd(t,o){return o.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${T(t.palette.common.black,n.opacity)}`).join(", ")}const fd={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 hd(t,fd[o])}function Me(t){return`${Number(t.shape.borderRadius)*1.5}px`}function io(t){return`${Number(t.shape.borderRadius)}px`}function gd({isOpen:t,onClose:o,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[d,c]=p.useState(""),[l,u]=p.useState(!1),[x,h]=p.useState(""),[b,m]=p.useState(null),[y,D]=p.useState(null),[v,C]=p.useState(!1),[S,I]=p.useState(""),f=p.useRef(null),[k,j]=p.useState("json"),[a,B]=p.useState(""),[R,q]=p.useState(""),[K,ee]=p.useState(""),[g,M]=p.useState("idle"),[W,V]=p.useState(""),[Z,xe]=p.useState(null),[me,F]=p.useState(0),A=async P=>{if(I(""),!P.name.endsWith(".json")){I("Only .json files are allowed");return}const ie=10*1024*1024;if(P.size>ie){I("File size exceeds 10MB limit");return}try{const de=await P.text();let le;try{le=JSON.parse(de)}catch{I("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(le)){I("JSON must be an array of objects");return}if(le.length===0){I("No data rows found in JSON file");return}m(P),D(le)}catch{I("Network error — please try again")}},H=P=>{P.preventDefault();const ie=P.dataTransfer.files[0];ie&&A(ie)},se=async()=>{if(a.trim()){M("loading"),V("");try{const P=await md(a.trim(),R.trim()||void 0,K.trim()||void 0);xe(P.data),F(P.data.length),M("ready")}catch(P){V((P==null?void 0:P.message)||"Connection failed"),M("error")}}},G=()=>{if(!d.trim()){u(!0);return}const P=k==="api"?Z:i||y;P&&(n(d.trim(),x.trim(),P),re())},re=()=>{c(""),u(!1),h(""),m(null),D(null),I(""),j("json"),B(""),q(""),ee(""),M("idle"),V(""),xe(null),F(0),o()},ae=i||y,ne=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(z.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: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:x,onChange:P=>h(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:k==="json"?0:1,onChange:(P,ie)=>{j(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(z.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(z.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),k==="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=>T(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=>T(P.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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:()=>C(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(z.Info,{sx:{fontSize:16}})})]}),e.jsxs(r.Box,{onDrop:H,onDragOver:P=>P.preventDefault(),onPaste:P=>P.preventDefault(),onClick:()=>{var P;return(P=f.current)==null?void 0:P.click()},sx:{position:"relative",border:"1.5px",borderStyle:y?"solid":"dashed",borderColor:y?"success.main":S?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:y?P=>T(P.palette.success.main,.04):S?P=>T(P.palette.error.main,.04):P=>T(P.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:y?P=>T(P.palette.success.main,.08):S?P=>T(P.palette.error.main,.08):P=>T(P.palette.primary.main,.08),borderColor:y?"success.dark":S?"error.dark":"primary.dark"}},children:[e.jsx(r.Box,{component:"input",ref:f,type:"file",accept:".json",sx:{display:"none"},onChange:P=>{var ie;return((ie=P.target.files)==null?void 0:ie[0])&&A(P.target.files[0])}}),y?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=>T(P.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(z.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:b==null?void 0:b.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=>T(P.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(z.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"}),S&&e.jsx(r.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:P=>T(P.palette.error.main,.08),border:1,borderColor:P=>T(P.palette.error.main,.2)},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:S})})]})]})]})}),k==="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=>{B(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(z.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()||g==="loading",onClick:se,startIcon:g==="loading"?e.jsx(r.CircularProgress,{size:16,color:"inherit"}):e.jsx(z.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:P=>T(P.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:g==="loading"?"Connecting...":"Test Connection & Load Data"}),g==="ready"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:P=>T(P.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(z.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:[me.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})]})]}),g==="error"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:P=>T(P.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(z.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=>T(P.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(r.Button,{onClick:G,disabled:k==="json"&&!ae||k==="api"&&g!=="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:v,onClose:()=>C(!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:()=>C(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(z.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 ii(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const td=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 rd(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})`:T(o,td(n))},lighten(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #fff ${ii(n)})`:Vo(o,n)},darken(o,n){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${o}, #000 ${ii(n)})`:Fo(o,n)}})}function sn(t={},...o){const{breakpoints:n,mixins:i={},spacing:s,palette:d={},transitions:l={},typography:c={},shape:u,colorSpace:h,...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.":dr(20));const b=hn({...d,colorSpace:h}),x=Vi(t);let y=Ze(x,{mixins:Fc(x.breakpoints,i),palette:b,shadows:qc.slice(),typography:Hc(b,c),transitions:Qc(l),zIndex:{...Zc}});if(y=Ze(y,m),y=o.reduce((D,v)=>Ze(D,v),y),process.env.NODE_ENV!=="production"){const D=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],v=(C,S)=>{let I;for(I in C){const f=C[I];if(D.includes(I)&&Object.keys(f).length>0){if(process.env.NODE_ENV!=="production"){const k=Cc("",I);console.error([`MUI: The \`${S}\` component increases the CSS specificity of the \`${I}\` internal state.`,"You can not override it like this: ",JSON.stringify(C,null,2),"",`Instead, you need to use the '&.${k}' syntax:`,JSON.stringify({root:{[`&.${k}`]:f}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
68
+ `))}C[I]={}}}};Object.keys(y.components).forEach(C=>{const S=y.components[C].styleOverrides;S&&C.startsWith("Mui")&&v(S,C)})}return y.unstable_sxConfig={...Po,...m==null?void 0:m.unstable_sxConfig},y.unstable_sx=function(v){return No({sx:v,theme:this})},y.toRuntimeSource=qi,rd(y),y}function od(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 nd=[...Array(25)].map((t,o)=>{if(o===0)return"none";const n=od(o);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Ji(t){return{inputPlaceholder:t==="dark"?.5:.42,inputUnderline:t==="dark"?.7:.42,switchTrackDisabled:t==="dark"?.2:.12,switchTrack:t==="dark"?.3:.38}}function Ki(t){return t==="dark"?nd:[]}function id(t){const{palette:o={mode:"light"},opacity:n,overlays:i,colorSpace:s,...d}=t,l=hn({...o,colorSpace:s});return{palette:l,opacity:{...Ji(l.mode),...n},overlays:i||Ki(l.mode),...d}}function sd(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 ad=t=>[...[...Array(25)].map((o,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],ld=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 l={};return ad(t.cssVarPrefix).forEach(c=>{l[c]=n[c],delete n[c]}),d==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:l}}:d?{[d.replace("%s",o)]:l,[`${i}, ${d.replace("%s",o)}`]:n}:{[i]:{...n,...l}}}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 cd(t,o){o.forEach(n=>{t[n]||(t[n]={})})}function N(t,o,n){!t[o]&&n&&(t[o]=n)}function eo(t){return typeof t!="string"||!t.startsWith("hsl")?t:Hi(t)}function Dt(t,o){`${o}Channel`in t||(t[`${o}Channel`]=Zr(eo(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 dd(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const jt=t=>{try{return t()}catch{}},ud=(t="mui")=>zc(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]=id({...n,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return}const{palette:l,...c}=sn({...i,palette:{mode:d,...n==null?void 0:n.palette},colorSpace:t});return o[s]={...n,palette:l,opacity:{...Ji(d),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||Ki(d)},c}function pd(t={},...o){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:d="mui",nativeColor:l=!1,shouldSkipGeneratingVar:c=sd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:h=":root",...m}=t,b=Object.keys(n)[0],x=i||(n.light&&b!=="light"?"light":b),y=ud(d),{[x]:D,light:v,dark:C,...S}=n,I={...S};let f=D;if((x==="dark"&&!("dark"in n)||x==="light"&&!("light"in n))&&(f=!0),!f)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${x}\` option is either missing or invalid.`:dr(21,x));let k;l&&(k="oklch");const j=en(k,I,f,m,x);v&&!I.light&&en(k,I,v,void 0,"light"),C&&!I.dark&&en(k,I,C,void 0,"dark");let a={defaultColorScheme:x,...j,cssVarPrefix:d,colorSchemeSelector:u,rootSelector:h,getCssVar:y,colorSchemes:I,font:{...Lc(j.typography),...j.font},spacing:dd(m.spacing)};Object.keys(a.colorSchemes).forEach(ee=>{const g=a.colorSchemes[ee].palette,M=V=>{const Q=V.split("-"),xe=Q[1],me=Q[2];return y(V,g[xe][me])};g.mode==="light"&&(N(g.common,"background","#fff"),N(g.common,"onBackground","#000")),g.mode==="dark"&&(N(g.common,"background","#000"),N(g.common,"onBackground","#fff"));function W(V,Q,xe){if(k){let me;return V===ar&&(me=`transparent ${((1-xe)*100).toFixed(0)}%`),V===Se&&(me=`#000 ${(xe*100).toFixed(0)}%`),V===je&&(me=`#fff ${(xe*100).toFixed(0)}%`),`color-mix(in ${k}, ${Q}, ${me})`}return V(Q,xe)}if(cd(g,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),g.mode==="light"){N(g.Alert,"errorColor",W(Se,g.error.light,.6)),N(g.Alert,"infoColor",W(Se,g.info.light,.6)),N(g.Alert,"successColor",W(Se,g.success.light,.6)),N(g.Alert,"warningColor",W(Se,g.warning.light,.6)),N(g.Alert,"errorFilledBg",M("palette-error-main")),N(g.Alert,"infoFilledBg",M("palette-info-main")),N(g.Alert,"successFilledBg",M("palette-success-main")),N(g.Alert,"warningFilledBg",M("palette-warning-main")),N(g.Alert,"errorFilledColor",jt(()=>g.getContrastText(g.error.main))),N(g.Alert,"infoFilledColor",jt(()=>g.getContrastText(g.info.main))),N(g.Alert,"successFilledColor",jt(()=>g.getContrastText(g.success.main))),N(g.Alert,"warningFilledColor",jt(()=>g.getContrastText(g.warning.main))),N(g.Alert,"errorStandardBg",W(je,g.error.light,.9)),N(g.Alert,"infoStandardBg",W(je,g.info.light,.9)),N(g.Alert,"successStandardBg",W(je,g.success.light,.9)),N(g.Alert,"warningStandardBg",W(je,g.warning.light,.9)),N(g.Alert,"errorIconColor",M("palette-error-main")),N(g.Alert,"infoIconColor",M("palette-info-main")),N(g.Alert,"successIconColor",M("palette-success-main")),N(g.Alert,"warningIconColor",M("palette-warning-main")),N(g.AppBar,"defaultBg",M("palette-grey-100")),N(g.Avatar,"defaultBg",M("palette-grey-400")),N(g.Button,"inheritContainedBg",M("palette-grey-300")),N(g.Button,"inheritContainedHoverBg",M("palette-grey-A100")),N(g.Chip,"defaultBorder",M("palette-grey-400")),N(g.Chip,"defaultAvatarColor",M("palette-grey-700")),N(g.Chip,"defaultIconColor",M("palette-grey-700")),N(g.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),N(g.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),N(g.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),N(g.LinearProgress,"primaryBg",W(je,g.primary.main,.62)),N(g.LinearProgress,"secondaryBg",W(je,g.secondary.main,.62)),N(g.LinearProgress,"errorBg",W(je,g.error.main,.62)),N(g.LinearProgress,"infoBg",W(je,g.info.main,.62)),N(g.LinearProgress,"successBg",W(je,g.success.main,.62)),N(g.LinearProgress,"warningBg",W(je,g.warning.main,.62)),N(g.Skeleton,"bg",k?W(ar,g.text.primary,.11):`rgba(${M("palette-text-primaryChannel")} / 0.11)`),N(g.Slider,"primaryTrack",W(je,g.primary.main,.62)),N(g.Slider,"secondaryTrack",W(je,g.secondary.main,.62)),N(g.Slider,"errorTrack",W(je,g.error.main,.62)),N(g.Slider,"infoTrack",W(je,g.info.main,.62)),N(g.Slider,"successTrack",W(je,g.success.main,.62)),N(g.Slider,"warningTrack",W(je,g.warning.main,.62));const V=k?W(Se,g.background.default,.6825):ho(g.background.default,.8);N(g.SnackbarContent,"bg",V),N(g.SnackbarContent,"color",jt(()=>k?nn.text.primary:g.getContrastText(V))),N(g.SpeedDialAction,"fabHoverBg",ho(g.background.paper,.15)),N(g.StepConnector,"border",M("palette-grey-400")),N(g.StepContent,"border",M("palette-grey-400")),N(g.Switch,"defaultColor",M("palette-common-white")),N(g.Switch,"defaultDisabledColor",M("palette-grey-100")),N(g.Switch,"primaryDisabledColor",W(je,g.primary.main,.62)),N(g.Switch,"secondaryDisabledColor",W(je,g.secondary.main,.62)),N(g.Switch,"errorDisabledColor",W(je,g.error.main,.62)),N(g.Switch,"infoDisabledColor",W(je,g.info.main,.62)),N(g.Switch,"successDisabledColor",W(je,g.success.main,.62)),N(g.Switch,"warningDisabledColor",W(je,g.warning.main,.62)),N(g.TableCell,"border",W(je,W(ar,g.divider,1),.88)),N(g.Tooltip,"bg",W(ar,g.grey[700],.92))}if(g.mode==="dark"){N(g.Alert,"errorColor",W(je,g.error.light,.6)),N(g.Alert,"infoColor",W(je,g.info.light,.6)),N(g.Alert,"successColor",W(je,g.success.light,.6)),N(g.Alert,"warningColor",W(je,g.warning.light,.6)),N(g.Alert,"errorFilledBg",M("palette-error-dark")),N(g.Alert,"infoFilledBg",M("palette-info-dark")),N(g.Alert,"successFilledBg",M("palette-success-dark")),N(g.Alert,"warningFilledBg",M("palette-warning-dark")),N(g.Alert,"errorFilledColor",jt(()=>g.getContrastText(g.error.dark))),N(g.Alert,"infoFilledColor",jt(()=>g.getContrastText(g.info.dark))),N(g.Alert,"successFilledColor",jt(()=>g.getContrastText(g.success.dark))),N(g.Alert,"warningFilledColor",jt(()=>g.getContrastText(g.warning.dark))),N(g.Alert,"errorStandardBg",W(Se,g.error.light,.9)),N(g.Alert,"infoStandardBg",W(Se,g.info.light,.9)),N(g.Alert,"successStandardBg",W(Se,g.success.light,.9)),N(g.Alert,"warningStandardBg",W(Se,g.warning.light,.9)),N(g.Alert,"errorIconColor",M("palette-error-main")),N(g.Alert,"infoIconColor",M("palette-info-main")),N(g.Alert,"successIconColor",M("palette-success-main")),N(g.Alert,"warningIconColor",M("palette-warning-main")),N(g.AppBar,"defaultBg",M("palette-grey-900")),N(g.AppBar,"darkBg",M("palette-background-paper")),N(g.AppBar,"darkColor",M("palette-text-primary")),N(g.Avatar,"defaultBg",M("palette-grey-600")),N(g.Button,"inheritContainedBg",M("palette-grey-800")),N(g.Button,"inheritContainedHoverBg",M("palette-grey-700")),N(g.Chip,"defaultBorder",M("palette-grey-700")),N(g.Chip,"defaultAvatarColor",M("palette-grey-300")),N(g.Chip,"defaultIconColor",M("palette-grey-300")),N(g.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),N(g.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),N(g.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),N(g.LinearProgress,"primaryBg",W(Se,g.primary.main,.5)),N(g.LinearProgress,"secondaryBg",W(Se,g.secondary.main,.5)),N(g.LinearProgress,"errorBg",W(Se,g.error.main,.5)),N(g.LinearProgress,"infoBg",W(Se,g.info.main,.5)),N(g.LinearProgress,"successBg",W(Se,g.success.main,.5)),N(g.LinearProgress,"warningBg",W(Se,g.warning.main,.5)),N(g.Skeleton,"bg",k?W(ar,g.text.primary,.13):`rgba(${M("palette-text-primaryChannel")} / 0.13)`),N(g.Slider,"primaryTrack",W(Se,g.primary.main,.5)),N(g.Slider,"secondaryTrack",W(Se,g.secondary.main,.5)),N(g.Slider,"errorTrack",W(Se,g.error.main,.5)),N(g.Slider,"infoTrack",W(Se,g.info.main,.5)),N(g.Slider,"successTrack",W(Se,g.success.main,.5)),N(g.Slider,"warningTrack",W(Se,g.warning.main,.5));const V=k?W(je,g.background.default,.985):ho(g.background.default,.98);N(g.SnackbarContent,"bg",V),N(g.SnackbarContent,"color",jt(()=>k?Yi.text.primary:g.getContrastText(V))),N(g.SpeedDialAction,"fabHoverBg",ho(g.background.paper,.15)),N(g.StepConnector,"border",M("palette-grey-600")),N(g.StepContent,"border",M("palette-grey-600")),N(g.Switch,"defaultColor",M("palette-grey-300")),N(g.Switch,"defaultDisabledColor",M("palette-grey-600")),N(g.Switch,"primaryDisabledColor",W(Se,g.primary.main,.55)),N(g.Switch,"secondaryDisabledColor",W(Se,g.secondary.main,.55)),N(g.Switch,"errorDisabledColor",W(Se,g.error.main,.55)),N(g.Switch,"infoDisabledColor",W(Se,g.info.main,.55)),N(g.Switch,"successDisabledColor",W(Se,g.success.main,.55)),N(g.Switch,"warningDisabledColor",W(Se,g.warning.main,.55)),N(g.TableCell,"border",W(Se,W(ar,g.divider,1),.68)),N(g.Tooltip,"bg",W(ar,g.grey[700],.92))}Dt(g.background,"default"),Dt(g.background,"paper"),Dt(g.common,"background"),Dt(g.common,"onBackground"),Dt(g,"divider"),Object.keys(g).forEach(V=>{const Q=g[V];V!=="tonalOffset"&&Q&&typeof Q=="object"&&(Q.main&&N(g[V],"mainChannel",Zr(eo(Q.main))),Q.light&&N(g[V],"lightChannel",Zr(eo(Q.light))),Q.dark&&N(g[V],"darkChannel",Zr(eo(Q.dark))),Q.contrastText&&N(g[V],"contrastTextChannel",Zr(eo(Q.contrastText))),V==="text"&&(Dt(g[V],"primary"),Dt(g[V],"secondary")),V==="action"&&(Q.active&&Dt(g[V],"active"),Q.selected&&Dt(g[V],"selected")))})}),a=o.reduce((ee,g)=>Ze(ee,g),a);const B={prefix:d,disableCssColorScheme:s,shouldSkipGeneratingVar:c,getSelector:ld(a),enableContrastVars:l},{vars:R,generateThemeVars:J,generateStyleSheets:K}=Ec(a,B);return a.vars=R,Object.entries(a.colorSchemes[a.defaultColorScheme]).forEach(([ee,g])=>{a[ee]=g}),a.generateThemeVars=J,a.generateStyleSheets=K,a.generateSpacing=function(){return Fi(m.spacing,pn(this))},a.getColorSchemeSelector=Oc(u),a.spacing=a.generateSpacing(),a.shouldSkipGeneratingVar=c,a.unstable_sxConfig={...Po,...m==null?void 0:m.unstable_sxConfig},a.unstable_sx=function(g){return No({sx:g,theme:this})},a.toRuntimeSource=qi,a}function si(t,o,n){t.colorSchemes&&n&&(t.colorSchemes[o]={...n!==!0&&n,palette:hn({...n===!0?{}:n.palette,mode:o})})}function xd(t={},...o){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:d=n==null?void 0:n.mode,...l}=t,c=d||"light",u=s==null?void 0:s[c],h={...s,...n?{[c]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return sn(t,...o);let m=n;"palette"in t||h[c]&&(h[c]!==!0?m=h[c].palette:c==="dark"&&(m={mode:"dark"}));const b=sn({...t,palette:m},...o);return b.defaultColorScheme=c,b.colorSchemes=h,b.palette.mode==="light"&&(b.colorSchemes.light={...h.light!==!0&&h.light,palette:b.palette},si(b,"dark",h.dark)),b.palette.mode==="dark"&&(b.colorSchemes.dark={...h.dark!==!0&&h.dark,palette:b.palette},si(b,"light",h.light)),b}return!n&&!("light"in h)&&c==="light"&&(h.light=!0),pd({...l,colorSchemes:h,defaultColorScheme:c,...typeof i!="boolean"&&i},...o)}const md=xd();function At(){const t=bc(md);return process.env.NODE_ENV!=="production"&&Io.useDebugValue(t),t[ll]||t}async function hd(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 l;try{l=await fetch(t,{headers:i,signal:s.signal})}catch(h){throw clearTimeout(d),(h==null?void 0:h.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(l.status===401)throw new Error("Authentication failed (401) — check your API key");if(!l.ok)throw new Error(`API error ${l.status}: ${l.statusText}`);let c;try{c=await l.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(c))u=c;else if(n&&c[n]&&Array.isArray(c[n]))u=c[n];else{const m=["data","results","items","records"].find(b=>c[b]&&Array.isArray(c[b]));if(m)u=c[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 fd(t,o){return o.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${T(t.palette.common.black,n.opacity)}`).join(", ")}const gd={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 fd(t,gd[o])}function Me(t){return`${Number(t.shape.borderRadius)*1.5}px`}function so(t){return`${Number(t.shape.borderRadius)}px`}function yd({isOpen:t,onClose:o,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[d,l]=p.useState(""),[c,u]=p.useState(!1),[h,m]=p.useState(""),[b,x]=p.useState(null),[y,D]=p.useState(null),[v,C]=p.useState(!1),[S,I]=p.useState(""),f=p.useRef(null),[k,j]=p.useState("json"),[a,B]=p.useState(""),[R,J]=p.useState(""),[K,ee]=p.useState(""),[g,M]=p.useState("idle"),[W,V]=p.useState(""),[Q,xe]=p.useState(null),[me,L]=p.useState(0),A=async P=>{if(I(""),!P.name.endsWith(".json")){I("Only .json files are allowed");return}const ie=10*1024*1024;if(P.size>ie){I("File size exceeds 10MB limit");return}try{const pe=await P.text();let le;try{le=JSON.parse(pe)}catch{I("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(le)){I("JSON must be an array of objects");return}if(le.length===0){I("No data rows found in JSON file");return}x(P),D(le)}catch{I("Network error — please try again")}},H=P=>{P.preventDefault();const ie=P.dataTransfer.files[0];ie&&A(ie)},se=async()=>{if(a.trim()){M("loading"),V("");try{const P=await hd(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")}}},G=()=>{if(!d.trim()){u(!0);return}const P=k==="api"?Q:i||y;P&&(n(d.trim(),h.trim(),P),re())},re=()=>{l(""),u(!1),m(""),x(null),D(null),I(""),j("json"),B(""),J(""),ee(""),M("idle"),V(""),xe(null),L(0),o()},ae=i||y,ne=c&&!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(z.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=>{l(P.target.value),c&&P.target.value.trim()&&u(!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:h,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:k==="json"?0:1,onChange:(P,ie)=>{j(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(z.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(z.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),k==="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=>T(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=>T(P.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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:()=>C(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(z.Info,{sx:{fontSize:16}})})]}),e.jsxs(r.Box,{onDrop:H,onDragOver:P=>P.preventDefault(),onPaste:P=>P.preventDefault(),onClick:()=>{var P;return(P=f.current)==null?void 0:P.click()},sx:{position:"relative",border:"1.5px",borderStyle:y?"solid":"dashed",borderColor:y?"success.main":S?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:y?P=>T(P.palette.success.main,.04):S?P=>T(P.palette.error.main,.04):P=>T(P.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:y?P=>T(P.palette.success.main,.08):S?P=>T(P.palette.error.main,.08):P=>T(P.palette.primary.main,.08),borderColor:y?"success.dark":S?"error.dark":"primary.dark"}},children:[e.jsx(r.Box,{component:"input",ref:f,type:"file",accept:".json",sx:{display:"none"},onChange:P=>{var ie;return((ie=P.target.files)==null?void 0:ie[0])&&A(P.target.files[0])}}),y?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=>T(P.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:e.jsx(z.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:b==null?void 0:b.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=>T(P.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:e.jsx(z.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"}),S&&e.jsx(r.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:P=>T(P.palette.error.main,.08),border:1,borderColor:P=>T(P.palette.error.main,.2)},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:S})})]})]})]})}),k==="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=>{B(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=>J(P.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:e.jsx(r.InputAdornment,{position:"start",children:e.jsx(z.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()||g==="loading",onClick:se,startIcon:g==="loading"?e.jsx(r.CircularProgress,{size:16,color:"inherit"}):e.jsx(z.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:P=>T(P.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:g==="loading"?"Connecting...":"Test Connection & Load Data"}),g==="ready"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:P=>T(P.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(z.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:[me.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})]})]}),g==="error"&&e.jsxs(r.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:P=>T(P.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(z.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=>T(P.palette.primary.main,.04)}},children:"Cancel"}),e.jsx(r.Button,{onClick:G,disabled:k==="json"&&!ae||k==="api"&&g!=="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:v,onClose:()=>C(!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:()=>C(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:e.jsx(z.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:()=>C(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Ki({isOpen:t,onClose:o}){return t?e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:n=>Me(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:n=>te(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(z.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:`[
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:()=>C(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Xi({isOpen:t,onClose:o}){return t?e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:n=>Me(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:n=>te(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(z.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 yd({onFileUpload:t,onError:o,isUploading:n}){const[i,s]=p.useState(!1),[d,c]=p.useState(""),[l,u]=p.useState(!1),x=p.useRef(null),h=async S=>{if(!S.name.endsWith(".json")){o("Only .json files are allowed");return}const I=10*1024*1024;if(S.size>I){o("File size exceeds 10MB limit");return}c(S.name);try{const f=await S.text();let k;try{k=JSON.parse(f)}catch{o("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(k)){o("JSON must be an array of objects");return}if(k.length===0){o("No data rows found in JSON file");return}t(k)}catch{o("Network error — please try again")}finally{c("")}},b=S=>{S.preventDefault(),s(!0)},m=S=>{S.preventDefault(),s(!1)},y=S=>{S.preventDefault(),s(!1);const I=S.dataTransfer.files[0];I&&h(I)},D=()=>{var S;(S=x.current)==null||S.click()},v=S=>{var f;const I=(f=S.target.files)==null?void 0:f[0];I&&h(I)},C=S=>{S.stopPropagation(),u(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{onDragOver:b,onDragLeave:m,onDrop:y,onPaste:S=>S.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?S=>T(S.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[e.jsx(r.Box,{component:"input",ref:x,type:"file",accept:".json",onChange:v,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:S=>T(S.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.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:C,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(z.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(Ki,{isOpen:l,onClose:()=>u(!1)})]})}function bd({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=>T(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(z.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 vd({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=>T(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=>T(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.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(z.Upload,{sx:{fontSize:16}}),onClick:o,sx:{fontWeight:500},children:"Try Again"})]})}function Xi({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=>T(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(z.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 Sd({value:t,onChange:o,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:d,disabled:c}){const[l,u]=p.useState(!1),[x,h]=p.useState(!1),[b,m]=p.useState(-1),y=p.useRef(null),D=p.useRef(null);p.useEffect(()=>{function R(q){y.current&&!y.current.contains(q.target)&&(u(!1),h(!1))}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[]);const v=p.useCallback(()=>{h(!0),m(-1),n.length>0&&u(!0)},[n.length]),C=p.useCallback(R=>{o(R),m(-1)},[o]),S=p.useCallback(R=>{var q;o(R),i(R),u(!1),(q=D.current)==null||q.blur()},[o,i]),I=p.useCallback(R=>{m(-1),S(R)},[S]),f=p.useCallback(R=>{var q;R.key==="Enter"?b>=0&&b<n.length?(R.preventDefault(),I(n[b].query)):t.trim()&&S(t.trim()):R.key==="Escape"?(u(!1),m(-1),(q=D.current)==null||q.blur()):R.key==="ArrowDown"?(R.preventDefault(),n.length>0&&(l||u(!0),m(K=>K<n.length-1?K+1:K))):R.key==="ArrowUp"&&(R.preventDefault(),m(K=>K>0?K-1:-1))},[b,n,t,l,I,S]),k=p.useCallback(()=>{var R;o(""),(R=D.current)==null||R.focus()},[o]),j=p.useMemo(()=>n.filter(R=>R.isFavourite),[n]),a=p.useMemo(()=>n.filter(R=>!R.isFavourite),[n]),B=l&&n.length>0;return e.jsxs(r.Box,{sx:{position:"relative",width:240},ref:y,children:[e.jsx(r.TextField,{inputRef:D,size:"small",fullWidth:!0,value:t,onChange:R=>C(R.target.value),onFocus:v,onKeyDown:f,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:R=>T(R.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:R=>T(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(z.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:t?e.jsx(r.InputAdornment,{position:"end",children:e.jsx(r.IconButton,{size:"small",onClick:k,edge:"end",sx:{mr:-.5},children:e.jsx(z.Close,{sx:{fontSize:16}})})}):null}}),B&&e.jsxs(r.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[j.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"}),j.map((R,q)=>e.jsx(si,{entry:R,isSelected:b===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:[j.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=j.length+q;return e.jsx(si,{entry:R,isSelected:b===K,onClick:()=>I(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`recent-${R.query}`)})]})]})]})}const si=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=>T(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>T(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(z.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(z.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(z.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function jd({views:t,activeViewId:o,isDirty:n,onSelectView:i,onCreateView:s,onManageViews:d,onToggleDefault:c,onToggleFavorite:l,onRestoreView:u,onPermanentDelete:x,isReadOnly:h,isAdmin:b=!1}){const m=_t(),[y,D]=p.useState(!1),[v,C]=p.useState(!1),[S,I]=p.useState({top:0,left:0}),[f,k]=p.useState(null),j=p.useRef(null),a=p.useRef(null),B=t.find(A=>A.id===o),R=B==null?void 0:B.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)),g=t.filter(A=>A.isDeleted);p.useEffect(()=>{if(y&&a.current){const A=a.current.getBoundingClientRect();I({top:A.bottom+window.scrollY+8,left:A.right+window.scrollX-320})}},[y]),p.useEffect(()=>{const A=H=>{j.current&&!j.current.contains(H.target)&&a.current&&!a.current.contains(H.target)&&D(!1)};return y&&document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[y]);const M=A=>{if(n&&A!==o){k(A),D(!1);return}i(A),D(!1)},W=()=>{f&&(i(f),k(null))},V=()=>{k(null)},Z=(A,H=!1)=>{const se=A.scope==="global",G=!h&&(!se||b);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:o===A.id?T(m.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:o===A.id?T(m.palette.primary.main,.12):m.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(z.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?m.palette.primary.dark:m.palette.text.primary,fontWeight:o===A.id?500:400},children:A.name}),H&&e.jsx(r.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:m.palette.text.secondary,backgroundColor:m.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:[G&&l&&e.jsx(r.IconButton,{onClick:re=>{re.stopPropagation(),l(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:A.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(z.Star,{sx:{fontSize:16}})}),G&&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:m.palette.action.hover}},title:"Set as default",children:e.jsx(z.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:m.palette.action.hover},children:[e.jsx(r.Typography,{sx:{color:m.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:m.palette.action.hover}},title:"Restore view",children:e.jsx(z.Undo,{sx:{fontSize:16,color:"success.main"}})}),x&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),x(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Delete permanently",children:e.jsx(z.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},A.id),me=n||!R,F=n;return e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsxs(r.IconButton,{ref:a,onClick:()=>D(!y),size:"small",sx:{position:"relative",color:me?"warning.main":"text.secondary",bgcolor:me?T(m.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:me?T(m.palette.warning.main,.2):T(m.palette.text.primary,.06),color:me?"warning.dark":"text.primary"}},title:`View: ${(B==null?void 0:B.name)||"Default View"}`,children:[e.jsx(z.Visibility,{sx:{fontSize:20}}),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"}})]}),y&&yi.createPortal(e.jsxs(r.Box,{ref:j,sx:{position:"fixed",width:"320px",backgroundColor:m.palette.background.paper,border:`1px solid ${m.palette.divider}`,borderRadius:1,boxShadow:m.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:S.top,left:S.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:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),q.map(A=>Z(A,A.isDefault))]}),ee.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${m.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:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[e.jsx(z.Star,{sx:{fontSize:12,color:"warning.light"}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),ee.map(A=>Z(A))]})]}),K.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${m.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:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),K.map(A=>Z(A))]})]}),g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),e.jsxs(r.Box,{sx:{py:.5},children:[e.jsxs(r.Button,{onClick:()=>C(!v),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},children:[e.jsxs(r.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",g.length,")"]}),e.jsx(z.ChevronRight,{sx:{fontSize:16}})]}),v&&e.jsx(r.Box,{sx:{backgroundColor:m.palette.action.hover},children:g.map(A=>xe(A))})]})]}),e.jsx(r.Box,{sx:{borderTop:`1px solid ${m.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:m.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},children:[e.jsx(z.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:m.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},children:[e.jsx(z.Settings,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body),e.jsxs(r.Dialog,{open:f!==null,onClose:V,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:io(m)}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[e.jsx(z.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 Cd({columnName:t,columnType:o="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:d=!1,hasModifications:c=!1,position:l,onSortAscending:u,onSortDescending:x,onRemoveSort:h,onFilter:b,onClearFilter:m,onGroupByColumn:y,onHideColumn:D,onManageColumns:v,onManageViews:C,onResetLayout:S,onClose:I}){var ee,g;const f=_t(),k=f.palette,j=p.useRef(null);p.useEffect(()=>{if(!j.current)return;const M=j.current,W=M.getBoundingClientRect(),V=window.innerWidth,Z=window.innerHeight;W.right>V-8&&(M.style.left=`${V-W.width-8}px`),W.bottom>Z-8&&(M.style.top=`${Z-W.height-8}px`)},[l]),p.useEffect(()=>{const M=V=>{j.current&&!j.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]),B=(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 yi.createPortal(e.jsxs(r.Paper,{ref:j,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:f.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:io(f),overflow:"hidden",boxShadow:`0 4px 20px ${T(((ee=k.common)==null?void 0:ee.black)??"#000",.12)}, 0 1px 4px ${T(((g=k.common)==null?void 0:g.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:B?"primary.main":"text.secondary",bgcolor:B?T(k.primary.main,.1):"transparent","&:hover":{bgcolor:T(k.primary.main,.08),color:"primary.main"}},children:e.jsx(z.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(()=>x(t)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?T(k.primary.main,.1):"transparent","&:hover":{bgcolor:T(k.primary.main,.08),color:"primary.main"}},children:e.jsx(z.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(()=>h(t)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:T(k.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:e.jsx(z.Close,{sx:{fontSize:16}})})})})]})]}),e.jsxs(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(z.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(()=>m(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:T(k.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(z.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!d&&y&&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(()=>y(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.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(z.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(v),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:T(k.primary.main,.08),color:"primary.main"}},children:e.jsx(z.Settings,{sx:{fontSize:16}})})})]}),d&&e.jsxs(r.MenuItem,{onClick:a(v),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),C&&e.jsxs(r.MenuItem,{onClick:a(C),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.TableRows,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Views",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!d&&c&&S&&e.jsxs(r.MenuItem,{onClick:a(S),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:T(k.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(z.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const wd=176,ai="COLUMN_HEADER",kd=p.memo(function({column:o,index:n,sortRule:i,hasFilters:s,isInSortStack:d,isReadOnly:c=!1,hasModifications:l=!1,width:u,onColumnClick:x,onMoveColumn:h,onColumnDragEnd:b,onResizeStart:m,onSortAscending:y,onSortDescending:D,onRemoveSort:v,onOpenFilterForColumn:C,onClearFiltersForColumn:S,onGroupByColumn:I,onHideColumn:f,onManageColumns:k,onManageViews:j,onResetLayout:a}){const B=p.useRef(null),[R,q]=p.useState(!1),[K,ee]=p.useState({x:0,y:0}),[{handlerId:g,isOver:M},W]=$t.useDrop({accept:ai,collect(G){return{handlerId:G.getHandlerId(),isOver:G.isOver()}},hover(G,re){var fe;if(!B.current)return;const ae=G.index,ne=n;if(ae===ne)return;const P=(fe=B.current)==null?void 0:fe.getBoundingClientRect(),ie=(P.right-P.left)/2,de=re.getClientOffset(),le=((de==null?void 0:de.x)??0)-P.left;ae<ne&&le<ie||ae>ne&&le>ie||(h(ae,ne),G.index=ne)}}),[{isDragging:V},Z]=$t.useDrag({type:ai,item:()=>({index:n,columnName:o.name}),collect:G=>({isDragging:G.isDragging()}),end:()=>{b==null||b()}});Z(W(B));const xe=p.useCallback(G=>{G.preventDefault(),G.stopPropagation(),ee({x:G.clientX,y:G.clientY}),q(!0)},[]),me=p.useCallback(()=>q(!1),[]),F=p.useCallback(()=>{x(o.name)},[x,o.name]),A=p.useCallback(G=>{G.stopPropagation(),C(o.name)},[C,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(z.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(z.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]),se=p.useCallback(()=>s?e.jsx(z.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:B,"data-handler-id":g,"data-column-index":n,onClick:F,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?G=>T(G.palette.primary.main,.08):"action.hover",boxShadow:G=>`0 1px 0 ${T(G.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:"1px solid",borderColor:"divider",py:0,px:2,height:34,"&:hover":{bgcolor:G=>T(G.palette.primary.main,.1),color:"primary.dark"},width:u?`${u}px`:`${wd}px`},children:[e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[Je(o.name),H(),se()]}),e.jsx(r.Box,{draggable:!1,onDragStart:G=>G.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:G=>{G.preventDefault(),G.stopPropagation(),m(G,o.name)},onClick:G=>G.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(Cd,{columnName:o.name,columnType:o.type,currentSort:i,hasFilters:s,isInSortStack:d,isReadOnly:c,hasModifications:l,position:K,onSortAscending:y,onSortDescending:D,onRemoveSort:v,onFilter:C,onClearFilter:S,onGroupByColumn:I,onHideColumn:f,onManageColumns:k,onManageViews:j,onResetLayout:a,onClose:me})]})});function Td({selectedCount:t,selectedRowIds:o,resolvedFavoritesSet:n,viewMode:i="list",onExportSelected:s,onClearSelection:d,onBulkSetFavorites:c}){const[l,u]=p.useState(null),x=p.useMemo(()=>Array.from(o),[o]),h=p.useMemo(()=>x.filter(S=>n.has(S)),[x,n]),b=p.useMemo(()=>x.filter(S=>!n.has(S)),[x,n]),m=h.length>0,y=b.length>0;if(t===0)return null;const D=()=>{c&&c(x,!0)},v=()=>{c&&c(x,!1)},C=S=>{s(S),u(null)};return e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:S=>T(S.palette.primary.main,.08),borderBottom:S=>`1px solid ${T(S.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," ",i==="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:d,startIcon:e.jsx(z.Close,{sx:{fontSize:16}}),size:"small",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:S=>T(S.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(r.Button,{onClick:S=>u(S.currentTarget),startIcon:e.jsx(z.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:S=>T(S.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:S=>T(S.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(r.Menu,{anchorEl:l,open:!!l,onClose:()=>u(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:180,borderRadius:1.5}},children:[e.jsx(r.MenuItem,{dense:!0,onClick:()=>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"})]}),c&&y&&e.jsx(r.Button,{onClick:D,startIcon:e.jsx(z.StarBorder,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:S=>T(S.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:S=>T(S.palette.warning.main,.06)}},children:"Add to Favorites"}),c&&m&&e.jsx(r.Button,{onClick:v,startIcon:e.jsx(z.Star,{sx:{fontSize:16,color:"warning.main"}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:S=>T(S.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:S=>T(S.palette.warning.main,.06)}},children:"Remove from Favorites"})]})]})})}const Id={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 ko(t,o){const n=Id[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:T(i.main,t.palette.mode==="dark"?.24:.12),color:t.palette.mode==="dark"?i.light:i.dark}}function zd(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 Bd={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 Dd(t,o){const n=Bd[o];return n?t.palette[n.hue][n.shade]:t.palette.text.secondary}function Pe(t){return T(t.palette.primary.main,t.palette.mode==="dark"?.24:.12)}function Ed(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=>ko(n,o).bg,color:n=>ko(n,o).color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function Od(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 Ed(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=zd(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 $d(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 Ad({row:t,rowIndex:o,visibleColumns:n,isSelected:i,isFavorite:s,isReadOnly:d,onToggleSelection:c,onToggleFavorite:l,onView:u,onEdit:x,onDuplicate:h,onDelete:b}){const[m,y]=p.useState(null),[D,v]=p.useState(!1),{primaryCol:C,idCol:S,bodyColumns:I}=p.useMemo(()=>$d(n),[n]),f=C?t[C.name]:null,k=S?t[S.name]:null,j=D||i||s||!!m;return e.jsxs(r.Box,{onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),onClick:()=>c(o),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":a=>T(a.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?a=>`0 0 0 3px ${T(a.palette.primary.main,.15)}, 0 2px 8px ${T(a.palette.common.black,.08)}`:D?a=>te(a,"cardHover"):a=>te(a,"cardRest"),transform:D&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:a=>T(a.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:f!=null&&f!==""?String(f):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:[I.map(a=>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:Je(a.name)}),e.jsx(r.Box,{sx:{flex:1,lineHeight:1},children:Od(a,t[a.name])})]},a.name)),I.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:a=>T(a.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:k?.85:0,userSelect:"none"},children:k?String(k):" "}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:j?1:0,transition:"opacity 0.15s ease"},onClick:a=>a.stopPropagation(),children:[l&&e.jsx(r.Tooltip,{title:s?"Remove from favorites":"Add to favorites",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:a=>{a.stopPropagation(),l(t)},sx:{width:28,height:28,color:s?"warning.main":"action.disabled","&:hover":{bgcolor:a=>T(a.palette.warning.main,.1),color:"warning.main"}},children:s?e.jsx(z.Star,{sx:{fontSize:17}}):e.jsx(z.StarBorder,{sx:{fontSize:17}})})}),e.jsx(r.Tooltip,{title:"More actions",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:a=>{a.stopPropagation(),y(a.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:a=>T(a.palette.text.primary,.08)}},children:e.jsx(z.MoreVert,{sx:{fontSize:17}})})})]})]}),e.jsxs(r.Popover,{open:!!m,anchorEl:m,onClose:()=>y(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:a=>te(a,"popover")}},onClick:a=>a.stopPropagation(),children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{u(t),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(z.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),!d&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{x(t,o),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(z.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),!d&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{h(o,t),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(z.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),!d&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{b(o,t),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(z.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function _d({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=>T(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(z.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(z.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Ti(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=>T(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])=>ki(d)).filter(Boolean).join(" • ")})]})}function Md({data:t,visibleColumns:o,grouping:n,selectedRowIds:i,resolvedFavoritesSet:s,isReadOnly:d,isGrouped:c,sortStack:l=[],onSort:u,onToggleRowSelection:x,onToggleRowFavorite:h,onToggleGroupCollapse:b,onViewRow:m,onEditRow:y,onDuplicateRow:D,onDeleteRow:v}){const C=p.useMemo(()=>{const S=new Set;return i.forEach(I=>{const f=I==null?void 0:I.__urm_row_id__;f!==void 0&&S.add(f)}),S},[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:S=>S.typography.fontFamily},children:[u&&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(S=>{const I=l.find(f=>f.column===S.name);return e.jsxs(r.Box,{onClick:()=>u(S.name),sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.25,py:.375,borderRadius:"6px",border:"1px solid",borderColor:I?"primary.main":"divider",bgcolor:I?f=>T(f.palette.primary.main,.07):"transparent",cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light",bgcolor:f=>T(f.palette.primary.main,.05)}},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",fontWeight:I?600:400,color:I?"primary.main":"text.secondary",whiteSpace:"nowrap"},children:Je(S.name)}),I?I.direction==="asc"?e.jsx(z.ArrowUpward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(z.ArrowDownward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(z.SwapVert,{sx:{fontSize:12,color:"text.disabled"}})]},S.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((S,I)=>c&&S.isGroupHeader?e.jsx(_d,{row:S,grouping:n,onToggleCollapse:b||(()=>{})},`group-${S.groupKey}`):e.jsx(Ad,{row:S,rowIndex:I,visibleColumns:o,isSelected:C.has(S==null?void 0:S.__urm_row_id__),isFavorite:s.has(S),isReadOnly:d,onToggleSelection:()=>x(S),onToggleFavorite:h,onView:m,onEdit:y,onDuplicate:D,onDelete:v},`card-${I}`))})]})}const li=[10,15,25,50,100];function Rd(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 Wd({currentPage:t,pageSize:o,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:d}){var M;const l=_t().palette,u=Math.ceil(n/o),[x,h]=p.useState(String(t)),[b,m]=p.useState(null),[y,D]=p.useState(!1),v=p.useRef(null);p.useEffect(()=>{y||(h(String(t)),m(null))},[t,y]);const C=p.useCallback(()=>{const W=Rd(x,u);if(W){m(W);return}const V=parseInt(x.trim(),10);m(null),D(!1),V!==t&&s(V)},[x,u,t,s]),S=p.useCallback(W=>{var V;W.key==="Enter"?(W.preventDefault(),C()):W.key==="Escape"&&(h(String(t)),m(null),D(!1),(V=v.current)==null||V.blur())},[C,t]),I=p.useCallback(()=>{h(String(t)),m(null),D(!1)},[t]),f=p.useCallback(()=>{D(!0),m(null),setTimeout(()=>{var W;return(W=v.current)==null?void 0:W.select()},0)},[]);if(n<=Math.min(...li))return null;const k=()=>{h(String(t)),m(null),D(!1)},j=()=>{k(),s(1)},a=()=>{k(),t>1&&s(t-1)},B=()=>{k(),t<u&&s(t+1)},R=()=>{k(),s(u)},q=(t-1)*o+1,K=Math.min(t*o,n),ee=`${Math.max(2,String(u).length+.5)}ch`,g={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:li.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:[b&&e.jsx(r.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:T(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${T(((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:T(l.error.main,.4)}},children:e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:500,color:"error.main",lineHeight:1.3},children:b})}),e.jsx(r.InputBase,{inputRef:v,value:x,onChange:W=>{h(W.target.value),b&&m(null)},onKeyDown:S,onFocus:f,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:b?"error.main":"text.primary",border:"1px solid",borderColor:b?"error.main":y?"primary.main":"divider",borderRadius:"4px",bgcolor:b?T(l.error.main,.04):y?T(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:b?"error.main":"text.secondary"},"&:focus-within":{boxShadow:b?`0 0 0 2px ${T(l.error.main,.2)}`:`0 0 0 2px ${T(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:j,disabled:t===1,size:"small",title:"First page",sx:g,children:e.jsx(z.FirstPage,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:a,disabled:t===1,size:"small",title:"Previous page",sx:g,children:e.jsx(z.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:B,disabled:t===u,size:"small",title:"Next page",sx:g,children:e.jsx(z.ChevronRight,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:R,disabled:t===u,size:"small",title:"Last page",sx:g,children:e.jsx(z.LastPage,{sx:{fontSize:20}})})]})]})]})}function Pd(){return e.jsx(r.Chip,{icon:e.jsx(z.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const Zi="urm_hint_seen_";function Nd(t){try{return localStorage.getItem(Zi+t)==="true"}catch{return!1}}function Ld(t){try{localStorage.setItem(Zi+t,"true")}catch{}}function ci(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 di(t){const o={fontSize:11};switch(t){case"number":return e.jsx(z.Numbers,{sx:o});case"boolean":return e.jsx(z.CheckBox,{sx:o});case"array":return e.jsx(z.DataArray,{sx:o});case"object":return e.jsx(z.DataObject,{sx:o});default:return e.jsx(z.TextFields,{sx:o})}}function ui(t,o){var n,i;switch(t){case"number":return{bg:T(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:T(((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:T(o.secondary.main,.08),color:o.secondary.main};default:return{bg:T(o.text.secondary,.07),color:o.text.secondary}}}function Fd({open:t,onClose:o,row:n,schema:i,reportName:s}){var b,m;const d=_t(),c=d.palette;if(!n)return null;const l=i.filter(y=>y.name in n),u=l.filter(y=>y.type!=="object"&&y.type!=="array"),x=l.filter(y=>y.type==="object"||y.type==="array"),h=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 ${T(((b=c.common)==null?void 0:b.black)??"#000",.14)}, 0 2px 8px ${T(((m=c.common)==null?void 0:m.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:T(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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," · ",h," ",h===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(z.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:0,overflowY:"auto",flex:1,bgcolor:T(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:x.length>0?1.5:2,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:u.map((y,D)=>{const v=n[y.name],C=ci(v,y.type),S=!C,I=ui(y.type,c),f=D===u.length-1&&u.length%2!==0;return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",px:2,py:1.75,gridColumn:f?"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:di(y.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:Je(y.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:S?400:500,color:S?"text.disabled":"text.primary",fontStyle:S?"italic":"normal",lineHeight:1.5,wordBreak:"break-word",fontFamily:y.type==="number"?'"Roboto Mono", monospace':"inherit"},children:S?"No value":C})]},y.name)})}),x.map(y=>{const D=n[y.name],v=ci(D,y.type),C=!v,S=ui(y.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:S.bg,color:S.color},children:di(y.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Je(y.name)}),e.jsx(r.Chip,{label:y.type,size:"small",sx:{height:18,fontSize:"0.625rem",fontWeight:600,ml:"auto",bgcolor:S.bg,color:S.color,border:"none",letterSpacing:"0.03em"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:2,py:1.5,bgcolor:T(c.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:C?"text.disabled":"text.primary",fontStyle:C?"italic":"normal",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6},children:C?"No value":v})]},y.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(z.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:y=>`${y.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function Vd({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=>T(s.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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(z.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=>T(s.palette.error.main,.1),border:s=>`1px solid ${T(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(z.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 en(t){const o={fontSize:11};switch(t){case"number":return e.jsx(z.Numbers,{sx:o});case"boolean":return e.jsx(z.CheckBox,{sx:o});case"array":return e.jsx(z.DataArray,{sx:o});case"object":return e.jsx(z.DataObject,{sx:o});default:return e.jsx(z.TextFields,{sx:o})}}function pi(t,o){var n,i;switch(t){case"number":return{bg:T(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:T(((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:T(o.secondary.main,.08),color:o.secondary.main};default:return{bg:T(o.text.secondary,.07),color:o.text.secondary}}}function Hd({open:t,onClose:o,onSave:n,row:i,schema:s,reportName:d}){var C,S,I;const c=_t(),l=c.palette,[u,x]=p.useState({});if(p.useEffect(()=>{t&&i&&x({...i})},[t,i]),!i)return null;const h=s.filter(f=>f.name in i),b=h.filter(f=>f.type!=="object"&&f.type!=="array"),m=h.filter(f=>f.type==="object"||f.type==="array"),y=(f,k)=>{x(j=>({...j,[f]:k}))},D=()=>{const f={...u};h.forEach(k=>{const j=u[k.name];if(k.type==="number"){const a=Number(j);f[k.name]=isNaN(a)?i[k.name]:a}else k.type==="boolean"&&(f[k.name]=!!j)}),n(f),o()},v=h.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 ${T(((C=l.common)==null?void 0:C.black)??"#000",.14)}, 0 2px 8px ${T(((S=l.common)==null?void 0:S.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:T(((I=l.warning)==null?void 0:I.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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," · ",v," ",v===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(z.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:T(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[b.length>0&&e.jsxs(r.Box,{children:[b.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:b.map((f,k)=>{const j=u[f.name],a=pi(f.type,l),B=f.type==="boolean",R=!B&&k===b.filter(K=>K.type!=="boolean").length-1&&b.filter(K=>K.type!=="boolean").length%2!==0,q=B||R;return f.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:en(f.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Je(f.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",ml:.25},children:j?"Enabled":"Disabled"})]}),e.jsx(r.Switch,{checked:!!j,onChange:K=>y(f.name,K.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}})]},f.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 ${T(l.primary.main,.12)}`}},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:T(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:en(f.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:Je(f.name)})]}),e.jsx(r.TextField,{value:j??"",onChange:K=>y(f.name,K.target.value),type:f.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"standard",placeholder:`Enter ${f.type==="number"?"number":"value"}…`,InputProps:{disableUnderline:!0},sx:{"& .MuiInputBase-root":{px:1.5,py:1,fontSize:"0.875rem",fontWeight:500,color:"text.primary",fontFamily:f.type==="number"?'"Roboto Mono", monospace':"inherit"},"& .MuiInputBase-input":{p:0,"&::placeholder":{color:"text.disabled",opacity:1,fontWeight:400}}}})]},f.name)})})]}),m.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(z.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:m.map(f=>{const k=i[f.name];let j="";try{j=k==null?"":JSON.stringify(k,null,2)}catch{j=String(k)}const a=pi(f.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:T(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:en(f.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1},children:Je(f.name)}),e.jsx(r.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:T(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:j?"text.primary":"text.disabled",fontStyle:j?"normal":"italic",bgcolor:T(l.text.primary,.015),overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:120,overflowY:"auto"},children:j||"No value"})]},f.name)})})]}),h.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(z.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:f=>`${f.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:D,variant:"contained",startIcon:e.jsx(z.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:f=>`${f.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Er=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=>ko(n,o).bg,color:n=>ko(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){return e.jsx(r.Box,{component:"span",sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.8125rem",fontWeight:400,letterSpacing:"0.04em"},children:t})}function Jd(t,o){const n=t.name.toLowerCase().replace(/[_\s-]/g,""),i=t.name.toLowerCase(),s=o.findIndex(x=>x.name===t.name),d=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(n),c=i.includes("name")||i.includes("task")||i.includes("title")||i.includes("label")||i.includes("subject")||i.includes("description")||i.includes("filename"),l=i.includes("assignee")||i.includes("assigned")||i.includes("owner")||i.includes("author")||i.includes("creator")||i.includes("member")||i.includes("contact")||i.includes("recipient")||i.includes("sender"),u=s===0&&t.type!=="boolean"&&!i.includes("status")&&!i.includes("state");return d||c&&!l||u&&!l}function Kd(t){return e.jsx(r.Box,{component:"span",sx:{fontWeight:700,color:"text.primary",fontSize:"inherit"},children:t})}function Xd(t,o,n=!1,i){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(o),d=t.name.toLowerCase().replace(/[_\s-]/g,""),c=/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase());if(c)return Yd(s);const l=/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase());if(l)return Gd(s);const u=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(d)||/^[A-Z]{2,8}-\d{2,}$/.test(s);if(u)return qd(s);if(n&&!c&&!l&&!u)return Kd(s);if(t.type==="date"){const x=t.dateFormat??"iso",h=Zs(o,x,i??null);return e.jsx(r.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:h})}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 x=o.slice(0,3).map(h=>typeof h=="object"?JSON.stringify(h):String(h)).join(", ");return e.jsxs(r.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[x,o.length>3?` +${o.length-3} more`:""]})}if(typeof o=="object"){const x=JSON.stringify(o);return e.jsx(r.Box,{component:"span",title:x,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:x.length>40?x.slice(0,40)+"…":x})}return s}function Zd({schema:t,data:o,sortStack:n=[],filters:i=[],views:s=[],activeViewId:d="",isDirty:c=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:x=[],columnWidths:h={},grouping:b=null,onSort:m,onSortAscending:y,onSortDescending:D,onOpenFilters:v,onOpenSort:C,onOpenFilterForColumn:S,onSelectView:I,onCreateView:f,onManageViews:k,onUpdateCurrentView:j,onSaveAsNewView:a,onToggleDefault:B,onToggleFavorite:R,onRestoreView:q,onPermanentDelete:K,isAdmin:ee=!1,onExport:g,onOpenColumns:M,onUpdateColumnWidth:W,onUpdateColumnOrder:V,onUpdateColumnVisibility:Z,onClearFiltersForColumn:xe,onResetLayout:me,onOpenGroup:F,onGroupByColumn:A,onToggleGroupCollapse:H,onOpenAuditHistory:se,onOpenScheduledReports:G,searchQuery:re,searchHistory:ae=[],onAddToSearchHistory:ne,onToggleSearchFavourite:P,onDeleteSearchHistory:ie,selectedRowIds:de=new Set,onSearchChange:le,onToggleRowSelection:fe,onToggleAllRows:J,onRangeSelection:Re,onClearSelection:He,onExportSelected:St,currentPage:Mt=1,pageSize:pr=15,totalRowsBeforePagination:Gt=o.length,onPageChange:pt,onPageSizeChange:Rt,isReadOnly:Be=!1,userRole:Xe,reportName:jt,onEditRow:ot,onDuplicateRow:Le,onDeleteRow:nt,favoriteRowIndices:Ct=[],resolvedFavoritesSet:Ze=new Set,showFavoritesOnly:it=!1,onToggleRowFavorite:We,onBulkSetFavorites:$r,showDevPanel:xr=!1,onOpenDevConfig:mr,onToggleFavoritesFilter:qt}){var so;const[st,Wt]=p.useState(null),[hr,wt]=p.useState(0),[fr,Ar]=p.useState(0),[Ue,Jt]=p.useState(null),ze=((so=cr().dates)==null?void 0:so.displayFormat)??null,[Kt,_r]=p.useState(null),[at,L]=p.useState(null),[lt,ye]=p.useState(null),[Ye,Pt]=p.useState(!1),[Mr,xt]=p.useState(!1),[Xt,kt]=p.useState(null),[yr,br]=p.useState(""),[Rr,Te]=p.useState(!1),[Q,ct]=p.useState(null),[Ie,Zt]=p.useState(null),[be,Qe]=p.useState(null),[Qt,mt]=p.useState(null),[Fe,vr]=p.useState("list"),[Tt,dt]=p.useState(!1),[It,Wr]=p.useState(()=>!Nd("toolbar_search"));p.useRef(null);const er=p.useRef(null),tr=p.useRef(null),Nt=p.useCallback(()=>{Ld("toolbar_search"),Wr(!1)},[]);p.useEffect(()=>{if(!It)return;const O=setTimeout(Nt,2e3);return()=>clearTimeout(O)},[It,Nt]);const Sr=p.useMemo(()=>{const O=Ue??x;return O.length>0?O.map(X=>t.find(he=>he.name===X)).filter(X=>X!==void 0):t},[Ue,x,t]),Ne=p.useMemo(()=>Sr.filter(O=>u[O.name]!==!1),[Sr,u]),ht=p.useMemo(()=>t.filter(O=>u[O.name]===!1).length,[t,u]),zt=p.useMemo(()=>t.map(O=>O.name),[t]),Lt=p.useMemo(()=>x.length===0?!1:JSON.stringify(x)!==JSON.stringify(zt),[x,zt]),Pr=p.useCallback((O,X)=>{O.preventDefault(),O.stopPropagation(),Wt(X),wt(O.clientX),Ar(h[X]||150)},[h]);p.useEffect(()=>{if(!st)return;const O=he=>{const Ve=he.clientX-hr,pe=Math.max(100,Math.min(600,fr+Ve));W==null||W(st,pe)},X=()=>{Wt(null)};return document.addEventListener("mousemove",O),document.addEventListener("mouseup",X),()=>{document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",X)}},[st,hr,fr,W]);const Nr=p.useCallback(O=>O==null?"-":typeof O=="object"?JSON.stringify(O):typeof O=="boolean"?O?"true":"false":String(O),[]);p.useCallback(O=>{const X=n.find(he=>he.column===O);return X?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[X.direction==="asc"?e.jsx(z.ArrowUpward,{sx:{fontSize:14}}):e.jsx(z.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:X.priority})]}):null},[n]),p.useCallback(O=>i.some(he=>he.column===O)?e.jsx(r.IconButton,{size:"small",onClick:he=>{he.stopPropagation(),S==null||S(O)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(z.FilterList,{sx:{fontSize:14}})}):null,[i,S]);const Ft=p.useCallback(O=>{m&&m(O)},[m]),Lr=p.useCallback((O,X)=>{Jt(he=>{const pe=[...he??(x.length>0?x:t.map(Vo=>Vo.name))],[Dt]=pe.splice(O,1);return pe.splice(X,0,Dt),pe})},[x,t]),Fr=p.useCallback(()=>{Ue&&V&&V(Ue),Jt(null)},[Ue,V]),rr=p.useCallback(O=>{if(!m)return;const X=n.find(he=>he.column===O);(!X||X.direction!=="asc")&&m(O)},[m,n]),jr=p.useCallback(O=>{if(!m)return;const X=n.find(he=>he.column===O);X?X.direction==="asc"&&m(O):(m(O),setTimeout(()=>m(O),0))},[m,n]),Cr=p.useCallback(O=>{if(!m)return;const X=n.find(he=>he.column===O);X&&(X.direction==="asc"?(m(O),setTimeout(()=>m(O),0)):X.direction==="desc"&&m(O))},[m,n]),wr=p.useCallback(O=>{Z&&Z(O,!1)},[Z]),or=(b==null?void 0:b.enabled)&&o.length>0&&o[0]&&"isGroupHeader"in o[0],kr=n.length>0||i.length>0||((b==null?void 0:b.enabled)??!1)||Object.values(u).some(O=>O===!1),ue=(Mt-1)*pr,ce=o,Ee=p.useMemo(()=>{const O=new Set;return de.forEach(X=>{const he=X==null?void 0:X.__urm_row_id__;he!==void 0&&O.add(he)}),O},[de]);p.useEffect(()=>{const O=X=>{!J||!He||X.target instanceof HTMLInputElement||X.target instanceof HTMLTextAreaElement||((X.ctrlKey||X.metaKey)&&X.key==="a"&&(X.preventDefault(),J(!0,ce)),X.key==="Escape"&&(X.preventDefault(),He()))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[J,He,ce]);const ut=p.useCallback((O,X)=>{fe&&(X.shiftKey&&Kt!==null?(X.preventDefault(),Re&&Re(Kt,O,ce)):(fe(ce[O]),_r(O)))},[fe,Kt,Re,ce]);!p.useMemo(()=>ce.length>0&&Ee.size>0&&ce.every(O=>Ee.has(O==null?void 0:O.__urm_row_id__)),[ce,Ee])&&ce.some(O=>Ee.has(O==null?void 0:O.__urm_row_id__));const Bt=fe&&J,Vr=p.useCallback(O=>{var Ve;const X=O.groupLevel,he=X*24;return e.jsx(r.TableRow,{onClick:()=>H==null?void 0:H(O.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(r.TableCell,{colSpan:Ne.length+(Bt?1:0),sx:{pl:`${he+24}px`},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[O.isCollapsed?e.jsx(z.ChevronRight,{sx:{fontSize:16}}):e.jsx(z.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:Ti(X,((Ve=b==null?void 0:b.levels[X])==null?void 0:Ve.column)||"",O.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:pe=>T(pe.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[O.rowCount," ",O.rowCount===1?"row":"rows"]}),Object.keys(O.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(O.aggregates).map(([pe,Dt])=>ki(Dt)).filter(Boolean).join(" • ")})]})})},O.groupKey)},[Ne,Bt,b,H]),Vt=p.useCallback((O,X)=>{const he=Ee.has(O==null?void 0:O.__urm_row_id__),Ve=at===X;return e.jsxs(r.TableRow,{"data-row-index":X,onMouseEnter:()=>L(X),onMouseLeave:()=>L(null),onClick:pe=>{!fe||pe.target.closest("[data-row-action-btn]")||ut(X,pe)},onContextMenu:pe=>{pe.preventDefault(),pe.stopPropagation(),Qe({mouseX:pe.clientX,mouseY:pe.clientY,row:O,rowIndex:X})},sx:{height:34,cursor:"pointer",bgcolor:he?pe=>T(pe.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:he?pe=>T(pe.palette.warning.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[Ne.map((pe,Dt)=>e.jsx(r.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,textAlign:"left",...Dt===Ne.length-1&&{pr:`${We?76:40}px`},fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"1px solid",borderColor:"divider",minWidth:h[pe.name]?`${h[pe.name]}px`:`${pe.type==="date"?Math.max(Er,180):Er}px`},children:Xd(pe,O[pe.name],Jd(pe,Ne),ze)},pe.name)),e.jsx(r.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:We?76:40,minWidth:We?76:40,maxWidth:We?76:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",background:Ve||Ze.has(O)?pe=>`linear-gradient(to right, transparent, ${he?T(pe.palette.warning.main,.12):pe.palette.background.paper} 32px)`:"transparent",opacity:Ve||Ze.has(O)?1:0,transition:"opacity 0.12s ease, background 0.12s ease",zIndex:10,verticalAlign:"middle"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",height:"100%",px:1,gap:.25},children:[We&&e.jsx(r.IconButton,{"data-row-action-btn":"true",size:"small",onClick:pe=>{pe.stopPropagation(),pe.preventDefault(),We(O)},title:Ze.has(O)?"Remove from favorites":"Add to favorites",sx:{color:Ze.has(O)?"warning.main":"text.secondary","&:hover":{bgcolor:pe=>T(pe.palette.warning.main,.08),color:"warning.main"}},children:Ze.has(O)?e.jsx(z.Star,{sx:{fontSize:18}}):e.jsx(z.StarBorder,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{"data-row-action-btn":"true",size:"small",onClick:pe=>{pe.stopPropagation(),pe.preventDefault(),Qe({anchorEl:pe.currentTarget,row:O,rowIndex:X})},sx:{color:"text.secondary",opacity:Ve?1:0,transition:"opacity 0.12s ease",pointerEvents:Ve?"auto":"none","&:hover":{bgcolor:pe=>T(pe.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(z.MoreVert,{sx:{fontSize:18}})})]})})]},X)},[de,ue,at,ut,Ne,h,Nr,ot,Le,nt,fe,We,Ze,ye,Pt,Qe]);return e.jsxs($t.DndProvider,{backend:sn.HTML5Backend,children:[e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[Bt&&St&&He&&e.jsx(Td,{selectedCount:Ee.size,selectedRowIds:de,resolvedFavoritesSet:Ze,viewMode:Fe,onExportSelected:St,onClearSelection:He,onBulkSetFavorites:$r}),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:[Be&&e.jsx(Pd,{}),le&&ne&&P&&ie&&e.jsx(r.Tooltip,{open:It,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:Nt},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(Sd,{value:re||"",onChange:O=>{It&&Nt(),le(O)},searchHistory:ae,onAddToHistory:ne,onToggleFavourite:P,onDeleteHistory:ie,disabled:Be})})}),e.jsx(r.Tooltip,{title:"JSON format guide",children:e.jsx(r.IconButton,{size:"small",onClick:()=>dt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:O=>T(O.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(z.InfoOutlined,{sx:{fontSize:20}})})}),qt&&e.jsx(r.Tooltip,{title:it?"Show all data":"Show favorites only",children:e.jsxs(r.IconButton,{onClick:qt,size:"small",disabled:Be,sx:{position:"relative",color:it?"warning.main":"text.secondary",bgcolor:it?O=>T(O.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:it?O=>T(O.palette.warning.main,.2):O=>T(O.palette.text.primary,.06),color:it?"warning.main":"text.primary"},"&.Mui-disabled":{color:"action.disabled"}},children:[it?e.jsx(z.Star,{sx:{fontSize:20}}):e.jsx(z.StarBorder,{sx:{fontSize:20}}),it&&Ct.length>0&&e.jsx(r.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"warning.main",color:"warning.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:Ct.length})]})}),xr&&mr&&e.jsx(r.Tooltip,{title:"Developer configuration",children:e.jsx(r.IconButton,{size:"small",onClick:mr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:O=>T(O.palette.text.secondary,.3),"&:hover":{bgcolor:O=>T(O.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(z.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(r.Box,{sx:{flexGrow:1}}),I&&f&&k&&j&&s.length>0&&e.jsx(jd,{views:s||[],activeViewId:d||"",isDirty:c,onSelectView:I,onCreateView:f,onManageViews:k,onToggleDefault:B,onToggleFavorite:R,onRestoreView:q,onPermanentDelete:K,isAdmin:ee,isReadOnly:Be}),!Be&&C&&e.jsx(r.Tooltip,{title:"Sort",children:e.jsxs(r.IconButton,{onClick:C,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?O=>Pe(O):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(z.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})]})}),!Be&&v&&e.jsx(r.Tooltip,{title:"Filter",children:e.jsxs(r.IconButton,{onClick:v,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?O=>Pe(O):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(z.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})]})}),!Be&&M&&e.jsx(r.Tooltip,{title:"Columns",children:e.jsxs(r.IconButton,{onClick:M,size:"small",sx:{position:"relative",color:ht>0||Lt?"primary.main":"text.secondary",bgcolor:ht>0||Lt?O=>Pe(O):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:ht>0||Lt?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:ht>0||Lt?"primary.main":"text.primary"}},children:[e.jsx(z.ViewColumn,{sx:{fontSize:20}}),ht>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:ht})]})}),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:()=>vr("list"),sx:{borderRadius:1,color:Fe==="list"?"primary.main":"text.secondary",bgcolor:Fe==="list"?O=>Pe(O):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Fe==="list"?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:Fe==="list"?"primary.main":"text.primary"}},children:e.jsx(z.TableRows,{sx:{fontSize:20}})})}),e.jsx(r.Tooltip,{title:"Grid view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>vr("grid"),sx:{borderRadius:1,color:Fe==="grid"?"primary.main":"text.secondary",bgcolor:Fe==="grid"?O=>Pe(O):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Fe==="grid"?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:Fe==="grid"?"primary.main":"text.primary"}},children:e.jsx(z.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:O=>mt(O.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:O=>T(O.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(z.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(r.Popover,{open:!!Qt,anchorEl:Qt,onClose:()=>mt(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:[g&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{g(),mt(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Download,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Export"})]}),!Be&&F&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{F(),mt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Grouping"})]}),se&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{se(),mt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Audit History"})]}),G&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{G(),mt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.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:[Fe==="grid"&&e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:e.jsx(Md,{data:ce,visibleColumns:Ne,grouping:b,selectedRowIds:de,resolvedFavoritesSet:Ze,isReadOnly:Be,isGrouped:!!or,sortStack:n,onSort:m,onToggleRowSelection:fe||(()=>{}),onToggleRowFavorite:We,onToggleGroupCollapse:H,onViewRow:O=>{ye(O),Pt(!0)},onEditRow:(O,X)=>{ct(O),Zt(X),Te(!0)},onDuplicateRow:(O,X)=>Le==null?void 0:Le(O,X),onDeleteRow:(O,X)=>{kt(X);const he=Object.values(X).find(Ve=>Ve!=null&&Ve!=="");br(he?String(he):""),xt(!0)}})}),Fe==="list"&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[e.jsx(r.Box,{ref:er,onScroll:O=>{tr.current&&(tr.current.scrollLeft=O.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:`${Ne.reduce((O,X)=>O+(h[X.name]||(X.type==="date"?180:Er)),We?76:40)}px`},children:[e.jsxs("colgroup",{children:[Ne.map(O=>e.jsx("col",{style:{width:`${h[O.name]||(O.type==="date"?180:Er)}px`}},O.name)),e.jsx("col",{style:{width:`${We?76:40}px`}})]}),e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[Ne.map((O,X)=>e.jsx(kd,{column:O,index:X,sortRule:n.find(he=>he.column===O.name),hasFilters:i.some(he=>he.column===O.name),isInSortStack:n.some(he=>he.column===O.name),isReadOnly:Be,hasModifications:kr,width:h[O.name],onColumnClick:Ft,onMoveColumn:Lr,onColumnDragEnd:Fr,onResizeStart:Pr,onSortAscending:y||rr,onSortDescending:D||jr,onRemoveSort:Cr,onOpenFilterForColumn:S||(()=>{}),onClearFiltersForColumn:xe||(()=>{}),onGroupByColumn:A,onHideColumn:wr,onManageColumns:M||(()=>{}),onManageViews:k,onResetLayout:me},O.name)),e.jsx(r.TableCell,{sx:{width:We?76:40,minWidth:We?76:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}})]})})]})}),e.jsx(r.Box,{ref:tr,onScroll:O=>{er.current&&(er.current.scrollLeft=O.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:O=>O.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:O=>O.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:`${Ne.reduce((O,X)=>O+(h[X.name]||(X.type==="date"?180:Er)),We?76:40)}px`},children:[e.jsxs("colgroup",{children:[Ne.map(O=>e.jsx("col",{style:{width:`${h[O.name]||(O.type==="date"?180:Er)}px`}},O.name)),e.jsx("col",{style:{width:`${We?76:40}px`}})]}),e.jsx(r.TableBody,{children:ce.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:Ne.length+(Bt?1:0),align:"center",sx:{py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):or?ce.map((O,X)=>O.isGroupHeader?Vr(O):Vt(O,X)):ce.map((O,X)=>Vt(O,X))})]})})]}),pt&&Rt&&e.jsx(Wd,{currentPage:Mt,pageSize:pr,totalRows:Gt,totalFields:t.length,onPageChange:pt,onPageSizeChange:Rt}),!(pt&&Rt)&&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 ",ce.length," ",ce.length===1?"row":"rows"]})})]})]}),e.jsxs(r.Popover,{open:!!be,onClose:()=>Qe(null),anchorEl:(be==null?void 0:be.anchorEl)||null,anchorReference:be!=null&&be.anchorEl?"anchorEl":"anchorPosition",anchorPosition:be&&!be.anchorEl?{top:be.mouseY,left:be.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:be!=null&&be.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:()=>{be&&(ye(be.row),Pt(!0)),Qe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{be&&(ct(be.row),Zt(be.rowIndex),Te(!0)),Qe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{be&&(Le==null||Le(be.rowIndex,be.row)),Qe(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.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(be){kt(be.row);const O=Object.values(be.row).find(X=>X!=null&&X!=="");br(O?String(O):""),xt(!0)}Qe(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(z.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Fd,{open:Ye,onClose:()=>{Pt(!1),ye(null)},row:lt,schema:t,reportName:jt}),e.jsx(Hd,{open:Rr,onClose:()=>{Te(!1),ct(null),Zt(null)},onSave:O=>{Ie!==null&&(ot==null||ot(Ie,O))},row:Q,schema:t,reportName:jt}),e.jsx(Vd,{open:Mr,onClose:()=>{xt(!1),kt(null)},onConfirm:()=>{Xt!==null&&(nt==null||nt(Xt))},rowPreview:yr}),e.jsx(Ki,{isOpen:Tt,onClose:()=>dt(!1)})]})}function dr({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=>T(s.palette.primary.main,.08)}},children:e.jsx(z.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=>T(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=>T(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>T(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 ur={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 Qd({schema:t,filters:o,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:s,onClearAll:d,onReplaceFilters:c,onClose:l,focusColumn:u}){const[x,h]=p.useState(""),[b,m]=p.useState(""),[y,D]=p.useState(""),[v,C]=p.useState([]),S=cr();p.useEffect(()=>{C([...o])},[o]),p.useEffect(()=>{u&&h(u)},[u]);const I=p.useCallback(()=>{h(""),m(""),D("")},[]),f=p.useMemo(()=>t.filter(M=>M.type!=="mixed"&&M.type!=="null"&&M.type!=="array"&&M.type!=="object"),[t]),k=t.find(M=>M.name===x),j=p.useMemo(()=>{const M=k?On(k.type):[],W=S.filter.allowedOperators;return W.length>0?M.filter(V=>W.includes(V.value)):M},[k]),a=p.useCallback(()=>!(!x||!b||co(b)&&!y.trim()||v.length>=S.filter.maxConditions),[x,b,y,v,S]),B=p.useCallback(()=>{if(!a())return;const M={column:x,operator:b};if(co(b)){const V=k==null?void 0:k.type;M.value=V==="number"?Number(y):y}if(v.some(V=>V.column===M.column&&V.operator===M.operator&&V.value===M.value)){I();return}C([...v,M]),I()},[a,x,b,k,y,v,I]),R=p.useCallback(M=>{C(v.filter((W,V)=>V!==M))},[v]),q=p.useMemo(()=>v.length!==o.length?!0:JSON.stringify(v)!==JSON.stringify(o),[v,o]),K=p.useCallback(()=>{c(v),l()},[v,c,l]),ee=p.useCallback(()=>{C([...o]),I(),l()},[o,I,l]),g=p.useCallback(M=>{var xe;const W=t.find(me=>me.name===M.column);if(!W)return"";const Z=((xe=On(W.type).find(me=>me.value===M.operator))==null?void 0:xe.label)||M.operator;return co(M.operator)?`${M.column} ${Z.toLowerCase()} "${M.value}"`:`${M.column} ${Z.toLowerCase()}`},[t]);return e.jsx(r.Box,{onClick:ee,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:M=>T(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(dr,{content:ur.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(z.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=>T(M.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:M=>T(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:v.length>=S.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:x,onChange:M=>{h(M.target.value),m(""),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:f.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=>T(W.palette.primary.main,.2)}}},children:[Je(M.name)," (",M.type,")"]},M.name))})]}),x&&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:b,onChange:M=>{m(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:j.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=>T(W.palette.primary.main,.2)}}},children:M.label},M.value))})]}),b&&co(b)&&e.jsx(r.TextField,{size:"small",fullWidth:!0,type:(k==null?void 0:k.type)==="number"?"number":"text",value:y,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:B,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"}),v.length>=S.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 ",S.filter.maxConditions," filters allowed. Remove an existing filter to add a new one."]})]}),v.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 (",v.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:v.map((M,W)=>e.jsx(r.Chip,{label:g(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 ${T(V.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:V=>T(V.palette.primary.main,.2),borderColor:V=>T(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 xi="SORT_RULE";function eu({rule:t,index:o,onToggleDirection:n,onRemove:i,onMove:s}){const d=p.useRef(null),[{handlerId:c},l]=$t.useDrop({accept:xi,collect(h){return{handlerId:h.getHandlerId()}},hover(h,b){var I;if(!d.current)return;const m=h.index,y=o;if(m===y)return;const D=(I=d.current)==null?void 0:I.getBoundingClientRect(),v=(D.bottom-D.top)/2,C=b.getClientOffset(),S=((C==null?void 0:C.y)??0)-D.top;m<y&&S<v||m>y&&S>v||(s(m,y),h.index=y)}}),[{isDragging:u},x]=$t.useDrag({type:xi,item:()=>({index:o}),collect:h=>({isDragging:h.isDragging()})});return x(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:h=>te(h,"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:h=>`0 1px 2px 0 ${T(h.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:h=>n(o,h.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:h=>Pe(h),"&:hover":{bgcolor:h=>T(h.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:h=>Pe(h),"&:hover":{bgcolor:h=>T(h.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:h=>T(h.palette.error.main,.08),transform:"scale(1.1)"}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]})}function tu({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]),x=cr(),h=p.useCallback(()=>!(c.length>=x.sort.maxLevels||!s||c.some(f=>f.column===s)),[c,s]),b=p.useCallback(()=>{if(!h())return;const f=c.length+1,k={column:s,direction:"asc",priority:f};l([...c,k]),d("")},[h,s,c]),m=p.useCallback(f=>{const j=c.filter((a,B)=>B!==f).map((a,B)=>({...a,priority:B+1}));l(j)},[c]),y=p.useCallback((f,k)=>{const j=[...c];j[f]={...j[f],direction:k},l(j)},[c]),D=p.useCallback((f,k)=>{const j=[...c],[a]=j.splice(f,1);j.splice(k,0,a);const B=j.map((R,q)=>({...R,priority:q+1}));l(B)},[c]),v=p.useCallback(()=>{n([]),i()},[n,i]),C=p.useCallback(()=>{n(c),i()},[c,n,i]),S=p.useCallback(()=>{l([...o]),d(""),i()},[o,i]),I=t.filter(f=>!c.some(k=>k.column===f.name));return e.jsx($t.DndProvider,{backend:sn.HTML5Backend,children:e.jsx(r.Box,{onClick:S,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:f=>T(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:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:f=>Me(f),bgcolor:"background.paper",outline:"none",boxShadow:f=>te(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:{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(dr,{content:ur.sort,isDev:process.env.NODE_ENV==="development"})]}),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(z.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:f=>T(f.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:f=>T(f.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>=x.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:f=>d(f.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(f=>e.jsx(r.MenuItem,{value:f.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:k=>Pe(k),"&:hover":{bgcolor:k=>T(k.palette.primary.main,.2)}}},children:Je(f.name)},f.name))})]}),e.jsx(r.Button,{onClick:b,disabled:!h(),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>=x.sort.maxLevels&&e.jsxs(r.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",x.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,"/",x.sort.maxLevels,")"]}),e.jsx(r.Button,{onClick:v,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((f,k)=>e.jsx(eu,{rule:f,index:k,onToggleDirection:y,onRemove:m,onMove:D},`${f.column}-${k}`))})]})]}),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:S,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:f=>`${f.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:!u||c.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:f=>`${f.shape.borderRadius}px`,boxShadow:f=>te(f,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:f=>te(f,"hoverButton")},"&:active":{boxShadow:f=>te(f,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function ru({views:t,activeViewId:o,onSelectView:n,onCreateView:i,onEditView:s,onDeleteView:d,onRestoreView:c,onPermanentDelete:l,onPromoteToGlobal:u,isAdmin:x=!1,onClose:h}){var f,k;const b=_t(),m=b.palette,y=t.filter(j=>!j.isDeleted),D=t.filter(j=>j.isDeleted),v=y.filter(j=>j.scope==="global"),C=y.filter(j=>j.scope!=="global"),S=j=>{var K,ee,g,M,W;const a=j.scope==="global",B=j.id===o,R=x||!a,q=x&&!a;return e.jsx(r.Paper,{variant:"outlined",sx:{p:0,overflow:"hidden",borderRadius:"8px",borderColor:B?"primary.main":"divider",bgcolor:B?T(m.primary.main,.03):"background.paper",transition:"border-color 0.15s","&:hover":{borderColor:B?"primary.main":T(m.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(j.id),h()},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:B?600:500,color:B?"primary.main":"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.name}),j.description&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.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(z.Language,{sx:{fontSize:"11px !important"}}),sx:{height:20,fontSize:"0.625rem",fontWeight:700,letterSpacing:"0.04em",bgcolor:T(((K=m.info)==null?void 0:K.main)??m.primary.main,.1),color:((ee=m.info)==null?void 0:ee.main)??m.primary.main,border:`1px solid ${T(((g=m.info)==null?void 0:g.main)??m.primary.main,.25)}`,"& .MuiChip-label":{px:.625},"& .MuiChip-icon":{ml:.5}}}),j.isDefault&&e.jsx(r.Chip,{label:"Default",size:"small",sx:{height:20,fontSize:"0.625rem",fontWeight:600,bgcolor:T(m.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(j.id)},sx:{p:.625,color:"text.secondary",borderRadius:"6px","&:hover":{color:((M=m.info)==null?void 0:M.main)??m.primary.main,bgcolor:T(((W=m.info)==null?void 0:W.main)??m.primary.main,.08)}},children:e.jsx(z.Language,{sx:{fontSize:16}})})}),R&&e.jsx(r.Tooltip,{title:a&&!x?"Global Views are read-only":"Edit view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!x,onClick:V=>{V.stopPropagation(),s(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"primary.main",bgcolor:T(m.primary.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(z.Edit,{sx:{fontSize:15}})})})}),e.jsx(r.Tooltip,{title:a&&!x?"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&&!x,onClick:V=>{V.stopPropagation(),d(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:T(m.error.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(z.Delete,{sx:{fontSize:15}})})})})]})]})},j.id)},I=j=>{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:T(m.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:j.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:B=>{B.stopPropagation(),c(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"success.main",bgcolor:T(((a=m.success)==null?void 0:a.main)??"#2e7d32",.08)}},children:e.jsx(z.Undo,{sx:{fontSize:15}})})}),l&&e.jsx(r.Tooltip,{title:"Delete permanently",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:B=>{B.stopPropagation(),l(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:T(m.error.main,.08)}},children:e.jsx(z.Delete,{sx:{fontSize:15}})})})]})]},j.id)};return e.jsxs(r.Dialog,{open:!0,onClose:h,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:Me(b),maxHeight:"min(640px, calc(100vh - 80px))",boxShadow:`0 8px 32px ${T(((f=m.common)==null?void 0:f.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"}),x&&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:h,size:"small",sx:{color:"text.secondary"},children:e.jsx(z.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(z.Add,{sx:{fontSize:16}}),size:"small",sx:{borderRadius:j=>`${j.shape.borderRadius}px`},children:"Create New View"})}),v.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(z.Language,{sx:{fontSize:14,color:((k=m.info)==null?void 0:k.main)??m.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:v.map(S)})]}),C.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:C.map(S)})]}),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)})]}),y.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:h,variant:"contained",sx:{fontSize:"0.875rem",borderRadius:j=>`${j.shape.borderRadius}px`,px:3},children:"Close"})})]})}const ho=50;function mi({currentSnapshot:t,onSave:o,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:d="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:u=10}){const[x,h]=p.useState(s),[b,m]=p.useState(!1),[y,D]=p.useState(d),[v,C]=p.useState(c),S=()=>{if(!x.trim()){m(!0);return}if(x.trim().length>ho){m(!0);return}o(x.trim(),y.trim(),v),n()},I=k=>{k.key==="Enter"&&!k.shiftKey?S():k.key==="Escape"&&n()},f=()=>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:k=>Me(k),boxShadow:k=>te(k,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[f(),e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(z.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:x,onChange:k=>{k.target.value.length<=ho&&h(k.target.value),b&&k.target.value.trim()&&m(!1)},onKeyDown:I,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:ho},error:b&&!x.trim(),helperText:b&&!x.trim()?"View name is required":`${x.length} / ${ho}`}),e.jsx(r.TextField,{label:"Description (optional)",value:y,onChange:k=>D(k.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: ",ua(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:v,onChange:k=>C(k.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:k=>`${k.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:S,variant:"contained",disabled:l&&!i,startIcon:e.jsx(z.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,boxShadow:k=>te(k,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:k=>te(k,"hoverButton")},"&:active":{boxShadow:k=>te(k,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function ou({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(z.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(z.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 go=100,yo=600,hi="COLUMN";function nu({column:t,index:o,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:d,moveColumn:c}){const l=p.useRef(null),[u,x]=p.useState(i.toString());p.useEffect(()=>{x(i.toString())},[i]);const[{handlerId:h},b]=$t.useDrop({accept:hi,collect(I){return{handlerId:I.getHandlerId()}},hover(I,f){var K;if(!l.current)return;const k=I.index,j=o;if(k===j)return;const a=(K=l.current)==null?void 0:K.getBoundingClientRect(),B=(a.bottom-a.top)/2,R=f.getClientOffset(),q=((R==null?void 0:R.y)??0)-a.top;k<j&&q<B||k>j&&q>B||(c(k,j),I.index=j)}}),[{isDragging:m},y]=$t.useDrag({type:hi,item:()=>({index:o}),collect:I=>({isDragging:I.isDragging()})});y(b(l));const D=()=>{const I=parseInt(u);if(isNaN(I)){x(i.toString()),d(t.name,i);return}const f=Math.max(go,Math.min(yo,I));x(f.toString()),d(t.name,f)},v=I=>{if(I===""||/^\d+$/.test(I)){x(I);const f=parseInt(I);if(!isNaN(f)&&f>=go){const k=Math.min(yo,f);d(t.name,k)}}},C=I=>{I.key==="Enter"&&(I.preventDefault(),D(),I.target.blur())},S=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":h,sx:{opacity:m?.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(z.DragIndicator,{sx:{fontSize:20}})}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:Je(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:`${S(t.type)}15`,color:S(t.type),border:`1px solid ${S(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=>v(I.target.value),onBlur:D,onKeyDown:C,placeholder:"150",size:"small",inputProps:{min:go,max:yo,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(z.Visibility,{sx:{fontSize:20}}):e.jsx(z.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=>T(I.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function iu({schema:t,columnVisibility:o,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:d="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:x,onSaveToCurrentView:h,onSaveToAllViews:b,onSelectView:m,onClose:y}){const[D,v]=p.useState(!1),[C,S]=p.useState(n),[I,f]=p.useState(i),[k,j]=p.useState("all"),[a,B]=p.useState(null);p.useEffect(()=>{S(n)},[n]),p.useEffect(()=>{f(i)},[i]);const R=(F,A)=>{f(H=>({...H,[F]:A})),u==null||u(F,A)},q=(F,A)=>{const H=[...C],[se]=H.splice(F,1);H.splice(A,0,se),S(H),l(H)},K=()=>{x(),v(!1)},g=C.map(F=>t.find(A=>A.name===F)).filter(F=>F!==void 0).filter(F=>{const A=o[F.name]??!0;return k==="active"?A:k==="hidden"?!A:!0}),M=Object.values(o).filter(F=>F).length,W=t.length,V=s.find(F=>F.id===d),Z=s.filter(F=>!F.isDeleted),xe=Z.length>1,me=p.useMemo(()=>{if(!V)return!1;const F=V.snapshot,A=F.columnVisibility??{},H=JSON.stringify(o)!==JSON.stringify(A),se=F.columnOrder??[],G=n??[],re=JSON.stringify(G)!==JSON.stringify(se)&&!(G.length===0&&se.length===0),ae=F.columnWidths??{},ne=JSON.stringify(I)!==JSON.stringify(ae);return H||re||ne},[V,o,n,I]);return e.jsx($t.DndProvider,{backend:sn.HTML5Backend,children:e.jsx(r.Box,{onClick:y,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:F=>T(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=>Me(F),bgcolor:"background.paper",outline:"none",boxShadow:F=>te(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.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(dr,{content:ur.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"]})]}),Z.length>0&&m&&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:F=>B(F.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(z.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:()=>B(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:F=>te(F,"small")}},children:Z.map(F=>e.jsx(r.MenuItem,{onClick:()=>{m(F.id),B(null)},selected:F.id===d,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:A=>Pe(A),"&:hover":{bgcolor:A=>T(A.palette.primary.main,.2)}}},children:F.name},F.id))})]}),e.jsx(r.IconButton,{onClick:y,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(z.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Tabs,{value:k,onChange:(F,A)=>j(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:F=>T(F.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:F=>T(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: ${go}px, max: ${yo}px)`,arrow:!0,placement:"top",children:e.jsx(z.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:g.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"})})}):g.map((F,A)=>e.jsx(nu,{column:F,index:A,isVisible:o[F.name]??!0,width:I[F.name]||170,onToggleVisibility:c,onWidthChange:R,moveColumn:q},F.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:()=>v(!0),disabled:!me,variant:"outlined",startIcon:e.jsx(z.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 to default"}),e.jsxs(r.Stack,{direction:"row",spacing:1.25,children:[h&&e.jsx(r.Button,{onClick:()=>{h(I),y()},disabled:!me,variant:"contained",startIcon:e.jsx(z.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=>te(F,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:F=>te(F,"hoverButton")},"&:active":{boxShadow:F=>te(F,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to current view"}),b&&xe&&e.jsx(r.Button,{onClick:()=>{b(I),y()},disabled:!me||!xe,variant:"contained",startIcon:e.jsx(z.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=>te(F,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"success.dark",boxShadow:F=>te(F,"hoverButton")},"&:active":{boxShadow:F=>te(F,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to all views"})]})]}),D&&e.jsx(r.Box,{onClick:()=>v(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:F=>T(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=>io(F),bgcolor:"background.paper",boxShadow:F=>te(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:()=>v(!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:K,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:F=>`${F.shape.borderRadius}px`,boxShadow:F=>te(F,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:F=>te(F,"hoverButton")},"&:active":{boxShadow:F=>te(F,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function su({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,x]=p.useState(null),h=p.useMemo(()=>ia(t),[t]),b=p.useMemo(()=>h.filter(B=>!s.levels.some((R,q)=>R.column===B.name&&q!==u)),[h,s.levels,u]),m=cr(),y=s.levels.length<m.grouping.maxLevels&&b.length>0,D=p.useCallback(()=>{!y||!c||(d({...s,levels:[...s.levels,{column:c}],enabled:!0}),l(""))},[y,c,s]),v=p.useCallback(B=>{const R=s.levels.filter((q,K)=>K!==B);if(R.length===0){n(null),i();return}d({...s,levels:R,enabled:R.length>0})},[s,n,i]),C=p.useCallback(B=>{x(B),l(s.levels[B].column)},[s.levels]),S=p.useCallback(()=>{if(u===null||!c)return;const B=[...s.levels];B[u]={column:c},d({...s,levels:B}),x(null),l("")},[u,c,s]),I=p.useCallback(()=>{x(null),l("")},[]),f=p.useCallback((B,R)=>{const q=R==="up"?B-1:B+1;if(q<0||q>=s.levels.length)return;const K=[...s.levels],[ee]=K.splice(B,1);K.splice(q,0,ee),d({...s,levels:K})},[s]),k=p.useCallback(()=>{n(null),i()},[n,i]),j=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:B=>T(B.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:B=>B.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:B=>B.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:B=>Me(B),bgcolor:"background.paper",outline:"none",boxShadow:B=>te(B,"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(dr,{content:ur.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(z.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:B=>T(B.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:B=>T(B.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:B=>l(B.target.value),disabled:!y,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..."}),b.map(B=>e.jsxs(r.MenuItem,{value:B.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:R=>Pe(R),"&:hover":{bgcolor:R=>T(R.palette.primary.main,.2)}}},children:[Je(B.name)," (",B.type.toUpperCase(),")"]},B.name))]})}),e.jsx(r.Button,{onClick:D,disabled:!y||!c,variant:"outlined",startIcon:e.jsx(z.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>=m.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"}),h.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:B=>`1px solid ${T(B.palette.warning.main,.5)}`,bgcolor:B=>T(B.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:B=>l(B.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:B=>Pe(B)}},children:[s.levels[u].column," (",(a=t.find(B=>B.name===s.levels[u].column))==null?void 0:a.type.toUpperCase(),")"]}),b.filter(B=>B.name!==s.levels[u].column).map(B=>e.jsxs(r.MenuItem,{value:B.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:R=>Pe(R)}},children:[Je(B.name)," (",B.type.toUpperCase(),")"]},B.name))]})}),e.jsxs(r.Stack,{direction:"row",spacing:1.5,children:[e.jsx(r.Button,{onClick:S,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:B=>te(B,"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:k,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((B,R)=>{const q=t.find(K=>K.name===B.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 ${T(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:B.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:()=>f(R,"up"),disabled:R===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(z.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>f(R,"down"),disabled:R===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(z.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>C(R),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:e.jsx(z.Edit,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>v(R),sx:{color:"text.secondary","&:hover":{bgcolor:K=>T(K.palette.error.main,.08),color:"error.main"}},children:e.jsx(z.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:B=>`${B.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:s.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:B=>`${B.shape.borderRadius}px`,boxShadow:B=>te(B,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:B=>te(B,"hoverButton")},"&:active":{boxShadow:B=>te(B,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const au={filters:z.FilterList,sorting:z.UnfoldMore,visibility:z.Visibility,order:z.ViewColumn,widths:z.Straighten,grouping:z.Layers};function lu({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(z.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=au[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 cu({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=>Pe(u),borderBottom:u=>`1px solid ${T(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=>T(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(lu,{changes:n,onClose:()=>l(!1)})]})}function du({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(z.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(z.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(z.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(r.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(z.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const fi=[{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 uu(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 pu(t,o){if(o===null)return[];const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()<n)}function xu({auditHistory:t,onClose:o,onClearAuditHistory:n}){var D,v,C,S;const i=_t(),s=i.palette,[d,c]=p.useState("1h"),[l,u]=p.useState(!1),x=[...t].sort((I,f)=>new Date(f.timestamp).getTime()-new Date(I.timestamp).getTime()),h=fi.find(I=>I.key===d),b=uu(t,h.ms),m=()=>u(!0),y=()=>{n&&(n(pu(t,h.ms)),u(!1))};return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{onClick:o,sx:{position:"fixed",inset:0,bgcolor:T(((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 ${T(((v=s.common)==null?void 0:v.black)??"#000",.14)}, 0 2px 8px ${T(((C=s.common)==null?void 0:C.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(dr,{content:ur.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:[x.length," event",x.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:T(s.text.primary,.3)}},children:fi.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(z.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:m,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:T(s.error.main,.5),"&:hover":{bgcolor:T(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(z.Close,{sx:{fontSize:17}})})]})]}),e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:T(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:T(s.text.primary,.14),borderRadius:3}},children:x.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[e.jsx(z.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:x.map(I=>{const f=Dd(i,I.feature),{summary:k,detail:j}=wa(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:T(s.text.primary,.18)}},children:[e.jsx(r.Chip,{label:Ia(I.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:T(f,.1),color:f,border:`1px solid ${T(f,.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:k}),j&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:j}),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(z.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:za(I.timestamp)})]}),I.user&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(z.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:io(i),boxShadow:`0 8px 32px ${T(((S=s.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:T(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.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:[b," audit record",b!==1?"s":""]})," ",h.key==="all"?"from all time":`from the ${h.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:y,variant:"contained",color:"error",startIcon:e.jsx(z.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",b," Record",b!==1?"s":""]})]})]})]})}function mu({onSave:t,onClose:o}){const[n,i]=p.useState(""),[s,d]=p.useState(""),[c,l]=p.useState(""),[u,x]=p.useState([]),[h,b]=p.useState(""),[m,y]=p.useState(""),D=j=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j),v=()=>{const j=c.trim();if(j){if(!D(j)){y("Please enter a valid email address");return}if(u.includes(j)){y("This email is already added");return}x([...u,j]),l(""),y("")}},C=j=>{x(u.filter(a=>a!==j))},S=j=>{j.key==="Enter"&&(j.preventDefault(),v())},I=()=>{if(!n.trim()){b("Preset name is required");return}t(n.trim(),s.trim(),u.length>0?u:void 0)},f=j=>{i(j),h&&b("")},k=j=>{l(j),m&&y("")};return e.jsx(r.Box,{onClick:o,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:j=>T(j.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:j=>j.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:j=>j.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:j=>Me(j),bgcolor:"background.paper",outline:"none",boxShadow:j=>te(j,"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(z.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:j=>T(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>T(j.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(z.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:j=>`1px solid ${T(j.palette.primary.main,.3)}`,bgcolor:j=>Pe(j),"& .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:j=>f(j.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!h,helperText:h,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:j=>d(j.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:j=>k(j.target.value),onKeyPress:S,placeholder:"Enter email address",error:!!m,helperText:m,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(z.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:v,variant:"outlined",startIcon:e.jsx(z.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:j=>`${j.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(j=>e.jsx(r.Chip,{label:j,onDelete:()=>C(j),deleteIcon:e.jsx(z.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"}}}},j))}),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:j=>`${j.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(z.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,boxShadow:j=>te(j,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:j=>te(j,"hoverButton")},"&:active":{boxShadow:j=>te(j,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function hu({presetName:t,onClear:o}){return e.jsx(r.Chip,{icon:e.jsx(z.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(z.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>T(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 fu({presets:t,reportId:o,onOpenPreset:n,onDeletePreset:i,onClose:s}){const[d,c]=p.useState(null),l=u=>new Date(u).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx(r.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:u=>T(u.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:u=>u.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:u=>u.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:u=>Me(u),bgcolor:"background.paper",outline:"none",boxShadow:u=>te(u,"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(z.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:u=>T(u.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(z.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(u=>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:x=>te(x,"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:u.name}),u.description&&e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:u.description})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(r.Chip,{label:`Created ${l(u.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 ${u.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(u.id,u.name),variant:"outlined",size:"small",startIcon:e.jsx(z.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:x=>`${x.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:x=>T(x.palette.error.main,.04)}},children:"Delete"})})]},u.id))})}),e.jsx(r.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:e.jsx(r.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:u=>`${u.shape.borderRadius}px`,boxShadow:u=>te(u,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:u=>te(u,"hoverButton")},"&:active":{boxShadow:u=>te(u,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const Qi={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},gu=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],yu=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function bu(t,o){const n=[];for(const i of t){if(i.type!=="string")continue;const s=yu.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=>gu.some(x=>x.test(u))).length/c.length>.6),(s||d)&&n.push(i.name)}return n}function hn(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(x=>String(x[c]??"")).filter(x=>x.length>0);if(l.length===0)return 5;const u=l.reduce((x,h)=>x+h.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 vu(t,o){const n=hn(t,o);return Math.ceil(n*3.5)}function Su(t,o){const n=hn(t,o);return Math.ceil(n*.7)}function ju(t,o,n){switch(t){case"csv":return hn(o,n);case"excel":return Su(o,n);case"json":return vu(o,n)}}function gi(t,o){return Math.ceil(t/o)}function Cu(t,o,n,i,s=Qi){const d=[],c=ju(t,o,n),l=o.length;if(l>s.maxRowsHard){const h=gi(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 ${h} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:h,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const h=gi(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 ${h} smaller export${h>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:h,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?d.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${eo(c)} exceeds the ${eo(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 ${eo(c)}`,detail:`This exceeds the recommended ${eo(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),t!=="excel"){const h=bu(i.filter(b=>n.includes(b.name)),o);if(h.length>0){const b=h.length>s.maxImageColumns;d.push({type:"image_columns",severity:b?"error":"warning",message:`Image column${h.length>1?"s":""} detected: ${h.map(m=>`"${m.replace(/_/g," ")}"`).join(", ")}`,detail:b?`Exporting ${h.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:h.length,limit:s.maxImageColumns})}}const u=d.some(h=>h.severity==="error"),x=d.some(h=>h.severity==="warning");return{violations:d,hasBlockingViolation:u,hasWarning:x,estimatedBytes:c}}function eo(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function wu({violation:t}){const n=_t().palette,i=t.severity==="error",s=i?n.error.main:n.warning.main,d=T(i?n.error.main:n.warning.main,.06),c=i?T(n.error.main,.25):T(n.warning.main,.3),l=i?z.ErrorOutline:z.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(z.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 ku({totalRows:t,visibleRows:o,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:d,sampleRows:c=[],allRows:l=[],processedRows:u=[],onExport:x,onClose:h}){var M,W,V;const b=_t(),m=b.palette,y=cr(),[D,v]=p.useState(y.export.allowedFormats[0]||"csv"),[C,S]=p.useState("visible"),[I,f]=p.useState("visible"),k=C==="visible"?o:t,j=I==="visible"?i:s,a=p.useMemo(()=>C==="visible"?u.length>0?u:new Array(o):l.length>0?l:new Array(t),[C,o,t,u,l]),B=p.useMemo(()=>I==="all"?d.map(Z=>Z.name):d.map(Z=>Z.name).slice(0,i),[I,d,i]),R=p.useMemo(()=>Cu(D,a,B,d,Qi),[D,a,B,d]),q=()=>{R.hasBlockingViolation||(x({format:D,scope:C,columnScope:I}),h())},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"}},g={color:"text.secondary","&.Mui-checked":{color:"primary.main"},pt:.125};return e.jsx(r.Box,{onClick:h,sx:{position:"fixed",inset:0,bgcolor:T(((M=m.common)==null?void 0:M.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:b.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:e.jsxs(r.Paper,{onClick:Z=>Z.stopPropagation(),elevation:0,sx:{width:480,maxWidth:"calc(100vw - 48px)",maxHeight:"min(680px, calc(100vh - 180px))",display:"flex",flexDirection:"column",borderRadius:Me(b),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${T(((W=m.common)==null?void 0:W.black)??"#000",.14)}, 0 2px 8px ${T(((V=m.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(dr,{content:ur.export,isDev:process.env.NODE_ENV==="development"})]}),e.jsx(r.IconButton,{onClick:h,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:e.jsx(z.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:T(m.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((Z,xe)=>e.jsx(wu,{violation:Z},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:Z=>v(Z.target.value),children:[y.export.allowedFormats.includes("csv")&&e.jsx(r.FormControlLabel,{value:"csv",control:e.jsx(r.Radio,{size:"small",sx:g}),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}}),y.export.allowedFormats.includes("excel")&&e.jsx(r.FormControlLabel,{value:"excel",control:e.jsx(r.Radio,{size:"small",sx:g}),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}}),y.export.allowedFormats.includes("json")&&e.jsx(r.FormControlLabel,{value:"json",control:e.jsx(r.Radio,{size:"small",sx:g}),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:C,onChange:Z=>S(Z.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:g}),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:g}),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:Z=>f(Z.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:g}),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:g}),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:k.toLocaleString()},{label:"Columns to export",value:String(j)},{label:"Estimated file size",value:eo(R.estimatedBytes),highlight:R.hasBlockingViolation?"error.main":R.hasWarning?"warning.main":void 0}].map(({label:Z,value:xe,highlight:me})=>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:Z}),e.jsx(r.Typography,{sx:{fontWeight:500,fontSize:"0.8125rem",color:me??"text.primary"},children:xe})]},Z))})]})]}),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:T(m.text.primary,.015)},children:[R.hasBlockingViolation&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[e.jsx(z.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:h,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(z.Download,{sx:{fontSize:16}}),sx:{fontSize:"0.875rem",px:2.5,borderRadius:"8px"},children:["Download ",K[D]]})]})]})})}function Tu({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(z.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:e.jsx(z.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 Iu({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(z.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(z.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(z.InfoOutlined,{sx:{fontSize:20}})}}})(),c=Pa(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(z.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 zu extends p.Component{constructor(n){super(n);Sn(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){ar.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=>T(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(z.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=>T(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(z.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Bu({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(z.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:e.jsx(z.Close,{sx:{fontSize:16}})}),children:[e.jsxs(r.AlertTitle,{children:[t," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Jr({children:t,feature:o,onError:n}){return e.jsx(zu,{context:o,onError:(i,s)=>{n&&n(i)},fallback:e.jsx(Bu,{feature:o}),children:t})}const Du=[{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"}],Eu=[{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 Kr({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 Ou({open:t,onClose:o,config:n,onApply:i}){const[s,d]=p.useState(0),[c,l]=p.useState(n),u=()=>l(n),x=()=>l(Ge),h=()=>{i(c),o()},b={sort:C=>l(S=>({...S,sort:{...S.sort,...C}})),filter:C=>l(S=>({...S,filter:{...S.filter,...C}})),columns:C=>l(S=>({...S,columns:{...S.columns,...C}})),grouping:C=>l(S=>({...S,grouping:{...S.grouping,...C}})),export:C=>l(S=>({...S,export:{...S.export,...C}}))},m=C=>{const S=c.filter.allowedOperators,I=S.includes(C)?S.filter(f=>f!==C):[...S,C];I.length!==0&&b.filter({allowedOperators:I})},y=C=>{const S=c.export.allowedFormats,I=S.includes(C)?S.filter(f=>f!==C):[...S,C];I.length!==0&&b.export({allowedFormats:I})},D=[{label:"Sort",icon:e.jsx(z.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(z.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(z.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(z.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(z.Download,{sx:{fontSize:17}})}],v=C=>JSON.stringify(c[C])===JSON.stringify(Ge[C]);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:C=>Me(C),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:C=>`0 8px 32px ${T(C.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:C=>T(C.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(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(r.Tabs,{value:s,onChange:(C,S)=>d(S),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:D.map((C,S)=>e.jsx(r.Tab,{label:C.label,icon:C.icon,iconPosition:"start"},S))})}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Kr,{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"}),!v("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:(C,S)=>b.sort({maxLevels:S}),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(Kr,{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"}),!v("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:(C,S)=>b.filter({maxConditions:S}),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(C=>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:C}),e.jsx(r.FormGroup,{row:!0,sx:{gap:.5},children:Du.filter(S=>S.group===C).map(S=>e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(S.value),onChange:()=>m(S.value)}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:S.label}),sx:{mr:1.5}},S.value))})]},C))]})]}),e.jsxs(Kr,{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"}),!v("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:(C,S)=>b.columns({maxVisible:S}),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:(C,S)=>b.columns({minColumnWidth:S}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:C=>`${C}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:(C,S)=>b.columns({maxColumnWidth:S}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:C=>`${C}px`})]})]})]})]}),e.jsxs(Kr,{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"}),!v("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(C=>e.jsxs(r.Box,{onClick:()=>b.grouping({maxLevels:C}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===C?"primary.main":"divider",bgcolor:c.grouping.maxLevels===C?S=>T(S.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:S=>T(S.palette.primary.main,.04)}},children:[e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===C?"primary.main":"text.secondary"},children:C}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][C-1]})]},C))}),e.jsxs(r.FormGroup,{row:!0,sx:{gap:2},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:c.grouping.allowNested,onChange:C=>b.grouping({allowNested:C.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:C=>b.grouping({allowCollapse:C.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(Kr,{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"}),!v("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:Eu.map(C=>e.jsxs(r.Box,{onClick:()=>y(C.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(C.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(C.value)?S=>T(S.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(r.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(C.value),onChange:()=>y(C.value),onClick:S=>S.stopPropagation()}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:C.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:C.desc})]})]},C.value))})]})})]}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:C=>T(C.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(r.Button,{startIcon:e.jsx(z.RestartAlt,{sx:{fontSize:18}}),onClick:x,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:C=>T(C.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:h,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const $u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Au={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 bo(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,x=l.getDay();let h=u-x;return h<0&&(h+=7),h===0&&l<=s&&(h=7),l.setDate(l.getDate()+h),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 _u(t){const o=es(t.time);return t.frequency==="daily"?`Daily at ${o}`:t.frequency==="weekly"?`Every ${$u[t.dayOfWeek??1]} at ${o}`:t.frequency==="monthly"?`Monthly on the ${Au[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 Mu(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 Ru(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 Wu=[{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"}],Pu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ns={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},sr={"& .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 Nu({initial:t=ns,isEditing:o=!1,onSave:n,onBack:i}){const[s,d]=p.useState(t),[c,l]=p.useState(!1),[u,x]=p.useState(!1),h=(y,D)=>d(v=>({...v,[y]:D})),b=s.email.trim().length>0&&!Pu.test(s.email.trim()),m=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!b;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:y=>T(y.palette.text.primary,.06)}},children:e.jsx(z.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:y=>{h("name",y.target.value),c&&y.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:sr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:sr,children:[e.jsx(r.InputLabel,{children:"Frequency"}),e.jsxs(r.Select,{value:s.frequency,label:"Frequency",onChange:y=>h("frequency",y.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:sr,children:[e.jsx(r.InputLabel,{children:"Day of week"}),e.jsx(r.Select,{value:s.dayOfWeek,label:"Day of week",onChange:y=>h("dayOfWeek",Number(y.target.value)),children:Wu.map(y=>e.jsx(r.MenuItem,{value:y.value,children:y.label},y.value))})]}),s.frequency==="monthly"&&e.jsx(r.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:y=>h("dayOfMonth",Number(y.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:sr}),e.jsx(r.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:y=>h("time",y.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:sr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:sr,children:[e.jsx(r.InputLabel,{children:"Export format"}),e.jsxs(r.Select,{value:s.format,label:"Export format",onChange:y=>h("format",y.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:y=>h("scope",y.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:y=>h("email",y.target.value),onBlur:()=>x(!0),placeholder:"user@company.com",error:u&&b,helperText:u&&b?"Enter a valid email address":void 0,InputProps:{startAdornment:e.jsx(z.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:sr}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[e.jsx(z.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:y=>T(y.palette.text.primary,.06)}},children:"Cancel"}),e.jsx(r.Button,{onClick:()=>m&&n(s),disabled:!m,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:o?"Save changes":"Create schedule"})]})]})}function Lu({scheduleName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>io(i),boxShadow:i=>{var s;return`0 8px 32px ${T(((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=>T(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.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 Fu({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=>T(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=>T(l.palette.success.main,.1):l=>T(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:_u(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=>T(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=>T(l.palette.text.primary,.06),color:"text.secondary"}}),t.email&&e.jsx(r.Chip,{icon:e.jsx(z.Email,{sx:{fontSize:11}}),label:t.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>T(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: ",Mu(t.nextRunAt)]}),t.lastRunAt?e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Ru(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=>T(l.palette.primary.main,.08)}},children:e.jsx(z.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=>T(l.palette.warning.main,.08):l=>T(l.palette.success.main,.08)}},children:c?e.jsx(z.Pause,{sx:{fontSize:15}}):e.jsx(z.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=>T(l.palette.primary.main,.08)}},children:e.jsx(z.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=>T(l.palette.error.main,.08)}},children:e.jsx(z.Delete,{sx:{fontSize:15}})})})]})]})]})}function Vu({open:t,onClose:o,reportId:n,reportName:i,onRunNow:s}){const[d,c]=p.useState([]),[l,u]=p.useState({type:"list"}),[x,h]=p.useState(0),[b,m]=p.useState(null);p.useEffect(()=>{t&&(c(rs(n)),u({type:"list"}))},[t,n]),p.useEffect(()=>{if(!t)return;const B=setInterval(()=>h(R=>R+1),3e4);return()=>clearInterval(B)},[t]);const y=p.useCallback(B=>{c(B),os(n,B)},[n]),D=B=>{const R=bo(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth),q={id:`sched-${Date.now()}`,reportId:n,name:B.name.trim(),frequency:B.frequency,dayOfWeek:B.frequency==="weekly"?B.dayOfWeek:void 0,dayOfMonth:B.frequency==="monthly"?B.dayOfMonth:void 0,time:B.time,format:B.format,scope:B.scope,email:B.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:R,runCount:0};y([...d,q]),u({type:"list"})},v=B=>{if(l.type!=="edit")return;const R=l.schedule,q=bo(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth);y(d.map(K=>K.id===R.id?{...R,name:B.name.trim(),frequency:B.frequency,dayOfWeek:B.frequency==="weekly"?B.dayOfWeek:void 0,dayOfMonth:B.frequency==="monthly"?B.dayOfMonth:void 0,time:B.time,format:B.format,scope:B.scope,email:B.email.trim()||void 0,nextRunAt:q}:K)),u({type:"list"})},C=B=>{y(d.map(R=>{if(R.id!==B)return R;const q=R.isActive?R.nextRunAt:bo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth);return{...R,isActive:!R.isActive,nextRunAt:q}}))},S=B=>{s(B);const R=new Date().toISOString();y(d.map(q=>q.id===B.id?{...q,lastRunAt:R,runCount:q.runCount+1}:q))},I=B=>{const R=d.find(q=>q.id===B)??null;m(R)},f=()=>{b&&(y(d.filter(B=>B.id!==b.id)),m(null))},k=B=>({name:B.name,frequency:B.frequency,dayOfWeek:B.dayOfWeek??1,dayOfMonth:B.dayOfMonth??1,time:B.time,format:B.format,scope:B.scope,email:B.email??""}),j=l.type!=="list",a=d.filter(B=>B.isActive).length;return e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:j,PaperProps:{sx:{borderRadius:B=>Me(B),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:B=>T(B.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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(dr,{content:ur.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:B=>T(B.palette.text.primary,.06)}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[j&&e.jsx(Nu,{initial:l.type==="edit"?k(l.schedule):ns,isEditing:l.type==="edit",onSave:l.type==="edit"?v: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(z.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(z.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(B=>e.jsx(Fu,{schedule:B,tick:x,onToggle:C,onRunNow:S,onEdit:R=>u({type:"edit",schedule:R}),onDelete:I},B.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:B=>T(B.palette.warning.main,.06),border:"1px solid",borderColor:B=>T(B.palette.warning.main,.2)},children:[e.jsx(z.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:B=>T(B.palette.text.primary,.06)}},children:"Close"})]})]}),b&&e.jsx(Lu,{scheduleName:b.name,onConfirm:f,onCancel:()=>m(null)})]})}const Hu=6e4;function Uu({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:u,sortStack:x,onFired:h}){const b=p.useRef({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:u,sortStack:x,onFired:h});p.useEffect(()=>{b.current={reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:c,columnOrder:l,filters:u,sortStack:x,onFired:h}});const m=p.useCallback(y=>{var B,R;const{reportName:D,uploadedData:v,processedData:C,schema:S,activeView:I,columnVisibility:f,columnOrder:k,filters:j,sortStack:a}=b.current;try{const q=y.scope==="all"?v:C,K=vo(q,S,j,a,I,f,k),ee=`${y.name}_scheduled`;switch(y.format){case"csv":So(K,ee,{scope:y.scope});break;case"excel":jo(K,ee,{scope:y.scope});break;case"json":Co(K,ee,{scope:y.scope});break}if(y.email){const g=encodeURIComponent(`Scheduled Report: ${y.name}`),M=encodeURIComponent(`Your scheduled report "${y.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=>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 bd({onFileUpload:t,onError:o,isUploading:n}){const[i,s]=p.useState(!1),[d,l]=p.useState(""),[c,u]=p.useState(!1),h=p.useRef(null),m=async S=>{if(!S.name.endsWith(".json")){o("Only .json files are allowed");return}const I=10*1024*1024;if(S.size>I){o("File size exceeds 10MB limit");return}l(S.name);try{const f=await S.text();let k;try{k=JSON.parse(f)}catch{o("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(k)){o("JSON must be an array of objects");return}if(k.length===0){o("No data rows found in JSON file");return}t(k)}catch{o("Network error — please try again")}finally{l("")}},b=S=>{S.preventDefault(),s(!0)},x=S=>{S.preventDefault(),s(!1)},y=S=>{S.preventDefault(),s(!1);const I=S.dataTransfer.files[0];I&&m(I)},D=()=>{var S;(S=h.current)==null||S.click()},v=S=>{var f;const I=(f=S.target.files)==null?void 0:f[0];I&&m(I)},C=S=>{S.stopPropagation(),u(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(r.Box,{onDragOver:b,onDragLeave:x,onDrop:y,onPaste:S=>S.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?S=>T(S.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[e.jsx(r.Box,{component:"input",ref:h,type:"file",accept:".json",onChange:v,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:S=>T(S.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.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:C,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:e.jsx(z.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(Xi,{isOpen:c,onClose:()=>u(!1)})]})}function vd({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=>T(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(z.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 Sd({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=>T(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=>T(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.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(z.Upload,{sx:{fontSize:16}}),onClick:o,sx:{fontWeight:500},children:"Try Again"})]})}function Qi({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=>T(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:e.jsx(z.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 jd({value:t,onChange:o,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:d,disabled:l}){const[c,u]=p.useState(!1),[h,m]=p.useState(!1),[b,x]=p.useState(-1),y=p.useRef(null),D=p.useRef(null);p.useEffect(()=>{function R(J){y.current&&!y.current.contains(J.target)&&(u(!1),m(!1))}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[]);const v=p.useCallback(()=>{m(!0),x(-1),n.length>0&&u(!0)},[n.length]),C=p.useCallback(R=>{o(R),x(-1)},[o]),S=p.useCallback(R=>{var J;o(R),i(R),u(!1),(J=D.current)==null||J.blur()},[o,i]),I=p.useCallback(R=>{x(-1),S(R)},[S]),f=p.useCallback(R=>{var J;R.key==="Enter"?b>=0&&b<n.length?(R.preventDefault(),I(n[b].query)):t.trim()&&S(t.trim()):R.key==="Escape"?(u(!1),x(-1),(J=D.current)==null||J.blur()):R.key==="ArrowDown"?(R.preventDefault(),n.length>0&&(c||u(!0),x(K=>K<n.length-1?K+1:K))):R.key==="ArrowUp"&&(R.preventDefault(),x(K=>K>0?K-1:-1))},[b,n,t,c,I,S]),k=p.useCallback(()=>{var R;o(""),(R=D.current)==null||R.focus()},[o]),j=p.useMemo(()=>n.filter(R=>R.isFavourite),[n]),a=p.useMemo(()=>n.filter(R=>!R.isFavourite),[n]),B=c&&n.length>0;return e.jsxs(r.Box,{sx:{position:"relative",width:240},ref:y,children:[e.jsx(r.TextField,{inputRef:D,size:"small",fullWidth:!0,value:t,onChange:R=>C(R.target.value),onFocus:v,onKeyDown:f,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:R=>T(R.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:R=>T(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(z.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:t?e.jsx(r.InputAdornment,{position:"end",children:e.jsx(r.IconButton,{size:"small",onClick:k,edge:"end",sx:{mr:-.5},children:e.jsx(z.Close,{sx:{fontSize:16}})})}):null}}),B&&e.jsxs(r.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[j.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"}),j.map((R,J)=>e.jsx(ai,{entry:R,isSelected:b===J,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:[j.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,J)=>{const K=j.length+J;return e.jsx(ai,{entry:R,isSelected:b===K,onClick:()=>I(R.query),onToggleFavourite:()=>s(R.query),onDelete:()=>d(R.query)},`recent-${R.query}`)})]})]})]})}const ai=p.memo(function({entry:o,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:d}){const l=p.useCallback(u=>{u.stopPropagation(),s()},[s]),c=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=>T(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>T(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:l,title:o.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:o.isFavourite?e.jsx(z.Star,{sx:{fontSize:14,color:"warning.light"}}):e.jsx(z.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),e.jsx(r.IconButton,{size:"small",onClick:c,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:e.jsx(z.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function Cd({views:t,activeViewId:o,isDirty:n,onSelectView:i,onCreateView:s,onManageViews:d,onToggleDefault:l,onToggleFavorite:c,onRestoreView:u,onPermanentDelete:h,isReadOnly:m,isAdmin:b=!1}){const x=At(),[y,D]=p.useState(!1),[v,C]=p.useState(!1),[S,I]=p.useState({top:0,left:0}),[f,k]=p.useState(null),j=p.useRef(null),a=p.useRef(null),B=t.find(A=>A.id===o),R=B==null?void 0:B.isDefault,J=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)),g=t.filter(A=>A.isDeleted);p.useEffect(()=>{if(y&&a.current){const A=a.current.getBoundingClientRect();I({top:A.bottom+window.scrollY+8,left:A.right+window.scrollX-320})}},[y]),p.useEffect(()=>{const A=H=>{j.current&&!j.current.contains(H.target)&&a.current&&!a.current.contains(H.target)&&D(!1)};return y&&document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[y]);const M=A=>{if(n&&A!==o){k(A),D(!1);return}i(A),D(!1)},W=()=>{f&&(i(f),k(null))},V=()=>{k(null)},Q=(A,H=!1)=>{const se=A.scope==="global",G=!m&&(!se||b);return e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:o===A.id?T(x.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:o===A.id?T(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(z.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:[G&&c&&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:A.isFavorite?"Remove from favorites":"Add to favorites",children:e.jsx(z.Star,{sx:{fontSize:16}})}),G&&l&&!A.isDefault&&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:"Set as default",children:e.jsx(z.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(z.Undo,{sx:{fontSize:16,color:"success.main"}})}),h&&e.jsx(r.IconButton,{onClick:H=>{H.stopPropagation(),h(A.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:x.palette.action.hover}},title:"Delete permanently",children:e.jsx(z.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},A.id),me=n||!R,L=n;return e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsxs(r.IconButton,{ref:a,onClick:()=>D(!y),size:"small",sx:{position:"relative",color:me?"warning.main":"text.secondary",bgcolor:me?T(x.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:me?T(x.palette.warning.main,.2):T(x.palette.text.primary,.06),color:me?"warning.dark":"text.primary"}},title:`View: ${(B==null?void 0:B.name)||"Default View"}`,children:[e.jsx(z.Visibility,{sx:{fontSize:20}}),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"}})]}),y&&bi.createPortal(e.jsxs(r.Box,{ref:j,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:S.top,left:S.left},children:[J.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"}),J.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(z.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))]})]}),g.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:()=>C(!v),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 (",g.length,")"]}),e.jsx(z.ChevronRight,{sx:{fontSize:16}})]}),v&&e.jsx(r.Box,{sx:{backgroundColor:x.palette.action.hover},children:g.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(z.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(z.Settings,{sx:{fontSize:16}}),e.jsx(r.Typography,{component:"span",sx:{fontSize:"inherit"},children:"View Setup"})]})]}),document.body),e.jsxs(r.Dialog,{open:f!==null,onClose:V,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:so(x)}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[e.jsx(z.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 wd({columnName:t,columnType:o="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:d=!1,hasModifications:l=!1,position:c,onSortAscending:u,onSortDescending:h,onRemoveSort:m,onFilter:b,onClearFilter:x,onGroupByColumn:y,onHideColumn:D,onManageColumns:v,onManageViews:C,onResetLayout:S,onClose:I}){var ee,g;const f=At(),k=f.palette,j=p.useRef(null);p.useEffect(()=>{if(!j.current)return;const M=j.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`)},[c]),p.useEffect(()=>{const M=V=>{j.current&&!j.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]),B=(n==null?void 0:n.direction)==="asc",R=(n==null?void 0:n.direction)==="desc",J=o==="number"?"0→9":o==="boolean"?"F→T":"A→Z",K=o==="number"?"9→0":o==="boolean"?"T→F":"Z→A";return bi.createPortal(e.jsxs(r.Paper,{ref:j,elevation:0,sx:{position:"fixed",left:`${c.x}px`,top:`${c.y}px`,zIndex:f.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:so(f),overflow:"hidden",boxShadow:`0 4px 20px ${T(((ee=k.common)==null?void 0:ee.black)??"#000",.12)}, 0 1px 4px ${T(((g=k.common)==null?void 0:g.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 (${J})`,placement:"top",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:a(()=>u(t)),sx:{p:.625,borderRadius:"6px",color:B?"primary.main":"text.secondary",bgcolor:B?T(k.primary.main,.1):"transparent","&:hover":{bgcolor:T(k.primary.main,.08),color:"primary.main"}},children:e.jsx(z.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(()=>h(t)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?T(k.primary.main,.1):"transparent","&:hover":{bgcolor:T(k.primary.main,.08),color:"primary.main"}},children:e.jsx(z.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:T(k.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:e.jsx(z.Close,{sx:{fontSize:16}})})})})]})]}),e.jsxs(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(z.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:T(k.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(z.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!d&&y&&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(()=>y(t)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.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(z.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(v),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:T(k.primary.main,.08),color:"primary.main"}},children:e.jsx(z.Settings,{sx:{fontSize:16}})})})]}),d&&e.jsxs(r.MenuItem,{onClick:a(v),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),C&&e.jsxs(r.MenuItem,{onClick:a(C),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[e.jsx(r.ListItemIcon,{sx:{minWidth:28},children:e.jsx(z.TableRows,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Manage Views",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!d&&l&&S&&e.jsxs(r.MenuItem,{onClick:a(S),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:T(k.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(z.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),e.jsx(r.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const kd=176,li="COLUMN_HEADER",Td=p.memo(function({column:o,index:n,sortRule:i,hasFilters:s,isInSortStack:d,isReadOnly:l=!1,hasModifications:c=!1,width:u,onColumnClick:h,onMoveColumn:m,onColumnDragEnd:b,onResizeStart:x,onSortAscending:y,onSortDescending:D,onRemoveSort:v,onOpenFilterForColumn:C,onClearFiltersForColumn:S,onGroupByColumn:I,onHideColumn:f,onManageColumns:k,onManageViews:j,onResetLayout:a}){const B=p.useRef(null),[R,J]=p.useState(!1),[K,ee]=p.useState({x:0,y:0}),[{handlerId:g,isOver:M},W]=Ot.useDrop({accept:li,collect(G){return{handlerId:G.getHandlerId(),isOver:G.isOver()}},hover(G,re){var ge;if(!B.current)return;const ae=G.index,ne=n;if(ae===ne)return;const P=(ge=B.current)==null?void 0:ge.getBoundingClientRect(),ie=(P.right-P.left)/2,pe=re.getClientOffset(),le=((pe==null?void 0:pe.x)??0)-P.left;ae<ne&&le<ie||ae>ne&&le>ie||(m(ae,ne),G.index=ne)}}),[{isDragging:V},Q]=Ot.useDrag({type:li,item:()=>({index:n,columnName:o.name}),collect:G=>({isDragging:G.isDragging()}),end:()=>{b==null||b()}});Q(W(B));const xe=p.useCallback(G=>{G.preventDefault(),G.stopPropagation(),ee({x:G.clientX,y:G.clientY}),J(!0)},[]),me=p.useCallback(()=>J(!1),[]),L=p.useCallback(()=>{h(o.name)},[h,o.name]),A=p.useCallback(G=>{G.stopPropagation(),C(o.name)},[C,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(z.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):e.jsx(z.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]),se=p.useCallback(()=>s?e.jsx(z.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:B,"data-handler-id":g,"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?G=>T(G.palette.primary.main,.08):"action.hover",boxShadow:G=>`0 1px 0 ${T(G.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:"1px solid",borderColor:"divider",py:0,px:2,height:34,"&:hover":{bgcolor:G=>T(G.palette.primary.main,.1),color:"primary.dark"},width:u?`${u}px`:`${kd}px`},children:[e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[Qe(o.name),H(),se()]}),e.jsx(r.Box,{draggable:!1,onDragStart:G=>G.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:G=>{G.preventDefault(),G.stopPropagation(),x(G,o.name)},onClick:G=>G.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(wd,{columnName:o.name,columnType:o.type,currentSort:i,hasFilters:s,isInSortStack:d,isReadOnly:l,hasModifications:c,position:K,onSortAscending:y,onSortDescending:D,onRemoveSort:v,onFilter:C,onClearFilter:S,onGroupByColumn:I,onHideColumn:f,onManageColumns:k,onManageViews:j,onResetLayout:a,onClose:me})]})});function Id({selectedCount:t,selectedRowIds:o,resolvedFavoritesSet:n,viewMode:i="list",onExportSelected:s,onClearSelection:d,onBulkSetFavorites:l}){const[c,u]=p.useState(null),h=p.useMemo(()=>Array.from(o),[o]),m=p.useMemo(()=>h.filter(S=>n.has(S)),[h,n]),b=p.useMemo(()=>h.filter(S=>!n.has(S)),[h,n]),x=m.length>0,y=b.length>0;if(t===0)return null;const D=()=>{l&&l(h,!0)},v=()=>{l&&l(h,!1)},C=S=>{s(S),u(null)};return e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:S=>T(S.palette.primary.main,.08),borderBottom:S=>`1px solid ${T(S.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," ",i==="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:d,startIcon:e.jsx(z.Close,{sx:{fontSize:16}}),size:"small",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",color:"text.secondary","&:hover":{bgcolor:S=>T(S.palette.text.primary,.06),color:"text.primary"}},children:"Clear"}),e.jsx(r.Button,{onClick:S=>u(S.currentTarget),startIcon:e.jsx(z.Download,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:S=>T(S.palette.primary.main,.4),color:"primary.main","&:hover":{borderColor:"primary.main",bgcolor:S=>T(S.palette.primary.main,.06)}},children:"Export Selected"}),e.jsxs(r.Menu,{anchorEl:c,open:!!c,onClose:()=>u(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:180,borderRadius:1.5}},children:[e.jsx(r.MenuItem,{dense:!0,onClick:()=>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"})]}),l&&y&&e.jsx(r.Button,{onClick:D,startIcon:e.jsx(z.StarBorder,{sx:{fontSize:16}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:S=>T(S.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:S=>T(S.palette.warning.main,.06)}},children:"Add to Favorites"}),l&&x&&e.jsx(r.Button,{onClick:v,startIcon:e.jsx(z.Star,{sx:{fontSize:16,color:"warning.main"}}),size:"small",variant:"outlined",sx:{fontSize:"0.875rem",px:2,py:.625,borderRadius:"18px",borderColor:S=>T(S.palette.warning.main,.5),color:"warning.dark","&:hover":{borderColor:"warning.main",bgcolor:S=>T(S.palette.warning.main,.06)}},children:"Remove from Favorites"})]})]})})}const zd={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 To(t,o){const n=zd[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:T(i.main,t.palette.mode==="dark"?.24:.12),color:t.palette.mode==="dark"?i.light:i.dark}}function Bd(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 Dd={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 Ed(t,o){const n=Dd[o];return n?t.palette[n.hue][n.shade]:t.palette.text.secondary}function We(t){return T(t.palette.primary.main,t.palette.mode==="dark"?.24:.12)}function Od(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=>To(n,o).bg,color:n=>To(n,o).color,whiteSpace:"nowrap",lineHeight:1.5},children:t})}function $d(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 Od(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return e.jsx(r.Box,{component:"span",sx:d=>{const l=Bd(d,s);return l?{color:l,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 Ad(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 _d({row:t,rowIndex:o,visibleColumns:n,isSelected:i,isFavorite:s,isReadOnly:d,onToggleSelection:l,onToggleFavorite:c,onView:u,onEdit:h,onDuplicate:m,onDelete:b}){const[x,y]=p.useState(null),[D,v]=p.useState(!1),{primaryCol:C,idCol:S,bodyColumns:I}=p.useMemo(()=>Ad(n),[n]),f=C?t[C.name]:null,k=S?t[S.name]:null,j=D||i||s||!!x;return e.jsxs(r.Box,{onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),onClick:()=>l(o),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":a=>T(a.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?a=>`0 0 0 3px ${T(a.palette.primary.main,.15)}, 0 2px 8px ${T(a.palette.common.black,.08)}`:D?a=>te(a,"cardHover"):a=>te(a,"cardRest"),transform:D&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:a=>T(a.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:f!=null&&f!==""?String(f):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:[I.map(a=>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(a.name)}),e.jsx(r.Box,{sx:{flex:1,lineHeight:1},children:$d(a,t[a.name])})]},a.name)),I.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:a=>T(a.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:k?.85:0,userSelect:"none"},children:k?String(k):" "}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:j?1:0,transition:"opacity 0.15s ease"},onClick:a=>a.stopPropagation(),children:[c&&e.jsx(r.Tooltip,{title:s?"Remove from favorites":"Add to favorites",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:a=>{a.stopPropagation(),c(t)},sx:{width:28,height:28,color:s?"warning.main":"action.disabled","&:hover":{bgcolor:a=>T(a.palette.warning.main,.1),color:"warning.main"}},children:s?e.jsx(z.Star,{sx:{fontSize:17}}):e.jsx(z.StarBorder,{sx:{fontSize:17}})})}),e.jsx(r.Tooltip,{title:"More actions",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:a=>{a.stopPropagation(),y(a.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:a=>T(a.palette.text.primary,.08)}},children:e.jsx(z.MoreVert,{sx:{fontSize:17}})})})]})]}),e.jsxs(r.Popover,{open:!!x,anchorEl:x,onClose:()=>y(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:a=>te(a,"popover")}},onClick:a=>a.stopPropagation(),children:[e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{u(t),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(z.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),!d&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{h(t,o),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(z.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),!d&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{m(o,t),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[e.jsx(z.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Duplicate"})]}),!d&&e.jsxs(e.Fragment,{children:[e.jsx(r.Divider,{sx:{my:.5,mx:.5}}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{b(o,t),y(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[e.jsx(z.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function Md({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=>T(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[t.isCollapsed?e.jsx(z.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):e.jsx(z.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Ii(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=>T(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])=>Ti(d)).filter(Boolean).join(" • ")})]})}function Rd({data:t,visibleColumns:o,grouping:n,selectedRowIds:i,resolvedFavoritesSet:s,isReadOnly:d,isGrouped:l,sortStack:c=[],onSort:u,onToggleRowSelection:h,onToggleRowFavorite:m,onToggleGroupCollapse:b,onViewRow:x,onEditRow:y,onDuplicateRow:D,onDeleteRow:v}){const C=p.useMemo(()=>{const S=new Set;return i.forEach(I=>{const f=I==null?void 0:I.__urm_row_id__;f!==void 0&&S.add(f)}),S},[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:S=>S.typography.fontFamily},children:[u&&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(S=>{const I=c.find(f=>f.column===S.name);return e.jsxs(r.Box,{onClick:()=>u(S.name),sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.25,py:.375,borderRadius:"6px",border:"1px solid",borderColor:I?"primary.main":"divider",bgcolor:I?f=>T(f.palette.primary.main,.07):"transparent",cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:"primary.light",bgcolor:f=>T(f.palette.primary.main,.05)}},children:[e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",fontWeight:I?600:400,color:I?"primary.main":"text.secondary",whiteSpace:"nowrap"},children:Qe(S.name)}),I?I.direction==="asc"?e.jsx(z.ArrowUpward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(z.ArrowDownward,{sx:{fontSize:12,color:"primary.main"}}):e.jsx(z.SwapVert,{sx:{fontSize:12,color:"text.disabled"}})]},S.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((S,I)=>l&&S.isGroupHeader?e.jsx(Md,{row:S,grouping:n,onToggleCollapse:b||(()=>{})},`group-${S.groupKey}`):e.jsx(_d,{row:S,rowIndex:I,visibleColumns:o,isSelected:C.has(S==null?void 0:S.__urm_row_id__),isFavorite:s.has(S),isReadOnly:d,onToggleSelection:()=>h(S),onToggleFavorite:m,onView:x,onEdit:y,onDuplicate:D,onDelete:v},`card-${I}`))})]})}const ci=[10,15,25,50,100];function Wd(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 Pd({currentPage:t,pageSize:o,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:d}){var M;const c=At().palette,u=Math.ceil(n/o),[h,m]=p.useState(String(t)),[b,x]=p.useState(null),[y,D]=p.useState(!1),v=p.useRef(null);p.useEffect(()=>{y||(m(String(t)),x(null))},[t,y]);const C=p.useCallback(()=>{const W=Wd(h,u);if(W){x(W);return}const V=parseInt(h.trim(),10);x(null),D(!1),V!==t&&s(V)},[h,u,t,s]),S=p.useCallback(W=>{var V;W.key==="Enter"?(W.preventDefault(),C()):W.key==="Escape"&&(m(String(t)),x(null),D(!1),(V=v.current)==null||V.blur())},[C,t]),I=p.useCallback(()=>{m(String(t)),x(null),D(!1)},[t]),f=p.useCallback(()=>{D(!0),x(null),setTimeout(()=>{var W;return(W=v.current)==null?void 0:W.select()},0)},[]);if(n<=Math.min(...ci))return null;const k=()=>{m(String(t)),x(null),D(!1)},j=()=>{k(),s(1)},a=()=>{k(),t>1&&s(t-1)},B=()=>{k(),t<u&&s(t+1)},R=()=>{k(),s(u)},J=(t-1)*o+1,K=Math.min(t*o,n),ee=`${Math.max(2,String(u).length+.5)}ch`,g={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:ci.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:[J,"–",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:[b&&e.jsx(r.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:T(c.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${T(((M=c.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:T(c.error.main,.4)}},children:e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:500,color:"error.main",lineHeight:1.3},children:b})}),e.jsx(r.InputBase,{inputRef:v,value:h,onChange:W=>{m(W.target.value),b&&x(null)},onKeyDown:S,onFocus:f,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:b?"error.main":"text.primary",border:"1px solid",borderColor:b?"error.main":y?"primary.main":"divider",borderRadius:"4px",bgcolor:b?T(c.error.main,.04):y?T(c.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:b?"error.main":"text.secondary"},"&:focus-within":{boxShadow:b?`0 0 0 2px ${T(c.error.main,.2)}`:`0 0 0 2px ${T(c.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:j,disabled:t===1,size:"small",title:"First page",sx:g,children:e.jsx(z.FirstPage,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:a,disabled:t===1,size:"small",title:"Previous page",sx:g,children:e.jsx(z.ChevronLeft,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:B,disabled:t===u,size:"small",title:"Next page",sx:g,children:e.jsx(z.ChevronRight,{sx:{fontSize:20}})}),e.jsx(r.IconButton,{onClick:R,disabled:t===u,size:"small",title:"Last page",sx:g,children:e.jsx(z.LastPage,{sx:{fontSize:20}})})]})]})]})}function Nd(){return e.jsx(r.Chip,{icon:e.jsx(z.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const Zi="urm_hint_seen_";function Ld(t){try{return localStorage.getItem(Zi+t)==="true"}catch{return!1}}function Fd(t){try{localStorage.setItem(Zi+t,"true")}catch{}}function di(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 ui(t){const o={fontSize:11};switch(t){case"number":return e.jsx(z.Numbers,{sx:o});case"boolean":return e.jsx(z.CheckBox,{sx:o});case"array":return e.jsx(z.DataArray,{sx:o});case"object":return e.jsx(z.DataObject,{sx:o});default:return e.jsx(z.TextFields,{sx:o})}}function pi(t,o){var n,i;switch(t){case"number":return{bg:T(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:T(((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:T(o.secondary.main,.08),color:o.secondary.main};default:return{bg:T(o.text.secondary,.07),color:o.text.secondary}}}function Vd({open:t,onClose:o,row:n,schema:i,reportName:s}){var b,x;const d=At(),l=d.palette;if(!n)return null;const c=i.filter(y=>y.name in n),u=c.filter(y=>y.type!=="object"&&y.type!=="array"),h=c.filter(y=>y.type==="object"||y.type==="array"),m=c.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 ${T(((b=l.common)==null?void 0:b.black)??"#000",.14)}, 0 2px 8px ${T(((x=l.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:T(l.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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(z.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:0,overflowY:"auto",flex:1,bgcolor:T(l.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:h.length>0?1.5:2,borderRadius:"12px",overflow:"hidden",border:"1px solid",borderColor:"divider"},children:u.map((y,D)=>{const v=n[y.name],C=di(v,y.type),S=!C,I=pi(y.type,l),f=D===u.length-1&&u.length%2!==0;return e.jsxs(r.Box,{sx:{bgcolor:"background.paper",px:2,py:1.75,gridColumn:f?"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:ui(y.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(y.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:S?400:500,color:S?"text.disabled":"text.primary",fontStyle:S?"italic":"normal",lineHeight:1.5,wordBreak:"break-word",fontFamily:y.type==="number"?'"Roboto Mono", monospace':"inherit"},children:S?"No value":C})]},y.name)})}),h.map(y=>{const D=n[y.name],v=di(D,y.type),C=!v,S=pi(y.type,l);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:S.bg,color:S.color},children:ui(y.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Qe(y.name)}),e.jsx(r.Chip,{label:y.type,size:"small",sx:{height:18,fontSize:"0.625rem",fontWeight:600,ml:"auto",bgcolor:S.bg,color:S.color,border:"none",letterSpacing:"0.03em"}})]}),e.jsx(r.Box,{component:"pre",sx:{m:0,px:2,py:1.5,bgcolor:T(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:C?"text.disabled":"text.primary",fontStyle:C?"italic":"normal",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6},children:C?"No value":v})]},y.name)}),c.length===0&&e.jsxs(r.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[e.jsx(z.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:y=>`${y.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function Hd({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=>T(s.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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(z.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=>T(s.palette.error.main,.1),border:s=>`1px solid ${T(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(z.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 tn(t){const o={fontSize:11};switch(t){case"number":return e.jsx(z.Numbers,{sx:o});case"boolean":return e.jsx(z.CheckBox,{sx:o});case"array":return e.jsx(z.DataArray,{sx:o});case"object":return e.jsx(z.DataObject,{sx:o});default:return e.jsx(z.TextFields,{sx:o})}}function xi(t,o){var n,i;switch(t){case"number":return{bg:T(o.primary.main,.08),color:o.primary.main};case"boolean":return{bg:T(((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:T(o.secondary.main,.08),color:o.secondary.main};default:return{bg:T(o.text.secondary,.07),color:o.text.secondary}}}function Ud({open:t,onClose:o,onSave:n,row:i,schema:s,reportName:d}){var C,S,I;const l=At(),c=l.palette,[u,h]=p.useState({});if(p.useEffect(()=>{t&&i&&h({...i})},[t,i]),!i)return null;const m=s.filter(f=>f.name in i),b=m.filter(f=>f.type!=="object"&&f.type!=="array"),x=m.filter(f=>f.type==="object"||f.type==="array"),y=(f,k)=>{h(j=>({...j,[f]:k}))},D=()=>{const f={...u};m.forEach(k=>{const j=u[k.name];if(k.type==="number"){const a=Number(j);f[k.name]=isNaN(a)?i[k.name]:a}else k.type==="boolean"&&(f[k.name]=!!j)}),n(f),o()},v=m.length;return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Me(l),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${T(((C=c.common)==null?void 0:C.black)??"#000",.14)}, 0 2px 8px ${T(((S=c.common)==null?void 0:S.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:T(((I=c.warning)==null?void 0:I.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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," · ",v," ",v===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(z.Close,{sx:{fontSize:18}})})]}),e.jsx(r.Divider,{}),e.jsxs(r.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:T(c.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[b.length>0&&e.jsxs(r.Box,{children:[b.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:b.map((f,k)=>{const j=u[f.name],a=xi(f.type,c),B=f.type==="boolean",R=!B&&k===b.filter(K=>K.type!=="boolean").length-1&&b.filter(K=>K.type!=="boolean").length%2!==0,J=B||R;return f.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(f.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em"},children:Qe(f.name)})]}),e.jsx(r.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",ml:.25},children:j?"Enabled":"Disabled"})]}),e.jsx(r.Switch,{checked:!!j,onChange:K=>y(f.name,K.target.checked),size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"primary.main"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"primary.main"}}})]},f.name):e.jsxs(r.Box,{sx:{gridColumn:J?"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 ${T(c.primary.main,.12)}`}},children:[e.jsxs(r.Box,{sx:{px:1.5,py:.875,borderBottom:"1px solid",borderColor:"divider",bgcolor:T(c.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(f.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(f.name)})]}),e.jsx(r.TextField,{value:j??"",onChange:K=>y(f.name,K.target.value),type:f.type==="number"?"number":"text",size:"small",fullWidth:!0,variant:"standard",placeholder:`Enter ${f.type==="number"?"number":"value"}…`,InputProps:{disableUnderline:!0},sx:{"& .MuiInputBase-root":{px:1.5,py:1,fontSize:"0.875rem",fontWeight:500,color:"text.primary",fontFamily:f.type==="number"?'"Roboto Mono", monospace':"inherit"},"& .MuiInputBase-input":{p:0,"&::placeholder":{color:"text.disabled",opacity:1,fontWeight:400}}}})]},f.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(z.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:x.map(f=>{const k=i[f.name];let j="";try{j=k==null?"":JSON.stringify(k,null,2)}catch{j=String(k)}const a=xi(f.type,c);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:T(c.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(f.type)}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.06em",flex:1},children:Qe(f.name)}),e.jsx(r.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:T(c.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:j?"text.primary":"text.disabled",fontStyle:j?"normal":"italic",bgcolor:T(c.text.primary,.015),overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:120,overflowY:"auto"},children:j||"No value"})]},f.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(z.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:f=>`${f.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:D,variant:"contained",startIcon:e.jsx(z.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:f=>`${f.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Dr=176,Yd={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Gd(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=>To(n,o).bg,color:n=>To(n,o).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:t})}function qd(t){const o=t.toLowerCase().trim(),n=Yd[o];return n?e.jsx(r.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:t}):t}function Jd(t){return e.jsx(r.Box,{component:"span",sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.8125rem",fontWeight:400,letterSpacing:"0.04em"},children:t})}function Kd(t,o){const n=t.name.toLowerCase().replace(/[_\s-]/g,""),i=t.name.toLowerCase(),s=o.findIndex(h=>h.name===t.name),d=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(n),l=i.includes("name")||i.includes("task")||i.includes("title")||i.includes("label")||i.includes("subject")||i.includes("description")||i.includes("filename"),c=i.includes("assignee")||i.includes("assigned")||i.includes("owner")||i.includes("author")||i.includes("creator")||i.includes("member")||i.includes("contact")||i.includes("recipient")||i.includes("sender"),u=s===0&&t.type!=="boolean"&&!i.includes("status")&&!i.includes("state");return d||l&&!c||u&&!c}function es(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,l)=>d.toLowerCase()===n.toLowerCase()?e.jsx(r.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:d},l):d)}function Xd(t,o=""){return e.jsx(r.Box,{component:"span",sx:{fontWeight:700,color:"text.primary",fontSize:"inherit"},children:es(t,o)})}function Qd(t,o,n=!1,i,s=""){if(o==null||o==="")return e.jsx(r.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const d=String(o),l=t.name.toLowerCase().replace(/[_\s-]/g,""),c=/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(t.name.toLowerCase());if(c)return Gd(d);const u=/\b(priority|severity|urgency|importance|criticality)\b/.test(t.name.toLowerCase());if(u)return qd(d);const h=/(\bid\b|id$|_id$|code$|ref$|no$|num$)/.test(l)||/^[A-Z]{2,8}-\d{2,}$/.test(d);if(h)return Jd(d);if(n&&!c&&!u&&!h)return Xd(d,s);if(t.type==="date"){const m=t.dateFormat??"iso",b=ea(o,m,i??null);return e.jsx(r.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:b})}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 m=o.slice(0,3).map(b=>typeof b=="object"?JSON.stringify(b):String(b)).join(", ");return e.jsxs(r.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[m,o.length>3?` +${o.length-3} more`:""]})}if(typeof o=="object"){const m=JSON.stringify(o);return e.jsx(r.Box,{component:"span",title:m,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:m.length>40?m.slice(0,40)+"…":m})}return es(d,s)}function Zd({schema:t,data:o,sortStack:n=[],filters:i=[],views:s=[],activeViewId:d="",isDirty:l=!1,isExporting:c=!1,columnVisibility:u={},columnOrder:h=[],columnWidths:m={},grouping:b=null,onSort:x,onSortAscending:y,onSortDescending:D,onOpenFilters:v,onOpenSort:C,onOpenFilterForColumn:S,onSelectView:I,onCreateView:f,onManageViews:k,onUpdateCurrentView:j,onSaveAsNewView:a,onToggleDefault:B,onToggleFavorite:R,onRestoreView:J,onPermanentDelete:K,isAdmin:ee=!1,onExport:g,onOpenColumns:M,onUpdateColumnWidth:W,onUpdateColumnOrder:V,onUpdateColumnVisibility:Q,onClearFiltersForColumn:xe,onResetLayout:me,onOpenGroup:L,onGroupByColumn:A,onToggleGroupCollapse:H,onOpenAuditHistory:se,onOpenScheduledReports:G,searchQuery:re,highlightQuery:ae="",searchHistory:ne=[],onAddToSearchHistory:P,onToggleSearchFavourite:ie,onDeleteSearchHistory:pe,selectedRowIds:le=new Set,onSearchChange:ge,onToggleRowSelection:q,onToggleAllRows:_e,onRangeSelection:et,onClearSelection:tt,onExportSelected:_t,currentPage:mr=1,pageSize:Mt=15,totalRowsBeforePagination:Rt=o.length,onPageChange:Wt,onPageSizeChange:pt,isReadOnly:Ve=!1,userRole:qe,reportName:Ue,onEditRow:rt,onDuplicateRow:Je,onDeleteRow:ot,favoriteRowIndices:wt=[],resolvedFavoritesSet:He=new Set,showFavoritesOnly:lt=!1,onToggleRowFavorite:Re,onBulkSetFavorites:Or,showDevPanel:$r=!1,onOpenDevConfig:qt,onToggleFavoritesFilter:hr}){var ao;const[Pt,xt]=p.useState(null),[Nt,fr]=p.useState(0),[kt,Ar]=p.useState(0),[Ye,gr]=p.useState(null),Jt=((ao=ur().dates)==null?void 0:ao.displayFormat)??null,[Ce,Mr]=p.useState(null),[yr,ct]=p.useState(null),[F,Ge]=p.useState(null),[we,Pe]=p.useState(!1),[Rr,Kt]=p.useState(!1),[mt,Xt]=p.useState(null),[Qt,Zt]=p.useState(""),[Wr,Lt]=p.useState(!1),[ze,Z]=p.useState(null),[ht,ke]=p.useState(null),[ye,nt]=p.useState(null),[er,ft]=p.useState(null),[Le,br]=p.useState("list"),[Tt,dt]=p.useState(!1),[It,Pr]=p.useState(()=>!Ld("toolbar_search")),tr=p.useRef(null),rr=p.useRef(null),Ft=p.useCallback(()=>{Fd("toolbar_search"),Pr(!1)},[]);p.useEffect(()=>{if(!It)return;const O=setTimeout(Ft,2e3);return()=>clearTimeout(O)},[It,Ft]);const vr=p.useMemo(()=>{const O=Ye??h;return O.length>0?O.map(X=>t.find(he=>he.name===X)).filter(X=>X!==void 0):t},[Ye,h,t]),Ne=p.useMemo(()=>vr.filter(O=>u[O.name]!==!1),[vr,u]),gt=p.useMemo(()=>t.filter(O=>u[O.name]===!1).length,[t,u]),or=p.useMemo(()=>t.map(O=>O.name),[t]),yt=p.useMemo(()=>h.length===0?!1:JSON.stringify(h)!==JSON.stringify(or),[h,or]),Nr=p.useCallback((O,X)=>{O.preventDefault(),O.stopPropagation(),xt(X),fr(O.clientX),Ar(m[X]||150)},[m]);p.useEffect(()=>{if(!Pt)return;const O=he=>{const Fe=he.clientX-Nt,ue=Math.max(100,Math.min(600,kt+Fe));W==null||W(Pt,ue)},X=()=>{xt(null)};return document.addEventListener("mousemove",O),document.addEventListener("mouseup",X),()=>{document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",X)}},[Pt,Nt,kt,W]);const Lr=p.useCallback(O=>O==null?"-":typeof O=="object"?JSON.stringify(O):typeof O=="boolean"?O?"true":"false":String(O),[]);p.useCallback(O=>{const X=n.find(he=>he.column===O);return X?e.jsxs(r.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[X.direction==="asc"?e.jsx(z.ArrowUpward,{sx:{fontSize:14}}):e.jsx(z.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:X.priority})]}):null},[n]),p.useCallback(O=>i.some(he=>he.column===O)?e.jsx(r.IconButton,{size:"small",onClick:he=>{he.stopPropagation(),S==null||S(O)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:e.jsx(z.FilterList,{sx:{fontSize:14}})}):null,[i,S]);const Vt=p.useCallback(O=>{x&&x(O)},[x]),Fr=p.useCallback((O,X)=>{gr(he=>{const ue=[...he??(h.length>0?h:t.map(Ho=>Ho.name))],[Bt]=ue.splice(O,1);return ue.splice(X,0,Bt),ue})},[h,t]),Vr=p.useCallback(()=>{Ye&&V&&V(Ye),gr(null)},[Ye,V]),nr=p.useCallback(O=>{if(!x)return;const X=n.find(he=>he.column===O);(!X||X.direction!=="asc")&&x(O)},[x,n]),Sr=p.useCallback(O=>{if(!x)return;const X=n.find(he=>he.column===O);X?X.direction==="asc"&&x(O):(x(O),setTimeout(()=>x(O),0))},[x,n]),jr=p.useCallback(O=>{if(!x)return;const X=n.find(he=>he.column===O);X&&(X.direction==="asc"?(x(O),setTimeout(()=>x(O),0)):X.direction==="desc"&&x(O))},[x,n]),Cr=p.useCallback(O=>{Q&&Q(O,!1)},[Q]),ir=(b==null?void 0:b.enabled)&&o.length>0&&o[0]&&"isGroupHeader"in o[0],wr=n.length>0||i.length>0||((b==null?void 0:b.enabled)??!1)||Object.values(u).some(O=>O===!1),de=(mr-1)*Mt,ce=o,De=p.useMemo(()=>{const O=new Set;return le.forEach(X=>{const he=X==null?void 0:X.__urm_row_id__;he!==void 0&&O.add(he)}),O},[le]);p.useEffect(()=>{const O=X=>{!_e||!tt||X.target instanceof HTMLInputElement||X.target instanceof HTMLTextAreaElement||((X.ctrlKey||X.metaKey)&&X.key==="a"&&(X.preventDefault(),_e(!0,ce)),X.key==="Escape"&&(X.preventDefault(),tt()))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[_e,tt,ce]);const ut=p.useCallback((O,X)=>{q&&(X.shiftKey&&Ce!==null?(X.preventDefault(),et&&et(Ce,O,ce)):(q(ce[O]),Mr(O)))},[q,Ce,et,ce]);!p.useMemo(()=>ce.length>0&&De.size>0&&ce.every(O=>De.has(O==null?void 0:O.__urm_row_id__)),[ce,De])&&ce.some(O=>De.has(O==null?void 0:O.__urm_row_id__));const zt=q&&_e,Hr=p.useCallback(O=>{var Fe;const X=O.groupLevel,he=X*24;return e.jsx(r.TableRow,{onClick:()=>H==null?void 0:H(O.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:e.jsx(r.TableCell,{colSpan:Ne.length+(zt?1:0),sx:{pl:`${he+24}px`},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[O.isCollapsed?e.jsx(z.ChevronRight,{sx:{fontSize:16}}):e.jsx(z.KeyboardArrowDown,{sx:{fontSize:16}}),e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600},children:Ii(X,((Fe=b==null?void 0:b.levels[X])==null?void 0:Fe.column)||"",O.groupValue)}),e.jsxs(r.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:ue=>T(ue.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[O.rowCount," ",O.rowCount===1?"row":"rows"]}),Object.keys(O.aggregates).length>0&&e.jsx(r.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(O.aggregates).map(([ue,Bt])=>Ti(Bt)).filter(Boolean).join(" • ")})]})})},O.groupKey)},[Ne,zt,b,H]),Ht=p.useCallback((O,X)=>{const he=De.has(O==null?void 0:O.__urm_row_id__),Fe=yr===X;return e.jsxs(r.TableRow,{"data-row-index":X,onMouseEnter:()=>ct(X),onMouseLeave:()=>ct(null),onClick:ue=>{!q||ue.target.closest("[data-row-action-btn]")||ut(X,ue)},onContextMenu:ue=>{ue.preventDefault(),ue.stopPropagation(),nt({mouseX:ue.clientX,mouseY:ue.clientY,row:O,rowIndex:X})},sx:{height:34,cursor:"pointer",bgcolor:he?ue=>T(ue.palette.warning.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:he?ue=>T(ue.palette.warning.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[Ne.map((ue,Bt)=>e.jsx(r.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,textAlign:"left",...Bt===Ne.length-1&&{pr:`${Re?76:40}px`},fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"1px solid",borderColor:"divider",minWidth:m[ue.name]?`${m[ue.name]}px`:`${ue.type==="date"?Math.max(Dr,180):Dr}px`},children:Qd(ue,O[ue.name],Kd(ue,Ne),Jt,ae)},ue.name)),e.jsx(r.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:Re?76:40,minWidth:Re?76:40,maxWidth:Re?76:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",background:Fe||He.has(O)?ue=>`linear-gradient(to right, transparent, ${he?T(ue.palette.warning.main,.12):ue.palette.background.paper} 32px)`:"transparent",opacity:Fe||He.has(O)?1:0,transition:"opacity 0.12s ease, background 0.12s ease",zIndex:10,verticalAlign:"middle"},children:e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",height:"100%",px:1,gap:.25},children:[Re&&e.jsx(r.IconButton,{"data-row-action-btn":"true",size:"small",onClick:ue=>{ue.stopPropagation(),ue.preventDefault(),Re(O)},title:He.has(O)?"Remove from favorites":"Add to favorites",sx:{color:He.has(O)?"warning.main":"text.secondary","&:hover":{bgcolor:ue=>T(ue.palette.warning.main,.08),color:"warning.main"}},children:He.has(O)?e.jsx(z.Star,{sx:{fontSize:18}}):e.jsx(z.StarBorder,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{"data-row-action-btn":"true",size:"small",onClick:ue=>{ue.stopPropagation(),ue.preventDefault(),nt({anchorEl:ue.currentTarget,row:O,rowIndex:X})},sx:{color:"text.secondary",opacity:Fe?1:0,transition:"opacity 0.12s ease",pointerEvents:Fe?"auto":"none","&:hover":{bgcolor:ue=>T(ue.palette.text.primary,.08),color:"text.primary"}},children:e.jsx(z.MoreVert,{sx:{fontSize:18}})})]})})]},X)},[le,de,yr,ut,Ne,m,ae,Lr,rt,Je,ot,q,Re,He,Ge,Pe,nt]);return e.jsxs(Ot.DndProvider,{backend:an.HTML5Backend,children:[e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[zt&&_t&&tt&&e.jsx(Id,{selectedCount:De.size,selectedRowIds:le,resolvedFavoritesSet:He,viewMode:Le,onExportSelected:_t,onClearSelection:tt,onBulkSetFavorites:Or}),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(Nd,{}),ge&&P&&ie&&pe&&e.jsx(r.Tooltip,{open:It,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:Ft},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(jd,{value:re||"",onChange:O=>{It&&Ft(),ge(O)},searchHistory:ne,onAddToHistory:P,onToggleFavourite:ie,onDeleteHistory:pe,disabled:Ve})})}),e.jsx(r.Tooltip,{title:"JSON format guide",children:e.jsx(r.IconButton,{size:"small",onClick:()=>dt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:O=>T(O.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(z.InfoOutlined,{sx:{fontSize:20}})})}),hr&&e.jsx(r.Tooltip,{title:lt?"Show all data":"Show favorites only",children:e.jsxs(r.IconButton,{onClick:hr,size:"small",disabled:Ve,sx:{position:"relative",color:lt?"warning.main":"text.secondary",bgcolor:lt?O=>T(O.palette.warning.main,.12):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:lt?O=>T(O.palette.warning.main,.2):O=>T(O.palette.text.primary,.06),color:lt?"warning.main":"text.primary"},"&.Mui-disabled":{color:"action.disabled"}},children:[lt?e.jsx(z.Star,{sx:{fontSize:20}}):e.jsx(z.StarBorder,{sx:{fontSize:20}}),lt&&wt.length>0&&e.jsx(r.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"warning.main",color:"warning.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:wt.length})]})}),$r&&qt&&e.jsx(r.Tooltip,{title:"Developer configuration",children:e.jsx(r.IconButton,{size:"small",onClick:qt,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:O=>T(O.palette.text.secondary,.3),"&:hover":{bgcolor:O=>T(O.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:e.jsx(z.DisplaySettings,{sx:{fontSize:20}})})}),e.jsx(r.Box,{sx:{flexGrow:1}}),I&&f&&k&&j&&s.length>0&&e.jsx(Cd,{views:s||[],activeViewId:d||"",isDirty:l,onSelectView:I,onCreateView:f,onManageViews:k,onToggleDefault:B,onToggleFavorite:R,onRestoreView:J,onPermanentDelete:K,isAdmin:ee,isReadOnly:Ve}),!Ve&&C&&e.jsx(r.Tooltip,{title:"Sort",children:e.jsxs(r.IconButton,{onClick:C,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?O=>We(O):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[e.jsx(z.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&&v&&e.jsx(r.Tooltip,{title:"Filter",children:e.jsxs(r.IconButton,{onClick:v,size:"small",sx:{position:"relative",color:i.length>0?"primary.main":"text.secondary",bgcolor:i.length>0?O=>We(O):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:i.length>0?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:i.length>0?"primary.main":"text.primary"}},children:[e.jsx(z.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:"Columns",children:e.jsxs(r.IconButton,{onClick:M,size:"small",sx:{position:"relative",color:gt>0||yt?"primary.main":"text.secondary",bgcolor:gt>0||yt?O=>We(O):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:gt>0||yt?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:gt>0||yt?"primary.main":"text.primary"}},children:[e.jsx(z.ViewColumn,{sx:{fontSize:20}}),gt>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:gt})]})}),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:()=>br("list"),sx:{borderRadius:1,color:Le==="list"?"primary.main":"text.secondary",bgcolor:Le==="list"?O=>We(O):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="list"?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:Le==="list"?"primary.main":"text.primary"}},children:e.jsx(z.TableRows,{sx:{fontSize:20}})})}),e.jsx(r.Tooltip,{title:"Grid view",children:e.jsx(r.IconButton,{size:"small",onClick:()=>br("grid"),sx:{borderRadius:1,color:Le==="grid"?"primary.main":"text.secondary",bgcolor:Le==="grid"?O=>We(O):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Le==="grid"?O=>T(O.palette.primary.main,.2):O=>T(O.palette.text.primary,.06),color:Le==="grid"?"primary.main":"text.primary"}},children:e.jsx(z.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:O=>ft(O.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:O=>T(O.palette.text.primary,.06),color:"text.primary"}},children:e.jsx(z.Settings,{sx:{fontSize:20}})})})]}),e.jsxs(r.Popover,{open:!!er,anchorEl:er,onClose:()=>ft(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:[g&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{g(),ft(null)},disabled:c,sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.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(),ft(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Layers,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Grouping"})]}),se&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{se(),ft(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.History,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Audit History"})]}),G&&e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{G(),ft(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.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(Rd,{data:ce,visibleColumns:Ne,grouping:b,selectedRowIds:le,resolvedFavoritesSet:He,isReadOnly:Ve,isGrouped:!!ir,sortStack:n,onSort:x,onToggleRowSelection:q||(()=>{}),onToggleRowFavorite:Re,onToggleGroupCollapse:H,onViewRow:O=>{Ge(O),Pe(!0)},onEditRow:(O,X)=>{Z(O),ke(X),Lt(!0)},onDuplicateRow:(O,X)=>Je==null?void 0:Je(O,X),onDeleteRow:(O,X)=>{Xt(X);const he=Object.values(X).find(Fe=>Fe!=null&&Fe!=="");Zt(he?String(he):""),Kt(!0)}})}),Le==="list"&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[e.jsx(r.Box,{ref:tr,onScroll:O=>{rr.current&&(rr.current.scrollLeft=O.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:`${Ne.reduce((O,X)=>O+(m[X.name]||(X.type==="date"?180:Dr)),Re?76:40)}px`},children:[e.jsxs("colgroup",{children:[Ne.map(O=>e.jsx("col",{style:{width:`${m[O.name]||(O.type==="date"?180:Dr)}px`}},O.name)),e.jsx("col",{style:{width:`${Re?76:40}px`}})]}),e.jsx(r.TableHead,{children:e.jsxs(r.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[Ne.map((O,X)=>e.jsx(Td,{column:O,index:X,sortRule:n.find(he=>he.column===O.name),hasFilters:i.some(he=>he.column===O.name),isInSortStack:n.some(he=>he.column===O.name),isReadOnly:Ve,hasModifications:wr,width:m[O.name],onColumnClick:Vt,onMoveColumn:Fr,onColumnDragEnd:Vr,onResizeStart:Nr,onSortAscending:y||nr,onSortDescending:D||Sr,onRemoveSort:jr,onOpenFilterForColumn:S||(()=>{}),onClearFiltersForColumn:xe||(()=>{}),onGroupByColumn:A,onHideColumn:Cr,onManageColumns:M||(()=>{}),onManageViews:k,onResetLayout:me},O.name)),e.jsx(r.TableCell,{sx:{width:Re?76:40,minWidth:Re?76:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}})]})})]})}),e.jsx(r.Box,{ref:rr,onScroll:O=>{tr.current&&(tr.current.scrollLeft=O.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:O=>O.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:O=>O.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:`${Ne.reduce((O,X)=>O+(m[X.name]||(X.type==="date"?180:Dr)),Re?76:40)}px`},children:[e.jsxs("colgroup",{children:[Ne.map(O=>e.jsx("col",{style:{width:`${m[O.name]||(O.type==="date"?180:Dr)}px`}},O.name)),e.jsx("col",{style:{width:`${Re?76:40}px`}})]}),e.jsx(r.TableBody,{children:ce.length===0?e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:Ne.length+(zt?1:0),align:"center",sx:{py:4},children:e.jsx(r.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):ir?ce.map((O,X)=>O.isGroupHeader?Hr(O):Ht(O,X)):ce.map((O,X)=>Ht(O,X))})]})})]}),Wt&&pt&&e.jsx(Pd,{currentPage:mr,pageSize:Mt,totalRows:Rt,totalFields:t.length,onPageChange:Wt,onPageSizeChange:pt}),!(Wt&&pt)&&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 ",ce.length," ",ce.length===1?"row":"rows"]})})]})]}),e.jsxs(r.Popover,{open:!!ye,onClose:()=>nt(null),anchorEl:(ye==null?void 0:ye.anchorEl)||null,anchorReference:ye!=null&&ye.anchorEl?"anchorEl":"anchorPosition",anchorPosition:ye&&!ye.anchorEl?{top:ye.mouseY,left:ye.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:ye!=null&&ye.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:()=>{ye&&(Ge(ye.row),Pe(!0)),nt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"View"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{ye&&(Z(ye.row),ke(ye.rowIndex),Lt(!0)),nt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.Edit,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(r.Typography,{variant:"body2",children:"Edit"})]}),e.jsxs(r.MenuItem,{dense:!0,onClick:()=>{ye&&(Je==null||Je(ye.rowIndex,ye.row)),nt(null)},sx:{py:1,px:2,gap:1.5},children:[e.jsx(z.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(ye){Xt(ye.row);const O=Object.values(ye.row).find(X=>X!=null&&X!=="");Zt(O?String(O):""),Kt(!0)}nt(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[e.jsx(z.Delete,{sx:{fontSize:18,color:"error.main"}}),e.jsx(r.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),e.jsx(Vd,{open:we,onClose:()=>{Pe(!1),Ge(null)},row:F,schema:t,reportName:Ue}),e.jsx(Ud,{open:Wr,onClose:()=>{Lt(!1),Z(null),ke(null)},onSave:O=>{ht!==null&&(rt==null||rt(ht,O))},row:ze,schema:t,reportName:Ue}),e.jsx(Hd,{open:Rr,onClose:()=>{Kt(!1),Xt(null)},onConfirm:()=>{mt!==null&&(ot==null||ot(mt))},rowPreview:Qt}),e.jsx(Xi,{isOpen:Tt,onClose:()=>dt(!1)})]})}function pr({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=>T(s.palette.primary.main,.08)}},children:e.jsx(z.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=>T(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=>T(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>T(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 xr={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 eu({schema:t,filters:o,onAddFilter:n,onRemoveFilter:i,onUpdateFilter:s,onClearAll:d,onReplaceFilters:l,onClose:c,focusColumn:u}){const[h,m]=p.useState(""),[b,x]=p.useState(""),[y,D]=p.useState(""),[v,C]=p.useState([]),S=ur();p.useEffect(()=>{C([...o])},[o]),p.useEffect(()=>{u&&m(u)},[u]);const I=p.useCallback(()=>{m(""),x(""),D("")},[]),f=p.useMemo(()=>t.filter(M=>M.type!=="mixed"&&M.type!=="null"&&M.type!=="array"&&M.type!=="object"),[t]),k=t.find(M=>M.name===h),j=p.useMemo(()=>{const M=k?$n(k.type):[],W=S.filter.allowedOperators;return W.length>0?M.filter(V=>W.includes(V.value)):M},[k]),a=p.useCallback(()=>!(!h||!b||uo(b)&&!y.trim()||v.length>=S.filter.maxConditions),[h,b,y,v,S]),B=p.useCallback(()=>{if(!a())return;const M={column:h,operator:b};if(uo(b)){const V=k==null?void 0:k.type;M.value=V==="number"?Number(y):y}if(v.some(V=>V.column===M.column&&V.operator===M.operator&&V.value===M.value)){I();return}C([...v,M]),I()},[a,h,b,k,y,v,I]),R=p.useCallback(M=>{C(v.filter((W,V)=>V!==M))},[v]),J=p.useMemo(()=>v.length!==o.length?!0:JSON.stringify(v)!==JSON.stringify(o),[v,o]),K=p.useCallback(()=>{l(v),c()},[v,l,c]),ee=p.useCallback(()=>{C([...o]),I(),c()},[o,I,c]),g=p.useCallback(M=>{var xe;const W=t.find(me=>me.name===M.column);if(!W)return"";const Q=((xe=$n(W.type).find(me=>me.value===M.operator))==null?void 0:xe.label)||M.operator;return uo(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=>T(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(pr,{content:xr.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(z.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=>T(M.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:M=>T(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:v.length>=S.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:h,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:f.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=>We(W),"&:hover":{bgcolor:W=>T(W.palette.primary.main,.2)}}},children:[Qe(M.name)," (",M.type,")"]},M.name))})]}),h&&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:b,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:j.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=>We(W),"&:hover":{bgcolor:W=>T(W.palette.primary.main,.2)}}},children:M.label},M.value))})]}),b&&uo(b)&&e.jsx(r.TextField,{size:"small",fullWidth:!0,type:(k==null?void 0:k.type)==="number"?"number":"text",value:y,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:B,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"}),v.length>=S.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 ",S.filter.maxConditions," filters allowed. Remove an existing filter to add a new one."]})]}),v.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 (",v.length,")"]}),e.jsx(r.Button,{onClick:()=>{d(),c()},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:v.map((M,W)=>e.jsx(r.Chip,{label:g(M),onDelete:()=>R(W),sx:{bgcolor:V=>We(V),color:"primary.main",fontSize:"0.875rem",fontWeight:400,height:32,borderRadius:"16px",border:V=>`1px solid ${T(V.palette.primary.main,.3)}`,transition:"all 0.2s ease","&:hover":{bgcolor:V=>T(V.palette.primary.main,.2),borderColor:V=>T(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:!J,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 mi="SORT_RULE";function tu({rule:t,index:o,onToggleDirection:n,onRemove:i,onMove:s}){const d=p.useRef(null),[{handlerId:l},c]=Ot.useDrop({accept:mi,collect(m){return{handlerId:m.getHandlerId()}},hover(m,b){var I;if(!d.current)return;const x=m.index,y=o;if(x===y)return;const D=(I=d.current)==null?void 0:I.getBoundingClientRect(),v=(D.bottom-D.top)/2,C=b.getClientOffset(),S=((C==null?void 0:C.y)??0)-D.top;x<y&&S<v||x>y&&S>v||(s(x,y),m.index=y)}}),[{isDragging:u},h]=Ot.useDrag({type:mi,item:()=>({index:o}),collect:m=>({isDragging:m.isDragging()})});return h(c(d)),e.jsxs(r.Box,{ref:d,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity: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 ${T(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=>We(m),"&:hover":{bgcolor:m=>T(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=>We(m),"&:hover":{bgcolor:m=>T(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=>T(m.palette.error.main,.08),transform:"scale(1.1)"}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]})}function ru({schema:t,sortStack:o,onUpdateSortStack:n,onClose:i}){const[s,d]=p.useState(""),[l,c]=p.useState([]);p.useEffect(()=>{c([...o])},[o]);const u=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(o),[l,o]),h=ur(),m=p.useCallback(()=>!(l.length>=h.sort.maxLevels||!s||l.some(f=>f.column===s)),[l,s]),b=p.useCallback(()=>{if(!m())return;const f=l.length+1,k={column:s,direction:"asc",priority:f};c([...l,k]),d("")},[m,s,l]),x=p.useCallback(f=>{const j=l.filter((a,B)=>B!==f).map((a,B)=>({...a,priority:B+1}));c(j)},[l]),y=p.useCallback((f,k)=>{const j=[...l];j[f]={...j[f],direction:k},c(j)},[l]),D=p.useCallback((f,k)=>{const j=[...l],[a]=j.splice(f,1);j.splice(k,0,a);const B=j.map((R,J)=>({...R,priority:J+1}));c(B)},[l]),v=p.useCallback(()=>{n([]),i()},[n,i]),C=p.useCallback(()=>{n(l),i()},[l,n,i]),S=p.useCallback(()=>{c([...o]),d(""),i()},[o,i]),I=t.filter(f=>!l.some(k=>k.column===f.name));return e.jsx(Ot.DndProvider,{backend:an.HTML5Backend,children:e.jsx(r.Box,{onClick:S,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:f=>T(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:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:f=>Me(f),bgcolor:"background.paper",outline:"none",boxShadow:f=>te(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:{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(pr,{content:xr.sort,isDev:process.env.NODE_ENV==="development"})]}),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(z.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:f=>T(f.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:f=>T(f.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:l.length>=h.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:f=>d(f.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(f=>e.jsx(r.MenuItem,{value:f.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:k=>We(k),"&:hover":{bgcolor:k=>T(k.palette.primary.main,.2)}}},children:Qe(f.name)},f.name))})]}),e.jsx(r.Button,{onClick:b,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"}),l.length>=h.sort.maxLevels&&e.jsxs(r.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",h.sort.maxLevels," sort levels allowed"]})]}),l.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 (",l.length,"/",h.sort.maxLevels,")"]}),e.jsx(r.Button,{onClick:v,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:l.map((f,k)=>e.jsx(tu,{rule:f,index:k,onToggleDirection:y,onRemove:x,onMove:D},`${f.column}-${k}`))})]})]}),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:S,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:f=>`${f.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:!u||l.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:f=>`${f.shape.borderRadius}px`,boxShadow:f=>te(f,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:f=>te(f,"hoverButton")},"&:active":{boxShadow:f=>te(f,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}function ou({views:t,activeViewId:o,onSelectView:n,onCreateView:i,onEditView:s,onDeleteView:d,onRestoreView:l,onPermanentDelete:c,onPromoteToGlobal:u,isAdmin:h=!1,onClose:m}){var f,k;const b=At(),x=b.palette,y=t.filter(j=>!j.isDeleted),D=t.filter(j=>j.isDeleted),v=y.filter(j=>j.scope==="global"),C=y.filter(j=>j.scope!=="global"),S=j=>{var K,ee,g,M,W;const a=j.scope==="global",B=j.id===o,R=h||!a,J=h&&!a;return e.jsx(r.Paper,{variant:"outlined",sx:{p:0,overflow:"hidden",borderRadius:"8px",borderColor:B?"primary.main":"divider",bgcolor:B?T(x.primary.main,.03):"background.paper",transition:"border-color 0.15s","&:hover":{borderColor:B?"primary.main":T(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(j.id),m()},children:[e.jsxs(r.Box,{sx:{minWidth:0},children:[e.jsx(r.Typography,{sx:{fontSize:"0.875rem",fontWeight:B?600:500,color:B?"primary.main":"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.name}),j.description&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.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(z.Language,{sx:{fontSize:"11px !important"}}),sx:{height:20,fontSize:"0.625rem",fontWeight:700,letterSpacing:"0.04em",bgcolor:T(((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 ${T(((g=x.info)==null?void 0:g.main)??x.primary.main,.25)}`,"& .MuiChip-label":{px:.625},"& .MuiChip-icon":{ml:.5}}}),j.isDefault&&e.jsx(r.Chip,{label:"Default",size:"small",sx:{height:20,fontSize:"0.625rem",fontWeight:600,bgcolor:T(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:[J&&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(j.id)},sx:{p:.625,color:"text.secondary",borderRadius:"6px","&:hover":{color:((M=x.info)==null?void 0:M.main)??x.primary.main,bgcolor:T(((W=x.info)==null?void 0:W.main)??x.primary.main,.08)}},children:e.jsx(z.Language,{sx:{fontSize:16}})})}),R&&e.jsx(r.Tooltip,{title:a&&!h?"Global Views are read-only":"Edit view",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(r.IconButton,{size:"small",disabled:a&&!h,onClick:V=>{V.stopPropagation(),s(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"primary.main",bgcolor:T(x.primary.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(z.Edit,{sx:{fontSize:15}})})})}),e.jsx(r.Tooltip,{title:a&&!h?"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&&!h,onClick:V=>{V.stopPropagation(),d(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:T(x.error.main,.08)},"&.Mui-disabled":{opacity:.35}},children:e.jsx(z.Delete,{sx:{fontSize:15}})})})})]})]})},j.id)},I=j=>{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:T(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:j.name}),e.jsxs(r.Box,{sx:{display:"flex",gap:.25,flexShrink:0,ml:1},children:[l&&e.jsx(r.Tooltip,{title:"Restore view",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:B=>{B.stopPropagation(),l(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"success.main",bgcolor:T(((a=x.success)==null?void 0:a.main)??"#2e7d32",.08)}},children:e.jsx(z.Undo,{sx:{fontSize:15}})})}),c&&e.jsx(r.Tooltip,{title:"Delete permanently",arrow:!0,children:e.jsx(r.IconButton,{size:"small",onClick:B=>{B.stopPropagation(),c(j.id)},sx:{p:.625,borderRadius:"6px","&:hover":{color:"error.main",bgcolor:T(x.error.main,.08)}},children:e.jsx(z.Delete,{sx:{fontSize:15}})})})]})]},j.id)};return e.jsxs(r.Dialog,{open:!0,onClose:m,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:Me(b),maxHeight:"min(640px, calc(100vh - 80px))",boxShadow:`0 8px 32px ${T(((f=x.common)==null?void 0:f.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"}),h&&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(z.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(z.Add,{sx:{fontSize:16}}),size:"small",sx:{borderRadius:j=>`${j.shape.borderRadius}px`},children:"Create New View"})}),v.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(z.Language,{sx:{fontSize:14,color:((k=x.info)==null?void 0:k.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:v.map(S)})]}),C.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:C.map(S)})]}),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)})]}),y.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:j=>`${j.shape.borderRadius}px`,px:3},children:"Close"})})]})}const fo=50;function hi({currentSnapshot:t,onSave:o,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:d="",initialIsDefault:l=!1,atViewLimit:c=!1,maxViews:u=10}){const[h,m]=p.useState(s),[b,x]=p.useState(!1),[y,D]=p.useState(d),[v,C]=p.useState(l),S=()=>{if(!h.trim()){x(!0);return}if(h.trim().length>fo){x(!0);return}o(h.trim(),y.trim(),v),n()},I=k=>{k.key==="Enter"&&!k.shiftKey?S():k.key==="Escape"&&n()},f=()=>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:k=>Me(k),boxShadow:k=>te(k,"menu")}},children:[e.jsxs(r.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[f(),e.jsx(r.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:e.jsx(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.DialogContent,{children:e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[c&&!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:h,onChange:k=>{k.target.value.length<=fo&&m(k.target.value),b&&k.target.value.trim()&&x(!1)},onKeyDown:I,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:c&&!i,inputProps:{maxLength:fo},error:b&&!h.trim(),helperText:b&&!h.trim()?"View name is required":`${h.length} / ${fo}`}),e.jsx(r.TextField,{label:"Description (optional)",value:y,onChange:k=>D(k.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: ",xa(t.sortStack)]}),e.jsx("li",{children:"Column order & visibility"})]})]}),!i&&e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:v,onChange:k=>C(k.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:k=>`${k.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),e.jsx(r.Button,{onClick:S,variant:"contained",disabled:c&&!i,startIcon:e.jsx(z.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,boxShadow:k=>te(k,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:k=>te(k,"hoverButton")},"&:active":{boxShadow:k=>te(k,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function nu({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(z.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(z.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 yo=100,bo=600,fi="COLUMN";function iu({column:t,index:o,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:d,moveColumn:l}){const c=p.useRef(null),[u,h]=p.useState(i.toString());p.useEffect(()=>{h(i.toString())},[i]);const[{handlerId:m},b]=Ot.useDrop({accept:fi,collect(I){return{handlerId:I.getHandlerId()}},hover(I,f){var K;if(!c.current)return;const k=I.index,j=o;if(k===j)return;const a=(K=c.current)==null?void 0:K.getBoundingClientRect(),B=(a.bottom-a.top)/2,R=f.getClientOffset(),J=((R==null?void 0:R.y)??0)-a.top;k<j&&J<B||k>j&&J>B||(l(k,j),I.index=j)}}),[{isDragging:x},y]=Ot.useDrag({type:fi,item:()=>({index:o}),collect:I=>({isDragging:I.isDragging()})});y(b(c));const D=()=>{const I=parseInt(u);if(isNaN(I)){h(i.toString()),d(t.name,i);return}const f=Math.max(yo,Math.min(bo,I));h(f.toString()),d(t.name,f)},v=I=>{if(I===""||/^\d+$/.test(I)){h(I);const f=parseInt(I);if(!isNaN(f)&&f>=yo){const k=Math.min(bo,f);d(t.name,k)}}},C=I=>{I.key==="Enter"&&(I.preventDefault(),D(),I.target.blur())},S=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:c,"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(z.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:`${S(t.type)}15`,color:S(t.type),border:`1px solid ${S(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=>v(I.target.value),onBlur:D,onKeyDown:C,placeholder:"150",size:"small",inputProps:{min:yo,max:bo,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(z.Visibility,{sx:{fontSize:20}}):e.jsx(z.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=>T(I.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function su({schema:t,columnVisibility:o,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:d="",onUpdateColumnVisibility:l,onUpdateColumnOrder:c,onUpdateColumnWidth:u,onResetLayout:h,onSaveToCurrentView:m,onSaveToAllViews:b,onSelectView:x,onClose:y}){const[D,v]=p.useState(!1),[C,S]=p.useState(n),[I,f]=p.useState(i),[k,j]=p.useState("all"),[a,B]=p.useState(null);p.useEffect(()=>{S(n)},[n]),p.useEffect(()=>{f(i)},[i]);const R=(L,A)=>{f(H=>({...H,[L]:A})),u==null||u(L,A)},J=(L,A)=>{const H=[...C],[se]=H.splice(L,1);H.splice(A,0,se),S(H),c(H)},K=()=>{h(),v(!1)},g=C.map(L=>t.find(A=>A.name===L)).filter(L=>L!==void 0).filter(L=>{const A=o[L.name]??!0;return k==="active"?A:k==="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,me=p.useMemo(()=>{if(!V)return!1;const L=V.snapshot,A=L.columnVisibility??{},H=JSON.stringify(o)!==JSON.stringify(A),se=L.columnOrder??[],G=n??[],re=JSON.stringify(G)!==JSON.stringify(se)&&!(G.length===0&&se.length===0),ae=L.columnWidths??{},ne=JSON.stringify(I)!==JSON.stringify(ae);return H||re||ne},[V,o,n,I]);return e.jsx(Ot.DndProvider,{backend:an.HTML5Backend,children:e.jsx(r.Box,{onClick:y,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:L=>T(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(pr,{content:xr.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=>B(L.currentTarget),variant:"outlined",size:"small",endIcon:e.jsx(z.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:()=>B(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:L=>te(L,"small")}},children:Q.map(L=>e.jsx(r.MenuItem,{onClick:()=>{x(L.id),B(null)},selected:L.id===d,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:A=>We(A),"&:hover":{bgcolor:A=>T(A.palette.primary.main,.2)}}},children:L.name},L.id))})]}),e.jsx(r.IconButton,{onClick:y,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(z.Close,{sx:{fontSize:20}})})]}),e.jsxs(r.Tabs,{value:k,onChange:(L,A)=>j(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=>T(L.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:L=>T(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: ${yo}px, max: ${bo}px)`,arrow:!0,placement:"top",children:e.jsx(z.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:g.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"})})}):g.map((L,A)=>e.jsx(iu,{column:L,index:A,isVisible:o[L.name]??!0,width:I[L.name]||170,onToggleVisibility:l,onWidthChange:R,moveColumn:J},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:()=>v(!0),disabled:!me,variant:"outlined",startIcon:e.jsx(z.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 to default"}),e.jsxs(r.Stack,{direction:"row",spacing:1.25,children:[m&&e.jsx(r.Button,{onClick:()=>{m(I),y()},disabled:!me,variant:"contained",startIcon:e.jsx(z.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"}),b&&xe&&e.jsx(r.Button,{onClick:()=>{b(I),y()},disabled:!me||!xe,variant:"contained",startIcon:e.jsx(z.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:()=>v(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:L=>T(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=>so(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:()=>v(!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 au({schema:t,grouping:o,onApply:n,onClose:i}){var a;const[s,d]=p.useState(o||{enabled:!1,levels:[],collapsedGroups:[]}),[l,c]=p.useState(""),[u,h]=p.useState(null),m=p.useMemo(()=>aa(t),[t]),b=p.useMemo(()=>m.filter(B=>!s.levels.some((R,J)=>R.column===B.name&&J!==u)),[m,s.levels,u]),x=ur(),y=s.levels.length<x.grouping.maxLevels&&b.length>0,D=p.useCallback(()=>{!y||!l||(d({...s,levels:[...s.levels,{column:l}],enabled:!0}),c(""))},[y,l,s]),v=p.useCallback(B=>{const R=s.levels.filter((J,K)=>K!==B);if(R.length===0){n(null),i();return}d({...s,levels:R,enabled:R.length>0})},[s,n,i]),C=p.useCallback(B=>{h(B),c(s.levels[B].column)},[s.levels]),S=p.useCallback(()=>{if(u===null||!l)return;const B=[...s.levels];B[u]={column:l},d({...s,levels:B}),h(null),c("")},[u,l,s]),I=p.useCallback(()=>{h(null),c("")},[]),f=p.useCallback((B,R)=>{const J=R==="up"?B-1:B+1;if(J<0||J>=s.levels.length)return;const K=[...s.levels],[ee]=K.splice(B,1);K.splice(J,0,ee),d({...s,levels:K})},[s]),k=p.useCallback(()=>{n(null),i()},[n,i]),j=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:B=>T(B.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:B=>B.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:B=>B.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:B=>Me(B),bgcolor:"background.paper",outline:"none",boxShadow:B=>te(B,"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(pr,{content:xr.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(z.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:B=>T(B.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:B=>T(B.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:l,onChange:B=>c(B.target.value),disabled:!y,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..."}),b.map(B=>e.jsxs(r.MenuItem,{value:B.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:R=>We(R),"&:hover":{bgcolor:R=>T(R.palette.primary.main,.2)}}},children:[Qe(B.name)," (",B.type.toUpperCase(),")"]},B.name))]})}),e.jsx(r.Button,{onClick:D,disabled:!y||!l,variant:"outlined",startIcon:e.jsx(z.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:B=>`1px solid ${T(B.palette.warning.main,.5)}`,bgcolor:B=>T(B.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:l,onChange:B=>c(B.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:B=>We(B)}},children:[s.levels[u].column," (",(a=t.find(B=>B.name===s.levels[u].column))==null?void 0:a.type.toUpperCase(),")"]}),b.filter(B=>B.name!==s.levels[u].column).map(B=>e.jsxs(r.MenuItem,{value:B.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:R=>We(R)}},children:[Qe(B.name)," (",B.type.toUpperCase(),")"]},B.name))]})}),e.jsxs(r.Stack,{direction:"row",spacing:1.5,children:[e.jsx(r.Button,{onClick:S,disabled:!l,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:B=>te(B,"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:k,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((B,R)=>{const J=t.find(K=>K.name===B.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 ${T(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:B.column}),e.jsx(r.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:J==null?void 0:J.type.toUpperCase()})]}),e.jsxs(r.Stack,{direction:"row",spacing:.5,children:[e.jsx(r.IconButton,{size:"small",onClick:()=>f(R,"up"),disabled:R===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(z.KeyboardArrowUp,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>f(R,"down"),disabled:R===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:e.jsx(z.KeyboardArrowDown,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>C(R),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:e.jsx(z.Edit,{sx:{fontSize:18}})}),e.jsx(r.IconButton,{size:"small",onClick:()=>v(R),sx:{color:"text.secondary","&:hover":{bgcolor:K=>T(K.palette.error.main,.08),color:"error.main"}},children:e.jsx(z.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:B=>`${B.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:s.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:B=>`${B.shape.borderRadius}px`,boxShadow:B=>te(B,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:B=>te(B,"hoverButton")},"&:active":{boxShadow:B=>te(B,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}const lu={filters:z.FilterList,sorting:z.UnfoldMore,visibility:z.Visibility,order:z.ViewColumn,widths:z.Straighten,grouping:z.Layers};function cu({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(z.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=lu[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 du({viewName:t,isDefaultView:o,changes:n=[],onSaveToCurrentView:i,onSaveAsNewView:s,onCancel:d}){const[l,c]=p.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{sx:{width:"100%",flexShrink:0,bgcolor:u=>We(u),borderBottom:u=>`1px solid ${T(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=>T(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"})]})]})}),l&&e.jsx(cu,{changes:n,onClose:()=>c(!1)})]})}function uu({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(z.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:e.jsx(z.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(z.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),e.jsx(r.Button,{onClick:t,variant:"contained",color:"warning",startIcon:e.jsx(z.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const gi=[{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 pu(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 xu(t,o){if(o===null)return[];const n=Date.now()-o;return t.filter(i=>new Date(i.timestamp).getTime()<n)}function mu({auditHistory:t,onClose:o,onClearAuditHistory:n}){var D,v,C,S;const i=At(),s=i.palette,[d,l]=p.useState("1h"),[c,u]=p.useState(!1),h=[...t].sort((I,f)=>new Date(f.timestamp).getTime()-new Date(I.timestamp).getTime()),m=gi.find(I=>I.key===d),b=pu(t,m.ms),x=()=>u(!0),y=()=>{n&&(n(xu(t,m.ms)),u(!1))};return e.jsxs(e.Fragment,{children:[e.jsx(r.Box,{onClick:o,sx:{position:"fixed",inset:0,bgcolor:T(((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 ${T(((v=s.common)==null?void 0:v.black)??"#000",.14)}, 0 2px 8px ${T(((C=s.common)==null?void 0:C.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(pr,{content:xr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),e.jsxs(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:[h.length," event",h.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=>l(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:T(s.text.primary,.3)}},children:gi.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(z.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:x,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:T(s.error.main,.5),"&:hover":{bgcolor:T(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(z.Close,{sx:{fontSize:17}})})]})]}),e.jsx(r.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:T(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:T(s.text.primary,.14),borderRadius:3}},children:h.length===0?e.jsxs(r.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[e.jsx(z.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:h.map(I=>{const f=Ed(i,I.feature),{summary:k,detail:j}=Ta(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:T(s.text.primary,.18)}},children:[e.jsx(r.Chip,{label:Ba(I.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:T(f,.1),color:f,border:`1px solid ${T(f,.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:k}),j&&e.jsx(r.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:j}),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(z.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),e.jsx(r.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:Da(I.timestamp)})]}),I.user&&e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[e.jsx(z.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:c,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:so(i),boxShadow:`0 8px 32px ${T(((S=s.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:T(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.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:[b," audit record",b!==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:y,variant:"contained",color:"error",startIcon:e.jsx(z.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",b," Record",b!==1?"s":""]})]})]})]})}function hu({onSave:t,onClose:o}){const[n,i]=p.useState(""),[s,d]=p.useState(""),[l,c]=p.useState(""),[u,h]=p.useState([]),[m,b]=p.useState(""),[x,y]=p.useState(""),D=j=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j),v=()=>{const j=l.trim();if(j){if(!D(j)){y("Please enter a valid email address");return}if(u.includes(j)){y("This email is already added");return}h([...u,j]),c(""),y("")}},C=j=>{h(u.filter(a=>a!==j))},S=j=>{j.key==="Enter"&&(j.preventDefault(),v())},I=()=>{if(!n.trim()){b("Preset name is required");return}t(n.trim(),s.trim(),u.length>0?u:void 0)},f=j=>{i(j),m&&b("")},k=j=>{c(j),x&&y("")};return e.jsx(r.Box,{onClick:o,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:j=>T(j.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:j=>j.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:j=>j.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:j=>Me(j),bgcolor:"background.paper",outline:"none",boxShadow:j=>te(j,"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(z.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:j=>T(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>T(j.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(z.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:j=>`1px solid ${T(j.palette.primary.main,.3)}`,bgcolor:j=>We(j),"& .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:j=>f(j.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:j=>d(j.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:l,onChange:j=>k(j.target.value),onKeyPress:S,placeholder:"Enter email address",error:!!x,helperText:x,fullWidth:!0,size:"small",InputProps:{startAdornment:e.jsx(z.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:v,variant:"outlined",startIcon:e.jsx(z.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:j=>`${j.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(j=>e.jsx(r.Chip,{label:j,onDelete:()=>C(j),deleteIcon:e.jsx(z.Delete,{sx:{fontSize:16}}),sx:{bgcolor:a=>We(a),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},j))}),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:j=>`${j.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(z.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,boxShadow:j=>te(j,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:j=>te(j,"hoverButton")},"&:active":{boxShadow:j=>te(j,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function fu({presetName:t,onClear:o}){return e.jsx(r.Chip,{icon:e.jsx(z.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(z.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>T(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 gu({presets:t,reportId:o,onOpenPreset:n,onDeletePreset:i,onClose:s}){const d=l=>new Date(l).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:l=>T(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:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, 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:{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(z.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:l=>T(l.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(z.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(l=>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:c=>te(c,"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:l.name}),l.description&&e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:l.description})]})}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[e.jsx(r.Chip,{label:`Created ${d(l.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 ${l.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(l.id,l.name),variant:"outlined",size:"small",startIcon:e.jsx(z.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:c=>`${c.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:c=>T(c.palette.error.main,.04)}},children:"Delete"})})]},l.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: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)"}},children:"Close"})})]})})}const ts={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},yu=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],bu=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function vu(t,o){const n=[];for(const i of t){if(i.type!=="string")continue;const s=bu.some(c=>c.test(i.name));let d=!1;const l=o.slice(0,10).map(c=>c[i.name]).filter(c=>typeof c=="string"&&c.length>0);l.length>0&&(d=l.filter(u=>yu.some(h=>h.test(u))).length/l.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(l=>{const c=n.map(h=>String(h[l]??"")).filter(h=>h.length>0);if(c.length===0)return 5;const u=c.reduce((h,m)=>h+m.length,0);return Math.ceil(u/c.length)+1}).reduce((l,c)=>l+c,0)+1;return o.reduce((l,c)=>l+c.length+1,0)+s*t.length}function Su(t,o){const n=fn(t,o);return Math.ceil(n*3.5)}function ju(t,o){const n=fn(t,o);return Math.ceil(n*.7)}function Cu(t,o,n){switch(t){case"csv":return fn(o,n);case"excel":return ju(o,n);case"json":return Su(o,n)}}function yi(t,o){return Math.ceil(t/o)}function wu(t,o,n,i,s=ts){const d=[],l=Cu(t,o,n),c=o.length;if(c>s.maxRowsHard){const m=yi(c,s.maxRows);d.push({type:"row_count",severity:"error",message:`Export blocked: ${c.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:c,limit:s.maxRowsHard})}else if(c>s.maxRows){const m=yi(c,s.maxRows);d.push({type:"row_count",severity:"warning",message:`Large export: ${c.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:c,limit:s.maxRows})}if(l>s.maxFileSizeHardBytes?d.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${to(l)} exceeds the ${to(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:l,limit:s.maxFileSizeHardBytes}):l>s.maxFileSizeBytes&&d.push({type:"file_size",severity:"warning",message:`Large file: estimated ${to(l)}`,detail:`This exceeds the recommended ${to(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:l,limit:s.maxFileSizeBytes}),t!=="excel"){const m=vu(i.filter(b=>n.includes(b.name)),o);if(m.length>0){const b=m.length>s.maxImageColumns;d.push({type:"image_columns",severity:b?"error":"warning",message:`Image column${m.length>1?"s":""} detected: ${m.map(x=>`"${x.replace(/_/g," ")}"`).join(", ")}`,detail:b?`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"),h=d.some(m=>m.severity==="warning");return{violations:d,hasBlockingViolation:u,hasWarning:h,estimatedBytes:l}}function to(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ku({violation:t}){const n=At().palette,i=t.severity==="error",s=i?n.error.main:n.warning.main,d=T(i?n.error.main:n.warning.main,.06),l=i?T(n.error.main,.25):T(n.warning.main,.3),c=i?z.ErrorOutline:z.WarningAmberOutlined;return e.jsxs(r.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"8px",bgcolor:d,border:"1px solid",borderColor:l},children:[e.jsx(c,{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(z.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 Tu({totalRows:t,visibleRows:o,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:d,sampleRows:l=[],allRows:c=[],processedRows:u=[],onExport:h,onClose:m}){var M,W,V;const b=At(),x=b.palette,y=ur(),[D,v]=p.useState(y.export.allowedFormats[0]||"csv"),[C,S]=p.useState("visible"),[I,f]=p.useState("visible"),k=C==="visible"?o:t,j=I==="visible"?i:s,a=p.useMemo(()=>C==="visible"?u.length>0?u:new Array(o):c.length>0?c:new Array(t),[C,o,t,u,c]),B=p.useMemo(()=>I==="all"?d.map(Q=>Q.name):d.map(Q=>Q.name).slice(0,i),[I,d,i]),R=p.useMemo(()=>wu(D,a,B,d,ts),[D,a,B,d]),J=()=>{R.hasBlockingViolation||(h({format:D,scope:C,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"}},g={color:"text.secondary","&.Mui-checked":{color:"primary.main"},pt:.125};return e.jsx(r.Box,{onClick:m,sx:{position:"fixed",inset:0,bgcolor:T(((M=x.common)==null?void 0:M.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:b.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(b),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${T(((W=x.common)==null?void 0:W.black)??"#000",.14)}, 0 2px 8px ${T(((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(pr,{content:xr.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(z.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:T(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(ku,{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=>v(Q.target.value),children:[y.export.allowedFormats.includes("csv")&&e.jsx(r.FormControlLabel,{value:"csv",control:e.jsx(r.Radio,{size:"small",sx:g}),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}}),y.export.allowedFormats.includes("excel")&&e.jsx(r.FormControlLabel,{value:"excel",control:e.jsx(r.Radio,{size:"small",sx:g}),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}}),y.export.allowedFormats.includes("json")&&e.jsx(r.FormControlLabel,{value:"json",control:e.jsx(r.Radio,{size:"small",sx:g}),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:C,onChange:Q=>S(Q.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:g}),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:g}),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=>f(Q.target.value),children:[e.jsx(r.FormControlLabel,{value:"visible",control:e.jsx(r.Radio,{size:"small",sx:g}),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:g}),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:k.toLocaleString()},{label:"Columns to export",value:String(j)},{label:"Estimated file size",value:to(R.estimatedBytes),highlight:R.hasBlockingViolation?"error.main":R.hasWarning?"warning.main":void 0}].map(({label:Q,value:xe,highlight:me})=>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:me??"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:T(x.text.primary,.015)},children:[R.hasBlockingViolation&&e.jsxs(r.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[e.jsx(z.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:J,disabled:R.hasBlockingViolation,variant:"contained",startIcon:e.jsx(z.Download,{sx:{fontSize:16}}),sx:{fontSize:"0.875rem",px:2.5,borderRadius:"8px"},children:["Download ",K[D]]})]})]})})}function Iu({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(z.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:e.jsx(z.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 zu({error:t,onDismiss:o,autoDismiss:n=!0,autoDismissDelay:i=5e3}){p.useEffect(()=>{if(n){const c=setTimeout(()=>{o()},i);return()=>clearTimeout(c)}},[n,i,o]);const d=(()=>{switch(t.type){case"system":return{severity:"error",icon:e.jsx(z.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:e.jsx(z.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:e.jsx(z.InfoOutlined,{sx:{fontSize:20}})}}})(),l=Na(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(z.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:l}),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 Bu extends p.Component{constructor(n){super(n);jn(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){cr.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=>T(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(z.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=>T(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(z.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Du({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(z.Warning,{sx:{fontSize:20}}),action:e.jsx(r.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:e.jsx(z.Close,{sx:{fontSize:16}})}),children:[e.jsxs(r.AlertTitle,{children:[t," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Kr({children:t,feature:o,onError:n}){return e.jsx(Bu,{context:o,onError:i=>{n&&n(i)},fallback:e.jsx(Du,{feature:o}),children:t})}const Eu=[{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"}],Ou=[{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 Xr({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 $u({open:t,onClose:o,config:n,onApply:i}){const[s,d]=p.useState(0),[l,c]=p.useState(n),u=()=>c(n),h=()=>c(Ke),m=()=>{i(l),o()},b={sort:C=>c(S=>({...S,sort:{...S.sort,...C}})),filter:C=>c(S=>({...S,filter:{...S.filter,...C}})),columns:C=>c(S=>({...S,columns:{...S.columns,...C}})),grouping:C=>c(S=>({...S,grouping:{...S.grouping,...C}})),export:C=>c(S=>({...S,export:{...S.export,...C}}))},x=C=>{const S=l.filter.allowedOperators,I=S.includes(C)?S.filter(f=>f!==C):[...S,C];I.length!==0&&b.filter({allowedOperators:I})},y=C=>{const S=l.export.allowedFormats,I=S.includes(C)?S.filter(f=>f!==C):[...S,C];I.length!==0&&b.export({allowedFormats:I})},D=[{label:"Sort",icon:e.jsx(z.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:e.jsx(z.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:e.jsx(z.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:e.jsx(z.Layers,{sx:{fontSize:17}})},{label:"Export",icon:e.jsx(z.Download,{sx:{fontSize:17}})}],v=C=>JSON.stringify(l[C])===JSON.stringify(Ke[C]);return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:C=>Me(C),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:C=>`0 8px 32px ${T(C.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:C=>T(C.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(z.Close,{sx:{fontSize:20}})})]}),e.jsx(r.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:e.jsx(r.Tabs,{value:s,onChange:(C,S)=>d(S),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:D.map((C,S)=>e.jsx(r.Tab,{label:C.label,icon:C.icon,iconPosition:"start"},S))})}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[e.jsxs(Xr,{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"}),!v("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:l.sort.maxLevels,onChange:(C,S)=>b.sort({maxLevels:S}),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(Xr,{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"}),!v("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:l.filter.maxConditions,onChange:(C,S)=>b.filter({maxConditions:S}),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(C=>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:C}),e.jsx(r.FormGroup,{row:!0,sx:{gap:.5},children:Eu.filter(S=>S.group===C).map(S=>e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{size:"small",checked:l.filter.allowedOperators.includes(S.value),onChange:()=>x(S.value)}),label:e.jsx(r.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:S.label}),sx:{mr:1.5}},S.value))})]},C))]})]}),e.jsxs(Xr,{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"}),!v("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:l.columns.maxVisible,onChange:(C,S)=>b.columns({maxVisible:S}),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:l.columns.minColumnWidth,onChange:(C,S)=>b.columns({minColumnWidth:S}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:C=>`${C}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:l.columns.maxColumnWidth,onChange:(C,S)=>b.columns({maxColumnWidth:S}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:C=>`${C}px`})]})]})]})]}),e.jsxs(Xr,{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"}),!v("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(C=>e.jsxs(r.Box,{onClick:()=>b.grouping({maxLevels:C}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:l.grouping.maxLevels===C?"primary.main":"divider",bgcolor:l.grouping.maxLevels===C?S=>T(S.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:S=>T(S.palette.primary.main,.04)}},children:[e.jsx(r.Typography,{variant:"h5",sx:{fontWeight:700,color:l.grouping.maxLevels===C?"primary.main":"text.secondary"},children:C}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][C-1]})]},C))}),e.jsxs(r.FormGroup,{row:!0,sx:{gap:2},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:l.grouping.allowNested,onChange:C=>b.grouping({allowNested:C.target.checked})}),label:e.jsx(r.Typography,{variant:"body2",children:"Allow nested groups"})}),e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:l.grouping.allowCollapse,onChange:C=>b.grouping({allowCollapse:C.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(Xr,{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"}),!v("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:Ou.map(C=>e.jsxs(r.Box,{onClick:()=>y(C.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(C.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(C.value)?S=>T(S.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[e.jsx(r.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(C.value),onChange:()=>y(C.value),onClick:S=>S.stopPropagation()}),e.jsxs(r.Box,{children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:500},children:C.label}),e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:C.desc})]})]},C.value))})]})})]}),e.jsxs(r.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:C=>T(C.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[e.jsx(r.Button,{startIcon:e.jsx(z.RestartAlt,{sx:{fontSize:18}}),onClick:h,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:C=>T(C.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 Au=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],_u={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 vo(t,o,n,i,s=new Date){const[d,l]=o.split(":").map(Number),c=new Date(s);if(c.setSeconds(0,0),c.setHours(d,l,0,0),t==="daily")return c<=s&&c.setDate(c.getDate()+1),c.toISOString();if(t==="weekly"){const u=n??1,h=c.getDay();let m=u-h;return m<0&&(m+=7),m===0&&c<=s&&(m=7),c.setDate(c.getDate()+m),c.toISOString()}if(t==="monthly"){const u=Math.min(i??1,28);return c.setDate(u),c<=s&&(c.setMonth(c.getMonth()+1),c.setDate(u)),c.toISOString()}return c.toISOString()}function Mu(t){const o=rs(t.time);return t.frequency==="daily"?`Daily at ${o}`:t.frequency==="weekly"?`Every ${Au[t.dayOfWeek??1]} at ${o}`:t.frequency==="monthly"?`Monthly on the ${_u[t.dayOfMonth??1]??`${t.dayOfMonth}th`} at ${o}`:o}function rs(t){const[o,n]=t.split(":").map(Number),i=o>=12?"PM":"AM";return`${o%12||12}:${String(n).padStart(2,"0")} ${i}`}function Ru(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 Wu(t){const o=new Date(t),n=new Date,i=o.toDateString()===n.toDateString(),s=rs(`${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 os(t){return`urm_schedules_${t}`}function ns(t){try{const o=localStorage.getItem(os(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 is(t,o){try{localStorage.setItem(os(t),JSON.stringify(o))}catch{}}const Pu=[{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"}],Nu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ss={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},lr={"& .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 Lu({initial:t=ss,isEditing:o=!1,onSave:n,onBack:i}){const[s,d]=p.useState(t),[l,c]=p.useState(!1),[u,h]=p.useState(!1),m=(y,D)=>d(v=>({...v,[y]:D})),b=s.email.trim().length>0&&!Nu.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)&&!b;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:y=>T(y.palette.text.primary,.06)}},children:e.jsx(z.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:y=>{m("name",y.target.value),l&&y.target.value.trim()&&c(!1)},onBlur:()=>c(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:l&&!s.name.trim(),helperText:l&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:lr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:lr,children:[e.jsx(r.InputLabel,{children:"Frequency"}),e.jsxs(r.Select,{value:s.frequency,label:"Frequency",onChange:y=>m("frequency",y.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:lr,children:[e.jsx(r.InputLabel,{children:"Day of week"}),e.jsx(r.Select,{value:s.dayOfWeek,label:"Day of week",onChange:y=>m("dayOfWeek",Number(y.target.value)),children:Pu.map(y=>e.jsx(r.MenuItem,{value:y.value,children:y.label},y.value))})]}),s.frequency==="monthly"&&e.jsx(r.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:y=>m("dayOfMonth",Number(y.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:lr}),e.jsx(r.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:y=>m("time",y.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:lr}),e.jsxs(r.FormControl,{size:"small",fullWidth:!0,sx:lr,children:[e.jsx(r.InputLabel,{children:"Export format"}),e.jsxs(r.Select,{value:s.format,label:"Export format",onChange:y=>m("format",y.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:y=>m("scope",y.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:y=>m("email",y.target.value),onBlur:()=>h(!0),placeholder:"user@company.com",error:u&&b,helperText:u&&b?"Enter a valid email address":void 0,InputProps:{startAdornment:e.jsx(z.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:lr}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[e.jsx(z.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:y=>T(y.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 Fu({scheduleName:t,onConfirm:o,onCancel:n}){return e.jsxs(r.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>so(i),boxShadow:i=>{var s;return`0 8px 32px ${T(((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=>T(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:e.jsx(z.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 Vu({schedule:t,tick:o,onToggle:n,onRunNow:i,onEdit:s,onDelete:d}){const l=t.isActive;return e.jsxs(r.Box,{sx:{border:"1px solid",borderColor:l?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:l?c=>T(c.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(r.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:l?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(r.Chip,{label:l?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:l?c=>T(c.palette.success.main,.1):c=>T(c.palette.text.primary,.06),color:l?"success.dark":"text.secondary"}})]}),e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Mu(t)}),e.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[e.jsx(r.Chip,{label:t.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:c=>T(c.palette.primary.main,.08),color:"primary.main"}}),e.jsx(r.Chip,{label:t.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:c=>T(c.palette.text.primary,.06),color:"text.secondary"}}),t.email&&e.jsx(r.Chip,{icon:e.jsx(z.Email,{sx:{fontSize:11}}),label:t.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:c=>T(c.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),e.jsxs(r.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[e.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[l&&e.jsxs(r.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",Ru(t.nextRunAt)]}),t.lastRunAt?e.jsxs(r.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Wu(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:c=>T(c.palette.primary.main,.08)}},children:e.jsx(z.Edit,{sx:{fontSize:15}})})}),e.jsx(r.Tooltip,{title:l?"Pause":"Resume",placement:"top",children:e.jsx(r.IconButton,{size:"small",onClick:()=>n(t.id),sx:{color:l?"warning.main":"success.main","&:hover":{bgcolor:l?c=>T(c.palette.warning.main,.08):c=>T(c.palette.success.main,.08)}},children:l?e.jsx(z.Pause,{sx:{fontSize:15}}):e.jsx(z.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:c=>T(c.palette.primary.main,.08)}},children:e.jsx(z.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:c=>T(c.palette.error.main,.08)}},children:e.jsx(z.Delete,{sx:{fontSize:15}})})})]})]})]})}function Hu({open:t,onClose:o,reportId:n,reportName:i,onRunNow:s}){const[d,l]=p.useState([]),[c,u]=p.useState({type:"list"}),[h,m]=p.useState(0),[b,x]=p.useState(null);p.useEffect(()=>{t&&(l(ns(n)),u({type:"list"}))},[t,n]),p.useEffect(()=>{if(!t)return;const B=setInterval(()=>m(R=>R+1),3e4);return()=>clearInterval(B)},[t]);const y=p.useCallback(B=>{l(B),is(n,B)},[n]),D=B=>{const R=vo(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth),J={id:`sched-${Date.now()}`,reportId:n,name:B.name.trim(),frequency:B.frequency,dayOfWeek:B.frequency==="weekly"?B.dayOfWeek:void 0,dayOfMonth:B.frequency==="monthly"?B.dayOfMonth:void 0,time:B.time,format:B.format,scope:B.scope,email:B.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:R,runCount:0};y([...d,J]),u({type:"list"})},v=B=>{if(c.type!=="edit")return;const R=c.schedule,J=vo(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth);y(d.map(K=>K.id===R.id?{...R,name:B.name.trim(),frequency:B.frequency,dayOfWeek:B.frequency==="weekly"?B.dayOfWeek:void 0,dayOfMonth:B.frequency==="monthly"?B.dayOfMonth:void 0,time:B.time,format:B.format,scope:B.scope,email:B.email.trim()||void 0,nextRunAt:J}:K)),u({type:"list"})},C=B=>{y(d.map(R=>{if(R.id!==B)return R;const J=R.isActive?R.nextRunAt:vo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth);return{...R,isActive:!R.isActive,nextRunAt:J}}))},S=B=>{s(B);const R=new Date().toISOString();y(d.map(J=>J.id===B.id?{...J,lastRunAt:R,runCount:J.runCount+1}:J))},I=B=>{const R=d.find(J=>J.id===B)??null;x(R)},f=()=>{b&&(y(d.filter(B=>B.id!==b.id)),x(null))},k=B=>({name:B.name,frequency:B.frequency,dayOfWeek:B.dayOfWeek??1,dayOfMonth:B.dayOfMonth??1,time:B.time,format:B.format,scope:B.scope,email:B.email??""}),j=c.type!=="list",a=d.filter(B=>B.isActive).length;return e.jsxs(e.Fragment,{children:[e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:j,PaperProps:{sx:{borderRadius:B=>Me(B),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:B=>T(B.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(z.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(pr,{content:xr.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:B=>T(B.palette.text.primary,.06)}},children:e.jsx(z.Close,{sx:{fontSize:18}})})]}),e.jsxs(r.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[j&&e.jsx(Lu,{initial:c.type==="edit"?k(c.schedule):ss,isEditing:c.type==="edit",onSave:c.type==="edit"?v:D,onBack:()=>u({type:"list"})}),c.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(z.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(z.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(B=>e.jsx(Vu,{schedule:B,tick:h,onToggle:C,onRunNow:S,onEdit:R=>u({type:"edit",schedule:R}),onDelete:I},B.id))})]})]}),c.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:B=>T(B.palette.warning.main,.06),border:"1px solid",borderColor:B=>T(B.palette.warning.main,.2)},children:[e.jsx(z.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:B=>T(B.palette.text.primary,.06)}},children:"Close"})]})]}),b&&e.jsx(Fu,{scheduleName:b.name,onConfirm:f,onCancel:()=>x(null)})]})}const Uu=6e4;function Yu({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:l,columnOrder:c,filters:u,sortStack:h,onFired:m}){const b=p.useRef({reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:l,columnOrder:c,filters:u,sortStack:h,onFired:m});p.useEffect(()=>{b.current={reportId:t,reportName:o,uploadedData:n,processedData:i,schema:s,activeView:d,columnVisibility:l,columnOrder:c,filters:u,sortStack:h,onFired:m}});const x=p.useCallback(y=>{var B,R;const{reportName:D,uploadedData:v,processedData:C,schema:S,activeView:I,columnVisibility:f,columnOrder:k,filters:j,sortStack:a}=b.current;try{const J=y.scope==="all"?v:C,K=So(J,S,j,a,I,f,k),ee=`${y.name}_scheduled`;switch(y.format){case"csv":jo(K,ee,{scope:y.scope});break;case"excel":Co(K,ee,{scope:y.scope});break;case"json":wo(K,ee,{scope:y.scope});break}if(y.email){const g=encodeURIComponent(`Scheduled Report: ${y.name}`),M=encodeURIComponent(`Your scheduled report "${y.name}" has been generated.
90
90
 
91
91
  Report: ${D}
92
92
  Format: ${y.format.toUpperCase()}
93
93
  Generated: ${new Date().toLocaleString()}
94
94
 
95
- The file has been downloaded to your device.`);window.open(`mailto:${y.email}?subject=${g}&body=${M}`,"_blank")}(R=(B=b.current).onFired)==null||R.call(B,y)}catch(q){ar.error("urm:scheduler",`Export failed for schedule: ${y.name}`,q)}},[]);p.useEffect(()=>{if(!t)return;const y=()=>{const{reportId:v}=b.current;if(!v)return;const C=rs(v),S=new Date;let I=!1;const f=C.map(k=>{if(!k.isActive)return k;if(new Date(k.nextRunAt)<=S){m(k);const a=bo(k.frequency,k.time,k.dayOfWeek,k.dayOfMonth,S);return I=!0,{...k,lastRunAt:S.toISOString(),nextRunAt:a,runCount:k.runCount+1}}return k});I&&os(v,f)};y();const D=setInterval(y,Hu);return()=>clearInterval(D)},[t,m])}function is({reportEngine:t}){var jr,Cr,wr,or,kr;const{activeReport:o,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:d,activeView:c,isDirty:l,currentTableState:u,viewChanges:x,showFilterPanel:h,setShowFilterPanel:b,filterFocusColumn:m,handleAddFilter:y,handleUpdateFilter:D,handleRemoveFilter:v,handleClearAllFilters:C,handleReplaceFilters:S,handleOpenFilterForColumn:I,handleCloseFilterPanel:f,handleClearFiltersForColumn:k,showSortPanel:j,setShowSortPanel:a,handleSort:B,handleUpdateSortStack:R,handleSortAscending:q,handleSortDescending:K,showManageViews:ee,setShowManageViews:g,showCreateViewModal:M,setShowCreateViewModal:W,showEditViewModal:V,setShowEditViewModal:Z,showDeleteConfirmation:xe,setShowDeleteConfirmation:me,editingView:F,deletingView:A,handleSelectView:H,handleCreateView:se,handleUpdateCurrentView:G,handleSaveColumnConfigToCurrentView:re,handleSaveColumnConfigToAllViews:ae,handleSaveAsNewView:ne,handleRevertChanges:P,handleToggleDefault:ie,handleToggleFavorite:de,handleSoftDelete:le,handleRestoreView:fe,handlePermanentDelete:J,handleEditView:Re,handleSaveEditView:He,handleConfirmDelete:St,handlePromoteToGlobal:Mt,showManageColumns:pr,setShowManageColumns:Gt,handleUpdateColumnVisibility:pt,handleUpdateColumnOrder:Rt,handleUpdateColumnWidth:Be,handleResetColumnLayout:Xe,showGroupPanel:jt,setShowGroupPanel:ot,handleGroup:Le,handleToggleGroupCollapse:nt,searchQuery:Ct,searchHistory:Ze,handleSearchChange:it,handleAddToSearchHistory:We,handleToggleSearchFavourite:$r,handleDeleteSearchHistory:xr,selectedRowIds:mr,handleToggleRowSelection:qt,handleToggleAllRows:st,handleRangeSelection:Wt,handleClearSelection:hr,handleUpdateSelectionAfterDelete:wt,currentPage:fr,pageSize:Ar,paginationEngine:Ue,handlePageChange:Jt,handlePageSizeChange:gr,isExporting:ze,showExportModal:Kt,setShowExportModal:_r,showDirtyExportWarning:at,handleExport:L,handleExportWithConfig:lt,handleExportSelected:ye,handleExportAnyway:Ye,handleSaveAndExport:Pt,handleCancelExport:Mr,showAuditHistory:xt,setShowAuditHistory:Xt,showCreatePreset:kt,setShowCreatePreset:yr,showManagePresets:br,setShowManagePresets:Rr,activePreset:Te,handleCreatePreset:Q,handleClearActivePreset:ct,handleOpenPresetById:Ie,handleDeletePresetById:Zt,isViewerRole:be,userRole:Qe,featureLimitWarning:Qt,setFeatureLimitWarning:mt,reportError:Fe,setReportError:vr,handleError:Tt,updateReport:dt,showSnack:It,favoriteRowIndices:Wr,resolvedFavoritesSet:er,showFavoritesOnly:tr,handleToggleRowFavorite:Nt,handleBulkSetFavorites:Sr,handleToggleFavoritesFilter:Ne}=t,[ht,zt]=p.useState(!1);Uu({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)||((jr=c==null?void 0:c.snapshot)==null?void 0:jr.columnVisibility)||{},columnOrder:(o==null?void 0:o.columnOrder)||((Cr=c==null?void 0:c.snapshot)==null?void 0:Cr.columnOrder)||[],filters:(o==null?void 0:o.filters)||[],sortStack:(o==null?void 0:o.sortStack)||[],onFired:ue=>{It(`Scheduled export "${ue.name}" completed`,"success")}});const Lt=p.useCallback((ue,ce)=>{if(!(o!=null&&o.uploadedData))return;const Ee=[...o.uploadedData];Ee[ue]=ce,dt(o.id,{uploadedData:Ee})},[o,dt]),Pr=p.useCallback(ue=>{if(!(o!=null&&o.uploadedData))return;const ce=o.uploadedData.indexOf(ue);if(ce===-1)return;const Ee=o.uploadedData.filter((et,Bt)=>Bt!==ce),ut=(o.favoriteRowIndices||[]).filter(et=>et!==ce).map(et=>et>ce?et-1:et);dt(o.id,{uploadedData:Ee,favoriteRowIndices:ut}),wt(ue)},[o,dt,wt]),Nr=p.useCallback((ue,ce)=>{if(!(o!=null&&o.uploadedData))return;const Ee=o.uploadedData.indexOf(ce),ut=Ee!==-1?Ee+1:ue+1,et=[...o.uploadedData];et.splice(ut,0,{...ce});const Vr=(o.favoriteRowIndices??[]).map(Vt=>Vt>=ut?Vt+1:Vt);dt(o.id,{uploadedData:et,favoriteRowIndices:Vr})},[o,dt]),Ft=cr(),{handleDevConfigChange:Lr}=zo(),[Fr,rr]=p.useState(!1);return p.useEffect(()=>{const ue=ce=>{ce.ctrlKey&&ce.shiftKey&&ce.key==="D"&&(ce.preventDefault(),rr(!0))};return document.addEventListener("keydown",ue),()=>document.removeEventListener("keydown",ue)},[]),!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:[!be&&l&&c&&e.jsx(cu,{viewName:c.name,isDefaultView:c.isDefault,changes:x,onSaveToCurrentView:c.isDefault?void 0:G,onSaveAsNewView:ne,onCancel:P}),e.jsxs(r.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[Qt&&e.jsx(Tu,{warning:Qt,onDismiss:()=>mt(null)}),Fe&&e.jsx(Iu,{error:Fe,onDismiss:()=>vr(null)}),at&&e.jsx(du,{onExportAnyway:Ye,onSaveAndExport:Pt,onCancel:Mr}),e.jsx(Zd,{schema:o.schema,data:n,sortStack:o.sortStack,filters:o.filters,views:o.views,activeViewId:o.activeViewId,isDirty:l,isExporting:ze,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:B,onSortAscending:q,onSortDescending:K,onOpenFilters:()=>b(!0),onOpenSort:()=>a(!0),onOpenFilterForColumn:I,onSelectView:H,onCreateView:()=>W(!0),onManageViews:()=>g(!0),onUpdateCurrentView:G,onSaveAsNewView:ne,onToggleDefault:ie,onToggleFavorite:de,onRestoreView:fe,onPermanentDelete:J,onExport:L,onOpenColumns:()=>Gt(!0),onUpdateColumnWidth:Be,onUpdateColumnOrder:Rt,onUpdateColumnVisibility:pt,onClearFiltersForColumn:k,onResetLayout:Xe,onOpenGroup:()=>ot(!0),onGroupByColumn:ue=>{Le({enabled:!0,levels:[{column:ue}],collapsedGroups:[]})},onToggleGroupCollapse:nt,onOpenAuditHistory:()=>Xt(!0),onOpenScheduledReports:()=>zt(!0),searchQuery:Ct,searchHistory:Ze,onAddToSearchHistory:We,onToggleSearchFavourite:$r,onDeleteSearchHistory:xr,selectedRowIds:mr,onSearchChange:it,onToggleRowSelection:qt,onToggleAllRows:st,onRangeSelection:Wt,onClearSelection:hr,onExportSelected:ye,currentPage:(Ue==null?void 0:Ue.currentPage)||fr,pageSize:(Ue==null?void 0:Ue.pageSize)||Ar,onPageChange:Jt,onPageSizeChange:gr,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:be,userRole:Qe,reportName:o.name,onEditRow:Lt,onDeleteRow:Pr,onDuplicateRow:Nr,favoriteRowIndices:Wr,resolvedFavoritesSet:er,showFavoritesOnly:tr,onToggleRowFavorite:Nt,onBulkSetFavorites:Sr,onToggleFavoritesFilter:Ne,showDevPanel:Ft.display.showDevPanel,onOpenDevConfig:()=>rr(!0)})]}),h&&e.jsx(Jr,{feature:"Filters",onError:ue=>{const ce=Ot("ui","filters",ue);Tt(ce)},children:e.jsx(Qd,{schema:o.schema,filters:o.filters??[],onAddFilter:y,onUpdateFilter:D,onRemoveFilter:v,onClearAll:C,onReplaceFilters:S,onClose:f,focusColumn:m})}),j&&e.jsx(Jr,{feature:"Sorting",onError:ue=>{const ce=Ot("ui","sorting",ue);Tt(ce)},children:e.jsx(tu,{schema:o.schema,sortStack:o.sortStack??[],onUpdateSortStack:R,onClose:()=>a(!1)})}),ee&&e.jsx(Jr,{feature:"Views",onError:ue=>{const ce=Ot("ui","views",ue);Tt(ce)},children:e.jsx(ru,{views:o.views,activeViewId:o.activeViewId??"",onSelectView:H,onCreateView:()=>{g(!1),W(!0)},onEditView:Re,onDeleteView:le,onRestoreView:fe,onPermanentDelete:J,onPromoteToGlobal:Mt,isAdmin:((wr=Ft.views)==null?void 0:wr.isAdmin)??!1,onClose:()=>g(!1)})}),M&&u&&(()=>{var Ee;const ue=(o.views??[]).filter(ut=>!ut.isDeleted).length,ce=((Ee=Ft.views)==null?void 0:Ee.maxViews)??10;return e.jsx(mi,{currentSnapshot:u,onSave:se,onClose:()=>W(!1),atViewLimit:ue>=ce,maxViews:ce})})(),V&&F&&e.jsx(mi,{currentSnapshot:F.snapshot,onSave:He,onClose:()=>{Z(!1)},isEditMode:!0,initialName:F.name,initialDescription:F.description,initialIsDefault:F.isDefault}),xe&&A&&e.jsx(ou,{viewName:A.name,onConfirm:St,onCancel:()=>{me(!1)}}),pr&&c&&e.jsx(iu,{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:pt,onUpdateColumnOrder:Rt,onUpdateColumnWidth:Be,onResetLayout:Xe,onSelectView:ue=>{H(ue)},onSaveToCurrentView:ue=>{re(ue),Gt(!1)},onSaveToAllViews:ue=>{ae(ue),Gt(!1)},onClose:()=>Gt(!1)}),jt&&e.jsx(Jr,{feature:"Grouping",onError:ue=>{const ce=Ot("ui","grouping",ue);Tt(ce)},children:e.jsx(su,{schema:o.schema,grouping:o.grouping||null,onApply:Le,onClose:()=>ot(!1)})}),xt&&e.jsx(xu,{auditHistory:o.auditHistory||[],onClose:()=>Xt(!1)}),kt&&e.jsx(mu,{onSave:Q,onClose:()=>yr(!1)}),br&&e.jsx(fu,{presets:o.presets||[],reportId:o.id,onOpenPreset:Ie,onDeletePreset:Zt,onClose:()=>Rr(!1)}),Te&&e.jsx(r.Box,{sx:{mt:2},children:e.jsx(hu,{presetName:Te.name,onClear:ct})}),Kt&&e.jsx(Jr,{feature:"Export",onError:ue=>{const ce=Ot("ui","export",ue);Tt(ce)},children:e.jsx(ku,{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:((kr=d==null?void 0:d.columnEngine)==null?void 0:kr.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:lt,onClose:()=>{_r(!1)}})}),o&&e.jsx(Vu,{open:ht,onClose:()=>zt(!1),reportId:o.id,reportName:o.name,onRunNow:ue=>{const ce=ue.scope==="all"?o.uploadedData||[]:i||[],Ee=vo(ce,o.schema||[],o.filters||[],o.sortStack||[],c,o.columnVisibility,o.columnOrder);ue.format==="csv"&&So(Ee,ue.name),ue.format==="excel"&&jo(Ee,ue.name),ue.format==="json"&&Co(Ee,ue.name),It(`"${ue.name}" exported successfully`,"success")}}),e.jsx(Ou,{open:Fr,onClose:()=>rr(!1),config:Ft,onApply:Lr})]})}const Yu={error:"err",warning:"warn",info:"info",success:"suc"};function ss({open:t,message:o,severity:n,onClose:i,autoHideDurationMs:s}){var I,f;const d=r.useTheme(),c=d.tokens,l=(c==null?void 0:c.notifPosition)??"top-right",u=(c==null?void 0:c.notifStyle)??"toast",x=(c==null?void 0:c.notifAccent)??"severity",h=(c==null?void 0:c.notifAutoDismiss)??!0,b=(c==null?void 0:c.toastW)??252,m=l.startsWith("top")?"top":"bottom",y=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",D=Yu[n],v=((I=c==null?void 0:c.status)==null?void 0:I[`${D}Soft`])??d.palette[n].light,C=((f=c==null?void 0:c.status)==null?void 0:f[`${D}Txt`])??d.palette[n].dark,S=x==="primary"?d.palette.primary.main:x==="mono"?d.palette.text.secondary:C;return e.jsx(r.Snackbar,{open:t,autoHideDuration:h?s??2e3:void 0,onClose:(k,j)=>{j!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:m,horizontal:y},children:e.jsx(r.Alert,{severity:n,icon:!1,onClose:h?void 0:i,sx:{width:b,alignItems:"flex-start",bgcolor:v,color:C,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 ${S}`:void 0,borderRadius:`${d.shape.borderRadius}px`},children:o})})}function as({hasExternalData:t=!1}){const o=zo(),{reports:n,activeReportId:i,activeReport:s,uploadState:d,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:u,setActiveReportId:x,createReport:h,handleFileUpload:b,handleUploadError:m,handleRetry:y,handleConfirm:D,snack:v,handleSnackClose:C,snackDurationMs:S}=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(sl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:x}),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(Xi,{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(bd,{schema:s.schema,onConfirm:D,hasConflicts:c}):s.uploadError?e.jsx(vd,{error:s.uploadError,onRetry:y}):e.jsx(yd,{onFileUpload:b,onError:m,isUploading:d==="uploading"})})}):null}),!t&&e.jsx(gd,{isOpen:l,onClose:()=>u(!1),onCreate:h}),e.jsx(ss,{open:v.open,message:v.message,severity:v.severity,onClose:C,autoHideDurationMs:S})]})}function Gu({data:t,dataSource:o,reportName:n,autoLoad:i=!0,config:s}={}){return e.jsx(cn,{mode:"builder",data:t,dataSource:o,reportName:n,autoLoad:i,config:s,children:e.jsx(as,{hasExternalData:!!(t||o)})})}function ls(){const t=zo(),{snack:o,handleSnackClose:n,snackDurationMs:i}=t;return e.jsxs(r.Box,{sx:{minHeight:"100vh"},children:[e.jsx(r.Box,{component:"main",children:t.activeReport?e.jsx(is,{reportEngine:t}):e.jsx(Xi,{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 qu({data:t,autoLoad:o=!0,config:n}){return e.jsx(cn,{data:t,mode:"viewer",autoLoad:o,config:n,children:e.jsx(ls,{})})}exports.URMBuilder=Gu;exports.URMBuilderRaw=as;exports.URMProvider=cn;exports.URMViewer=qu;exports.URMViewerRaw=ls;exports.useURMContext=zo;
95
+ The file has been downloaded to your device.`);window.open(`mailto:${y.email}?subject=${g}&body=${M}`,"_blank")}(R=(B=b.current).onFired)==null||R.call(B,y)}catch(J){cr.error("urm:scheduler",`Export failed for schedule: ${y.name}`,J)}},[]);p.useEffect(()=>{if(!t)return;const y=()=>{const{reportId:v}=b.current;if(!v)return;const C=ns(v),S=new Date;let I=!1;const f=C.map(k=>{if(!k.isActive)return k;if(new Date(k.nextRunAt)<=S){x(k);const a=vo(k.frequency,k.time,k.dayOfWeek,k.dayOfMonth,S);return I=!0,{...k,lastRunAt:S.toISOString(),nextRunAt:a,runCount:k.runCount+1}}return k});I&&is(v,f)};y();const D=setInterval(y,Uu);return()=>clearInterval(D)},[t,x])}function as({reportEngine:t}){var Sr,jr,Cr,ir,wr;const{activeReport:o,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:d,activeView:l,isDirty:c,currentTableState:u,viewChanges:h,showFilterPanel:m,setShowFilterPanel:b,filterFocusColumn:x,handleAddFilter:y,handleUpdateFilter:D,handleRemoveFilter:v,handleClearAllFilters:C,handleReplaceFilters:S,handleOpenFilterForColumn:I,handleCloseFilterPanel:f,handleClearFiltersForColumn:k,showSortPanel:j,setShowSortPanel:a,handleSort:B,handleUpdateSortStack:R,handleSortAscending:J,handleSortDescending:K,showManageViews:ee,setShowManageViews:g,showCreateViewModal:M,setShowCreateViewModal:W,showEditViewModal:V,setShowEditViewModal:Q,showDeleteConfirmation:xe,setShowDeleteConfirmation:me,editingView:L,deletingView:A,handleSelectView:H,handleCreateView:se,handleUpdateCurrentView:G,handleSaveColumnConfigToCurrentView:re,handleSaveColumnConfigToAllViews:ae,handleSaveAsNewView:ne,handleRevertChanges:P,handleToggleDefault:ie,handleToggleFavorite:pe,handleSoftDelete:le,handleRestoreView:ge,handlePermanentDelete:q,handleEditView:_e,handleSaveEditView:et,handleConfirmDelete:tt,handlePromoteToGlobal:_t,showManageColumns:mr,setShowManageColumns:Mt,handleUpdateColumnVisibility:Rt,handleUpdateColumnOrder:Wt,handleUpdateColumnWidth:pt,handleResetColumnLayout:Ve,showGroupPanel:qe,setShowGroupPanel:Ue,handleGroup:rt,handleToggleGroupCollapse:Je,searchQuery:ot,debouncedSearchQuery:wt,searchHistory:He,handleSearchChange:lt,handleAddToSearchHistory:Re,handleToggleSearchFavourite:Or,handleDeleteSearchHistory:$r,selectedRowIds:qt,handleToggleRowSelection:hr,handleToggleAllRows:Pt,handleRangeSelection:xt,handleClearSelection:Nt,handleUpdateSelectionAfterDelete:fr,currentPage:kt,pageSize:Ar,paginationEngine:Ye,handlePageChange:gr,handlePageSizeChange:_r,isExporting:Jt,showExportModal:Ce,setShowExportModal:Mr,showDirtyExportWarning:yr,handleExport:ct,handleExportWithConfig:F,handleExportSelected:Ge,handleExportAnyway:we,handleSaveAndExport:Pe,handleCancelExport:Rr,showAuditHistory:Kt,setShowAuditHistory:mt,showCreatePreset:Xt,setShowCreatePreset:Qt,showManagePresets:Zt,setShowManagePresets:Wr,activePreset:Lt,handleCreatePreset:ze,handleClearActivePreset:Z,handleOpenPresetById:ht,handleDeletePresetById:ke,isViewerRole:ye,userRole:nt,featureLimitWarning:er,setFeatureLimitWarning:ft,reportError:Le,setReportError:br,handleError:Tt,updateReport:dt,showSnack:It,favoriteRowIndices:Pr,resolvedFavoritesSet:tr,showFavoritesOnly:rr,handleToggleRowFavorite:Ft,handleBulkSetFavorites:vr,handleToggleFavoritesFilter:Ne}=t,[gt,or]=p.useState(!1);Yu({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:l,columnVisibility:(o==null?void 0:o.columnVisibility)||((Sr=l==null?void 0:l.snapshot)==null?void 0:Sr.columnVisibility)||{},columnOrder:(o==null?void 0:o.columnOrder)||((jr=l==null?void 0:l.snapshot)==null?void 0:jr.columnOrder)||[],filters:(o==null?void 0:o.filters)||[],sortStack:(o==null?void 0:o.sortStack)||[],onFired:de=>{It(`Scheduled export "${de.name}" completed`,"success")}});const yt=p.useCallback((de,ce)=>{if(!(o!=null&&o.uploadedData))return;const De=[...o.uploadedData];De[de]=ce,dt(o.id,{uploadedData:De})},[o,dt]),Nr=p.useCallback(de=>{if(!(o!=null&&o.uploadedData))return;const ce=o.uploadedData.indexOf(de);if(ce===-1)return;const De=o.uploadedData.filter((it,zt)=>zt!==ce),ut=(o.favoriteRowIndices||[]).filter(it=>it!==ce).map(it=>it>ce?it-1:it);dt(o.id,{uploadedData:De,favoriteRowIndices:ut}),fr(de)},[o,dt,fr]),Lr=p.useCallback((de,ce)=>{if(!(o!=null&&o.uploadedData))return;const De=o.uploadedData.indexOf(ce),ut=De!==-1?De+1:de+1,it=[...o.uploadedData];it.splice(ut,0,{...ce});const Hr=(o.favoriteRowIndices??[]).map(Ht=>Ht>=ut?Ht+1:Ht);dt(o.id,{uploadedData:it,favoriteRowIndices:Hr})},[o,dt]),Vt=ur(),{handleDevConfigChange:Fr}=Bo(),[Vr,nr]=p.useState(!1);return p.useEffect(()=>{const de=ce=>{ce.ctrlKey&&ce.shiftKey&&ce.key==="D"&&(ce.preventDefault(),nr(!0))};return document.addEventListener("keydown",de),()=>document.removeEventListener("keydown",de)},[]),!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:[!ye&&c&&l&&e.jsx(du,{viewName:l.name,isDefaultView:l.isDefault,changes:h,onSaveToCurrentView:l.isDefault?void 0:G,onSaveAsNewView:ne,onCancel:P}),e.jsxs(r.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[er&&e.jsx(Iu,{warning:er,onDismiss:()=>ft(null)}),Le&&e.jsx(zu,{error:Le,onDismiss:()=>br(null)}),yr&&e.jsx(uu,{onExportAnyway:we,onSaveAndExport:Pe,onCancel:Rr}),e.jsx(Zd,{schema:o.schema,data:n,sortStack:o.sortStack,filters:o.filters,views:o.views,activeViewId:o.activeViewId,isDirty:c,isExporting:Jt,columnVisibility:o.columnVisibility||(l==null?void 0:l.snapshot.columnVisibility),columnOrder:o.columnOrder||(l==null?void 0:l.snapshot.columnOrder),columnWidths:o.columnWidths||(l==null?void 0:l.snapshot.columnWidths),grouping:o.grouping,onSort:B,onSortAscending:J,onSortDescending:K,onOpenFilters:()=>b(!0),onOpenSort:()=>a(!0),onOpenFilterForColumn:I,onSelectView:H,onCreateView:()=>W(!0),onManageViews:()=>g(!0),onUpdateCurrentView:G,onSaveAsNewView:ne,onToggleDefault:ie,onToggleFavorite:pe,onRestoreView:ge,onPermanentDelete:q,onExport:ct,onOpenColumns:()=>Mt(!0),onUpdateColumnWidth:pt,onUpdateColumnOrder:Wt,onUpdateColumnVisibility:Rt,onClearFiltersForColumn:k,onResetLayout:Ve,onOpenGroup:()=>Ue(!0),onGroupByColumn:de=>{rt({enabled:!0,levels:[{column:de}],collapsedGroups:[]})},onToggleGroupCollapse:Je,onOpenAuditHistory:()=>mt(!0),onOpenScheduledReports:()=>or(!0),searchQuery:ot,highlightQuery:wt,searchHistory:He,onAddToSearchHistory:Re,onToggleSearchFavourite:Or,onDeleteSearchHistory:$r,selectedRowIds:qt,onSearchChange:lt,onToggleRowSelection:hr,onToggleAllRows:Pt,onRangeSelection:xt,onClearSelection:Nt,onExportSelected:Ge,currentPage:(Ye==null?void 0:Ye.currentPage)||kt,pageSize:(Ye==null?void 0:Ye.pageSize)||Ar,onPageChange:gr,onPageSizeChange:_r,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:ye,userRole:nt,reportName:o.name,onEditRow:yt,onDeleteRow:Nr,onDuplicateRow:Lr,favoriteRowIndices:Pr,resolvedFavoritesSet:tr,showFavoritesOnly:rr,onToggleRowFavorite:Ft,onBulkSetFavorites:vr,onToggleFavoritesFilter:Ne,showDevPanel:Vt.display.showDevPanel,onOpenDevConfig:()=>nr(!0)})]}),m&&e.jsx(Kr,{feature:"Filters",onError:de=>{const ce=Et("ui","filters",de);Tt(ce)},children:e.jsx(eu,{schema:o.schema,filters:o.filters??[],onAddFilter:y,onUpdateFilter:D,onRemoveFilter:v,onClearAll:C,onReplaceFilters:S,onClose:f,focusColumn:x})}),j&&e.jsx(Kr,{feature:"Sorting",onError:de=>{const ce=Et("ui","sorting",de);Tt(ce)},children:e.jsx(ru,{schema:o.schema,sortStack:o.sortStack??[],onUpdateSortStack:R,onClose:()=>a(!1)})}),ee&&e.jsx(Kr,{feature:"Views",onError:de=>{const ce=Et("ui","views",de);Tt(ce)},children:e.jsx(ou,{views:o.views,activeViewId:o.activeViewId??"",onSelectView:H,onCreateView:()=>{g(!1),W(!0)},onEditView:_e,onDeleteView:le,onRestoreView:ge,onPermanentDelete:q,onPromoteToGlobal:_t,isAdmin:((Cr=Vt.views)==null?void 0:Cr.isAdmin)??!1,onClose:()=>g(!1)})}),M&&u&&(()=>{var De;const de=(o.views??[]).filter(ut=>!ut.isDeleted).length,ce=((De=Vt.views)==null?void 0:De.maxViews)??10;return e.jsx(hi,{currentSnapshot:u,onSave:se,onClose:()=>W(!1),atViewLimit:de>=ce,maxViews:ce})})(),V&&L&&e.jsx(hi,{currentSnapshot:L.snapshot,onSave:et,onClose:()=>{Q(!1)},isEditMode:!0,initialName:L.name,initialDescription:L.description,initialIsDefault:L.isDefault}),xe&&A&&e.jsx(nu,{viewName:A.name,onConfirm:tt,onCancel:()=>{me(!1)}}),mr&&l&&e.jsx(su,{schema:o.schema,columnVisibility:o.columnVisibility||l.snapshot.columnVisibility,columnOrder:o.columnOrder||l.snapshot.columnOrder,columnWidths:o.columnWidths||l.snapshot.columnWidths,views:o.views,activeViewId:o.activeViewId,onUpdateColumnVisibility:Rt,onUpdateColumnOrder:Wt,onUpdateColumnWidth:pt,onResetLayout:Ve,onSelectView:de=>{H(de)},onSaveToCurrentView:de=>{re(de),Mt(!1)},onSaveToAllViews:de=>{ae(de),Mt(!1)},onClose:()=>Mt(!1)}),qe&&e.jsx(Kr,{feature:"Grouping",onError:de=>{const ce=Et("ui","grouping",de);Tt(ce)},children:e.jsx(au,{schema:o.schema,grouping:o.grouping||null,onApply:rt,onClose:()=>Ue(!1)})}),Kt&&e.jsx(mu,{auditHistory:o.auditHistory||[],onClose:()=>mt(!1)}),Xt&&e.jsx(hu,{onSave:ze,onClose:()=>Qt(!1)}),Zt&&e.jsx(gu,{presets:o.presets||[],reportId:o.id,onOpenPreset:ht,onDeletePreset:ke,onClose:()=>Wr(!1)}),Lt&&e.jsx(r.Box,{sx:{mt:2},children:e.jsx(fu,{presetName:Lt.name,onClear:Z})}),Ce&&e.jsx(Kr,{feature:"Export",onError:de=>{const ce=Et("ui","export",de);Tt(ce)},children:e.jsx(Tu,{totalRows:(s==null?void 0:s.totalRows)||((ir=o.uploadedData)==null?void 0:ir.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((wr=d==null?void 0:d.columnEngine)==null?void 0:wr.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:F,onClose:()=>{Mr(!1)}})}),o&&e.jsx(Hu,{open:gt,onClose:()=>or(!1),reportId:o.id,reportName:o.name,onRunNow:de=>{const ce=de.scope==="all"?o.uploadedData||[]:i||[],De=So(ce,o.schema||[],o.filters||[],o.sortStack||[],l,o.columnVisibility,o.columnOrder);de.format==="csv"&&jo(De,de.name),de.format==="excel"&&Co(De,de.name),de.format==="json"&&wo(De,de.name),It(`"${de.name}" exported successfully`,"success")}}),e.jsx($u,{open:Vr,onClose:()=>nr(!1),config:Vt,onApply:Fr})]})}const Gu={error:"err",warning:"warn",info:"info",success:"suc"};function ls({open:t,message:o,severity:n,onClose:i,autoHideDurationMs:s}){var I,f;const d=r.useTheme(),l=d.tokens,c=(l==null?void 0:l.notifPosition)??"top-right",u=(l==null?void 0:l.notifStyle)??"toast",h=(l==null?void 0:l.notifAccent)??"severity",m=(l==null?void 0:l.notifAutoDismiss)??!0,b=(l==null?void 0:l.toastW)??252,x=c.startsWith("top")?"top":"bottom",y=c.endsWith("center")?"center":c.endsWith("left")?"left":"right",D=Gu[n],v=((I=l==null?void 0:l.status)==null?void 0:I[`${D}Soft`])??d.palette[n].light,C=((f=l==null?void 0:l.status)==null?void 0:f[`${D}Txt`])??d.palette[n].dark,S=h==="primary"?d.palette.primary.main:h==="mono"?d.palette.text.secondary:C;return e.jsx(r.Snackbar,{open:t,autoHideDuration:m?s??2e3:void 0,onClose:(k,j)=>{j!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:x,horizontal:y},children:e.jsx(r.Alert,{severity:n,icon:!1,onClose:m?void 0:i,sx:{width:b,alignItems:"flex-start",bgcolor:v,color:C,boxShadow:u==="inline"?"none":(l==null?void 0:l.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(l==null?void 0:l.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${S}`:void 0,borderRadius:`${d.shape.borderRadius}px`},children:o})})}function cs({hasExternalData:t=!1}){const o=Bo(),{reports:n,activeReportId:i,activeReport:s,uploadState:d,hasSchemaConflicts:l,isModalOpen:c,setIsModalOpen:u,setActiveReportId:h,createReport:m,handleFileUpload:b,handleUploadError:x,handleRetry:y,handleConfirm:D,snack:v,handleSnackClose:C,snackDurationMs:S}=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(al,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:h}),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(Qi,{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(as,{reportEngine:o}):e.jsx(r.Box,{sx:{p:3},children:d==="preview"&&s.schema&&s.uploadedData?e.jsx(vd,{schema:s.schema,onConfirm:D,hasConflicts:l}):s.uploadError?e.jsx(Sd,{error:s.uploadError,onRetry:y}):e.jsx(bd,{onFileUpload:b,onError:x,isUploading:d==="uploading"})})}):null}),!t&&e.jsx(yd,{isOpen:c,onClose:()=>u(!1),onCreate:m}),e.jsx(ls,{open:v.open,message:v.message,severity:v.severity,onClose:C,autoHideDurationMs:S})]})}function qu({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(cs,{hasExternalData:!!(t||o)})})}function ds(){const t=Bo(),{snack:o,handleSnackClose:n,snackDurationMs:i}=t;return e.jsxs(r.Box,{sx:{minHeight:"100vh"},children:[e.jsx(r.Box,{component:"main",children:t.activeReport?e.jsx(as,{reportEngine:t}):e.jsx(Qi,{title:"No report data",description:"This viewer requires report data to be loaded."})}),e.jsx(ls,{open:o.open,message:o.message,severity:o.severity,onClose:n,autoHideDurationMs:i})]})}function Ju({data:t,autoLoad:o=!0,config:n}){return e.jsx(dn,{data:t,mode:"viewer",autoLoad:o,config:n,children:e.jsx(ds,{})})}exports.URMBuilder=qu;exports.URMBuilderRaw=cs;exports.URMProvider=dn;exports.URMViewer=Ju;exports.URMViewerRaw=ds;exports.useURMContext=Bo;