dts-universal-report-module 1.3.10 → 1.3.12

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 +5873 -5840
  2. package/dist/index.js +30 -30
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var ya=Object.defineProperty;var ba=(e,r,n)=>r in e?ya(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Ii=(e,r,n)=>ba(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),va=require("xlsx"),O=require("@mui/icons-material"),o=require("@mui/material"),Bs=require("react-dom"),Sa=require("@emotion/react"),ir=require("react-dnd"),ui=require("react-dnd-html5-backend");function Ts(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const dn=Ts(p),Go=Ts(va),yt={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","pdf"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},Is="urm_dev_config";function Ca(){try{const e=localStorage.getItem(Is);if(!e)return yt;const r=JSON.parse(e),n={sort:{...yt.sort,...r.sort},filter:{...yt.filter,...r.filter},columns:{...yt.columns,...r.columns},grouping:{...yt.grouping,...r.grouping},export:{...yt.export,...r.export},views:{...yt.views,...r.views},dates:{...yt.dates,...r.dates},display:{...yt.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return yt}}function wa(e){try{localStorage.setItem(Is,JSON.stringify(e))}catch{}}function ja(e,r,n){if(!n||!r)return e;const i={sort:{...e.sort,...r.sort},filter:{...e.filter,...r.filter},columns:{...e.columns,...r.columns},grouping:{...e.grouping,...r.grouping},export:{...e.export,...r.export},views:{...e.views,...r.views},dates:{...e.dates,...r.dates},display:{...e.display,...r.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const Es=p.createContext(yt);function gr(){return p.useContext(Es)}const ka=/^\d{4}-\d{2}-\d{2}$/,za=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Ba=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Ta=9783072e5,Ia=41024448e5,Ea=978307200,Da=4102444800;function _a(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=Ta&&e<=Ia?"timestamp_ms":Number.isInteger(e)&&e>=Ea&&e<=Da?"timestamp_s":"unknown":typeof e!="string"?"unknown":za.test(e)||ka.test(e)?"iso":Ba.test(e.trim())?"locale_string":"unknown"}function $a(e,r){const n=r.map(c=>c[e]).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=_a(c);i[l]++}const s=n.length,a=.7;for(const c of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[c]/s>=a)return c;return"unknown"}function Oa(e,r){if(e==null||e==="")return null;try{switch(r){case"timestamp_ms":{const n=new Date(Number(e));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(e)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const Ei=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ma=["January","February","March","April","May","June","July","August","September","October","November","December"];function qe(e){return String(e).padStart(2,"0")}function Aa(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),a=Math.floor(s/60),c=Math.floor(a/60),l=Math.floor(c/24),u=Math.floor(l/7),y=Math.floor(l/30),g=Math.floor(l/365);let m;return s<60?m="just now":a<60?m=`${a} minute${a!==1?"s":""}`:c<24?m=`${c} hour${c!==1?"s":""}`:l<7?m=`${l} day${l!==1?"s":""}`:u<5?m=`${u} week${u!==1?"s":""}`:y<12?m=`${y} month${y!==1?"s":""}`:m=`${g} year${g!==1?"s":""}`,s<60?m:i?`${m} ago`:`in ${m}`}function Wa(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),c=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${qe(i+1)}-${qe(s)}`;case"DD/MM/YYYY":return`${qe(s)}/${qe(i+1)}/${n}`;case"MM/DD/YYYY":return`${qe(i+1)}/${qe(s)}/${n}`;case"MMM DD, YYYY":return`${Ei[i]} ${qe(s)}, ${n}`;case"DD MMM YYYY":return`${qe(s)} ${Ei[i]} ${n}`;case"MMMM D, YYYY":return`${Ma[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${qe(i+1)}-${qe(s)} ${qe(a)}:${qe(c)}`;case"DD/MM/YYYY HH:mm":return`${qe(s)}/${qe(i+1)}/${n} ${qe(a)}:${qe(c)}`;case"MM/DD/YYYY HH:mm":return`${qe(i+1)}/${qe(s)}/${n} ${qe(a)}:${qe(c)}`;case"relative":return Aa(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function Ra(e,r,n){if(!n||r==="unknown")return String(e);const i=Oa(e,r);return!i||isNaN(i.getTime())?String(e):Wa(i,n)}function Pa(e){return e==null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?"number":typeof e=="boolean"?"boolean":typeof e=="string"?"string":"mixed"}function Ds(e,r="",n=0){if(n>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const a=r?`${r}.${s}`:s,c=e[s];c!==null&&typeof c=="object"&&!Array.isArray(c)&&n<2?Object.assign(i,Ds(c,a,n+1)):i[a]=c}return i}function so(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:Ds(r))}function bo(e){if(!Array.isArray(e)||e.length===0)return[];const r=so(e),n=new Set;r.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;r.forEach(S=>{typeof S=="object"&&S!==null&&c in S&&(u++,l.add(Pa(S[c])))});const y=u===r.length,g=l.size>1&&!l.has("null");let m="mixed";if(l.size===1)m=Array.from(l)[0];else if(l.size===2&&l.has("null")){const S=Array.from(l).filter(C=>C!=="null");S.length===1&&(m=S[0])}i.push({name:c,type:m,required:y,hasConflict:g})});const a=r.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=$a(c.name,a);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function Di(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function Na(e){return e.some(r=>r.hasConflict)}function dt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function _i(e){return e==null}function La(e){return(r,n,i)=>{const s=_i(r),a=_i(n);if(s&&a)return 0;if(s)return 1;if(a)return-1;let c=0;switch(e){case"number":const l=Number(r),u=Number(n);c=l-u;break;case"boolean":c=(r?1:0)-(n?1:0);break;case"string":c=String(r).localeCompare(String(n));break;case"array":case"object":c=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:c=String(r).localeCompare(String(n));break}return i==="asc"?c:-c}}function Fa(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((s,a)=>s.priority-a.priority);return[...e].sort((s,a)=>{for(const c of i){const l=r.find(g=>g.name===c.column);if(!l)continue;const y=La(l.type)(s[c.column],a[c.column],c.direction);if(y!==0)return y}return 0})}function Va(e){return e===null?"asc":e==="asc"?"desc":null}function Ha(e){return e==="string"||e==="boolean"}function Ua(e){return e.filter(r=>Ha(r.type))}function Ga(e,r){const n={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(a=>a[i.name]).filter(a=>typeof a=="number");s.length>0&&(n[i.name]=s.reduce((a,c)=>a+c,0))}}),n}function Ya(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=pi(e,n.levels,r);return _s(i,n.collapsedGroups||[])}function pi(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,c=new Map;e.forEach(y=>{const g=y[a],m=g==null?"(empty)":String(g);c.has(m)||c.set(m,[]),c.get(m).push(y)});const l=[];return Array.from(c.keys()).sort().forEach(y=>{const g=c.get(y),m=`${a}:${y}`,S=i?`${i}|${m}`:m,C=Ga(g,n),D=s<r.length-1?pi(g,r,n,S,s+1):g,v={key:S,level:s,column:a,value:y,rowCount:g.length,aggregates:C,children:D};l.push(v)}),l}function _s(e,r,n=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const a=r.includes(s.key);n.push({isGroupHeader:!0,groupKey:s.key,groupLevel:s.level,groupColumn:s.column,groupValue:s.value,rowCount:s.rowCount,aggregates:s.aggregates,isCollapsed:a}),!a&&s.children&&_s(s.children,r,n,i+1)}else n.push({...s,__urm_row_id__:s.__urm_row_id__,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function $i(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=pi(e,n.levels,r),s=[],a=c=>{for(const l of c)"key"in l&&"level"in l&&"children"in l&&(s.push(l.key),a(l.children))};return a(i),s}function qa(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function $s(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Ja(e,r,n){const i=r?dt(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function lo(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Xe(e){return"children"in e}function At(){return{id:lo(),operator:"and",children:[]}}function He(e){return e?Array.isArray(e)?{id:lo(),operator:"and",children:e.map(r=>({...r,id:r.id??lo()}))}:e:At()}function Tt(e){return e?Xe(e)?e.children.reduce((r,n)=>r+Tt(n),0):1:0}function en(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(Xe(n)){const i=en(n,r);if(i)return i}}}function co(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Xe(i)?co(i,r,n):i)}}function hi(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!Xe(i)?{...i,...n}:Xe(i)?hi(i,r,n):i)}}function mi(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>Xe(i)?mi(i,r,n):i)}}function fi(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>Xe(i)?fi(i,r):i).filter(i=>!Xe(i)||i.children.length>0);return{...e,children:n}}function ni(e,r){return e?Xe(e)?e.children.some(n=>ni(n,r)):e.column===r:!1}function Os(e,r){const n=e.children.filter(i=>Xe(i)||i.column!==r).map(i=>Xe(i)?Os(i,r):i).filter(i=>!Xe(i)||i.children.length>0);return{...e,children:n}}function Ms(e){return e?Xe(e)?e.children.flatMap(Ms):[e]:[]}function Eo(e){if(!e)return null;if(!Xe(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(Eo)}}function wo(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const n=r.levels.map(s=>s.column),i=e.filter(s=>!n.includes(s));return[...n,...i]}function xi(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(a=>a.column),s=e.filter(a=>!i.includes(a));if(n){const a=[],c=new Set(i),l=new Set(s);let u=0;for(const y of n)c.has(y)?a.push(y):l.has(y)&&u<s.length?(a.push(s[u]),u++):l.has(y)||a.push(y);for(let y=u;y<s.length;y++)a.includes(s[y])||a.push(s[y]);return a}return[...e]}function Gn(e){const r={},n=[],i={};return e.forEach(s=>{r[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:At(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Ka(e,r,n,i,s,a,c,l){const u={},y=[],g={};n.forEach(C=>{u[C.name]=!0,y.push(C.name),g[C.name]=170});const S=xi(s||y,c||null,l||y);return{filters:He(e),sortStack:r||[],columnVisibility:i||u,columnOrder:S,columnWidths:a||g,grouping:c||null}}function Xa(e,r){const n=C=>{if(C==null)return C;if(Array.isArray(C))return C.map(D=>n(D));if(typeof C=="object"){const D={};return Object.keys(C).sort().forEach(v=>{D[v]=n(C[v])}),D}return C},i=C=>JSON.stringify(n(C));if(i(Eo(e.filters))!==i(Eo(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},a=r.columnVisibility??{};if(i(s)!==i(a))return!0;const c=xi(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),l=[...c].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(l!==u)return!1;const y=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==y){if(c.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const C=[...c].sort().join(",");if(c.join(",")!==C)return!0}const m=e.columnWidths??{},S=r.columnWidths??{};return i(m)!==i(S)||i(e.grouping)!==i(r.grouping)}function Qa(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function Za(e,r){var v,x,B;const n=[],i=JSON.stringify(Eo(e.filters)),s=JSON.stringify(Eo(r.filters));if(i!==s){const h=Tt(e.filters),k=Tt(r.filters);h>k?n.push({category:"filters",label:"Filters Added",description:`${h-k} new filter${h-k>1?"s":""} added`}):h<k?n.push({category:"filters",label:"Filters Removed",description:`${k-h} filter${k-h>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),c=JSON.stringify(r.sortStack);if(a!==c){const h=e.sortStack.length,k=r.sortStack.length;h>k?n.push({category:"sorting",label:"Sorting Added",description:`${h-k} new sort rule${h-k>1?"s":""} added`}):h<k?n.push({category:"sorting",label:"Sorting Removed",description:`${k-h} sort rule${k-h>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const l=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(l!==u){const h=Object.values(e.columnVisibility).filter(T=>T).length,k=Object.values(r.columnVisibility).filter(T=>T).length;h>k?n.push({category:"visibility",label:"Columns Shown",description:`${h-k} column${h-k>1?"s":""} made visible`}):h<k?n.push({category:"visibility",label:"Columns Hidden",description:`${k-h} column${k-h>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const y=JSON.stringify(e.columnOrder),g=JSON.stringify(r.columnOrder);y!==g&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const m=JSON.stringify(e.columnWidths),S=JSON.stringify(r.columnWidths);if(m!==S){const h=Object.keys(e.columnWidths).filter(k=>e.columnWidths[k]!==r.columnWidths[k]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${h} column width${h>1?"s":""} modified`})}const C=JSON.stringify(e.grouping),D=JSON.stringify(r.grouping);if(C!==D){const h=(v=e.grouping)==null?void 0:v.enabled,k=(x=r.grouping)==null?void 0:x.enabled;if(h&&!k){const T=((B=e.grouping)==null?void 0:B.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${T} grouping level${T>1?"s":""} added`})}else!h&&k?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 Oi(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Mi(e){return`[${e}]`}const Jt={warn(e,r,...n){Oi()&&console.warn(Mi(e),r,...n)},error(e,r,...n){Oi()&&console.error(Mi(e),r,...n)}},As="urm_report_";function el(e,r){try{const n=`${As}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Jt.error("urm:persistence","Failed to save report state",n)}}function tl(e){try{const r=`${As}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Jt.error("urm:persistence","Failed to load report state",r),null}}function _o(e,r,n=0){const i=[];for(const s of e){const a=r.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:a}),!a&&s.children&&s.children.length>0){const c=s.children[0];if(rl(c)){const l=s.children,u=_o(l,r,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 rl(e){return e&&typeof e=="object"&&"key"in e&&"level"in e&&"column"in e&&"value"in e&&"rowCount"in e&&"aggregates"in e&&"children"in e}function un(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function pn(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),c=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${c}.${r}`}function rn(e,r,n,i,s,a,c){let l,u;a?(l={...a},u=c||r.map(g=>g.name)):s?(l={...s.snapshot.columnVisibility},u=c||[...s.snapshot.columnOrder]):(l={},u=[],r.forEach(g=>{l[g.name]=!0,u.push(g.name)}));const y=Object.entries(l).filter(([g,m])=>!m).map(([g,m])=>g);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:y,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function on(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(m=>e.columnVisibility[m]);let l;if(a&&a.enabled){const m=a.collapsedGroups??[],S=_o(i,m);l=un(S)}else l=i;const u=c.join(","),y=l.map(m=>c.map(S=>{const C=m[S];if(C==null)return"";const D=String(C);return D.includes(",")||D.includes('"')||D.includes(`
2
- `)?`"${D.replace(/"/g,'""')}"`:D}).join(",")),g=[u,...y].join(`
3
- `);gi(g,pn(r,"csv"),"text/csv;charset=utf-8;")}function nn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(m=>e.columnVisibility[m]);let l;if(a&&a.enabled){const m=a.collapsedGroups??[],S=_o(i,m);l=un(S)}else l=i;const u=[c,...l.map(m=>c.map(S=>m[S]??""))],y=Go.utils.aoa_to_sheet(u),g=Go.utils.book_new();Go.utils.book_append_sheet(g,y,"Data"),Go.writeFile(g,pn(r,"xlsx"))}function sn(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:c,hiddenColumns:l,columnOrder:u,grouping:y}=e,g=u.filter(D=>e.columnVisibility[D]);let m;if(y&&y.enabled){const D=y.collapsedGroups??[],v=_o(i,D);m=un(v)}else m=i;m=m.map(D=>{const v={};return g.forEach(x=>{v[x]=D[x]}),v});const S={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(c==null?void 0:c.name)||"Default View",filters:Ms(s).map(D=>({field:D.column,operator:D.operator,value:D.value})),sortStack:a.map(D=>({field:D.column,direction:D.direction,priority:D.priority})),grouping:y||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:m},C=JSON.stringify(S,null,2);gi(C,pn(r,"json"),"application/json;charset=utf-8;")}function gi(e,r,n){const i=new Blob([e],{type:n}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}function yi(e,r="export",n){var v;const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(x=>e.columnVisibility[x]);let l;if(a&&a.enabled){const x=a.collapsedGroups??[],B=_o(i,x);l=un(B)}else l=i;const u=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),y=c.map(x=>`<th>${Yo(x)}</th>`).join(""),g=l.map((x,B)=>{const h=c.map(k=>{const T=x[k],b=T==null?"":String(T);return`<td>${Yo(b)}</td>`}).join("");return`<tr class="${B%2===0?"even":"odd"}">${h}</tr>`}).join(""),m=`<!DOCTYPE html>
1
+ "use strict";var va=Object.defineProperty;var Sa=(e,r,n)=>r in e?va(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Di=(e,r,n)=>Sa(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),Ca=require("xlsx"),M=require("@mui/icons-material"),o=require("@mui/material"),Is=require("react-dom"),wa=require("@emotion/react"),nr=require("react-dnd"),pi=require("react-dnd-html5-backend");function Es(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const pn=Es(p),qo=Es(Ca),ft={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","pdf"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},Ds="urm_dev_config";function ja(){try{const e=localStorage.getItem(Ds);if(!e)return ft;const r=JSON.parse(e),n={sort:{...ft.sort,...r.sort},filter:{...ft.filter,...r.filter},columns:{...ft.columns,...r.columns},grouping:{...ft.grouping,...r.grouping},export:{...ft.export,...r.export},views:{...ft.views,...r.views},dates:{...ft.dates,...r.dates},display:{...ft.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return ft}}function ka(e){try{localStorage.setItem(Ds,JSON.stringify(e))}catch{}}function za(e,r,n){if(!n||!r)return e;const i={sort:{...e.sort,...r.sort},filter:{...e.filter,...r.filter},columns:{...e.columns,...r.columns},grouping:{...e.grouping,...r.grouping},export:{...e.export,...r.export},views:{...e.views,...r.views},dates:{...e.dates,...r.dates},display:{...e.display,...r.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const Ba=/^\d{4}-\d{2}-\d{2}$/,Ta=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Ia=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Ea=9783072e5,Da=41024448e5,_a=978307200,$a=4102444800;function Oa(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=Ea&&e<=Da?"timestamp_ms":Number.isInteger(e)&&e>=_a&&e<=$a?"timestamp_s":"unknown":typeof e!="string"?"unknown":Ta.test(e)||Ba.test(e)?"iso":Ia.test(e.trim())?"locale_string":"unknown"}function Ma(e,r){const n=r.map(d=>d[e]).filter(d=>d!=null&&d!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const d of n){const l=Oa(d);i[l]++}const s=n.length,a=.7;for(const d of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[d]/s>=a)return d;return"unknown"}function Aa(e,r){if(e==null||e==="")return null;try{switch(r){case"timestamp_ms":{const n=new Date(Number(e));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(e)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const _i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Wa=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ye(e){return String(e).padStart(2,"0")}function Ra(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),a=Math.floor(s/60),d=Math.floor(a/60),l=Math.floor(d/24),u=Math.floor(l/7),x=Math.floor(l/30),g=Math.floor(l/365);let m;return s<60?m="just now":a<60?m=`${a} minute${a!==1?"s":""}`:d<24?m=`${d} hour${d!==1?"s":""}`:l<7?m=`${l} day${l!==1?"s":""}`:u<5?m=`${u} week${u!==1?"s":""}`:x<12?m=`${x} month${x!==1?"s":""}`:m=`${g} year${g!==1?"s":""}`,s<60?m:i?`${m} ago`:`in ${m}`}function Pa(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),d=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${Ye(i+1)}-${Ye(s)}`;case"DD/MM/YYYY":return`${Ye(s)}/${Ye(i+1)}/${n}`;case"MM/DD/YYYY":return`${Ye(i+1)}/${Ye(s)}/${n}`;case"MMM DD, YYYY":return`${_i[i]} ${Ye(s)}, ${n}`;case"DD MMM YYYY":return`${Ye(s)} ${_i[i]} ${n}`;case"MMMM D, YYYY":return`${Wa[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ye(i+1)}-${Ye(s)} ${Ye(a)}:${Ye(d)}`;case"DD/MM/YYYY HH:mm":return`${Ye(s)}/${Ye(i+1)}/${n} ${Ye(a)}:${Ye(d)}`;case"MM/DD/YYYY HH:mm":return`${Ye(i+1)}/${Ye(s)}/${n} ${Ye(a)}:${Ye(d)}`;case"relative":return Ra(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function Na(e,r,n){if(!n||r==="unknown")return String(e);const i=Aa(e,r);return!i||isNaN(i.getTime())?String(e):Pa(i,n)}function La(e){return e==null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?"number":typeof e=="boolean"?"boolean":typeof e=="string"?"string":"mixed"}function _s(e,r="",n=0){if(n>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const a=r?`${r}.${s}`:s,d=e[s];d!==null&&typeof d=="object"&&!Array.isArray(d)&&n<2?Object.assign(i,_s(d,a,n+1)):i[a]=d}return i}function so(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:_s(r))}function So(e){if(!Array.isArray(e)||e.length===0)return[];const r=so(e),n=new Set;r.forEach(d=>{typeof d=="object"&&d!==null&&Object.keys(d).forEach(l=>n.add(l))});const i=[];n.forEach(d=>{const l=new Set;let u=0;r.forEach(C=>{typeof C=="object"&&C!==null&&d in C&&(u++,l.add(La(C[d])))});const x=u===r.length,g=l.size>1&&!l.has("null");let m="mixed";if(l.size===1)m=Array.from(l)[0];else if(l.size===2&&l.has("null")){const C=Array.from(l).filter(S=>S!=="null");C.length===1&&(m=C[0])}i.push({name:d,type:m,required:x,hasConflict:g})});const a=r.slice(0,50);for(const d of i){if(d.type!=="string"&&d.type!=="number")continue;const l=Ma(d.name,a);l!=="unknown"&&(d.type="date",d.dateFormat=l)}return i}function $i(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function Fa(e){return e.some(r=>r.hasConflict)}function ct(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function Oi(e){return e==null}function Va(e){return(r,n,i)=>{const s=Oi(r),a=Oi(n);if(s&&a)return 0;if(s)return 1;if(a)return-1;let d=0;switch(e){case"number":const l=Number(r),u=Number(n);d=l-u;break;case"boolean":d=(r?1:0)-(n?1:0);break;case"string":d=String(r).localeCompare(String(n));break;case"array":case"object":d=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:d=String(r).localeCompare(String(n));break}return i==="asc"?d:-d}}function Ha(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((s,a)=>s.priority-a.priority);return[...e].sort((s,a)=>{for(const d of i){const l=r.find(g=>g.name===d.column);if(!l)continue;const x=Va(l.type)(s[d.column],a[d.column],d.direction);if(x!==0)return x}return 0})}function Ua(e){return e===null?"asc":e==="asc"?"desc":null}function Ga(e){return e==="string"||e==="boolean"}function Ya(e){return e.filter(r=>Ga(r.type))}function qa(e,r){const n={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(a=>a[i.name]).filter(a=>typeof a=="number");s.length>0&&(n[i.name]=s.reduce((a,d)=>a+d,0))}}),n}function Ja(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=hi(e,n.levels,r);return $s(i,n.collapsedGroups||[])}function hi(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,d=new Map;e.forEach(x=>{const g=x[a],m=g==null?"(empty)":String(g);d.has(m)||d.set(m,[]),d.get(m).push(x)});const l=[];return Array.from(d.keys()).sort().forEach(x=>{const g=d.get(x),m=`${a}:${x}`,C=i?`${i}|${m}`:m,S=qa(g,n),E=s<r.length-1?hi(g,r,n,C,s+1):g,v={key:C,level:s,column:a,value:x,rowCount:g.length,aggregates:S,children:E};l.push(v)}),l}function $s(e,r,n=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const a=r.includes(s.key);n.push({isGroupHeader:!0,groupKey:s.key,groupLevel:s.level,groupColumn:s.column,groupValue:s.value,rowCount:s.rowCount,aggregates:s.aggregates,isCollapsed:a}),!a&&s.children&&$s(s.children,r,n,i+1)}else n.push({...s,__urm_row_id__:s.__urm_row_id__,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function Mi(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=hi(e,n.levels,r),s=[],a=d=>{for(const l of d)"key"in l&&"level"in l&&"children"in l&&(s.push(l.key),a(l.children))};return a(i),s}function Ka(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function Os(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Xa(e,r,n){const i=r?ct(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function lo(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Xe(e){return"children"in e}function Pt(){return{id:lo(),operator:"and",children:[]}}function He(e){return e?Array.isArray(e)?{id:lo(),operator:"and",children:e.map(r=>({...r,id:r.id??lo()}))}:e:Pt()}function Et(e){return e?Xe(e)?e.children.reduce((r,n)=>r+Et(n),0):1:0}function rn(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(Xe(n)){const i=rn(n,r);if(i)return i}}}function co(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Xe(i)?co(i,r,n):i)}}function mi(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!Xe(i)?{...i,...n}:Xe(i)?mi(i,r,n):i)}}function fi(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>Xe(i)?fi(i,r,n):i)}}function xi(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>Xe(i)?xi(i,r):i).filter(i=>!Xe(i)||i.children.length>0);return{...e,children:n}}function ii(e,r){return e?Xe(e)?e.children.some(n=>ii(n,r)):e.column===r:!1}function Ms(e,r){const n=e.children.filter(i=>Xe(i)||i.column!==r).map(i=>Xe(i)?Ms(i,r):i).filter(i=>!Xe(i)||i.children.length>0);return{...e,children:n}}function As(e){return e?Xe(e)?e.children.flatMap(As):[e]:[]}function _o(e){if(!e)return null;if(!Xe(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(_o)}}function ko(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const n=r.levels.map(s=>s.column),i=e.filter(s=>!n.includes(s));return[...n,...i]}function gi(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(a=>a.column),s=e.filter(a=>!i.includes(a));if(n){const a=[],d=new Set(i),l=new Set(s);let u=0;for(const x of n)d.has(x)?a.push(x):l.has(x)&&u<s.length?(a.push(s[u]),u++):l.has(x)||a.push(x);for(let x=u;x<s.length;x++)a.includes(s[x])||a.push(s[x]);return a}return[...e]}function Yn(e){const r={},n=[],i={};return e.forEach(s=>{r[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:Pt(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Qa(e,r,n,i,s,a,d,l){const u={},x=[],g={};n.forEach(S=>{u[S.name]=!0,x.push(S.name),g[S.name]=170});const C=gi(s||x,d||null,l||x);return{filters:He(e),sortStack:r||[],columnVisibility:i||u,columnOrder:C,columnWidths:a||g,grouping:d||null}}function Za(e,r){const n=S=>{if(S==null)return S;if(Array.isArray(S))return S.map(E=>n(E));if(typeof S=="object"){const E={};return Object.keys(S).sort().forEach(v=>{E[v]=n(S[v])}),E}return S},i=S=>JSON.stringify(n(S));if(i(_o(e.filters))!==i(_o(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},a=r.columnVisibility??{};if(i(s)!==i(a))return!0;const d=gi(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),l=[...d].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(l!==u)return!1;const x=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==x){if(d.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const S=[...d].sort().join(",");if(d.join(",")!==S)return!0}const m=e.columnWidths??{},C=r.columnWidths??{};return i(m)!==i(C)||i(e.grouping)!==i(r.grouping)}function el(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function tl(e,r){var v,y,k;const n=[],i=JSON.stringify(_o(e.filters)),s=JSON.stringify(_o(r.filters));if(i!==s){const h=Et(e.filters),j=Et(r.filters);h>j?n.push({category:"filters",label:"Filters Added",description:`${h-j} new filter${h-j>1?"s":""} added`}):h<j?n.push({category:"filters",label:"Filters Removed",description:`${j-h} filter${j-h>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),d=JSON.stringify(r.sortStack);if(a!==d){const h=e.sortStack.length,j=r.sortStack.length;h>j?n.push({category:"sorting",label:"Sorting Added",description:`${h-j} new sort rule${h-j>1?"s":""} added`}):h<j?n.push({category:"sorting",label:"Sorting Removed",description:`${j-h} sort rule${j-h>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const l=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(l!==u){const h=Object.values(e.columnVisibility).filter(T=>T).length,j=Object.values(r.columnVisibility).filter(T=>T).length;h>j?n.push({category:"visibility",label:"Columns Shown",description:`${h-j} column${h-j>1?"s":""} made visible`}):h<j?n.push({category:"visibility",label:"Columns Hidden",description:`${j-h} column${j-h>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const x=JSON.stringify(e.columnOrder),g=JSON.stringify(r.columnOrder);x!==g&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const m=JSON.stringify(e.columnWidths),C=JSON.stringify(r.columnWidths);if(m!==C){const h=Object.keys(e.columnWidths).filter(j=>e.columnWidths[j]!==r.columnWidths[j]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${h} column width${h>1?"s":""} modified`})}const S=JSON.stringify(e.grouping),E=JSON.stringify(r.grouping);if(S!==E){const h=(v=e.grouping)==null?void 0:v.enabled,j=(y=r.grouping)==null?void 0:y.enabled;if(h&&!j){const T=((k=e.grouping)==null?void 0:k.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${T} grouping level${T>1?"s":""} added`})}else!h&&j?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 Ai(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Wi(e){return`[${e}]`}const Jt={warn(e,r,...n){Ai()&&console.warn(Wi(e),r,...n)},error(e,r,...n){Ai()&&console.error(Wi(e),r,...n)}},Ws="urm_report_";function rl(e,r){try{const n=`${Ws}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Jt.error("urm:persistence","Failed to save report state",n)}}function ol(e){try{const r=`${Ws}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Jt.error("urm:persistence","Failed to load report state",r),null}}function Oo(e,r,n=0){const i=[];for(const s of e){const a=r.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:a}),!a&&s.children&&s.children.length>0){const d=s.children[0];if(nl(d)){const l=s.children,u=Oo(l,r,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 nl(e){return e&&typeof e=="object"&&"key"in e&&"level"in e&&"column"in e&&"value"in e&&"rowCount"in e&&"aggregates"in e&&"children"in e}function hn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function mn(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),d=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${d}.${r}`}function nn(e,r,n,i,s,a,d){let l,u;a?(l={...a},u=d||r.map(g=>g.name)):s?(l={...s.snapshot.columnVisibility},u=d||[...s.snapshot.columnOrder]):(l={},u=[],r.forEach(g=>{l[g.name]=!0,u.push(g.name)}));const x=Object.entries(l).filter(([g,m])=>!m).map(([g,m])=>g);return{data:e,schema:r,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 sn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,d=s.filter(m=>e.columnVisibility[m]);let l;if(a&&a.enabled){const m=a.collapsedGroups??[],C=Oo(i,m);l=hn(C)}else l=i;const u=d.join(","),x=l.map(m=>d.map(C=>{const S=m[C];if(S==null)return"";const E=String(S);return E.includes(",")||E.includes('"')||E.includes(`
2
+ `)?`"${E.replace(/"/g,'""')}"`:E}).join(",")),g=[u,...x].join(`
3
+ `);yi(g,mn(r,"csv"),"text/csv;charset=utf-8;")}function an(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,d=s.filter(m=>e.columnVisibility[m]);let l;if(a&&a.enabled){const m=a.collapsedGroups??[],C=Oo(i,m);l=hn(C)}else l=i;const u=[d,...l.map(m=>d.map(C=>m[C]??""))],x=qo.utils.aoa_to_sheet(u),g=qo.utils.book_new();qo.utils.book_append_sheet(g,x,"Data"),qo.writeFile(g,mn(r,"xlsx"))}function ln(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:d,hiddenColumns:l,columnOrder:u,grouping:x}=e,g=u.filter(E=>e.columnVisibility[E]);let m;if(x&&x.enabled){const E=x.collapsedGroups??[],v=Oo(i,E);m=hn(v)}else m=i;m=m.map(E=>{const v={};return g.forEach(y=>{v[y]=E[y]}),v});const C={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(d==null?void 0:d.name)||"Default View",filters:As(s).map(E=>({field:E.column,operator:E.operator,value:E.value})),sortStack:a.map(E=>({field:E.column,direction:E.direction,priority:E.priority})),grouping:x||{},hiddenColumns:l,columnOrder:u,exportConfig:n||{scope:"visible"}},data:m},S=JSON.stringify(C,null,2);yi(S,mn(r,"json"),"application/json;charset=utf-8;")}function yi(e,r,n){const i=new Blob([e],{type:n}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}function bi(e,r="export",n){var v;const{data:i,columnOrder:s,grouping:a}=e,d=s.filter(y=>e.columnVisibility[y]);let l;if(a&&a.enabled){const y=a.collapsedGroups??[],k=Oo(i,y);l=hn(k)}else l=i;const u=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),x=d.map(y=>`<th>${Jo(y)}</th>`).join(""),g=l.map((y,k)=>{const h=d.map(j=>{const T=y[j],b=T==null?"":String(T);return`<td>${Jo(b)}</td>`}).join("");return`<tr class="${k%2===0?"even":"odd"}">${h}</tr>`}).join(""),m=`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8" />
7
- <title>${Yo(r)}</title>
7
+ <title>${Jo(r)}</title>
8
8
  <style>
9
9
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
10
10
  body {
@@ -82,14 +82,14 @@
82
82
  </head>
83
83
  <body>
84
84
  <div class="report-header">
85
- <div class="report-title">${Yo(r)}</div>
85
+ <div class="report-title">${Jo(r)}</div>
86
86
  <div class="report-meta">
87
87
  ${l.length.toLocaleString()} row${l.length!==1?"s":""}<br/>
88
88
  Generated ${u}
89
89
  </div>
90
90
  </div>
91
91
  <table>
92
- <thead><tr>${y}</tr></thead>
92
+ <thead><tr>${x}</tr></thead>
93
93
  <tbody>${g}</tbody>
94
94
  </table>
95
95
  <div class="report-footer">Universal Report Module &mdash; PDF Export</div>
@@ -102,26 +102,26 @@
102
102
  };
103
103
  <\/script>
104
104
  </body>
105
- </html>`;try{const x=document.createElement("iframe");x.style.position="fixed",x.style.right="0",x.style.bottom="0",x.style.width="0",x.style.height="0",x.style.border="0",document.body.appendChild(x);const B=((v=x.contentWindow)==null?void 0:v.document)||x.contentDocument;if(B){B.open(),B.write(m),B.close(),setTimeout(()=>{var h,k;try{(h=x.contentWindow)==null||h.focus(),(k=x.contentWindow)==null||k.print()}catch{}setTimeout(()=>{document.body.removeChild(x)},3e3)},300);return}}catch{}const S=new Blob([m],{type:"text/html;charset=utf-8;"}),C=URL.createObjectURL(S);window.open(C,"_blank")||gi(m,pn(r,"html"),"text/html;charset=utf-8;")}function Yo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Ai=10;function ol(e,r){const n=r.trim();if(!n)return e;const i=e.findIndex(a=>a.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...e[i],lastUsed:Date.now()},...e.slice(0,i),...e.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...e],s.length>Ai&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Ai)),s}function nl(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function il(e,r){return e.filter(n=>n.query!==r)}function sl(e){const r=e.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),n=e.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...r,...n]}const al={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 ll(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function kt(e,r){return al[r].includes(e)}function zt(e){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"}[e]||"perform this action"}.`}function cl(e){return e==="viewer"}const Wi=1e3;function ii(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function qt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return ii(n)}const dl={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 ul(e){if(!e||!e.column)return"a filter";const r=qt(e.column),n=dl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function Yn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":ul(e):"a filter"}function Ri(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${qt(n.column)}"`).join(", ")}`}function pl(e){var s,a,c;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Yn(i)}`};case"filter_removed":return{summary:`Filter removed: ${Yn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const l=n,u=i;return l!=null&&l.column&&(u!=null&&u.column)&&l.column!==u.column?{summary:`Filter changed on "${qt(u.column)}"`,detail:`Previously filtered "${qt(l.column)}"`}:{summary:`Filter updated: ${Yn(u)}`}}case"filter_cleared":{const l=n&&typeof n=="object"&&"count"in n?n.count: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?qt(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?qt(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: ${Ri(i)}`};case"group_level_removed":{const l=n,u=(a=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&a.column?qt(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Ri(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: "${qt(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${qt(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: "${qt(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":case"export_pdf":{const l=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,y=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",g=(i==null?void 0:i.viewName)??"",m=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${m}`,detail:g?`${ii(y)} · View: "${g}"`:ii(y)}}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"row_edited":{const l=(i==null?void 0:i.id)??(n==null?void 0:n.id)??"",u=(i==null?void 0:i.label)??(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}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:ml(r)}}}function hl(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Bo(e,r,n,i,s,a){return{id:hl(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function To(e,r){const n=[r,...e];return n.length>Wi?n.slice(0,Wi):n}function ml(e){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",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function qn(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function fl(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Pi=100;function xl(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function gl(e){var a;const r=(a=e.views)==null?void 0:a.find(c=>c.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=xi(i,e.grouping||null,n);return{filters:He(e.filters),sortStack:e.sortStack?[...e.sortStack]:[],columnVisibility:e.columnVisibility?{...e.columnVisibility}:{},columnOrder:s,columnWidths:e.columnWidths?{...e.columnWidths}:{},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}function yl(e,r,n,i){return{id:xl(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function bl(e,r){const n=e||[];if(n.length>=Pi)throw new Error(`Maximum of ${Pi} presets reached. Please delete old presets first.`);return[...n,r]}function vl(e,r){return(e||[]).filter(i=>i.id!==r)}function Ni(e,r){if(e)return e.find(n=>n.id===r)}function Sl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Cl(e){const r=e.columnOrder,n=wo(r,e.grouping);return{filters:He(e.filters),sortStack:e.sortStack.length>0?[...e.sortStack]:void 0,columnVisibility:{...e.columnVisibility},columnOrder:n,columnWidths:{...e.columnWidths},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}async function wl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Jt.warn("urm:presets","Clipboard API blocked, using fallback method",r)}try{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width="2em",r.style.height="2em",r.style.padding="0",r.style.border="none",r.style.outline="none",r.style.boxShadow="none",r.style.background="transparent",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let n=!1;try{n=document.execCommand("copy")}catch(i){Jt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Jt.error("urm:presets","Fallback copy method failed",r),!1}}function jl(e,r){return{totalRows:e.length,totalColumns:r.length}}function fr(e,r,n,i){const s=n instanceof Error?n.message:n,a={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:kl(e,r)};return process.env.NODE_ENV==="development"&&Jt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function kl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function zl(e){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"}[e.context]||"An error occurred";return e.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function Bl(e){return{filters:e.filters,sortStack:e.sortStack?[...e.sortStack]:void 0,grouping:e.grouping?{...e.grouping}:void 0,columnVisibility:e.columnVisibility?{...e.columnVisibility}:void 0,columnOrder:e.columnOrder?[...e.columnOrder]:void 0,columnWidths:e.columnWidths?{...e.columnWidths}:void 0,activeViewId:e.activeViewId}}function Tl(e,r,n){n(e.id,{filters:He(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function Il(e,r,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(r)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:e==="number"&&["gt","gte","lt","lte","equals"].includes(r)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:e==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function Ws(e,r){const n=[],i=[],s=new Set(r.map(a=>a.name));return e.forEach(a=>{s.has(a.column)?n.push(a):i.push(a.column)}),{validRules:n,invalidColumns:i}}function Rs(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(a=>a.name)),i=[],s=[];return e.levels.forEach(a=>{n.has(a.column)?i.push(a):s.push(a.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function El(e,r){const n=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=c=>{const l=c.children.filter(u=>{if(Xe(u))return!0;const y=i.has(u.column);return y||n.push(`Filter for column "${u.column}" ignored (column not found)`),y}).map(u=>Xe(u)?a(u):u).filter(u=>!Xe(u)||u.children.length>0);return{...c,children:l}};s.filters=a(He(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:c}=Ws(s.sortStack,r);c.length>0&&n.push(`Sort rules for columns ignored: ${c.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:c}=Rs(s.grouping,r);c.length>0&&n.push(`Grouping for columns ignored: ${c.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column visibility for "${c}" ignored (column not found)`)}),s.columnVisibility=Object.keys(a).length>0?a:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const a=s.columnOrder.filter(c=>{const l=i.has(c);return l||n.push(`Column "${c}" in order ignored (column not found)`),l});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([c,l])=>{i.has(c)?a[c]=l:n.push(`Column width for "${c}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:n}}function Dl(e,r){return fr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Li(e,r,n,i){const s=Bo(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return To(i||[],s)}function _l(e){return e==null}function $l(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(_l(e))return!1;if(n==="date"){const a=new Date(e).getTime(),c=new Date(s).getTime();switch(i){case"equals":return a===c;case"gt":return a>c;case"lt":return a<c;case"gte":return a>=c;case"lte":return a<=c;default:return!0}}switch(i){case"equals":return String(e).toLowerCase()===String(s).toLowerCase();case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function si(e,r,n){var s;if(Xe(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>si(e,a,n)):r.children.some(a=>si(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return $l(e[r.column],r,i)}function Ol(e,r,n){return!r||r.children.length===0?e:e.filter(i=>si(i,r,n))}function an(e){switch(e){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"date":return[{value:"equals",label:"Is"},{value:"gt",label:"After"},{value:"lt",label:"Before"},{value:"gte",label:"On or after"},{value:"lte",label:"On or before"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Ml(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Al({data:e,filters:r,schema:n}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:Ol(e,r,n),[e,r,n])}}function Wl(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),a=r.filter(c=>i.includes(c.name));return e.filter(c=>a.some(l=>{const u=c[l.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function Rl({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:p.useMemo(()=>s==="server"||!r||r.trim()===""?e:Wl(e,n,r,i),[e,r,n,i,s])}}function Pl({data:e,sortStack:r,schema:n}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:Fa(e,n,r),[e,r,n])}}function Nl({data:e,grouping:r,schema:n}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:Ya(e,n,r),[e,r,n]),s=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function Ll({schema:e,columnVisibility:r,columnOrder:n}){const i=p.useMemo(()=>n.filter(l=>r[l]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([l,u])=>!u).map(([l,u])=>l),[r]),a=p.useMemo(()=>n.map(l=>e.find(y=>y.name===l)||{name:l,type:"string"}),[n,e]),c=p.useMemo(()=>i.map(l=>e.find(y=>y.name===l)||{name:l,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:c,hiddenCount:s.length}}function Fl({views:e,activeViewId:r,currentState:n}){const i=p.useMemo(()=>e.find(y=>y.id===r),[e,r]),s=p.useMemo(()=>i?Xa(n,i.snapshot):!1,[i,n]),a=p.useMemo(()=>e.find(y=>y.isDefault),[e]),c=p.useMemo(()=>e.filter(y=>!y.isDefault&&!y.isDeleted),[e]),l=p.useMemo(()=>e.filter(y=>y.isFavorite&&!y.isDeleted),[e]),u=p.useMemo(()=>e.filter(y=>y.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:c,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Vl(e,r,n){if(!e||e.length===0)return[];if(r<=0)return e.slice(0,n);const i=e.slice(r,n);if(i.length===0)return[];const s=i[0],a=!!(s.__isGroupHeader||s.isGroupHeader),c=a?s.groupLevel??0:s.__urm_group_level__??0;if(c===0&&a)return i;const l=c-1;if(l<0)return i;const u={};let y=l+1;for(let D=r-1;D>=0;D--){const v=e[D];if(v.__isGroupHeader||v.isGroupHeader){const x=v.groupLevel??0;if(x<=l&&u[x]===void 0&&(u[x]=v,y--,y<=0))break}}const g=[];for(let D=0;D<=l;D++)u[D]&&g.push({...u[D],__urm_is_continuation_header__:!0});const m=Math.max(0,n-r-g.length),S=r+m,C=e.slice(r,S);return[...g,...C]}function Hl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=p.useState(i),c=e.length,l=Math.max(1,Math.ceil(c/n));p.useEffect(()=>{s>l&&a(l)},[s,l]);const u=p.useMemo(()=>{if(!r)return e;const C=(s-1)*n,D=C+n;return Vl(e,C,D)},[e,r,s,n]),y=p.useCallback(C=>{const D=Math.max(1,Math.min(C,l));a(D)},[l]),g=p.useCallback(()=>{s<l&&a(C=>Math.min(C+1,l))},[l]),m=p.useCallback(()=>{s>1&&a(C=>Math.max(C-1,1))},[]),S=p.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:y,nextPage:g,prevPage:m,resetPage:S,hasNextPage:s<l,hasPrevPage:s>1}}function Ul(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:c,searchMode:l,columnVisibility:u,columnOrder:y,columnWidths:g,views:m,activeViewId:S,pagination:C}=e,D=p.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:y,columnWidths:g}),[i,s,a,u,y,g]),v=Fl({views:m,activeViewId:S,currentState:D}),x=Ll({schema:n,columnVisibility:u,columnOrder:y}),{filteredData:B}=Al({data:r,filters:i,schema:n}),{sortedData:h}=Pl({data:B,sortStack:s,schema:n}),{groupedData:k,isGrouped:T}=Nl({data:h,grouping:a,schema:n}),{searchedData:b}=Rl({data:k,searchQuery:c,schema:n,visibleColumns:x.visibleColumns,mode:l}),R=Hl({data:b,enabled:(C==null?void 0:C.enabled)||!1,pageSize:(C==null?void 0:C.pageSize)||100,initialPage:(C==null?void 0:C.currentPage)||1}),H=C!=null&&C.enabled?R.paginatedData:b,E=p.useMemo(()=>({totalRows:r.length,filteredRows:B.length,sortedRows:h.length,groupedRows:T?k.length:h.length,searchedRows:b.length,visibleRows:H.length,hiddenColumns:x.hiddenCount,activeFilters:Tt(i),activeSorts:s.length,isGrouped:T}),[r.length,B.length,h.length,k.length,b.length,H.length,x.hiddenCount,i,s.length,T]);return{data:H,filteredData:B,sortedData:h,groupedData:k,searchedData:b,viewEngine:v,columnEngine:x,paginationEngine:R,metrics:E,isGrouped:T,isPaginated:(C==null?void 0:C.enabled)||!1}}let Gl=0;function Yl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):Gl++,writable:!1,enumerable:!1,configurable:!1})}const Mt="user-demo-001";function ql(e={}){var or,Uo,ki,zi,Bi;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:c,scheduler:l,reportName:u,reportId:y,sharedReportId:g,sharedViewId:m,viewPersistence:S,permissions:C,config:D={}}=e,v=(S==null?void 0:S.mode)??"local",x=(a==null?void 0:a.mode)??"client",B=(c==null?void 0:c.mode)??"client",[h,k]=p.useState([]),T=gr(),[b,R]=p.useState(""),[H,E]=p.useState(!1),[Y,Z]=p.useState(!1),[I,f]=p.useState({message:"",severity:"info",open:!1}),w=(z,_="info")=>{f({message:z,severity:_,open:!0})},P=()=>f(z=>({...z,open:!1})),te=D.notifDurationMs??2e3,d=h.find(z=>z.id===b),[J,re]=p.useState("idle"),[we,F]=p.useState(!1),[X,ue]=p.useState(!1),[pe,K]=p.useState(!1),[he,le]=p.useState(!1),[W,ie]=p.useState(!1),[U,ne]=p.useState(void 0),[Be,Q]=p.useState(null),[$e,Pe]=p.useState(null),[Wt,Kt]=p.useState(!1),[Ar,Rt]=p.useState(!1),[mt,St]=p.useState(null),[Wr,Qe]=p.useState(!1),[Dt,Xt]=p.useState(!1),[Pt,ar]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[lr,Rr]=p.useState(""),[Qt,br]=p.useState(""),[Ct,Je]=p.useState(new Set),[vr,ft]=p.useState(1),[rt,Nt]=p.useState(15),[cr,uo]=p.useState(!1),[Pr,dr]=p.useState(!1),[Ke,je]=p.useState(!1),[_t,Sr]=p.useState(null),[Nr,ur]=p.useState(!1),[Cr,Lr]=p.useState(null),[pr,Ze]=p.useState(null),Lt=p.useRef(null),Ce=p.useMemo(()=>d?ll(d.permissions,Mt):"owner",[d]),Ao=cl(Ce),fe=p.useMemo(()=>!(d!=null&&d.uploadedData)||!(d!=null&&d.schema)?{totalRows:0,totalColumns:0}:jl(d.uploadedData,d.schema),[d==null?void 0:d.uploadedData,d==null?void 0:d.schema]),wt=p.useCallback(()=>{d&&(Lt.current=Bl(d))},[d]),V=p.useCallback((z,_)=>{k(A=>A.map(M=>M.id===z?{...M,..._}:M))},[]),xt=p.useCallback(z=>{if(!d)return;Ze(z);const _=Li(d.id,Mt,z,d.auditHistory||[]);V(d.id,{auditHistory:_}),w(z.message,"error"),z.recoverable&&Lt.current&&setTimeout(()=>{Tl(d,Lt.current,V),w("Previous state restored","success")},100)},[d,V]),se=p.useCallback((z,_,A,M)=>{if(!d)return;const q=Bo(d.id,Mt,z,_,A,M),G=d.auditHistory||[],ae=To(G,q);setTimeout(()=>{V(d.id,{auditHistory:ae})},0)},[d,V]);p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const z=Gn(d.schema);(()=>{try{const _=localStorage.getItem("urm_dev_config");return _?JSON.parse(_):null}catch{return null}})(),V(d.id,{views:[z],activeViewId:z.id,filters:z.snapshot.filters,sortStack:z.snapshot.sortStack,columnVisibility:z.snapshot.columnVisibility,columnOrder:z.snapshot.columnOrder,columnWidths:z.snapshot.columnWidths,grouping:z.snapshot.grouping})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,V]),p.useEffect(()=>{if(i&&n&&!Y&&h.length===0){const z=so(i),_={id:y||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:z,schema:Di(bo(z),D.hiddenColumns),permissions:C??{owner:Mt,editors:[],viewers:[]}};k([_]),R(_.id),Z(!0),re("confirmed")}},[i,n,Y,h.length,r,u,y]),p.useEffect(()=>{x!=="server"||!Y||!b||V(b,{uploadedData:so(i||[])})},[i,x,Y,b]),p.useEffect(()=>{x==="server"&&((a==null?void 0:a.page)!==void 0&&ft(a.page),(a==null?void 0:a.pageSize)!==void 0&&Nt(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,x]),p.useEffect(()=>{if(!s||Y)return;let z=!1,_=null;const A=async()=>{try{re("uploading");let M;if(s.type==="api"){const G=await fetch(s.url,{headers:s.headers||{}});if(!G.ok)throw new Error(`HTTP ${G.status}: ${G.statusText}`);M=await G.json()}else M=await s.fetch();if(z)return;if(!Array.isArray(M))throw new Error("Data source must return an array of objects");const q=bo(M);if(Y)k(G=>G.map(ae=>ae.id===b?{...ae,uploadedData:so(M)}:ae)),re("confirmed");else{const G={id:y||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:so(M),schema:Di(bo(so(M)),D.hiddenColumns),permissions:C??{owner:Mt,editors:[],viewers:[]}};k([G]),R(G.id),Z(!0),re("confirmed")}}catch(M){z||(re("error"),d&&V(d.id,{uploadError:(M==null?void 0:M.message)||"Failed to load data from source"}))}};return A(),s.refreshInterval&&s.refreshInterval>0&&(_=setInterval(A,s.refreshInterval)),()=>{z=!0,_&&clearInterval(_)}},[s,u,r,y]);const st=(or=d==null?void 0:d.views)==null?void 0:or.find(z=>z.id===d.activeViewId),wr=p.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(z=>Yl(z,D.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);p.useEffect(()=>{Je(z=>{if(z.size===0)return z;const _=new Set(wr.map(M=>M==null?void 0:M.__urm_row_id__)),A=new Set(Array.from(z).filter(M=>_.has(M==null?void 0:M.__urm_row_id__)));return A.size===z.size?z:A})},[wr]);const jt=Ul({rawData:wr,schema:(d==null?void 0:d.schema)||[],filters:He(d==null?void 0:d.filters),sortStack:(d==null?void 0:d.sortStack)||[],grouping:(d==null?void 0:d.grouping)||null,searchQuery:Qt||"",searchMode:B,columnVisibility:(d==null?void 0:d.columnVisibility)||(st==null?void 0:st.snapshot.columnVisibility)||{},columnOrder:(d==null?void 0:d.columnOrder)||(st==null?void 0:st.snapshot.columnOrder)||[],columnWidths:(d==null?void 0:d.columnWidths)||(st==null?void 0:st.snapshot.columnWidths)||{},views:(d==null?void 0:d.views)||[],activeViewId:(d==null?void 0:d.activeViewId)||"",pagination:{enabled:x==="client",pageSize:rt,currentPage:vr}}),{data:Fr=[],searchedData:hr=[],groupedData:jr=[],sortedData:Ft=[],metrics:kr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Vr=!1,paginationEngine:ke}=jt||{},ut=x==="server"?(a==null?void 0:a.totalRows)??0:kr.searchedRows,ee=((Uo=jt.viewEngine)==null?void 0:Uo.activeView)||st,ce=((ki=jt.viewEngine)==null?void 0:ki.isDirty)||!1;p.useEffect(()=>{if(!(!ee||!d)&&!d.columnOrder){const z=ee.snapshot.columnOrder,_=wo(z,ee.snapshot.grouping);V(d.id,{columnOrder:_})}},[d==null?void 0:d.activeViewId]);const ye=p.useMemo(()=>!(d!=null&&d.schema)||!ee?null:Ka(d.filters,d.sortStack||[],d.schema,d.columnVisibility,d.columnOrder,d.columnWidths,d.grouping,ee.snapshot.columnOrder),[d==null?void 0:d.filters,d==null?void 0:d.sortStack,d==null?void 0:d.schema,d==null?void 0:d.columnVisibility,d==null?void 0:d.columnOrder,d==null?void 0:d.columnWidths,d==null?void 0:d.grouping,ee]),po=p.useMemo(()=>!ee||!ye||!ce?[]:Za(ye,ee.snapshot),[ee,ye,ce]),zr=p.useCallback((z,_,A)=>{const M={id:`report-${Date.now()}`,name:z,description:_,schemaLocked:!1,permissions:{owner:Mt,editors:[],viewers:[]}};if(A&&Array.isArray(A)&&A.length>0){const q=bo(A),G=Gn(q);M.uploadedData=A,M.schema=q,M.schemaLocked=!0,M.views=[G],M.activeViewId=G.id,M.sortStack=G.snapshot.sortStack,M.filters=G.snapshot.filters,M.columnVisibility=G.snapshot.columnVisibility,M.columnOrder=G.snapshot.columnOrder,M.columnWidths=G.snapshot.columnWidths,M.grouping=G.snapshot.grouping}k(q=>[...q,M]),R(M.id),E(!1),re("confirmed")},[]),Br=p.useCallback(z=>{d&&(re("uploading"),setTimeout(()=>{const _=bo(z);V(d.id,{uploadedData:z,schema:_,uploadError:void 0}),re("preview")},500))},[d,V]),Hr=p.useCallback(z=>{d&&(V(d.id,{uploadError:z}),re("idle"))},[d,V]),ho=p.useCallback(()=>{d&&(V(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),re("idle"))},[d,V]),Vt=p.useCallback(()=>{d&&(V(d.id,{schemaLocked:!0}),re("confirmed"))},[d,V]),mo=p.useCallback(z=>{if(!d)return;if(!kt("edit_sorting",Ce)){w(zt("edit_sorting"),"error");return}const _=d.sortStack??[],A=_.find(M=>M.column===z);if(A){const M=Va(A.direction);if(M===null){const q=_.filter(G=>G.column!==z).map((G,ae)=>({...G,priority:ae+1}));se("sorting","sort_level_removed",A,null),V(d.id,{sortStack:q.length>0?q:void 0})}else{const q=M,G=_.map(ae=>ae.column===z?{...ae,direction:q}:ae);se("sorting","sort_reordered",{column:z,direction:A.direction},{column:z,direction:q}),V(d.id,{sortStack:G})}}else{if(_.length>=T.sort.maxLevels){w(`Sort limit reached — maximum ${T.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:z,direction:"asc",priority:_.length+1};se("sorting","sort_level_added",null,M),V(d.id,{sortStack:[..._,M]})}},[d,Ce,V,se]),Ur=p.useCallback(z=>{if(!d)return;const _=d.sortStack??[],A=z.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:M,invalidColumns:q}=Ws(z,d.schema);q.length>0&&w(`Removed invalid sort columns: ${q.join(", ")}`),wt();try{se("sorting",A,_,M.length>0?M:null),V(d.id,{sortStack:M.length>0?M:void 0})}catch(G){const ae=fr("processing","sorting",G);xt(ae)}}else se("sorting",A,_,z.length>0?z:null),V(d.id,{sortStack:z.length>0?z:void 0})},[d,V,wt,xt,se]),$t=p.useCallback(z=>{if(!d)return;const _=d.sortStack??[],A=_.find(M=>M.column===z);if(!(A&&A.direction==="asc"))if(A){const M=_.map(q=>q.column===z?{...q,direction:"asc"}:q);se("sorting","sort_reordered",{column:z,direction:A.direction},{column:z,direction:"asc"}),V(d.id,{sortStack:M})}else{if(_.length>=T.sort.maxLevels){w(`Sort limit reached — maximum ${T.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:z,direction:"asc",priority:_.length+1};se("sorting","sort_level_added",null,M),V(d.id,{sortStack:[..._,M]})}},[d,V,se]),Tr=p.useCallback(z=>{if(!d)return;const _=d.sortStack??[],A=_.find(M=>M.column===z);if(!(A&&A.direction==="desc"))if(A){const M=_.map(q=>q.column===z?{...q,direction:"desc"}:q);se("sorting","sort_reordered",{column:z,direction:A.direction},{column:z,direction:"desc"}),V(d.id,{sortStack:M})}else{if(_.length>=T.sort.maxLevels){w(`Sort limit reached — maximum ${T.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:z,direction:"desc",priority:_.length+1};se("sorting","sort_level_added",null,M),V(d.id,{sortStack:[..._,M]})}},[d,V,se]),ze=p.useCallback((z,_)=>{var M;if(!d)return;if(!kt("edit_filters",Ce)){w(zt("edit_filters"),"error");return}const A=(M=d.schema)==null?void 0:M.find(q=>q.name===_.column);if(A&&_.value!==void 0){const q=Il(A.type,_.operator,_.value);if(!q.isValid){w(q.errorMessage||"Invalid filter value","error");return}}wt();try{const q=He(d.filters),G={..._,id:lo()},ae=co(q,z,G);se("filters","filter_added",null,G),V(d.id,{filters:ae})}catch(q){const G=fr("processing","filters",q);xt(G)}},[d,Ce,V,wt,xt,se]),Ge=p.useCallback(z=>{if(!d)return;if(!kt("edit_filters",Ce)){w(zt("edit_filters"),"error");return}const _=He(d.filters),A=co(_,z,At());se("filters","filter_added",null,"a condition group"),V(d.id,{filters:A})},[d,Ce,V,se]),Ir=p.useCallback((z,_)=>{if(!d)return;if(!kt("edit_filters",Ce)){w(zt("edit_filters"),"error");return}const A=He(d.filters),M=en(A,z),q=hi(A,z,_),G=en(q,z);se("filters","filter_updated",M,G),V(d.id,{filters:q})},[d,Ce,V,se]),at=p.useCallback((z,_)=>{if(!d)return;if(!kt("edit_filters",Ce)){w(zt("edit_filters"),"error");return}const A=He(d.filters),M=mi(A,z,_);se("filters","filter_updated",null,`group operator changed to ${_.toUpperCase()}`),V(d.id,{filters:M})},[d,Ce,V,se]),Zt=p.useCallback(z=>{if(!d)return;if(!kt("edit_filters",Ce)){w(zt("edit_filters"),"error");return}const _=He(d.filters),A=en(_,z),M=fi(_,z);se("filters","filter_removed",A,null),V(d.id,{filters:M})},[d,Ce,V,se]),me=p.useCallback(()=>{if(!d)return;if(!kt("edit_filters",Ce)){w(zt("edit_filters"),"error");return}const z=He(d.filters);se("filters","filter_cleared",{count:Tt(z)},null),V(d.id,{filters:At()})},[d,Ce,V,se]),xe=p.useCallback(z=>{if(!d)return;if(!kt("edit_filters",Ce)){w(zt("edit_filters"),"error");return}const _=He(d.filters);se("filters","filter_cleared",{count:Tt(_)},{count:Tt(z)}),V(d.id,{filters:z})},[d,Ce,V,se]),Ye=p.useCallback(z=>{var q;if(!d)return;const _=(q=d.views)==null?void 0:q.find(G=>G.id===z);if(!_)return;const A=_.snapshot.columnOrder,M=wo(A,_.snapshot.grouping);se("views","view_switched",{previousViewId:d.activeViewId},{viewId:z,name:_.name}),V(d.id,{filters:_.snapshot.filters,sortStack:_.snapshot.sortStack.length>0?[..._.snapshot.sortStack]:void 0,columnVisibility:{..._.snapshot.columnVisibility},columnOrder:M,columnWidths:{..._.snapshot.columnWidths},grouping:_.snapshot.grouping,activeViewId:z}),Je(new Set)},[d,V,se]),Ae=p.useCallback((z,_,A)=>{var Se;if(!(d!=null&&d.schema)||!ye)return;const M=d.views??[],q=M.filter(Gt=>!Gt.isDeleted).length,G=((Se=T.views)==null?void 0:Se.maxViews)??10;if(q>=G){w(`View limit reached — you can have at most ${G} saved views. Delete an existing view to create a new one.`,"error");return}const ae={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:z,description:_||void 0,isDefault:A,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...ye}},be=A?M.map(Gt=>({...Gt,isDefault:!1})):M;se("views","view_created",null,{viewId:ae.id,name:z,isDefault:A}),V(d.id,{views:[...be,ae],activeViewId:ae.id}),w(`"${z}" view created`,"success")},[d,ye,V,se]),nt=p.useCallback(z=>{var ae;if(!(d!=null&&d.views))return;const _=d.views.find(be=>be.id===z);if(!_)return;const A=d.views,M=A.filter(be=>!be.isDeleted).length,q=((ae=T.views)==null?void 0:ae.maxViews)??10;if(M>=q){w(`View limit reached — you can have at most ${q} saved views. Delete an existing view to create a new one.`,"error");return}const G={..._,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${_.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{..._.snapshot}};V(d.id,{views:[...A,G]}),w(`"${G.name}" created`,"success")},[d,T,V]),it=p.useCallback(()=>{var _;if(!ee||!ye||!d)return;const z=(_=d.views)==null?void 0:_.map(A=>A.id===ee.id?{...A,snapshot:{...ye}}:A);V(d.id,{views:z}),w(`"${ee.name}" view updated`,"success")},[ee,ye,d,V]),Ot=p.useCallback(z=>{var M;if(!ee||!ye||!d)return;const _=z??ye.columnWidths,A=(M=d.views)==null?void 0:M.map(q=>q.id===ee.id?{...q,snapshot:{...q.snapshot,columnVisibility:ye.columnVisibility,columnOrder:ye.columnOrder,columnWidths:_},updatedAt:Date.now()}:q);V(d.id,{views:A,columnWidths:_}),w(`Column configuration saved to "${ee.name}"`,"success")},[ee,ye,d,V]),In=p.useCallback(z=>{var G,ae;if(!ye||!d||!ee)return;const _=z??ye.columnWidths,A={...ee,snapshot:{...ee.snapshot,columnVisibility:ye.columnVisibility,columnOrder:ye.columnOrder,columnWidths:_},updatedAt:Date.now()},M=(G=d.views)==null?void 0:G.map(be=>be.id===ee.id?A:{...be,snapshot:{...be.snapshot,columnVisibility:ye.columnVisibility,columnOrder:ye.columnOrder,columnWidths:_},updatedAt:Date.now()});V(d.id,{views:M,columnWidths:_});const q=(((ae=d.views)==null?void 0:ae.length)||0)-1;w(`Column configuration saved to current view and ${q} other view${q===1?"":"s"}`,"success")},[ye,d,ee,V]),Wo=p.useCallback(()=>{K(!0)},[]),Gr=p.useCallback(()=>{if(!ee||!d)return;const z=ee.snapshot.columnOrder,_=wo(z,ee.snapshot.grouping);V(d.id,{filters:ee.snapshot.filters,sortStack:ee.snapshot.sortStack.length>0?[...ee.snapshot.sortStack]:void 0,columnVisibility:{...ee.snapshot.columnVisibility},columnOrder:_,columnWidths:{...ee.snapshot.columnWidths},grouping:ee.snapshot.grouping}),w("Changes reverted to last saved state","success")},[ee,d,V]),En=p.useCallback(z=>{if(!(d!=null&&d.views))return;const _=d.views.map(M=>({...M,isDefault:M.id===z}));V(d.id,{views:_});const A=d.views.find(M=>M.id===z);A&&w(`"${A.name}" set as default view`,"success")},[d,V]),Yr=p.useCallback(z=>{if(!(d!=null&&d.views))return;const _=d.views.map(M=>M.id===z?{...M,isFavorite:!M.isFavorite,updatedAt:Date.now()}:M);V(d.id,{views:_});const A=d.views.find(M=>M.id===z);A&&!A.isFavorite?w(`"${A.name}" added to favorites`,"success"):A&&w(`"${A.name}" removed from favorites`,"info")},[d,V]),fo=p.useCallback(z=>{if(!(d!=null&&d.views))return;const _=d.views.find(Se=>Se.id===z),A=d.views.filter(Se=>!Se.isDeleted||Se.id===z);if((_==null?void 0:_.isDefault)&&A.filter(Se=>Se.isDefault).length===1){w("Cannot delete the last default view","error");return}const q=d.views.map(Se=>Se.id===z?{...Se,isDeleted:!0,updatedAt:Date.now()}:Se),G=d.activeViewId===z,ae=q.find(Se=>Se.isDefault&&!Se.isDeleted);V(d.id,{views:q,activeViewId:G&&ae?ae.id:d.activeViewId,filters:G&&ae?ae.snapshot.filters:d.filters,sortStack:G&&ae?ae.snapshot.sortStack.length>0?ae.snapshot.sortStack:void 0:d.sortStack});const be=d.views.find(Se=>Se.id===z);be&&w(`"${be.name}" moved to Recently Deleted`,"info")},[d,V]),Dn=p.useCallback(z=>{if(!(d!=null&&d.views))return;const _=d.views.map(M=>M.id===z?{...M,isDeleted:!1,updatedAt:Date.now()}:M);V(d.id,{views:_});const A=d.views.find(M=>M.id===z);A&&w(`"${A.name}" restored`,"success")},[d,V]),Ro=p.useCallback(z=>{if(!(d!=null&&d.views))return;const _=d.views.find(be=>be.id===z),A=d.views.filter(be=>!be.isDeleted||be.id===z);if((_==null?void 0:_.isDefault)&&A.filter(be=>be.isDefault).length===1){w("Cannot delete the last default view","error");return}const q=d.views.filter(be=>be.id!==z),G=d.activeViewId===z,ae=q.find(be=>be.isDefault&&!be.isDeleted);V(d.id,{views:q,activeViewId:G&&ae?ae.id:d.activeViewId,filters:G&&ae?ae.snapshot.filters:d.filters,sortStack:G&&ae?ae.snapshot.sortStack.length>0?ae.snapshot.sortStack:void 0:d.sortStack}),_&&w(`"${_.name}" permanently deleted`,"success")},[d,V]),qr=p.useCallback(z=>{Q(z),le(!0)},[]),Po=p.useCallback(async z=>{if(!d)return;const _=new URLSearchParams(window.location.search);_.set("reportId",d.id),_.set("view",z);const A=`${window.location.origin}${window.location.pathname}?${_.toString()}`,M=await wl(A);w(M?"Link copied to clipboard":"Failed to copy link",M?"success":"error")},[d]),Jr=p.useCallback((z,_)=>{if(!Be||!(d!=null&&d.views))return;const A=d.views.map(M=>M.id===Be?{...M,name:z,description:_||void 0}:M);V(d.id,{views:A}),Q(null)},[Be,d,V]),xo=p.useCallback(z=>{Pe(z),ie(!0)},[]),No=p.useCallback(()=>{if(!$e||!(d!=null&&d.views))return;const z=d.views.find(q=>q.id===$e),_=d.views.filter(q=>q.id!==$e),A=d.activeViewId===$e,M=_.find(q=>q.isDefault);se("views","view_deleted",{viewId:$e,name:z==null?void 0:z.name},null),V(d.id,{views:_,activeViewId:A&&M?M.id:d.activeViewId,filters:A&&M?M.snapshot.filters:d.filters,sortStack:A&&M?M.snapshot.sortStack.length>0?M.snapshot.sortStack:void 0:d.sortStack}),Pe(null),ie(!1)},[$e,d,V,se]),Kr=p.useCallback(z=>{var q;if(!(d!=null&&d.views))return;if(!(((q=T.views)==null?void 0:q.isAdmin)??!1)){w("Only administrators can promote views to Global.","error");return}const A=d.views.find(G=>G.id===z);if(!A)return;if(A.scope==="global"){w(`"${A.name}" is already a Global View.`,"info");return}const M=d.views.map(G=>G.id===z?{...G,scope:"global",isDefault:!0,updatedAt:Date.now()}:G.scope==="global"&&G.isDefault?{...G,isDefault:!1}:G);V(d.id,{views:M}),w(`"${A.name}" promoted to Global View and set as default.`,"success")},[d,T,V]),Xr=p.useCallback((z,_)=>{if(!(d!=null&&d.views))return;const A=d.views.find(G=>G.id===z);if(!A)return;const M=d.views.map(G=>G.id===z?{...G,isDefaultForAllUsers:_,updatedAt:Date.now()}:_&&G.isDefaultForAllUsers?{...G,isDefaultForAllUsers:!1}:G);se("views",_?"view_set_default":"view_updated",{viewId:z,isDefaultForAllUsers:!_},{viewId:z,isDefaultForAllUsers:_}),V(d.id,{views:M}),w(`"${A.name}" ${_?"set as":"removed from"} default for all users.`,"success")},[d,V,se]),er=p.useRef(!0);p.useEffect(()=>{var z;if(er.current){er.current=!1;return}if(x==="server"){ft(1),(z=a==null?void 0:a.onPaginationChange)==null||z.call(a,1,rt);return}ke!=null&&ke.resetPage?ke.resetPage():ft(1)},[d==null?void 0:d.filters,Qt,d==null?void 0:d.activeViewId]);const Lo=p.useCallback(z=>{var _;if(x==="server"){ft(z),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,z,rt);return}ke!=null&&ke.goToPage&&ke.goToPage(z)},[x,a,rt,ke]),Qr=p.useCallback(z=>{var q;const A=((x==="server"?vr:(ke==null?void 0:ke.currentPage)||1)-1)*rt,M=Math.floor(A/z)+1;if(x==="server"){Nt(z),ft(M),(q=a==null?void 0:a.onPaginationChange)==null||q.call(a,M,z);return}Nt(z),ke==null||ke.goToPage(M)},[vr,rt,x,a,ke]),_n=p.useCallback((z,_)=>{if(!d)return;if(!kt("edit_columns",Ce)){w(zt("edit_columns"),"error");return}const M={...d.columnVisibility||(ee==null?void 0:ee.snapshot.columnVisibility)||{},[z]:_};se("columns",_?"column_shown":"column_hidden",{columnName:z,visible:!_},{columnName:z,visible:_}),V(d.id,{columnVisibility:M})},[d,ee,Ce,V,se]),$n=p.useCallback(z=>{if(d){if(!kt("edit_columns",Ce)){w(zt("edit_columns"),"error");return}se("columns","column_reordered",d.columnOrder,z),V(d.id,{columnOrder:z})}},[d,Ce,V,se]),On=p.useCallback((z,_)=>{if(!d)return;if(!kt("edit_columns",Ce)){w(zt("edit_columns"),"error");return}const A=d.columnWidths||(ee==null?void 0:ee.snapshot.columnWidths)||{},M={...A,[z]:_};se("columns","column_resized",{columnName:z,width:A[z]},{columnName:z,width:_}),V(d.id,{columnWidths:M})},[d,ee,Ce,V,se]),Mn=p.useCallback(z=>{if(!d)return;const _=He(d.filters),A=Os(_,z);V(d.id,{filters:A})},[d,V]),An=p.useCallback(()=>{if(!ee||!(d!=null&&d.schema))return;const z={},_=[],A={};d.schema.forEach(M=>{z[M.name]=!0,_.push(M.name),A[M.name]=170}),V(d.id,{columnVisibility:z,columnOrder:_,columnWidths:A,filters:void 0,sortStack:void 0}),w("Reset to default layout - all filters and sorts cleared","success")},[ee,d,V]);p.useEffect(()=>{const z=setTimeout(()=>br(lr),300);return()=>clearTimeout(z)},[lr]),p.useEffect(()=>{var z;B==="server"&&((z=c==null?void 0:c.onSearchChange)==null||z.call(c,Qt))},[Qt,B,c]);const Wn=p.useCallback(z=>{Rr(z),ft(1)},[]),Rn=p.useCallback(z=>{if(!z.trim()||!d)return;const _=d.searchHistory||[],A=ol(_,z);V(d.id,{searchHistory:A})},[d,V]),Pn=p.useCallback(z=>{if(!d)return;const _=d.searchHistory||[],A=nl(_,z);V(d.id,{searchHistory:A})},[d,V]),Nn=p.useCallback(z=>{if(!d)return;const _=d.searchHistory||[],A=il(_,z);V(d.id,{searchHistory:A})},[d,V]);p.useEffect(()=>{if(!D.onSelectionChange)return;const z=Array.from(Ct);D.onSelectionChange(z,z.map(_=>_==null?void 0:_.__urm_row_id__))},[Ct,D.onSelectionChange]);const Zr=p.useCallback(z=>{const _=z==null?void 0:z.__urm_row_id__;Je(A=>{const M=new Set(A);let q;return _!==void 0?q=Array.from(M).find(G=>(G==null?void 0:G.__urm_row_id__)===_):q=Array.from(M).find(G=>G===z),q!==void 0?M.delete(q):M.add(z),M})},[]),tr=p.useCallback((z,_)=>{Je(A=>{const M=new Set(A),q=_.filter(G=>!G.isGroupHeader);for(const G of q){const ae=G==null?void 0:G.__urm_row_id__;if(z){let be;ae!==void 0?be=Array.from(M).find(Se=>(Se==null?void 0:Se.__urm_row_id__)===ae):be=Array.from(M).find(Se=>Se===G),be===void 0&&M.add(G)}else{let be;ae!==void 0?be=Array.from(M).find(Se=>(Se==null?void 0:Se.__urm_row_id__)===ae):be=Array.from(M).find(Se=>Se===G),be!==void 0&&M.delete(be)}}return M})},[]),Ln=p.useCallback((z,_,A)=>{Je(M=>{const q=new Set(M),G=A.filter(Se=>!Se.isGroupHeader),ae=Math.min(z,_),be=Math.max(z,_);for(let Se=ae;Se<=be;Se++){const Gt=G[Se];if(!Gt)continue;const Ti=Gt==null?void 0:Gt.__urm_row_id__;let Un;Ti!==void 0?Un=Array.from(q).find(yo=>(yo==null?void 0:yo.__urm_row_id__)===Ti):Un=Array.from(q).find(yo=>yo===Gt),Un===void 0&&q.add(Gt)}return q})},[]),Fn=p.useCallback(()=>{Je(new Set)},[]),Ve=p.useCallback(z=>{const _=z==null?void 0:z.__urm_row_id__;Je(A=>{const M=new Set(A);if(_!==void 0){const q=Array.from(M).find(G=>(G==null?void 0:G.__urm_row_id__)===_);q!==void 0&&M.delete(q)}else M.delete(z);return M})},[]),lt=p.useCallback(z=>{var _,A;if(d){if(!kt("edit_columns",Ce)){w(zt("edit_columns"),"error");return}if(z&&d.schema){const{validGrouping:M,invalidColumns:q}=Rs(z,d.schema);q.length>0&&w(`Removed invalid grouping columns: ${q.join(", ")}`,"warning"),wt();try{const G=d.grouping;M===null?se("grouping","group_cleared",G,null):G?se("grouping","group_reordered",G,M):se("grouping","group_level_added",null,M);const ae=(ee==null?void 0:ee.snapshot.columnOrder)||d.columnOrder||[],be=wo(ae,M),Se=M.levels.length>0?{...M,collapsedGroups:$i(Ft,d.schema,M)}:M;V(d.id,{grouping:Se,columnOrder:be}),x==="server"?(ft(1),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,1,rt)):ke==null||ke.resetPage(),JSON.stringify(be)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,be),Xt(!1)}catch(G){const ae=fr("processing","grouping",G);xt(ae)}}else{const M=d.grouping;se("grouping","group_cleared",M,null);const q=(ee==null?void 0:ee.snapshot.columnOrder)||d.columnOrder||[];V(d.id,{grouping:z,columnOrder:q}),x==="server"?(ft(1),(A=a==null?void 0:a.onPaginationChange)==null||A.call(a,1,rt)):ke==null||ke.resetPage(),JSON.stringify(q)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,q),Xt(!1)}}},[d,ee,Ce,V,wt,xt,se,Ft]),go=p.useCallback(z=>{if(!d||!T.grouping.allowCollapse)return;const _=d.grouping;if(!_)return;const A=qa(_,z);V(d.id,{grouping:A})},[d,T,V]),eo=p.useCallback(()=>{!(d!=null&&d.grouping)||!T.grouping.allowCollapse||V(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,T,V]),Fo=p.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema||!T.grouping.allowCollapse)return;const z=$i(Ft,d.schema,d.grouping);V(d.id,{grouping:{...d.grouping,collapsedGroups:z}})},[d,Ft,T,V]),Vn=p.useCallback(()=>{ur(!0)},[]),gt=p.useCallback(z=>{d!=null&&d.schema&&(Kt(!0),setTimeout(()=>{try{let _;z.scope==="visible"?_=hr:_=d.uploadedData||[];let A;z.columnScope==="all"?(A={},(d.schema??[]).forEach(be=>{A[be.name]=!0})):A=d.columnVisibility||(ee==null?void 0:ee.snapshot.columnVisibility)||{};const M=d.columnOrder||(ee==null?void 0:ee.snapshot.columnOrder),q=rn(_,d.schema,He(d.filters),d.sortStack??[],ee,A,M),G=d.name;let ae;switch(z.format){case"csv":on(q,G,z),ae="export_csv";break;case"excel":nn(q,G,z),ae="export_excel";break;case"json":sn(q,G,z),ae="export_json";break;case"pdf":yi(q,G,z),ae="export_pdf";break}se("export",ae,null,{format:z.format,scope:z.scope,columnScope:z.columnScope,rowCount:_.length,viewName:(ee==null?void 0:ee.name)||"Default View"}),w(`Export completed successfully (${z.format.toUpperCase()})`,"success")}catch(_){const A=Dl(_,{onRetry:()=>gt(z)});w(`Export failed: ${A.message}. Click Export to retry.`,"error");const M=Li(d.id,Mt,A,d.auditHistory||[]);V(d.id,{auditHistory:M}),Jt.error("urm:report-engine","Export failed",_)}finally{Kt(!1)}},500))},[d,ee,hr,V,se]),rr=p.useCallback(z=>{if(d!=null&&d.schema){if(ce&&ee&&!ee.isDefault){St(z.format),Rt(!0),ur(!1);return}gt(z),ur(!1)}},[d,ee,ce,gt]),Er=p.useCallback(z=>{gt({format:z,scope:"visible",columnScope:"visible"})},[gt]),Hn=p.useCallback(()=>{mt&&Er(mt),Rt(!1),St(null)},[mt,Er]),Vo=p.useCallback(()=>{it(),mt&&Er(mt),Rt(!1),St(null)},[it,mt,Er]),Ho=p.useCallback(()=>{Rt(!1),St(null)},[]),j=p.useCallback(z=>{!(d!=null&&d.schema)||Ct.size===0||(Kt(!0),setTimeout(()=>{try{const _=Array.from(Ct),A=rn(_,d.schema,He(d.filters),d.sortStack??[],ee),M=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(z){case"csv":on(A,M);break;case"excel":nn(A,M);break;case"json":sn(A,M);break}w(`Exported ${_.length} selected rows`,"info")}catch(_){w("Export failed. Please try again.","error"),Jt.error("urm:report-engine","Bulk export failed",_)}finally{Kt(!1)}},500))},[d,ee,Ct,jr]),N=p.useCallback((z,_)=>{if(d)try{const A=gl(d),M=yl(z,_,Mt,A),q=bl(d.presets,M);V(d.id,{presets:q}),se("presets","preset_created",null,{presetId:M.id,name:M.name}),dr(!1),w(`Preset "${z}" saved successfully`,"success")}catch(A){w(A instanceof Error?A.message:"Failed to create preset","error")}},[d,V,se]),oe=p.useCallback(()=>{Sr(null),w("Exited preset view","info")},[]),Te=p.useCallback(()=>{je(!0)},[]),Ne=p.useCallback((z,_)=>{if(!d)return;const A=vl(d.presets,z);V(d.id,{presets:A}),se("presets","preset_deleted",{presetId:z,name:_},null),_t===z&&Sr(null),w(`Preset "${_}" deleted`,"success")},[d,_t,V,se]);p.useEffect(()=>{if(!g||h.length===0)return;const z=h.find(_=>_.id===g);z&&z.id!==b&&R(z.id)},[g,h,b]);const et=p.useRef(!1);p.useEffect(()=>{var _;if(!m||et.current||!d||d.id!==g)return;const z=(_=d.views)==null?void 0:_.find(A=>A.id===m&&!A.isDeleted);z&&Ye(z.id),et.current=!0},[m,g,d,Ye]),p.useEffect(()=>{if(!d)return;const z=Sl();if(z&&d.presets&&d.schemaLocked&&d.schema){const _=Ni(d.presets,z);if(_){const{sanitizedConfig:A,warnings:M}=El(_.config,d.schema);M.length>0&&M.forEach(G=>w(G,"warning"));const q=Cl(A);V(d.id,q),Sr(z),se("presets","preset_applied",null,{presetId:_.id,name:_.name}),w(`Loaded preset: ${_.name}`,"info")}else w("Preset not found","info")}},[d==null?void 0:d.schemaLocked]);const tt=_t?Ni(d==null?void 0:d.presets,_t):void 0;p.useEffect(()=>{var z;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&((z=S==null?void 0:S.onViewsChange)==null||z.call(S,d.views,d.activeViewId),v!=="api"&&el(d.id,{views:d.views,activeViewId:d.activeViewId}))},[d==null?void 0:d.views,d==null?void 0:d.activeViewId,d==null?void 0:d.id,v,S]),p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const z=v==="api"?S!=null&&S.views&&S.views.length>0?{views:S.views,activeViewId:S.activeViewId??S.views[0].id}:null:tl(d.id);if(z&&z.views.length>0){const _=z.views.find(A=>A.id===z.activeViewId);if(_)V(d.id,{views:z.views,activeViewId:z.activeViewId,filters:He(_.snapshot.filters),sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0});else{const A=z.views.find(M=>M.isDefault)||Gn(d.schema);V(d.id,{views:z.views,activeViewId:A.id,filters:He(A.snapshot.filters),sortStack:A.snapshot.sortStack.length>0?A.snapshot.sortStack:void 0})}}}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,v,S]);const ge=p.useCallback(z=>{var M;const _=He(d==null?void 0:d.filters),A=((M=T.filter)==null?void 0:M.maxConditions)??3;if(Tt(_)>=A){w(`Filter limit reached — maximum ${A} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}ne(z),F(!0)},[d,T,w]),Ht=p.useCallback(()=>{F(!1),ne(void 0)},[]),Ut=(zi=d==null?void 0:d.views)==null?void 0:zi.find(z=>z.id===Be),We=(Bi=d==null?void 0:d.views)==null?void 0:Bi.find(z=>z.id===$e);return{reports:h,activeReport:d,activeReportId:b,setActiveReportId:R,isModalOpen:H,setIsModalOpen:E,createReport:zr,updateReport:V,uploadState:J,handleFileUpload:Br,handleUploadError:Hr,handleRetry:ho,handleConfirm:Vt,paginatedData:Fr,processedData:hr,displayData:jr,tableMetrics:kr,isGrouped:Vr,tableEngine:jt,activeView:ee,isDirty:ce,currentTableState:ye,viewChanges:po,filters:d==null?void 0:d.filters,showFilterPanel:we,setShowFilterPanel:F,filterFocusColumn:U,handleAddCondition:ze,handleAddGroup:Ge,handleUpdateCondition:Ir,handleSetGroupOperator:at,handleRemoveFilterNode:Zt,handleClearAllFilters:me,handleReplaceFilters:xe,handleOpenFilterForColumn:ge,handleCloseFilterPanel:Ht,handleClearFiltersForColumn:Mn,sortStack:d==null?void 0:d.sortStack,showSortPanel:X,setShowSortPanel:ue,handleSort:mo,handleUpdateSortStack:Ur,handleSortAscending:$t,handleSortDescending:Tr,views:d==null?void 0:d.views,showCreateViewModal:pe,setShowCreateViewModal:K,showEditViewModal:he,setShowEditViewModal:le,showDeleteConfirmation:W,setShowDeleteConfirmation:ie,editingView:Ut,deletingView:We,editingViewId:Be,deletingViewId:$e,handleSelectView:Ye,handleCreateView:Ae,handleCloneView:nt,handleUpdateCurrentView:it,handleSaveColumnConfigToCurrentView:Ot,handleSaveColumnConfigToAllViews:In,handleSaveAsNewView:Wo,handleRevertChanges:Gr,handleToggleDefault:En,handleToggleFavorite:Yr,handleSoftDelete:fo,handleRestoreView:Dn,handlePermanentDelete:Ro,handleEditView:qr,handleCopyViewLink:Po,handleSaveEditView:Jr,handleDeleteView:xo,handleConfirmDelete:No,handlePromoteToGlobal:Kr,handleSetDefaultForAllUsers:Xr,showManageColumns:Wr,setShowManageColumns:Qe,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:_n,handleUpdateColumnOrder:$n,handleUpdateColumnWidth:On,handleResetColumnLayout:An,showGroupPanel:Dt,setShowGroupPanel:Xt,grouping:d==null?void 0:d.grouping,groupingState:Pt,handleGroup:lt,handleToggleGroupCollapse:go,handleExpandAllGroups:eo,handleCollapseAllGroups:Fo,searchQuery:lr,debouncedSearchQuery:Qt,searchHistory:sl((d==null?void 0:d.searchHistory)||[]),handleSearchChange:Wn,handleAddToSearchHistory:Rn,handleToggleSearchFavourite:Pn,handleDeleteSearchHistory:Nn,selectedRowIds:Ct,handleToggleRowSelection:Zr,handleToggleAllRows:tr,handleRangeSelection:Ln,handleClearSelection:Fn,handleUpdateSelectionAfterDelete:Ve,currentPage:x==="server"?vr:(ke==null?void 0:ke.currentPage)||1,pageSize:rt,paginationEngine:ke,paginationMode:x,paginationTotalRows:ut,handlePageChange:Lo,handlePageSizeChange:Qr,isExporting:Wt,showExportModal:Nr,setShowExportModal:ur,showDirtyExportWarning:Ar,handleExport:Vn,handleExportWithConfig:rr,handleExportSelected:j,handleExportAnyway:Hn,handleSaveAndExport:Vo,handleCancelExport:Ho,showAuditHistory:cr,setShowAuditHistory:uo,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:Pr,setShowCreatePreset:dr,showManagePresets:Ke,setShowManagePresets:je,activePreset:tt,activePresetId:_t,handleOpenManagePresets:Te,handleCreatePreset:N,handleClearActivePreset:oe,handleDeletePresetById:Ne,userRole:Ce,isViewerRole:Ao,currentUserId:Mt,permissions:d==null?void 0:d.permissions,featureLimitWarning:Cr,setFeatureLimitWarning:Lr,datasetMeta:fe,reportError:pr,setReportError:Ze,handleError:xt,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?Na(d.schema):!1,snack:I,handleSnackClose:P,showSnack:w,snackDurationMs:te,config:D,scheduler:l}}const Ps=p.createContext(void 0);function bi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:c,pagination:l,search:u,scheduler:y,mode:g="builder",autoLoad:m=!0,config:S,devConfig:C,showDevPanel:D=!1,sharedReportId:v,sharedViewId:x,viewPersistence:B,permissions:h}=e,T=ql({mode:g,autoLoad:m,initialData:i||n,dataSource:c,pagination:l,search:u,scheduler:y,reportName:s,reportId:a,sharedReportId:v,sharedViewId:x,viewPersistence:B,permissions:h,config:S}),[b,R]=p.useState(()=>Ca()),H=(()=>{const I=ja(b,C,!!C);return{...I,display:{...I.display,showDevPanel:D||I.display.showDevPanel}}})(),E=p.useCallback(Z=>{R(Z),wa(Z)},[]),Y={...T,activeDevConfig:H,handleDevConfigChange:E};return t.jsx(Es.Provider,{value:H,children:t.jsx(Ps.Provider,{value:Y,children:r})})}function hn(){const e=p.useContext(Ps);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Jl({onCreateReport:e,reports:r=[],activeReportId:n,onReportClick:i}){const s=r.find(a=>a.id===n);return t.jsx(o.Box,{component:"header",sx:a=>{var g,m,S;const c=((S=(m=(g=a.components)==null?void 0:g.MuiCardHeader)==null?void 0:m.styleOverrides)==null?void 0:S.root)||{},l=c.backgroundColor&&c.backgroundColor!=="transparent"?c.backgroundColor:a.palette.background.paper,u=c.borderBottom&&c.borderBottom!=="none"?c.borderBottom:"1px solid",y=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:y,bgcolor:l}},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsxs(o.Breadcrumbs,{separator:t.jsx(O.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.375rem",color:a=>a.typography.h6.color||"text.primary",letterSpacing:"-0.01em",cursor:r.length>0&&s?"pointer":"default","&:hover":r.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),s&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),t.jsx(o.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:t.jsx(O.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(o.Button,{variant:"contained",startIcon:t.jsx(O.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Or(e,...r){const n=new URL(`https://mui.com/production-error/?code=${e}`);return r.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${e}; visit ${n} for the full message.`}const Kl="$$material";function Xl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qo={exports:{}},Jo={exports:{}},Ie={};/** @license React v16.13.1
105
+ </html>`;try{const y=document.createElement("iframe");y.style.position="fixed",y.style.right="0",y.style.bottom="0",y.style.width="0",y.style.height="0",y.style.border="0",document.body.appendChild(y);const k=((v=y.contentWindow)==null?void 0:v.document)||y.contentDocument;if(k){k.open(),k.write(m),k.close(),setTimeout(()=>{var h,j;try{(h=y.contentWindow)==null||h.focus(),(j=y.contentWindow)==null||j.print()}catch{}setTimeout(()=>{document.body.removeChild(y)},3e3)},300);return}}catch{}const C=new Blob([m],{type:"text/html;charset=utf-8;"}),S=URL.createObjectURL(C);window.open(S,"_blank")||yi(m,mn(r,"html"),"text/html;charset=utf-8;")}function Jo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Ri=10;function il(e,r){const n=r.trim();if(!n)return e;const i=e.findIndex(a=>a.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...e[i],lastUsed:Date.now()},...e.slice(0,i),...e.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...e],s.length>Ri&&(s=[...s].sort((d,l)=>d.isFavourite&&!l.isFavourite?-1:!d.isFavourite&&l.isFavourite?1:l.lastUsed-d.lastUsed).slice(0,Ri)),s}function sl(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function al(e,r){return e.filter(n=>n.query!==r)}function ll(e){const r=e.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),n=e.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...r,...n]}const cl={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 dl(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function Bt(e,r){return cl[r].includes(e)}function Tt(e){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"}[e]||"perform this action"}.`}function ul(e){return e==="viewer"}const Pi=1e3;function si(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function qt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return si(n)}const pl={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 hl(e){if(!e||!e.column)return"a filter";const r=qt(e.column),n=pl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function qn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":hl(e):"a filter"}function Ni(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${qt(n.column)}"`).join(", ")}`}function ml(e){var s,a,d;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${qn(i)}`};case"filter_removed":return{summary:`Filter removed: ${qn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const l=n,u=i;return l!=null&&l.column&&(u!=null&&u.column)&&l.column!==u.column?{summary:`Filter changed on "${qt(u.column)}"`,detail:`Previously filtered "${qt(l.column)}"`}:{summary:`Filter updated: ${qn(u)}`}}case"filter_cleared":{const l=n&&typeof n=="object"&&"count"in n?n.count: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?qt(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?qt(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: ${Ni(i)}`};case"group_level_removed":{const l=n,u=(a=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&a.column?qt(l.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Ni(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: "${qt(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${qt(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: "${qt(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":case"export_pdf":{const l=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,x=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",g=(i==null?void 0:i.viewName)??"",m=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${m}`,detail:g?`${si(x)} · View: "${g}"`:si(x)}}case"export_triggered":{const l=((d=i==null?void 0:i.format)==null?void 0:d.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"row_edited":{const l=(i==null?void 0:i.id)??(n==null?void 0:n.id)??"",u=(i==null?void 0:i.label)??(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const l=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}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:xl(r)}}}function fl(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Io(e,r,n,i,s,a){return{id:fl(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function Eo(e,r){const n=[r,...e];return n.length>Pi?n.slice(0,Pi):n}function xl(e){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",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function Jn(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function gl(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),d=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:d<7?`${d} day${d>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Li=100;function yl(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function bl(e){var a;const r=(a=e.views)==null?void 0:a.find(d=>d.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=gi(i,e.grouping||null,n);return{filters:He(e.filters),sortStack:e.sortStack?[...e.sortStack]:[],columnVisibility:e.columnVisibility?{...e.columnVisibility}:{},columnOrder:s,columnWidths:e.columnWidths?{...e.columnWidths}:{},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}function vl(e,r,n,i){return{id:yl(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function Sl(e,r){const n=e||[];if(n.length>=Li)throw new Error(`Maximum of ${Li} presets reached. Please delete old presets first.`);return[...n,r]}function Cl(e,r){return(e||[]).filter(i=>i.id!==r)}function Fi(e,r){if(e)return e.find(n=>n.id===r)}function wl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function jl(e){const r=e.columnOrder,n=ko(r,e.grouping);return{filters:He(e.filters),sortStack:e.sortStack.length>0?[...e.sortStack]:void 0,columnVisibility:{...e.columnVisibility},columnOrder:n,columnWidths:{...e.columnWidths},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}async function kl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Jt.warn("urm:presets","Clipboard API blocked, using fallback method",r)}try{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width="2em",r.style.height="2em",r.style.padding="0",r.style.border="none",r.style.outline="none",r.style.boxShadow="none",r.style.background="transparent",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let n=!1;try{n=document.execCommand("copy")}catch(i){Jt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Jt.error("urm:presets","Fallback copy method failed",r),!1}}function zl(e,r){return{totalRows:e.length,totalColumns:r.length}}function xr(e,r,n,i){const s=n instanceof Error?n.message:n,a={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:Bl(e,r)};return process.env.NODE_ENV==="development"&&Jt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function Bl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Tl(e){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"}[e.context]||"An error occurred";return e.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function Il(e){return{filters:e.filters,sortStack:e.sortStack?[...e.sortStack]:void 0,grouping:e.grouping?{...e.grouping}:void 0,columnVisibility:e.columnVisibility?{...e.columnVisibility}:void 0,columnOrder:e.columnOrder?[...e.columnOrder]:void 0,columnWidths:e.columnWidths?{...e.columnWidths}:void 0,activeViewId:e.activeViewId}}function El(e,r,n){n(e.id,{filters:He(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function Dl(e,r,n){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(r)&&(n==null||n==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:e==="number"&&["gt","gte","lt","lte","equals"].includes(r)&&isNaN(Number(n))?{isValid:!1,errorMessage:"Value must be a valid number"}:e==="date"&&n&&isNaN(Date.parse(n))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function Rs(e,r){const n=[],i=[],s=new Set(r.map(a=>a.name));return e.forEach(a=>{s.has(a.column)?n.push(a):i.push(a.column)}),{validRules:n,invalidColumns:i}}function Ps(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(a=>a.name)),i=[],s=[];return e.levels.forEach(a=>{n.has(a.column)?i.push(a):s.push(a.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function _l(e,r){const n=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=d=>{const l=d.children.filter(u=>{if(Xe(u))return!0;const x=i.has(u.column);return x||n.push(`Filter for column "${u.column}" ignored (column not found)`),x}).map(u=>Xe(u)?a(u):u).filter(u=>!Xe(u)||u.children.length>0);return{...d,children:l}};s.filters=a(He(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:d}=Rs(s.sortStack,r);d.length>0&&n.push(`Sort rules for columns ignored: ${d.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:d}=Ps(s.grouping,r);d.length>0&&n.push(`Grouping for columns ignored: ${d.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([d,l])=>{i.has(d)?a[d]=l:n.push(`Column visibility for "${d}" ignored (column not found)`)}),s.columnVisibility=Object.keys(a).length>0?a:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const a=s.columnOrder.filter(d=>{const l=i.has(d);return l||n.push(`Column "${d}" in order ignored (column not found)`),l});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([d,l])=>{i.has(d)?a[d]=l:n.push(`Column width for "${d}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:n}}function $l(e,r){return xr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Vi(e,r,n,i){const s=Io(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Eo(i||[],s)}function Ol(e){return e==null}function Ml(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(Ol(e))return!1;if(n==="date"){const a=new Date(e).getTime(),d=new Date(s).getTime();switch(i){case"equals":return a===d;case"gt":return a>d;case"lt":return a<d;case"gte":return a>=d;case"lte":return a<=d;default:return!0}}switch(i){case"equals":return String(e).toLowerCase()===String(s).toLowerCase();case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function ai(e,r,n){var s;if(Xe(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>ai(e,a,n)):r.children.some(a=>ai(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return Ml(e[r.column],r,i)}function Al(e,r,n){return!r||r.children.length===0?e:e.filter(i=>ai(i,r,n))}function cn(e){switch(e){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"date":return[{value:"equals",label:"Is"},{value:"gt",label:"After"},{value:"lt",label:"Before"},{value:"gte",label:"On or after"},{value:"lte",label:"On or before"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Wl(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Rl({data:e,filters:r,schema:n}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:Al(e,r,n),[e,r,n])}}function Pl(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),a=r.filter(d=>i.includes(d.name));return e.filter(d=>a.some(l=>{const u=d[l.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function Nl({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:p.useMemo(()=>s==="server"||!r||r.trim()===""?e:Pl(e,n,r,i),[e,r,n,i,s])}}function Ll({data:e,sortStack:r,schema:n}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:Ha(e,n,r),[e,r,n])}}function Fl({data:e,grouping:r,schema:n}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:Ja(e,n,r),[e,r,n]),s=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function Vl({schema:e,columnVisibility:r,columnOrder:n}){const i=p.useMemo(()=>n.filter(l=>r[l]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([l,u])=>!u).map(([l,u])=>l),[r]),a=p.useMemo(()=>n.map(l=>e.find(x=>x.name===l)||{name:l,type:"string"}),[n,e]),d=p.useMemo(()=>i.map(l=>e.find(x=>x.name===l)||{name:l,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:d,hiddenCount:s.length}}function Hl({views:e,activeViewId:r,currentState:n}){const i=p.useMemo(()=>e.find(x=>x.id===r),[e,r]),s=p.useMemo(()=>i?Za(n,i.snapshot):!1,[i,n]),a=p.useMemo(()=>e.find(x=>x.isDefault),[e]),d=p.useMemo(()=>e.filter(x=>!x.isDefault&&!x.isDeleted),[e]),l=p.useMemo(()=>e.filter(x=>x.isFavorite&&!x.isDeleted),[e]),u=p.useMemo(()=>e.filter(x=>x.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:d,favoriteViews:l,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Ul(e,r,n){if(!e||e.length===0)return[];if(r<=0)return e.slice(0,n);const i=e.slice(r,n);if(i.length===0)return[];const s=i[0],a=!!(s.__isGroupHeader||s.isGroupHeader),d=a?s.groupLevel??0:s.__urm_group_level__??0;if(d===0&&a)return i;const l=d-1;if(l<0)return i;const u={};let x=l+1;for(let E=r-1;E>=0;E--){const v=e[E];if(v.__isGroupHeader||v.isGroupHeader){const y=v.groupLevel??0;if(y<=l&&u[y]===void 0&&(u[y]=v,x--,x<=0))break}}const g=[];for(let E=0;E<=l;E++)u[E]&&g.push({...u[E],__urm_is_continuation_header__:!0});const m=Math.max(0,n-r-g.length),C=r+m,S=e.slice(r,C);return[...g,...S]}function Gl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=p.useState(i),d=e.length,l=Math.max(1,Math.ceil(d/n));p.useEffect(()=>{s>l&&a(l)},[s,l]);const u=p.useMemo(()=>{if(!r)return e;const S=(s-1)*n,E=S+n;return Ul(e,S,E)},[e,r,s,n]),x=p.useCallback(S=>{const E=Math.max(1,Math.min(S,l));a(E)},[l]),g=p.useCallback(()=>{s<l&&a(S=>Math.min(S+1,l))},[l]),m=p.useCallback(()=>{s>1&&a(S=>Math.max(S-1,1))},[]),C=p.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:l,pageSize:n,totalRows:d,goToPage:x,nextPage:g,prevPage:m,resetPage:C,hasNextPage:s<l,hasPrevPage:s>1}}function Yl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:d,searchMode:l,columnVisibility:u,columnOrder:x,columnWidths:g,views:m,activeViewId:C,pagination:S}=e,E=p.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:x,columnWidths:g}),[i,s,a,u,x,g]),v=Hl({views:m,activeViewId:C,currentState:E}),y=Vl({schema:n,columnVisibility:u,columnOrder:x}),{filteredData:k}=Rl({data:r,filters:i,schema:n}),{sortedData:h}=Ll({data:k,sortStack:s,schema:n}),{groupedData:j,isGrouped:T}=Fl({data:h,grouping:a,schema:n}),{searchedData:b}=Nl({data:j,searchQuery:d,schema:n,visibleColumns:y.visibleColumns,mode:l}),R=Gl({data:b,enabled:(S==null?void 0:S.enabled)||!1,pageSize:(S==null?void 0:S.pageSize)||100,initialPage:(S==null?void 0:S.currentPage)||1}),H=S!=null&&S.enabled?R.paginatedData:b,I=p.useMemo(()=>({totalRows:r.length,filteredRows:k.length,sortedRows:h.length,groupedRows:T?j.length:h.length,searchedRows:b.length,visibleRows:H.length,hiddenColumns:y.hiddenCount,activeFilters:Et(i),activeSorts:s.length,isGrouped:T}),[r.length,k.length,h.length,j.length,b.length,H.length,y.hiddenCount,i,s.length,T]);return{data:H,filteredData:k,sortedData:h,groupedData:j,searchedData:b,viewEngine:v,columnEngine:y,paginationEngine:R,metrics:I,isGrouped:T,isPaginated:(S==null?void 0:S.enabled)||!1}}let ql=0;function Jl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):ql++,writable:!1,enumerable:!1,configurable:!1})}const Rt="user-demo-001";function Kl(e={}){var Yo,zi,Bi,Ti,Ii;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:d,scheduler:l,reportName:u,reportId:x,sharedReportId:g,sharedViewId:m,viewPersistence:C,permissions:S,config:E={},devConfig:v}=e,y=(C==null?void 0:C.mode)??"local",k=(a==null?void 0:a.mode)??"client",h=(d==null?void 0:d.mode)??"client",[j,T]=p.useState([]),b=v??ft,[R,H]=p.useState(""),[I,J]=p.useState(!1),[Z,B]=p.useState(!1),[f,$]=p.useState({message:"",severity:"info",open:!1}),D=(z,_="info")=>{$({message:z,severity:_,open:!0})},ee=()=>$(z=>({...z,open:!1})),oe=E.notifDurationMs,c=j.find(z=>z.id===R),[re,fe]=p.useState("idle"),[U,K]=p.useState(!1),[de,ue]=p.useState(!1),[X,pe]=p.useState(!1),[le,P]=p.useState(!1),[se,G]=p.useState(!1),[ne,De]=p.useState(void 0),[Q,Pe]=p.useState(null),[Te,$t]=p.useState(null),[Rr,Kt]=p.useState(!1),[br,Ot]=p.useState(!1),[dt,Xt]=p.useState(null),[Qe,Mt]=p.useState(!1),[vr,wt]=p.useState(!1),[Qt,uo]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[sr,po]=p.useState(""),[Zt,Sr]=p.useState(""),[jt,qe]=p.useState(new Set),[Cr,ut]=p.useState(1),[tt,Nt]=p.useState(15),[ar,ho]=p.useState(!1),[Pr,lr]=p.useState(!1),[Je,we]=p.useState(!1),[At,wr]=p.useState(null),[Nr,cr]=p.useState(!1),[jr,Lr]=p.useState(null),[dr,Ze]=p.useState(null),Lt=p.useRef(null),Se=p.useMemo(()=>c?dl(c.permissions,Rt):"owner",[c]),Ro=ul(Se),he=p.useMemo(()=>!(c!=null&&c.uploadedData)||!(c!=null&&c.schema)?{totalRows:0,totalColumns:0}:zl(c.uploadedData,c.schema),[c==null?void 0:c.uploadedData,c==null?void 0:c.schema]),kt=p.useCallback(()=>{c&&(Lt.current=Il(c))},[c]),F=p.useCallback((z,_)=>{T(W=>W.map(A=>A.id===z?{...A,..._}:A))},[]),yt=p.useCallback(z=>{if(!c)return;Ze(z);const _=Vi(c.id,Rt,z,c.auditHistory||[]);F(c.id,{auditHistory:_}),D(z.message,"error"),z.recoverable&&Lt.current&&setTimeout(()=>{El(c,Lt.current,F),D("Previous state restored","success")},100)},[c,F]),ie=p.useCallback((z,_,W,A)=>{if(!c)return;const q=Io(c.id,Rt,z,_,W,A),Y=c.auditHistory||[],ae=Eo(Y,q);setTimeout(()=>{F(c.id,{auditHistory:ae})},0)},[c,F]);p.useEffect(()=>{if(c!=null&&c.schemaLocked&&c.schema&&(!c.views||c.views.length===0)){const z=Yn(c.schema);(()=>{try{const _=localStorage.getItem("urm_dev_config");return _?JSON.parse(_):null}catch{return null}})(),F(c.id,{views:[z],activeViewId:z.id,filters:z.snapshot.filters,sortStack:z.snapshot.sortStack,columnVisibility:z.snapshot.columnVisibility,columnOrder:z.snapshot.columnOrder,columnWidths:z.snapshot.columnWidths,grouping:z.snapshot.grouping})}},[c==null?void 0:c.schemaLocked,c==null?void 0:c.schema,c==null?void 0:c.id,F]),p.useEffect(()=>{if(i&&n&&!Z&&j.length===0){const z=so(i),_={id:x||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:z,schema:$i(So(z),E.hiddenColumns),permissions:S??{owner:Rt,editors:[],viewers:[]}};T([_]),H(_.id),B(!0),fe("confirmed")}},[i,n,Z,j.length,r,u,x]),p.useEffect(()=>{k!=="server"||!Z||!R||F(R,{uploadedData:so(i||[])})},[i,k,Z,R]),p.useEffect(()=>{k==="server"&&((a==null?void 0:a.page)!==void 0&&ut(a.page),(a==null?void 0:a.pageSize)!==void 0&&Nt(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,k]),p.useEffect(()=>{if(!s||Z)return;let z=!1,_=null;const W=async()=>{try{fe("uploading");let A;if(s.type==="api"){const Y=await fetch(s.url,{headers:s.headers||{}});if(!Y.ok)throw new Error(`HTTP ${Y.status}: ${Y.statusText}`);A=await Y.json()}else A=await s.fetch();if(z)return;if(!Array.isArray(A))throw new Error("Data source must return an array of objects");const q=So(A);if(Z)T(Y=>Y.map(ae=>ae.id===R?{...ae,uploadedData:so(A)}:ae)),fe("confirmed");else{const Y={id:x||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:so(A),schema:$i(So(so(A)),E.hiddenColumns),permissions:S??{owner:Rt,editors:[],viewers:[]}};T([Y]),H(Y.id),B(!0),fe("confirmed")}}catch(A){z||(fe("error"),c&&F(c.id,{uploadError:(A==null?void 0:A.message)||"Failed to load data from source"}))}};return W(),s.refreshInterval&&s.refreshInterval>0&&(_=setInterval(W,s.refreshInterval)),()=>{z=!0,_&&clearInterval(_)}},[s,u,r,x]);const st=(Yo=c==null?void 0:c.views)==null?void 0:Yo.find(z=>z.id===c.activeViewId),kr=p.useMemo(()=>c!=null&&c.uploadedData?(c.uploadedData.forEach(z=>Jl(z,E.getRowId)),c.uploadedData):[],[c==null?void 0:c.uploadedData]);p.useEffect(()=>{qe(z=>{if(z.size===0)return z;const _=new Set(kr.map(A=>A==null?void 0:A.__urm_row_id__)),W=new Set(Array.from(z).filter(A=>_.has(A==null?void 0:A.__urm_row_id__)));return W.size===z.size?z:W})},[kr]);const zt=Yl({rawData:kr,schema:(c==null?void 0:c.schema)||[],filters:He(c==null?void 0:c.filters),sortStack:(c==null?void 0:c.sortStack)||[],grouping:(c==null?void 0:c.grouping)||null,searchQuery:Zt||"",searchMode:h,columnVisibility:(c==null?void 0:c.columnVisibility)||(st==null?void 0:st.snapshot.columnVisibility)||{},columnOrder:(c==null?void 0:c.columnOrder)||(st==null?void 0:st.snapshot.columnOrder)||[],columnWidths:(c==null?void 0:c.columnWidths)||(st==null?void 0:st.snapshot.columnWidths)||{},views:(c==null?void 0:c.views)||[],activeViewId:(c==null?void 0:c.activeViewId)||"",pagination:{enabled:k==="client",pageSize:tt,currentPage:Cr}}),{data:Fr=[],searchedData:ur=[],groupedData:zr=[],sortedData:Ft=[],metrics:pr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Br=!1,paginationEngine:Ce}=zt||{},pt=k==="server"?(a==null?void 0:a.totalRows)??0:Br?pr.totalRows:pr.searchedRows,ht=k==="server"?Math.max(1,Math.ceil(((a==null?void 0:a.totalRows)??0)/tt)):(Ce==null?void 0:Ce.totalPages)??1,V=((zi=zt.viewEngine)==null?void 0:zi.activeView)||st,Me=((Bi=zt.viewEngine)==null?void 0:Bi.isDirty)||!1;p.useEffect(()=>{if(!(!V||!c)&&!c.columnOrder){const z=V.snapshot.columnOrder,_=ko(z,V.snapshot.grouping);F(c.id,{columnOrder:_})}},[c==null?void 0:c.activeViewId]);const Ae=p.useMemo(()=>!(c!=null&&c.schema)||!V?null:Qa(c.filters,c.sortStack||[],c.schema,c.columnVisibility,c.columnOrder,c.columnWidths,c.grouping,V.snapshot.columnOrder),[c==null?void 0:c.filters,c==null?void 0:c.sortStack,c==null?void 0:c.schema,c==null?void 0:c.columnVisibility,c==null?void 0:c.columnOrder,c==null?void 0:c.columnWidths,c==null?void 0:c.grouping,V]),Tr=p.useMemo(()=>!V||!Ae||!Me?[]:tl(Ae,V.snapshot),[V,Ae,Me]),Ir=p.useCallback((z,_,W)=>{const A={id:`report-${Date.now()}`,name:z,description:_,schemaLocked:!1,permissions:{owner:Rt,editors:[],viewers:[]}};if(W&&Array.isArray(W)&&W.length>0){const q=So(W),Y=Yn(q);A.uploadedData=W,A.schema=q,A.schemaLocked=!0,A.views=[Y],A.activeViewId=Y.id,A.sortStack=Y.snapshot.sortStack,A.filters=Y.snapshot.filters,A.columnVisibility=Y.snapshot.columnVisibility,A.columnOrder=Y.snapshot.columnOrder,A.columnWidths=Y.snapshot.columnWidths,A.grouping=Y.snapshot.grouping}T(q=>[...q,A]),H(A.id),J(!1),fe("confirmed")},[]),Vr=p.useCallback(z=>{c&&(fe("uploading"),setTimeout(()=>{const _=So(z);F(c.id,{uploadedData:z,schema:_,uploadError:void 0}),fe("preview")},500))},[c,F]),mo=p.useCallback(z=>{c&&(F(c.id,{uploadError:z}),fe("idle"))},[c,F]),Vt=p.useCallback(()=>{c&&(F(c.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),fe("idle"))},[c,F]),fo=p.useCallback(()=>{c&&(F(c.id,{schemaLocked:!0}),fe("confirmed"))},[c,F]),Hr=p.useCallback(z=>{if(!c)return;if(!Bt("edit_sorting",Se)){D(Tt("edit_sorting"),"error");return}const _=c.sortStack??[],W=_.find(A=>A.column===z);if(W){const A=Ua(W.direction);if(A===null){const q=_.filter(Y=>Y.column!==z).map((Y,ae)=>({...Y,priority:ae+1}));ie("sorting","sort_level_removed",W,null),F(c.id,{sortStack:q.length>0?q:void 0})}else{const q=A,Y=_.map(ae=>ae.column===z?{...ae,direction:q}:ae);ie("sorting","sort_reordered",{column:z,direction:W.direction},{column:z,direction:q}),F(c.id,{sortStack:Y})}}else{if(_.length>=b.sort.maxLevels){D(`Sort limit reached — maximum ${b.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const A={column:z,direction:"asc",priority:_.length+1};ie("sorting","sort_level_added",null,A),F(c.id,{sortStack:[..._,A]})}},[c,Se,F,ie]),Wt=p.useCallback(z=>{if(!c)return;const _=c.sortStack??[],W=z.length===0?"sort_cleared":"sort_reordered";if(c.schema){const{validRules:A,invalidColumns:q}=Rs(z,c.schema);q.length>0&&D(`Removed invalid sort columns: ${q.join(", ")}`),kt();try{ie("sorting",W,_,A.length>0?A:null),F(c.id,{sortStack:A.length>0?A:void 0})}catch(Y){const ae=xr("processing","sorting",Y);yt(ae)}}else ie("sorting",W,_,z.length>0?z:null),F(c.id,{sortStack:z.length>0?z:void 0})},[c,F,kt,yt,ie]),Er=p.useCallback(z=>{if(!c)return;const _=c.sortStack??[],W=_.find(A=>A.column===z);if(!(W&&W.direction==="asc"))if(W){const A=_.map(q=>q.column===z?{...q,direction:"asc"}:q);ie("sorting","sort_reordered",{column:z,direction:W.direction},{column:z,direction:"asc"}),F(c.id,{sortStack:A})}else{if(_.length>=b.sort.maxLevels){D(`Sort limit reached — maximum ${b.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const A={column:z,direction:"asc",priority:_.length+1};ie("sorting","sort_level_added",null,A),F(c.id,{sortStack:[..._,A]})}},[c,F,ie]),je=p.useCallback(z=>{if(!c)return;const _=c.sortStack??[],W=_.find(A=>A.column===z);if(!(W&&W.direction==="desc"))if(W){const A=_.map(q=>q.column===z?{...q,direction:"desc"}:q);ie("sorting","sort_reordered",{column:z,direction:W.direction},{column:z,direction:"desc"}),F(c.id,{sortStack:A})}else{if(_.length>=b.sort.maxLevels){D(`Sort limit reached — maximum ${b.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const A={column:z,direction:"desc",priority:_.length+1};ie("sorting","sort_level_added",null,A),F(c.id,{sortStack:[..._,A]})}},[c,F,ie]),Ge=p.useCallback((z,_)=>{var A;if(!c)return;if(!Bt("edit_filters",Se)){D(Tt("edit_filters"),"error");return}const W=(A=c.schema)==null?void 0:A.find(q=>q.name===_.column);if(W&&_.value!==void 0){const q=Dl(W.type,_.operator,_.value);if(!q.isValid){D(q.errorMessage||"Invalid filter value","error");return}}kt();try{const q=He(c.filters),Y={..._,id:lo()},ae=co(q,z,Y);ie("filters","filter_added",null,Y),F(c.id,{filters:ae})}catch(q){const Y=xr("processing","filters",q);yt(Y)}},[c,Se,F,kt,yt,ie]),Dr=p.useCallback(z=>{if(!c)return;if(!Bt("edit_filters",Se)){D(Tt("edit_filters"),"error");return}const _=He(c.filters),W=co(_,z,Pt());ie("filters","filter_added",null,"a condition group"),F(c.id,{filters:W})},[c,Se,F,ie]),at=p.useCallback((z,_)=>{if(!c)return;if(!Bt("edit_filters",Se)){D(Tt("edit_filters"),"error");return}const W=He(c.filters),A=rn(W,z),q=mi(W,z,_),Y=rn(q,z);ie("filters","filter_updated",A,Y),F(c.id,{filters:q})},[c,Se,F,ie]),er=p.useCallback((z,_)=>{if(!c)return;if(!Bt("edit_filters",Se)){D(Tt("edit_filters"),"error");return}const W=He(c.filters),A=fi(W,z,_);ie("filters","filter_updated",null,`group operator changed to ${_.toUpperCase()}`),F(c.id,{filters:A})},[c,Se,F,ie]),me=p.useCallback(z=>{if(!c)return;if(!Bt("edit_filters",Se)){D(Tt("edit_filters"),"error");return}const _=He(c.filters),W=rn(_,z),A=xi(_,z);ie("filters","filter_removed",W,null),F(c.id,{filters:A})},[c,Se,F,ie]),xe=p.useCallback(()=>{if(!c)return;if(!Bt("edit_filters",Se)){D(Tt("edit_filters"),"error");return}const z=He(c.filters);ie("filters","filter_cleared",{count:Et(z)},null),F(c.id,{filters:Pt()})},[c,Se,F,ie]),et=p.useCallback(z=>{if(!c)return;if(!Bt("edit_filters",Se)){D(Tt("edit_filters"),"error");return}const _=He(c.filters);ie("filters","filter_cleared",{count:Et(_)},{count:Et(z)}),F(c.id,{filters:z})},[c,Se,F,ie]),_e=p.useCallback(z=>{var q;if(!c)return;const _=(q=c.views)==null?void 0:q.find(Y=>Y.id===z);if(!_)return;const W=_.snapshot.columnOrder,A=ko(W,_.snapshot.grouping);ie("views","view_switched",{previousViewId:c.activeViewId},{viewId:z,name:_.name}),F(c.id,{filters:_.snapshot.filters,sortStack:_.snapshot.sortStack.length>0?[..._.snapshot.sortStack]:void 0,columnVisibility:{..._.snapshot.columnVisibility},columnOrder:A,columnWidths:{..._.snapshot.columnWidths},grouping:_.snapshot.grouping,activeViewId:z}),qe(new Set)},[c,F,ie]),it=p.useCallback((z,_,W)=>{var ve;if(!(c!=null&&c.schema)||!Ae)return;const A=c.views??[],q=A.filter(Gt=>!Gt.isDeleted).length,Y=((ve=b.views)==null?void 0:ve.maxViews)??10;if(q>=Y){D(`View limit reached — you can have at most ${Y} saved views. Delete an existing view to create a new one.`,"error");return}const ae={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:z,description:_||void 0,isDefault:W,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:Rt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Ae}},ye=W?A.map(Gt=>({...Gt,isDefault:!1})):A;ie("views","view_created",null,{viewId:ae.id,name:z,isDefault:W}),F(c.id,{views:[...ye,ae],activeViewId:ae.id}),D(`"${z}" view created`,"success")},[c,Ae,F,ie]),mt=p.useCallback(z=>{var ae;if(!(c!=null&&c.views))return;const _=c.views.find(ye=>ye.id===z);if(!_)return;const W=c.views,A=W.filter(ye=>!ye.isDeleted).length,q=((ae=b.views)==null?void 0:ae.maxViews)??10;if(A>=q){D(`View limit reached — you can have at most ${q} saved views. Delete an existing view to create a new one.`,"error");return}const Y={..._,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${_.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:Rt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{..._.snapshot}};F(c.id,{views:[...W,Y]}),D(`"${Y.name}" created`,"success")},[c,b,F]),bt=p.useCallback(()=>{var _;if(!V||!Ae||!c)return;const z=(_=c.views)==null?void 0:_.map(W=>W.id===V.id?{...W,snapshot:{...Ae}}:W);F(c.id,{views:z}),D(`"${V.name}" view updated`,"success")},[V,Ae,c,F]),Dn=p.useCallback(z=>{var A;if(!V||!Ae||!c)return;const _=z??Ae.columnWidths,W=(A=c.views)==null?void 0:A.map(q=>q.id===V.id?{...q,snapshot:{...q.snapshot,columnVisibility:Ae.columnVisibility,columnOrder:Ae.columnOrder,columnWidths:_},updatedAt:Date.now()}:q);F(c.id,{views:W,columnWidths:_}),D(`Column configuration saved to "${V.name}"`,"success")},[V,Ae,c,F]),Po=p.useCallback(z=>{var Y,ae;if(!Ae||!c||!V)return;const _=z??Ae.columnWidths,W={...V,snapshot:{...V.snapshot,columnVisibility:Ae.columnVisibility,columnOrder:Ae.columnOrder,columnWidths:_},updatedAt:Date.now()},A=(Y=c.views)==null?void 0:Y.map(ye=>ye.id===V.id?W:{...ye,snapshot:{...ye.snapshot,columnVisibility:Ae.columnVisibility,columnOrder:Ae.columnOrder,columnWidths:_},updatedAt:Date.now()});F(c.id,{views:A,columnWidths:_});const q=(((ae=c.views)==null?void 0:ae.length)||0)-1;D(`Column configuration saved to current view and ${q} other view${q===1?"":"s"}`,"success")},[Ae,c,V,F]),Ur=p.useCallback(()=>{pe(!0)},[]),_n=p.useCallback(()=>{if(!V||!c)return;const z=V.snapshot.columnOrder,_=ko(z,V.snapshot.grouping);F(c.id,{filters:V.snapshot.filters,sortStack:V.snapshot.sortStack.length>0?[...V.snapshot.sortStack]:void 0,columnVisibility:{...V.snapshot.columnVisibility},columnOrder:_,columnWidths:{...V.snapshot.columnWidths},grouping:V.snapshot.grouping}),D("Changes reverted to last saved state","success")},[V,c,F]),Gr=p.useCallback(z=>{if(!(c!=null&&c.views))return;const _=c.views.map(A=>({...A,isDefault:A.id===z}));F(c.id,{views:_});const W=c.views.find(A=>A.id===z);W&&D(`"${W.name}" set as default view`,"success")},[c,F]),xo=p.useCallback(z=>{if(!(c!=null&&c.views))return;const _=c.views.map(A=>A.id===z?{...A,isFavorite:!A.isFavorite,updatedAt:Date.now()}:A);F(c.id,{views:_});const W=c.views.find(A=>A.id===z);W&&!W.isFavorite?D(`"${W.name}" added to favorites`,"success"):W&&D(`"${W.name}" removed from favorites`,"info")},[c,F]),$n=p.useCallback(z=>{if(!(c!=null&&c.views))return;const _=c.views.find(ve=>ve.id===z),W=c.views.filter(ve=>!ve.isDeleted||ve.id===z);if((_==null?void 0:_.isDefault)&&W.filter(ve=>ve.isDefault).length===1){D("Cannot delete the last default view","error");return}const q=c.views.map(ve=>ve.id===z?{...ve,isDeleted:!0,updatedAt:Date.now()}:ve),Y=c.activeViewId===z,ae=q.find(ve=>ve.isDefault&&!ve.isDeleted);F(c.id,{views:q,activeViewId:Y&&ae?ae.id:c.activeViewId,filters:Y&&ae?ae.snapshot.filters:c.filters,sortStack:Y&&ae?ae.snapshot.sortStack.length>0?ae.snapshot.sortStack:void 0:c.sortStack});const ye=c.views.find(ve=>ve.id===z);ye&&D(`"${ye.name}" moved to Recently Deleted`,"info")},[c,F]),No=p.useCallback(z=>{if(!(c!=null&&c.views))return;const _=c.views.map(A=>A.id===z?{...A,isDeleted:!1,updatedAt:Date.now()}:A);F(c.id,{views:_});const W=c.views.find(A=>A.id===z);W&&D(`"${W.name}" restored`,"success")},[c,F]),Yr=p.useCallback(z=>{if(!(c!=null&&c.views))return;const _=c.views.find(ye=>ye.id===z),W=c.views.filter(ye=>!ye.isDeleted||ye.id===z);if((_==null?void 0:_.isDefault)&&W.filter(ye=>ye.isDefault).length===1){D("Cannot delete the last default view","error");return}const q=c.views.filter(ye=>ye.id!==z),Y=c.activeViewId===z,ae=q.find(ye=>ye.isDefault&&!ye.isDeleted);F(c.id,{views:q,activeViewId:Y&&ae?ae.id:c.activeViewId,filters:Y&&ae?ae.snapshot.filters:c.filters,sortStack:Y&&ae?ae.snapshot.sortStack.length>0?ae.snapshot.sortStack:void 0:c.sortStack}),_&&D(`"${_.name}" permanently deleted`,"success")},[c,F]),Lo=p.useCallback(z=>{Pe(z),P(!0)},[]),qr=p.useCallback(async z=>{if(!c)return;const _=new URLSearchParams(window.location.search);_.set("reportId",c.id),_.set("view",z);const W=`${window.location.origin}${window.location.pathname}?${_.toString()}`,A=await kl(W);D(A?"Link copied to clipboard":"Failed to copy link",A?"success":"error")},[c]),go=p.useCallback((z,_)=>{if(!Q||!(c!=null&&c.views))return;const W=c.views.map(A=>A.id===Q?{...A,name:z,description:_||void 0}:A);F(c.id,{views:W}),Pe(null)},[Q,c,F]),Fo=p.useCallback(z=>{$t(z),G(!0)},[]),Jr=p.useCallback(()=>{if(!Te||!(c!=null&&c.views))return;const z=c.views.find(q=>q.id===Te),_=c.views.filter(q=>q.id!==Te),W=c.activeViewId===Te,A=_.find(q=>q.isDefault);ie("views","view_deleted",{viewId:Te,name:z==null?void 0:z.name},null),F(c.id,{views:_,activeViewId:W&&A?A.id:c.activeViewId,filters:W&&A?A.snapshot.filters:c.filters,sortStack:W&&A?A.snapshot.sortStack.length>0?A.snapshot.sortStack:void 0:c.sortStack}),$t(null),G(!1)},[Te,c,F,ie]),Kr=p.useCallback(z=>{var q;if(!(c!=null&&c.views))return;if(!(((q=b.views)==null?void 0:q.isAdmin)??!1)){D("Only administrators can promote views to Global.","error");return}const W=c.views.find(Y=>Y.id===z);if(!W)return;if(W.scope==="global"){D(`"${W.name}" is already a Global View.`,"info");return}const A=c.views.map(Y=>Y.id===z?{...Y,scope:"global",isDefault:!0,updatedAt:Date.now()}:Y.scope==="global"&&Y.isDefault?{...Y,isDefault:!1}:Y);F(c.id,{views:A}),D(`"${W.name}" promoted to Global View and set as default.`,"success")},[c,b,F]),hr=p.useCallback((z,_)=>{if(!(c!=null&&c.views))return;const W=c.views.find(Y=>Y.id===z);if(!W)return;const A=c.views.map(Y=>Y.id===z?{...Y,isDefaultForAllUsers:_,updatedAt:Date.now()}:_&&Y.isDefaultForAllUsers?{...Y,isDefaultForAllUsers:!1}:Y);ie("views",_?"view_set_default":"view_updated",{viewId:z,isDefaultForAllUsers:!_},{viewId:z,isDefaultForAllUsers:_}),F(c.id,{views:A}),D(`"${W.name}" ${_?"set as":"removed from"} default for all users.`,"success")},[c,F,ie]),yo=p.useRef(!0);p.useEffect(()=>{var z;if(yo.current){yo.current=!1;return}if(k==="server"){ut(1),(z=a==null?void 0:a.onPaginationChange)==null||z.call(a,1,tt);return}Ce!=null&&Ce.resetPage?Ce.resetPage():ut(1)},[c==null?void 0:c.filters,Zt,c==null?void 0:c.activeViewId]);const Xr=p.useCallback(z=>{var _;if(k==="server"){ut(z),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,z,tt);return}Ce!=null&&Ce.goToPage&&Ce.goToPage(z)},[k,a,tt,Ce]),On=p.useCallback(z=>{var q;const W=((k==="server"?Cr:(Ce==null?void 0:Ce.currentPage)||1)-1)*tt,A=Math.floor(W/z)+1;if(k==="server"){Nt(z),ut(A),(q=a==null?void 0:a.onPaginationChange)==null||q.call(a,A,z);return}Nt(z),Ce==null||Ce.goToPage(A)},[Cr,tt,k,a,Ce]),Mn=p.useCallback((z,_)=>{if(!c)return;if(!Bt("edit_columns",Se)){D(Tt("edit_columns"),"error");return}const A={...c.columnVisibility||(V==null?void 0:V.snapshot.columnVisibility)||{},[z]:_};ie("columns",_?"column_shown":"column_hidden",{columnName:z,visible:!_},{columnName:z,visible:_}),F(c.id,{columnVisibility:A})},[c,V,Se,F,ie]),An=p.useCallback(z=>{if(c){if(!Bt("edit_columns",Se)){D(Tt("edit_columns"),"error");return}ie("columns","column_reordered",c.columnOrder,z),F(c.id,{columnOrder:z})}},[c,Se,F,ie]),Wn=p.useCallback((z,_)=>{if(!c)return;if(!Bt("edit_columns",Se)){D(Tt("edit_columns"),"error");return}const W=c.columnWidths||(V==null?void 0:V.snapshot.columnWidths)||{},A={...W,[z]:_};ie("columns","column_resized",{columnName:z,width:W[z]},{columnName:z,width:_}),F(c.id,{columnWidths:A})},[c,V,Se,F,ie]),Rn=p.useCallback(z=>{if(!c)return;const _=He(c.filters),W=Ms(_,z);F(c.id,{filters:W})},[c,F]),Pn=p.useCallback(()=>{if(!V||!(c!=null&&c.schema))return;const z={},_=[],W={};c.schema.forEach(A=>{z[A.name]=!0,_.push(A.name),W[A.name]=170}),F(c.id,{columnVisibility:z,columnOrder:_,columnWidths:W,filters:void 0,sortStack:void 0}),D("Reset to default layout - all filters and sorts cleared","success")},[V,c,F]);p.useEffect(()=>{const z=setTimeout(()=>Sr(sr),300);return()=>clearTimeout(z)},[sr]),p.useEffect(()=>{var z;h==="server"&&((z=d==null?void 0:d.onSearchChange)==null||z.call(d,Zt))},[Zt,h,d]);const Nn=p.useCallback(z=>{po(z),ut(1)},[]),Ln=p.useCallback(z=>{if(!z.trim()||!c)return;const _=c.searchHistory||[],W=il(_,z);F(c.id,{searchHistory:W})},[c,F]),Fn=p.useCallback(z=>{if(!c)return;const _=c.searchHistory||[],W=sl(_,z);F(c.id,{searchHistory:W})},[c,F]),Qr=p.useCallback(z=>{if(!c)return;const _=c.searchHistory||[],W=al(_,z);F(c.id,{searchHistory:W})},[c,F]);p.useEffect(()=>{if(!E.onSelectionChange)return;const z=Array.from(jt);E.onSelectionChange(z,z.map(_=>_==null?void 0:_.__urm_row_id__))},[jt,E.onSelectionChange]);const tr=p.useCallback(z=>{const _=z==null?void 0:z.__urm_row_id__;qe(W=>{const A=new Set(W);let q;return _!==void 0?q=Array.from(A).find(Y=>(Y==null?void 0:Y.__urm_row_id__)===_):q=Array.from(A).find(Y=>Y===z),q!==void 0?A.delete(q):A.add(z),A})},[]),Vn=p.useCallback((z,_)=>{qe(W=>{const A=new Set(W),q=_.filter(Y=>!Y.isGroupHeader);for(const Y of q){const ae=Y==null?void 0:Y.__urm_row_id__;if(z){let ye;ae!==void 0?ye=Array.from(A).find(ve=>(ve==null?void 0:ve.__urm_row_id__)===ae):ye=Array.from(A).find(ve=>ve===Y),ye===void 0&&A.add(Y)}else{let ye;ae!==void 0?ye=Array.from(A).find(ve=>(ve==null?void 0:ve.__urm_row_id__)===ae):ye=Array.from(A).find(ve=>ve===Y),ye!==void 0&&A.delete(ye)}}return A})},[]),Hn=p.useCallback((z,_,W)=>{qe(A=>{const q=new Set(A),Y=W.filter(ve=>!ve.isGroupHeader),ae=Math.min(z,_),ye=Math.max(z,_);for(let ve=ae;ve<=ye;ve++){const Gt=Y[ve];if(!Gt)continue;const Ei=Gt==null?void 0:Gt.__urm_row_id__;let Gn;Ei!==void 0?Gn=Array.from(q).find(vo=>(vo==null?void 0:vo.__urm_row_id__)===Ei):Gn=Array.from(q).find(vo=>vo===Gt),Gn===void 0&&q.add(Gt)}return q})},[]),Ve=p.useCallback(()=>{qe(new Set)},[]),lt=p.useCallback(z=>{const _=z==null?void 0:z.__urm_row_id__;qe(W=>{const A=new Set(W);if(_!==void 0){const q=Array.from(A).find(Y=>(Y==null?void 0:Y.__urm_row_id__)===_);q!==void 0&&A.delete(q)}else A.delete(z);return A})},[]),bo=p.useCallback(z=>{var _,W;if(c){if(!Bt("edit_columns",Se)){D(Tt("edit_columns"),"error");return}if(z&&c.schema){const{validGrouping:A,invalidColumns:q}=Ps(z,c.schema);q.length>0&&D(`Removed invalid grouping columns: ${q.join(", ")}`,"warning"),kt();try{const Y=c.grouping;A===null?ie("grouping","group_cleared",Y,null):Y?ie("grouping","group_reordered",Y,A):ie("grouping","group_level_added",null,A);const ae=(V==null?void 0:V.snapshot.columnOrder)||c.columnOrder||[],ye=ko(ae,A),ve=A.levels.length>0?{...A,collapsedGroups:Mi(Ft,c.schema,A)}:A;F(c.id,{grouping:ve,columnOrder:ye}),k==="server"?(ut(1),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,1,tt)):Ce==null||Ce.resetPage(),JSON.stringify(ye)!==JSON.stringify(c.columnOrder)&&ie("columns","column_reordered",c.columnOrder,ye),wt(!1)}catch(Y){const ae=xr("processing","grouping",Y);yt(ae)}}else{const A=c.grouping;ie("grouping","group_cleared",A,null);const q=(V==null?void 0:V.snapshot.columnOrder)||c.columnOrder||[];F(c.id,{grouping:z,columnOrder:q}),k==="server"?(ut(1),(W=a==null?void 0:a.onPaginationChange)==null||W.call(a,1,tt)):Ce==null||Ce.resetPage(),JSON.stringify(q)!==JSON.stringify(c.columnOrder)&&ie("columns","column_reordered",c.columnOrder,q),wt(!1)}}},[c,V,Se,F,kt,yt,ie,Ft]),Zr=p.useCallback(z=>{if(!c||!b.grouping.allowCollapse)return;const _=c.grouping;if(!_)return;const W=Ka(_,z);F(c.id,{grouping:W})},[c,b,F]),Vo=p.useCallback(()=>{!(c!=null&&c.grouping)||!b.grouping.allowCollapse||F(c.id,{grouping:{...c.grouping,collapsedGroups:[]}})},[c,b,F]),Un=p.useCallback(()=>{if(!(c!=null&&c.grouping)||!c.schema||!b.grouping.allowCollapse)return;const z=Mi(Ft,c.schema,c.grouping);F(c.id,{grouping:{...c.grouping,collapsedGroups:z}})},[c,Ft,b,F]),rr=p.useCallback(()=>{cr(!0)},[]),vt=p.useCallback(z=>{c!=null&&c.schema&&(Kt(!0),setTimeout(()=>{try{let _;z.scope==="visible"?_=ur:_=c.uploadedData||[];let W;z.columnScope==="all"?(W={},(c.schema??[]).forEach(ye=>{W[ye.name]=!0})):W=c.columnVisibility||(V==null?void 0:V.snapshot.columnVisibility)||{};const A=c.columnOrder||(V==null?void 0:V.snapshot.columnOrder),q=nn(_,c.schema,He(c.filters),c.sortStack??[],V,W,A),Y=c.name;let ae;switch(z.format){case"csv":sn(q,Y,z),ae="export_csv";break;case"excel":an(q,Y,z),ae="export_excel";break;case"json":ln(q,Y,z),ae="export_json";break;case"pdf":bi(q,Y,z),ae="export_pdf";break}ie("export",ae,null,{format:z.format,scope:z.scope,columnScope:z.columnScope,rowCount:_.length,viewName:(V==null?void 0:V.name)||"Default View"}),D(`Export completed successfully (${z.format.toUpperCase()})`,"success")}catch(_){const W=$l(_,{onRetry:()=>vt(z)});D(`Export failed: ${W.message}. Click Export to retry.`,"error");const A=Vi(c.id,Rt,W,c.auditHistory||[]);F(c.id,{auditHistory:A}),Jt.error("urm:report-engine","Export failed",_)}finally{Kt(!1)}},500))},[c,V,ur,F,ie]),Ho=p.useCallback(z=>{if(c!=null&&c.schema){if(Me&&V&&!V.isDefault){Xt(z.format),Ot(!0),cr(!1);return}vt(z),cr(!1)}},[c,V,Me,vt]),eo=p.useCallback(z=>{vt({format:z,scope:"visible",columnScope:"visible"})},[vt]),Uo=p.useCallback(()=>{dt&&eo(dt),Ot(!1),Xt(null)},[dt,eo]),Go=p.useCallback(()=>{bt(),dt&&eo(dt),Ot(!1),Xt(null)},[bt,dt,eo]),w=p.useCallback(()=>{Ot(!1),Xt(null)},[]),N=p.useCallback(z=>{!(c!=null&&c.schema)||jt.size===0||(Kt(!0),setTimeout(()=>{try{const _=Array.from(jt),W=nn(_,c.schema,He(c.filters),c.sortStack??[],V),A=`${c.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(z){case"csv":sn(W,A);break;case"excel":an(W,A);break;case"json":ln(W,A);break}D(`Exported ${_.length} selected rows`,"info")}catch(_){D("Export failed. Please try again.","error"),Jt.error("urm:report-engine","Bulk export failed",_)}finally{Kt(!1)}},500))},[c,V,jt,zr]),te=p.useCallback((z,_)=>{if(c)try{const W=bl(c),A=vl(z,_,Rt,W),q=Sl(c.presets,A);F(c.id,{presets:q}),ie("presets","preset_created",null,{presetId:A.id,name:A.name}),lr(!1),D(`Preset "${z}" saved successfully`,"success")}catch(W){D(W instanceof Error?W.message:"Failed to create preset","error")}},[c,F,ie]),ke=p.useCallback(()=>{wr(null),D("Exited preset view","info")},[]),Ne=p.useCallback(()=>{we(!0)},[]),rt=p.useCallback((z,_)=>{if(!c)return;const W=Cl(c.presets,z);F(c.id,{presets:W}),ie("presets","preset_deleted",{presetId:z,name:_},null),At===z&&wr(null),D(`Preset "${_}" deleted`,"success")},[c,At,F,ie]);p.useEffect(()=>{if(!g||j.length===0)return;const z=j.find(_=>_.id===g);z&&z.id!==R&&H(z.id)},[g,j,R]);const Ke=p.useRef(!1);p.useEffect(()=>{var _;if(!m||Ke.current||!c||c.id!==g)return;const z=(_=c.views)==null?void 0:_.find(W=>W.id===m&&!W.isDeleted);z&&_e(z.id),Ke.current=!0},[m,g,c,_e]),p.useEffect(()=>{if(!c)return;const z=wl();if(z&&c.presets&&c.schemaLocked&&c.schema){const _=Fi(c.presets,z);if(_){const{sanitizedConfig:W,warnings:A}=_l(_.config,c.schema);A.length>0&&A.forEach(Y=>D(Y,"warning"));const q=jl(W);F(c.id,q),wr(z),ie("presets","preset_applied",null,{presetId:_.id,name:_.name}),D(`Loaded preset: ${_.name}`,"info")}else D("Preset not found","info")}},[c==null?void 0:c.schemaLocked]);const ge=At?Fi(c==null?void 0:c.presets,At):void 0;p.useEffect(()=>{var z;c!=null&&c.views&&c.views.length>0&&c.activeViewId&&((z=C==null?void 0:C.onViewsChange)==null||z.call(C,c.views,c.activeViewId),y!=="api"&&rl(c.id,{views:c.views,activeViewId:c.activeViewId}))},[c==null?void 0:c.views,c==null?void 0:c.activeViewId,c==null?void 0:c.id,y,C]),p.useEffect(()=>{if(c!=null&&c.schemaLocked&&c.schema&&(!c.views||c.views.length===0)){const z=y==="api"?C!=null&&C.views&&C.views.length>0?{views:C.views,activeViewId:C.activeViewId??C.views[0].id}:null:ol(c.id);if(z&&z.views.length>0){const _=z.views.find(W=>W.id===z.activeViewId);if(_)F(c.id,{views:z.views,activeViewId:z.activeViewId,filters:He(_.snapshot.filters),sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0});else{const W=z.views.find(A=>A.isDefault)||Yn(c.schema);F(c.id,{views:z.views,activeViewId:W.id,filters:He(W.snapshot.filters),sortStack:W.snapshot.sortStack.length>0?W.snapshot.sortStack:void 0})}}}},[c==null?void 0:c.schemaLocked,c==null?void 0:c.schema,c==null?void 0:c.id,y,C]);const Ht=p.useCallback(z=>{var A;const _=He(c==null?void 0:c.filters),W=((A=b.filter)==null?void 0:A.maxConditions)??3;if(Et(_)>=W){D(`Filter limit reached — maximum ${W} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}De(z),K(!0)},[c,b,D]),Ut=p.useCallback(()=>{K(!1),De(void 0)},[]),We=(Ti=c==null?void 0:c.views)==null?void 0:Ti.find(z=>z.id===Q),mr=(Ii=c==null?void 0:c.views)==null?void 0:Ii.find(z=>z.id===Te);return{reports:j,activeReport:c,activeReportId:R,setActiveReportId:H,isModalOpen:I,setIsModalOpen:J,createReport:Ir,updateReport:F,uploadState:re,handleFileUpload:Vr,handleUploadError:mo,handleRetry:Vt,handleConfirm:fo,paginatedData:Fr,processedData:ur,displayData:zr,tableMetrics:pr,isGrouped:Br,tableEngine:zt,activeView:V,isDirty:Me,currentTableState:Ae,viewChanges:Tr,filters:c==null?void 0:c.filters,showFilterPanel:U,setShowFilterPanel:K,filterFocusColumn:ne,handleAddCondition:Ge,handleAddGroup:Dr,handleUpdateCondition:at,handleSetGroupOperator:er,handleRemoveFilterNode:me,handleClearAllFilters:xe,handleReplaceFilters:et,handleOpenFilterForColumn:Ht,handleCloseFilterPanel:Ut,handleClearFiltersForColumn:Rn,sortStack:c==null?void 0:c.sortStack,showSortPanel:de,setShowSortPanel:ue,handleSort:Hr,handleUpdateSortStack:Wt,handleSortAscending:Er,handleSortDescending:je,views:c==null?void 0:c.views,showCreateViewModal:X,setShowCreateViewModal:pe,showEditViewModal:le,setShowEditViewModal:P,showDeleteConfirmation:se,setShowDeleteConfirmation:G,editingView:We,deletingView:mr,editingViewId:Q,deletingViewId:Te,handleSelectView:_e,handleCreateView:it,handleCloneView:mt,handleUpdateCurrentView:bt,handleSaveColumnConfigToCurrentView:Dn,handleSaveColumnConfigToAllViews:Po,handleSaveAsNewView:Ur,handleRevertChanges:_n,handleToggleDefault:Gr,handleToggleFavorite:xo,handleSoftDelete:$n,handleRestoreView:No,handlePermanentDelete:Yr,handleEditView:Lo,handleCopyViewLink:qr,handleSaveEditView:go,handleDeleteView:Fo,handleConfirmDelete:Jr,handlePromoteToGlobal:Kr,handleSetDefaultForAllUsers:hr,showManageColumns:Qe,setShowManageColumns:Mt,columnVisibility:c==null?void 0:c.columnVisibility,columnOrder:c==null?void 0:c.columnOrder,columnWidths:c==null?void 0:c.columnWidths,handleUpdateColumnVisibility:Mn,handleUpdateColumnOrder:An,handleUpdateColumnWidth:Wn,handleResetColumnLayout:Pn,showGroupPanel:vr,setShowGroupPanel:wt,grouping:c==null?void 0:c.grouping,groupingState:Qt,handleGroup:bo,handleToggleGroupCollapse:Zr,handleExpandAllGroups:Vo,handleCollapseAllGroups:Un,searchQuery:sr,debouncedSearchQuery:Zt,searchHistory:ll((c==null?void 0:c.searchHistory)||[]),handleSearchChange:Nn,handleAddToSearchHistory:Ln,handleToggleSearchFavourite:Fn,handleDeleteSearchHistory:Qr,selectedRowIds:jt,handleToggleRowSelection:tr,handleToggleAllRows:Vn,handleRangeSelection:Hn,handleClearSelection:Ve,handleUpdateSelectionAfterDelete:lt,currentPage:k==="server"?Cr:(Ce==null?void 0:Ce.currentPage)||1,pageSize:tt,paginationEngine:Ce,paginationMode:k,paginationTotalRows:pt,paginationTotalPages:ht,handlePageChange:Xr,handlePageSizeChange:On,isExporting:Rr,showExportModal:Nr,setShowExportModal:cr,showDirtyExportWarning:br,handleExport:rr,handleExportWithConfig:Ho,handleExportSelected:N,handleExportAnyway:Uo,handleSaveAndExport:Go,handleCancelExport:w,showAuditHistory:ar,setShowAuditHistory:ho,auditHistory:c==null?void 0:c.auditHistory,showCreatePreset:Pr,setShowCreatePreset:lr,showManagePresets:Je,setShowManagePresets:we,activePreset:ge,activePresetId:At,handleOpenManagePresets:Ne,handleCreatePreset:te,handleClearActivePreset:ke,handleDeletePresetById:rt,userRole:Se,isViewerRole:Ro,currentUserId:Rt,permissions:c==null?void 0:c.permissions,featureLimitWarning:jr,setFeatureLimitWarning:Lr,datasetMeta:he,reportError:dr,setReportError:Ze,handleError:yt,schema:c==null?void 0:c.schema,hasSchemaConflicts:c!=null&&c.schema?Fa(c.schema):!1,snack:f,handleSnackClose:ee,showSnack:D,snackDurationMs:oe,config:E,scheduler:l}}const Ns=p.createContext(ft);function Ar(){return p.useContext(Ns)}const Ls=p.createContext(void 0);function vi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:d,pagination:l,search:u,scheduler:x,mode:g="builder",autoLoad:m=!0,config:C,devConfig:S,showDevPanel:E=!1,sharedReportId:v,sharedViewId:y,viewPersistence:k,permissions:h}=e,j=i||n,[T,b]=p.useState(()=>ja()),R=(()=>{const B=za(T,S,!!S);return{...B,display:{...B.display,showDevPanel:E||B.display.showDevPanel}}})(),H=Kl({mode:g,autoLoad:m,initialData:j,dataSource:d,pagination:l,search:u,scheduler:x,reportName:s,reportId:a,sharedReportId:v,sharedViewId:y,viewPersistence:k,permissions:h,config:C,devConfig:R}),I=p.useCallback(Z=>{b(Z),ka(Z)},[]),J={...H,activeDevConfig:R,handleDevConfigChange:I};return t.jsx(Ns.Provider,{value:R,children:t.jsx(Ls.Provider,{value:J,children:r})})}function fn(){const e=p.useContext(Ls);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Xl({onCreateReport:e,reports:r=[],activeReportId:n,onReportClick:i}){const s=r.find(a=>a.id===n);return t.jsx(o.Box,{component:"header",sx:a=>{var g,m,C;const d=((C=(m=(g=a.components)==null?void 0:g.MuiCardHeader)==null?void 0:m.styleOverrides)==null?void 0:C.root)||{},l=d.backgroundColor&&d.backgroundColor!=="transparent"?d.backgroundColor:a.palette.background.paper,u=d.borderBottom&&d.borderBottom!=="none"?d.borderBottom:"1px solid",x=d.boxShadow&&d.boxShadow!=="none"?d.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:x,bgcolor:l}},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsxs(o.Breadcrumbs,{separator:t.jsx(M.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.375rem",color:a=>a.typography.h6.color||"text.primary",letterSpacing:"-0.01em",cursor:r.length>0&&s?"pointer":"default","&:hover":r.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),s&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontWeight:a=>a.typography.h6.fontWeight||500,fontSize:a=>a.typography.h6.fontSize||"1.125rem",color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),t.jsx(o.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:t.jsx(M.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(o.Button,{variant:"contained",startIcon:t.jsx(M.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Mr(e,...r){const n=new URL(`https://mui.com/production-error/?code=${e}`);return r.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${e}; visit ${n} for the full message.`}const Ql="$$material";function Zl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ko={exports:{}},Xo={exports:{}},ze={};/** @license React v16.13.1
106
106
  * react-is.production.min.js
107
107
  *
108
108
  * Copyright (c) Facebook, Inc. and its affiliates.
109
109
  *
110
110
  * This source code is licensed under the MIT license found in the
111
111
  * LICENSE file in the root directory of this source tree.
112
- */var Fi;function Ql(){if(Fi)return Ie;Fi=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,y=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,m=e?Symbol.for("react.suspense"):60113,S=e?Symbol.for("react.suspense_list"):60120,C=e?Symbol.for("react.memo"):60115,D=e?Symbol.for("react.lazy"):60116,v=e?Symbol.for("react.block"):60121,x=e?Symbol.for("react.fundamental"):60117,B=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function k(b){if(typeof b=="object"&&b!==null){var R=b.$$typeof;switch(R){case r:switch(b=b.type,b){case u:case y:case i:case a:case s:case m:return b;default:switch(b=b&&b.$$typeof,b){case l:case g:case D:case C:case c:return b;default:return R}}case n:return R}}}function T(b){return k(b)===y}return Ie.AsyncMode=u,Ie.ConcurrentMode=y,Ie.ContextConsumer=l,Ie.ContextProvider=c,Ie.Element=r,Ie.ForwardRef=g,Ie.Fragment=i,Ie.Lazy=D,Ie.Memo=C,Ie.Portal=n,Ie.Profiler=a,Ie.StrictMode=s,Ie.Suspense=m,Ie.isAsyncMode=function(b){return T(b)||k(b)===u},Ie.isConcurrentMode=T,Ie.isContextConsumer=function(b){return k(b)===l},Ie.isContextProvider=function(b){return k(b)===c},Ie.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===r},Ie.isForwardRef=function(b){return k(b)===g},Ie.isFragment=function(b){return k(b)===i},Ie.isLazy=function(b){return k(b)===D},Ie.isMemo=function(b){return k(b)===C},Ie.isPortal=function(b){return k(b)===n},Ie.isProfiler=function(b){return k(b)===a},Ie.isStrictMode=function(b){return k(b)===s},Ie.isSuspense=function(b){return k(b)===m},Ie.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===i||b===y||b===a||b===s||b===m||b===S||typeof b=="object"&&b!==null&&(b.$$typeof===D||b.$$typeof===C||b.$$typeof===c||b.$$typeof===l||b.$$typeof===g||b.$$typeof===x||b.$$typeof===B||b.$$typeof===h||b.$$typeof===v)},Ie.typeOf=k,Ie}var Ee={};/** @license React v16.13.1
112
+ */var Hi;function ec(){if(Hi)return ze;Hi=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,d=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,m=e?Symbol.for("react.suspense"):60113,C=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,E=e?Symbol.for("react.lazy"):60116,v=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,k=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function j(b){if(typeof b=="object"&&b!==null){var R=b.$$typeof;switch(R){case r:switch(b=b.type,b){case u:case x:case i:case a:case s:case m:return b;default:switch(b=b&&b.$$typeof,b){case l:case g:case E:case S:case d:return b;default:return R}}case n:return R}}}function T(b){return j(b)===x}return ze.AsyncMode=u,ze.ConcurrentMode=x,ze.ContextConsumer=l,ze.ContextProvider=d,ze.Element=r,ze.ForwardRef=g,ze.Fragment=i,ze.Lazy=E,ze.Memo=S,ze.Portal=n,ze.Profiler=a,ze.StrictMode=s,ze.Suspense=m,ze.isAsyncMode=function(b){return T(b)||j(b)===u},ze.isConcurrentMode=T,ze.isContextConsumer=function(b){return j(b)===l},ze.isContextProvider=function(b){return j(b)===d},ze.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===r},ze.isForwardRef=function(b){return j(b)===g},ze.isFragment=function(b){return j(b)===i},ze.isLazy=function(b){return j(b)===E},ze.isMemo=function(b){return j(b)===S},ze.isPortal=function(b){return j(b)===n},ze.isProfiler=function(b){return j(b)===a},ze.isStrictMode=function(b){return j(b)===s},ze.isSuspense=function(b){return j(b)===m},ze.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===i||b===x||b===a||b===s||b===m||b===C||typeof b=="object"&&b!==null&&(b.$$typeof===E||b.$$typeof===S||b.$$typeof===d||b.$$typeof===l||b.$$typeof===g||b.$$typeof===y||b.$$typeof===k||b.$$typeof===h||b.$$typeof===v)},ze.typeOf=j,ze}var Be={};/** @license React v16.13.1
113
113
  * react-is.development.js
114
114
  *
115
115
  * Copyright (c) Facebook, Inc. and its affiliates.
116
116
  *
117
117
  * This source code is licensed under the MIT license found in the
118
118
  * LICENSE file in the root directory of this source tree.
119
- */var Vi;function Zl(){return Vi||(Vi=1,process.env.NODE_ENV!=="production"&&(function(){var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,y=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,m=e?Symbol.for("react.suspense"):60113,S=e?Symbol.for("react.suspense_list"):60120,C=e?Symbol.for("react.memo"):60115,D=e?Symbol.for("react.lazy"):60116,v=e?Symbol.for("react.block"):60121,x=e?Symbol.for("react.fundamental"):60117,B=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function k(Q){return typeof Q=="string"||typeof Q=="function"||Q===i||Q===y||Q===a||Q===s||Q===m||Q===S||typeof Q=="object"&&Q!==null&&(Q.$$typeof===D||Q.$$typeof===C||Q.$$typeof===c||Q.$$typeof===l||Q.$$typeof===g||Q.$$typeof===x||Q.$$typeof===B||Q.$$typeof===h||Q.$$typeof===v)}function T(Q){if(typeof Q=="object"&&Q!==null){var $e=Q.$$typeof;switch($e){case r:var Pe=Q.type;switch(Pe){case u:case y:case i:case a:case s:case m:return Pe;default:var Wt=Pe&&Pe.$$typeof;switch(Wt){case l:case g:case D:case C:case c:return Wt;default:return $e}}case n:return $e}}}var b=u,R=y,H=l,E=c,Y=r,Z=g,I=i,f=D,w=C,P=n,te=a,d=s,J=m,re=!1;function we(Q){return re||(re=!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.")),F(Q)||T(Q)===u}function F(Q){return T(Q)===y}function X(Q){return T(Q)===l}function ue(Q){return T(Q)===c}function pe(Q){return typeof Q=="object"&&Q!==null&&Q.$$typeof===r}function K(Q){return T(Q)===g}function he(Q){return T(Q)===i}function le(Q){return T(Q)===D}function W(Q){return T(Q)===C}function ie(Q){return T(Q)===n}function U(Q){return T(Q)===a}function ne(Q){return T(Q)===s}function Be(Q){return T(Q)===m}Ee.AsyncMode=b,Ee.ConcurrentMode=R,Ee.ContextConsumer=H,Ee.ContextProvider=E,Ee.Element=Y,Ee.ForwardRef=Z,Ee.Fragment=I,Ee.Lazy=f,Ee.Memo=w,Ee.Portal=P,Ee.Profiler=te,Ee.StrictMode=d,Ee.Suspense=J,Ee.isAsyncMode=we,Ee.isConcurrentMode=F,Ee.isContextConsumer=X,Ee.isContextProvider=ue,Ee.isElement=pe,Ee.isForwardRef=K,Ee.isFragment=he,Ee.isLazy=le,Ee.isMemo=W,Ee.isPortal=ie,Ee.isProfiler=U,Ee.isStrictMode=ne,Ee.isSuspense=Be,Ee.isValidElementType=k,Ee.typeOf=T})()),Ee}var Hi;function Ns(){return Hi||(Hi=1,process.env.NODE_ENV==="production"?Jo.exports=Ql():Jo.exports=Zl()),Jo.exports}/*
119
+ */var Ui;function tc(){return Ui||(Ui=1,process.env.NODE_ENV!=="production"&&(function(){var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,d=e?Symbol.for("react.provider"):60109,l=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,m=e?Symbol.for("react.suspense"):60113,C=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,E=e?Symbol.for("react.lazy"):60116,v=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,k=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function j(Q){return typeof Q=="string"||typeof Q=="function"||Q===i||Q===x||Q===a||Q===s||Q===m||Q===C||typeof Q=="object"&&Q!==null&&(Q.$$typeof===E||Q.$$typeof===S||Q.$$typeof===d||Q.$$typeof===l||Q.$$typeof===g||Q.$$typeof===y||Q.$$typeof===k||Q.$$typeof===h||Q.$$typeof===v)}function T(Q){if(typeof Q=="object"&&Q!==null){var Pe=Q.$$typeof;switch(Pe){case r:var Te=Q.type;switch(Te){case u:case x:case i:case a:case s:case m:return Te;default:var $t=Te&&Te.$$typeof;switch($t){case l:case g:case E:case S:case d:return $t;default:return Pe}}case n:return Pe}}}var b=u,R=x,H=l,I=d,J=r,Z=g,B=i,f=E,$=S,D=n,ee=a,oe=s,c=m,re=!1;function fe(Q){return re||(re=!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.")),U(Q)||T(Q)===u}function U(Q){return T(Q)===x}function K(Q){return T(Q)===l}function de(Q){return T(Q)===d}function ue(Q){return typeof Q=="object"&&Q!==null&&Q.$$typeof===r}function X(Q){return T(Q)===g}function pe(Q){return T(Q)===i}function le(Q){return T(Q)===E}function P(Q){return T(Q)===S}function se(Q){return T(Q)===n}function G(Q){return T(Q)===a}function ne(Q){return T(Q)===s}function De(Q){return T(Q)===m}Be.AsyncMode=b,Be.ConcurrentMode=R,Be.ContextConsumer=H,Be.ContextProvider=I,Be.Element=J,Be.ForwardRef=Z,Be.Fragment=B,Be.Lazy=f,Be.Memo=$,Be.Portal=D,Be.Profiler=ee,Be.StrictMode=oe,Be.Suspense=c,Be.isAsyncMode=fe,Be.isConcurrentMode=U,Be.isContextConsumer=K,Be.isContextProvider=de,Be.isElement=ue,Be.isForwardRef=X,Be.isFragment=pe,Be.isLazy=le,Be.isMemo=P,Be.isPortal=se,Be.isProfiler=G,Be.isStrictMode=ne,Be.isSuspense=De,Be.isValidElementType=j,Be.typeOf=T})()),Be}var Gi;function Fs(){return Gi||(Gi=1,process.env.NODE_ENV==="production"?Xo.exports=ec():Xo.exports=tc()),Xo.exports}/*
120
120
  object-assign
121
121
  (c) Sindre Sorhus
122
122
  @license MIT
123
- */var Jn,Ui;function ec(){if(Ui)return Jn;Ui=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function s(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var c={},l=0;l<10;l++)c["_"+String.fromCharCode(l)]=l;var u=Object.getOwnPropertyNames(c).map(function(g){return c[g]});if(u.join("")!=="0123456789")return!1;var y={};return"abcdefghijklmnopqrst".split("").forEach(function(g){y[g]=g}),Object.keys(Object.assign({},y)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Jn=s()?Object.assign:function(a,c){for(var l,u=i(a),y,g=1;g<arguments.length;g++){l=Object(arguments[g]);for(var m in l)r.call(l,m)&&(u[m]=l[m]);if(e){y=e(l);for(var S=0;S<y.length;S++)n.call(l,y[S])&&(u[y[S]]=l[y[S]])}}return u},Jn}var Kn,Gi;function vi(){if(Gi)return Kn;Gi=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Kn=e,Kn}var Xn,Yi;function Ls(){return Yi||(Yi=1,Xn=Function.call.bind(Object.prototype.hasOwnProperty)),Xn}var Qn,qi;function tc(){if(qi)return Qn;qi=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=vi(),n={},i=Ls();e=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(a,c,l,u,y){if(process.env.NODE_ENV!=="production"){for(var g in a)if(i(a,g)){var m;try{if(typeof a[g]!="function"){var S=Error((u||"React class")+": "+l+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw S.name="Invariant Violation",S}m=a[g](c,g,u,l,null,r)}catch(D){m=D}if(m&&!(m instanceof Error)&&e((u||"React class")+": type specification of "+l+" `"+g+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in n)){n[m.message]=!0;var C=y?y():"";e("Failed "+l+" type: "+m.message+(C??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Qn=s,Qn}var Zn,Ji;function rc(){if(Ji)return Zn;Ji=1;var e=Ns(),r=ec(),n=vi(),i=Ls(),s=tc(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(l){var u="Warning: "+l;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function c(){return null}return Zn=function(l,u){var y=typeof Symbol=="function"&&Symbol.iterator,g="@@iterator";function m(F){var X=F&&(y&&F[y]||F[g]);if(typeof X=="function")return X}var S="<<anonymous>>",C={array:B("array"),bigint:B("bigint"),bool:B("boolean"),func:B("function"),number:B("number"),object:B("object"),string:B("string"),symbol:B("symbol"),any:h(),arrayOf:k,element:T(),elementType:b(),instanceOf:R,node:Z(),objectOf:E,oneOf:H,oneOfType:Y,shape:f,exact:w};function D(F,X){return F===X?F!==0||1/F===1/X:F!==F&&X!==X}function v(F,X){this.message=F,this.data=X&&typeof X=="object"?X:{},this.stack=""}v.prototype=Error.prototype;function x(F){if(process.env.NODE_ENV!=="production")var X={},ue=0;function pe(he,le,W,ie,U,ne,Be){if(ie=ie||S,ne=ne||W,Be!==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+":"+W;!X[$e]&&ue<3&&(a("You are manually calling a React.PropTypes validation function for the `"+ne+"` 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."),X[$e]=!0,ue++)}}return le[W]==null?he?le[W]===null?new v("The "+U+" `"+ne+"` is marked as required "+("in `"+ie+"`, but its value is `null`.")):new v("The "+U+" `"+ne+"` is marked as required in "+("`"+ie+"`, but its value is `undefined`.")):null:F(le,W,ie,U,ne)}var K=pe.bind(null,!1);return K.isRequired=pe.bind(null,!0),K}function B(F){function X(ue,pe,K,he,le,W){var ie=ue[pe],U=d(ie);if(U!==F){var ne=J(ie);return new v("Invalid "+he+" `"+le+"` of type "+("`"+ne+"` supplied to `"+K+"`, expected ")+("`"+F+"`."),{expectedType:F})}return null}return x(X)}function h(){return x(c)}function k(F){function X(ue,pe,K,he,le){if(typeof F!="function")return new v("Property `"+le+"` of component `"+K+"` has invalid PropType notation inside arrayOf.");var W=ue[pe];if(!Array.isArray(W)){var ie=d(W);return new v("Invalid "+he+" `"+le+"` of type "+("`"+ie+"` supplied to `"+K+"`, expected an array."))}for(var U=0;U<W.length;U++){var ne=F(W,U,K,he,le+"["+U+"]",n);if(ne instanceof Error)return ne}return null}return x(X)}function T(){function F(X,ue,pe,K,he){var le=X[ue];if(!l(le)){var W=d(le);return new v("Invalid "+K+" `"+he+"` of type "+("`"+W+"` supplied to `"+pe+"`, expected a single ReactElement."))}return null}return x(F)}function b(){function F(X,ue,pe,K,he){var le=X[ue];if(!e.isValidElementType(le)){var W=d(le);return new v("Invalid "+K+" `"+he+"` of type "+("`"+W+"` supplied to `"+pe+"`, expected a single ReactElement type."))}return null}return x(F)}function R(F){function X(ue,pe,K,he,le){if(!(ue[pe]instanceof F)){var W=F.name||S,ie=we(ue[pe]);return new v("Invalid "+he+" `"+le+"` of type "+("`"+ie+"` supplied to `"+K+"`, expected ")+("instance of `"+W+"`."))}return null}return x(X)}function H(F){if(!Array.isArray(F))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("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])."):a("Invalid argument supplied to oneOf, expected an array.")),c;function X(ue,pe,K,he,le){for(var W=ue[pe],ie=0;ie<F.length;ie++)if(D(W,F[ie]))return null;var U=JSON.stringify(F,function(Be,Q){var $e=J(Q);return $e==="symbol"?String(Q):Q});return new v("Invalid "+he+" `"+le+"` of value `"+String(W)+"` "+("supplied to `"+K+"`, expected one of "+U+"."))}return x(X)}function E(F){function X(ue,pe,K,he,le){if(typeof F!="function")return new v("Property `"+le+"` of component `"+K+"` has invalid PropType notation inside objectOf.");var W=ue[pe],ie=d(W);if(ie!=="object")return new v("Invalid "+he+" `"+le+"` of type "+("`"+ie+"` supplied to `"+K+"`, expected an object."));for(var U in W)if(i(W,U)){var ne=F(W,U,K,he,le+"."+U,n);if(ne instanceof Error)return ne}return null}return x(X)}function Y(F){if(!Array.isArray(F))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var X=0;X<F.length;X++){var ue=F[X];if(typeof ue!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+re(ue)+" at index "+X+"."),c}function pe(K,he,le,W,ie){for(var U=[],ne=0;ne<F.length;ne++){var Be=F[ne],Q=Be(K,he,le,W,ie,n);if(Q==null)return null;Q.data&&i(Q.data,"expectedType")&&U.push(Q.data.expectedType)}var $e=U.length>0?", expected one of type ["+U.join(", ")+"]":"";return new v("Invalid "+W+" `"+ie+"` supplied to "+("`"+le+"`"+$e+"."))}return x(pe)}function Z(){function F(X,ue,pe,K,he){return P(X[ue])?null:new v("Invalid "+K+" `"+he+"` supplied to "+("`"+pe+"`, expected a ReactNode."))}return x(F)}function I(F,X,ue,pe,K){return new v((F||"React class")+": "+X+" type `"+ue+"."+pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+K+"`.")}function f(F){function X(ue,pe,K,he,le){var W=ue[pe],ie=d(W);if(ie!=="object")return new v("Invalid "+he+" `"+le+"` of type `"+ie+"` "+("supplied to `"+K+"`, expected `object`."));for(var U in F){var ne=F[U];if(typeof ne!="function")return I(K,he,le,U,J(ne));var Be=ne(W,U,K,he,le+"."+U,n);if(Be)return Be}return null}return x(X)}function w(F){function X(ue,pe,K,he,le){var W=ue[pe],ie=d(W);if(ie!=="object")return new v("Invalid "+he+" `"+le+"` of type `"+ie+"` "+("supplied to `"+K+"`, expected `object`."));var U=r({},ue[pe],F);for(var ne in U){var Be=F[ne];if(i(F,ne)&&typeof Be!="function")return I(K,he,le,ne,J(Be));if(!Be)return new v("Invalid "+he+" `"+le+"` key `"+ne+"` supplied to `"+K+"`.\nBad object: "+JSON.stringify(ue[pe],null," ")+`
124
- Valid keys: `+JSON.stringify(Object.keys(F),null," "));var Q=Be(W,ne,K,he,le+"."+ne,n);if(Q)return Q}return null}return x(X)}function P(F){switch(typeof F){case"number":case"string":case"undefined":return!0;case"boolean":return!F;case"object":if(Array.isArray(F))return F.every(P);if(F===null||l(F))return!0;var X=m(F);if(X){var ue=X.call(F),pe;if(X!==F.entries){for(;!(pe=ue.next()).done;)if(!P(pe.value))return!1}else for(;!(pe=ue.next()).done;){var K=pe.value;if(K&&!P(K[1]))return!1}}else return!1;return!0;default:return!1}}function te(F,X){return F==="symbol"?!0:X?X["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&X instanceof Symbol:!1}function d(F){var X=typeof F;return Array.isArray(F)?"array":F instanceof RegExp?"object":te(X,F)?"symbol":X}function J(F){if(typeof F>"u"||F===null)return""+F;var X=d(F);if(X==="object"){if(F instanceof Date)return"date";if(F instanceof RegExp)return"regexp"}return X}function re(F){var X=J(F);switch(X){case"array":case"object":return"an "+X;case"boolean":case"date":case"regexp":return"a "+X;default:return X}}function we(F){return!F.constructor||!F.constructor.name?S:F.constructor.name}return C.checkPropTypes=s,C.resetWarningCache=s.resetWarningCache,C.PropTypes=C,C},Zn}var ei,Ki;function oc(){if(Ki)return ei;Ki=1;var e=vi();function r(){}function n(){}return n.resetWarningCache=r,ei=function(){function i(c,l,u,y,g,m){if(m!==e){var S=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 S.name="Invariant Violation",S}}i.isRequired=i;function s(){return i}var a={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:r};return a.PropTypes=a,a},ei}var Xi;function nc(){if(Xi)return qo.exports;if(Xi=1,process.env.NODE_ENV!=="production"){var e=Ns(),r=!0;qo.exports=rc()(e.isElement,r)}else qo.exports=oc()();return qo.exports}var ic=nc();const vo=Xl(ic);var Ko={exports:{}},Oe={};/**
123
+ */var Kn,Yi;function rc(){if(Yi)return Kn;Yi=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function s(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var d={},l=0;l<10;l++)d["_"+String.fromCharCode(l)]=l;var u=Object.getOwnPropertyNames(d).map(function(g){return d[g]});if(u.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(g){x[g]=g}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Kn=s()?Object.assign:function(a,d){for(var l,u=i(a),x,g=1;g<arguments.length;g++){l=Object(arguments[g]);for(var m in l)r.call(l,m)&&(u[m]=l[m]);if(e){x=e(l);for(var C=0;C<x.length;C++)n.call(l,x[C])&&(u[x[C]]=l[x[C]])}}return u},Kn}var Xn,qi;function Si(){if(qi)return Xn;qi=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Xn=e,Xn}var Qn,Ji;function Vs(){return Ji||(Ji=1,Qn=Function.call.bind(Object.prototype.hasOwnProperty)),Qn}var Zn,Ki;function oc(){if(Ki)return Zn;Ki=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=Si(),n={},i=Vs();e=function(a){var d="Warning: "+a;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function s(a,d,l,u,x){if(process.env.NODE_ENV!=="production"){for(var g in a)if(i(a,g)){var m;try{if(typeof a[g]!="function"){var C=Error((u||"React class")+": "+l+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw C.name="Invariant Violation",C}m=a[g](d,g,u,l,null,r)}catch(E){m=E}if(m&&!(m instanceof Error)&&e((u||"React class")+": type specification of "+l+" `"+g+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in n)){n[m.message]=!0;var S=x?x():"";e("Failed "+l+" type: "+m.message+(S??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Zn=s,Zn}var ei,Xi;function nc(){if(Xi)return ei;Xi=1;var e=Fs(),r=rc(),n=Si(),i=Vs(),s=oc(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(l){var u="Warning: "+l;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function d(){return null}return ei=function(l,u){var x=typeof Symbol=="function"&&Symbol.iterator,g="@@iterator";function m(U){var K=U&&(x&&U[x]||U[g]);if(typeof K=="function")return K}var C="<<anonymous>>",S={array:k("array"),bigint:k("bigint"),bool:k("boolean"),func:k("function"),number:k("number"),object:k("object"),string:k("string"),symbol:k("symbol"),any:h(),arrayOf:j,element:T(),elementType:b(),instanceOf:R,node:Z(),objectOf:I,oneOf:H,oneOfType:J,shape:f,exact:$};function E(U,K){return U===K?U!==0||1/U===1/K:U!==U&&K!==K}function v(U,K){this.message=U,this.data=K&&typeof K=="object"?K:{},this.stack=""}v.prototype=Error.prototype;function y(U){if(process.env.NODE_ENV!=="production")var K={},de=0;function ue(pe,le,P,se,G,ne,De){if(se=se||C,ne=ne||P,De!==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 Pe=se+":"+P;!K[Pe]&&de<3&&(a("You are manually calling a React.PropTypes validation function for the `"+ne+"` prop on `"+se+"`. 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."),K[Pe]=!0,de++)}}return le[P]==null?pe?le[P]===null?new v("The "+G+" `"+ne+"` is marked as required "+("in `"+se+"`, but its value is `null`.")):new v("The "+G+" `"+ne+"` is marked as required in "+("`"+se+"`, but its value is `undefined`.")):null:U(le,P,se,G,ne)}var X=ue.bind(null,!1);return X.isRequired=ue.bind(null,!0),X}function k(U){function K(de,ue,X,pe,le,P){var se=de[ue],G=oe(se);if(G!==U){var ne=c(se);return new v("Invalid "+pe+" `"+le+"` of type "+("`"+ne+"` supplied to `"+X+"`, expected ")+("`"+U+"`."),{expectedType:U})}return null}return y(K)}function h(){return y(d)}function j(U){function K(de,ue,X,pe,le){if(typeof U!="function")return new v("Property `"+le+"` of component `"+X+"` has invalid PropType notation inside arrayOf.");var P=de[ue];if(!Array.isArray(P)){var se=oe(P);return new v("Invalid "+pe+" `"+le+"` of type "+("`"+se+"` supplied to `"+X+"`, expected an array."))}for(var G=0;G<P.length;G++){var ne=U(P,G,X,pe,le+"["+G+"]",n);if(ne instanceof Error)return ne}return null}return y(K)}function T(){function U(K,de,ue,X,pe){var le=K[de];if(!l(le)){var P=oe(le);return new v("Invalid "+X+" `"+pe+"` of type "+("`"+P+"` supplied to `"+ue+"`, expected a single ReactElement."))}return null}return y(U)}function b(){function U(K,de,ue,X,pe){var le=K[de];if(!e.isValidElementType(le)){var P=oe(le);return new v("Invalid "+X+" `"+pe+"` of type "+("`"+P+"` supplied to `"+ue+"`, expected a single ReactElement type."))}return null}return y(U)}function R(U){function K(de,ue,X,pe,le){if(!(de[ue]instanceof U)){var P=U.name||C,se=fe(de[ue]);return new v("Invalid "+pe+" `"+le+"` of type "+("`"+se+"` supplied to `"+X+"`, expected ")+("instance of `"+P+"`."))}return null}return y(K)}function H(U){if(!Array.isArray(U))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("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])."):a("Invalid argument supplied to oneOf, expected an array.")),d;function K(de,ue,X,pe,le){for(var P=de[ue],se=0;se<U.length;se++)if(E(P,U[se]))return null;var G=JSON.stringify(U,function(De,Q){var Pe=c(Q);return Pe==="symbol"?String(Q):Q});return new v("Invalid "+pe+" `"+le+"` of value `"+String(P)+"` "+("supplied to `"+X+"`, expected one of "+G+"."))}return y(K)}function I(U){function K(de,ue,X,pe,le){if(typeof U!="function")return new v("Property `"+le+"` of component `"+X+"` has invalid PropType notation inside objectOf.");var P=de[ue],se=oe(P);if(se!=="object")return new v("Invalid "+pe+" `"+le+"` of type "+("`"+se+"` supplied to `"+X+"`, expected an object."));for(var G in P)if(i(P,G)){var ne=U(P,G,X,pe,le+"."+G,n);if(ne instanceof Error)return ne}return null}return y(K)}function J(U){if(!Array.isArray(U))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var K=0;K<U.length;K++){var de=U[K];if(typeof de!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+re(de)+" at index "+K+"."),d}function ue(X,pe,le,P,se){for(var G=[],ne=0;ne<U.length;ne++){var De=U[ne],Q=De(X,pe,le,P,se,n);if(Q==null)return null;Q.data&&i(Q.data,"expectedType")&&G.push(Q.data.expectedType)}var Pe=G.length>0?", expected one of type ["+G.join(", ")+"]":"";return new v("Invalid "+P+" `"+se+"` supplied to "+("`"+le+"`"+Pe+"."))}return y(ue)}function Z(){function U(K,de,ue,X,pe){return D(K[de])?null:new v("Invalid "+X+" `"+pe+"` supplied to "+("`"+ue+"`, expected a ReactNode."))}return y(U)}function B(U,K,de,ue,X){return new v((U||"React class")+": "+K+" type `"+de+"."+ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+X+"`.")}function f(U){function K(de,ue,X,pe,le){var P=de[ue],se=oe(P);if(se!=="object")return new v("Invalid "+pe+" `"+le+"` of type `"+se+"` "+("supplied to `"+X+"`, expected `object`."));for(var G in U){var ne=U[G];if(typeof ne!="function")return B(X,pe,le,G,c(ne));var De=ne(P,G,X,pe,le+"."+G,n);if(De)return De}return null}return y(K)}function $(U){function K(de,ue,X,pe,le){var P=de[ue],se=oe(P);if(se!=="object")return new v("Invalid "+pe+" `"+le+"` of type `"+se+"` "+("supplied to `"+X+"`, expected `object`."));var G=r({},de[ue],U);for(var ne in G){var De=U[ne];if(i(U,ne)&&typeof De!="function")return B(X,pe,le,ne,c(De));if(!De)return new v("Invalid "+pe+" `"+le+"` key `"+ne+"` supplied to `"+X+"`.\nBad object: "+JSON.stringify(de[ue],null," ")+`
124
+ Valid keys: `+JSON.stringify(Object.keys(U),null," "));var Q=De(P,ne,X,pe,le+"."+ne,n);if(Q)return Q}return null}return y(K)}function D(U){switch(typeof U){case"number":case"string":case"undefined":return!0;case"boolean":return!U;case"object":if(Array.isArray(U))return U.every(D);if(U===null||l(U))return!0;var K=m(U);if(K){var de=K.call(U),ue;if(K!==U.entries){for(;!(ue=de.next()).done;)if(!D(ue.value))return!1}else for(;!(ue=de.next()).done;){var X=ue.value;if(X&&!D(X[1]))return!1}}else return!1;return!0;default:return!1}}function ee(U,K){return U==="symbol"?!0:K?K["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&K instanceof Symbol:!1}function oe(U){var K=typeof U;return Array.isArray(U)?"array":U instanceof RegExp?"object":ee(K,U)?"symbol":K}function c(U){if(typeof U>"u"||U===null)return""+U;var K=oe(U);if(K==="object"){if(U instanceof Date)return"date";if(U instanceof RegExp)return"regexp"}return K}function re(U){var K=c(U);switch(K){case"array":case"object":return"an "+K;case"boolean":case"date":case"regexp":return"a "+K;default:return K}}function fe(U){return!U.constructor||!U.constructor.name?C:U.constructor.name}return S.checkPropTypes=s,S.resetWarningCache=s.resetWarningCache,S.PropTypes=S,S},ei}var ti,Qi;function ic(){if(Qi)return ti;Qi=1;var e=Si();function r(){}function n(){}return n.resetWarningCache=r,ti=function(){function i(d,l,u,x,g,m){if(m!==e){var C=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 C.name="Invariant Violation",C}}i.isRequired=i;function s(){return i}var a={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:r};return a.PropTypes=a,a},ti}var Zi;function sc(){if(Zi)return Ko.exports;if(Zi=1,process.env.NODE_ENV!=="production"){var e=Fs(),r=!0;Ko.exports=nc()(e.isElement,r)}else Ko.exports=ic()();return Ko.exports}var ac=sc();const Co=Zl(ac);var Qo={exports:{}},$e={};/**
125
125
  * @license React
126
126
  * react-is.production.js
127
127
  *
@@ -129,7 +129,7 @@ Valid keys: `+JSON.stringify(Object.keys(F),null," "));var Q=Be(W,ne,K,he,le+".
129
129
  *
130
130
  * This source code is licensed under the MIT license found in the
131
131
  * LICENSE file in the root directory of this source tree.
132
- */var Qi;function sc(){if(Qi)return Oe;Qi=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),C=Symbol.for("react.client.reference");function D(v){if(typeof v=="object"&&v!==null){var x=v.$$typeof;switch(x){case e:switch(v=v.type,v){case n:case s:case i:case u:case y:case S:return v;default:switch(v=v&&v.$$typeof,v){case c:case l:case m:case g:return v;case a:return v;default:return x}}case r:return x}}}return Oe.ContextConsumer=a,Oe.ContextProvider=c,Oe.Element=e,Oe.ForwardRef=l,Oe.Fragment=n,Oe.Lazy=m,Oe.Memo=g,Oe.Portal=r,Oe.Profiler=s,Oe.StrictMode=i,Oe.Suspense=u,Oe.SuspenseList=y,Oe.isContextConsumer=function(v){return D(v)===a},Oe.isContextProvider=function(v){return D(v)===c},Oe.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===e},Oe.isForwardRef=function(v){return D(v)===l},Oe.isFragment=function(v){return D(v)===n},Oe.isLazy=function(v){return D(v)===m},Oe.isMemo=function(v){return D(v)===g},Oe.isPortal=function(v){return D(v)===r},Oe.isProfiler=function(v){return D(v)===s},Oe.isStrictMode=function(v){return D(v)===i},Oe.isSuspense=function(v){return D(v)===u},Oe.isSuspenseList=function(v){return D(v)===y},Oe.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===s||v===i||v===u||v===y||typeof v=="object"&&v!==null&&(v.$$typeof===m||v.$$typeof===g||v.$$typeof===c||v.$$typeof===a||v.$$typeof===l||v.$$typeof===C||v.getModuleId!==void 0)},Oe.typeOf=D,Oe}var Me={};/**
132
+ */var es;function lc(){if(es)return $e;es=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),d=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),C=Symbol.for("react.view_transition"),S=Symbol.for("react.client.reference");function E(v){if(typeof v=="object"&&v!==null){var y=v.$$typeof;switch(y){case e:switch(v=v.type,v){case n:case s:case i:case u:case x:case C:return v;default:switch(v=v&&v.$$typeof,v){case d:case l:case m:case g:return v;case a:return v;default:return y}}case r:return y}}}return $e.ContextConsumer=a,$e.ContextProvider=d,$e.Element=e,$e.ForwardRef=l,$e.Fragment=n,$e.Lazy=m,$e.Memo=g,$e.Portal=r,$e.Profiler=s,$e.StrictMode=i,$e.Suspense=u,$e.SuspenseList=x,$e.isContextConsumer=function(v){return E(v)===a},$e.isContextProvider=function(v){return E(v)===d},$e.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===e},$e.isForwardRef=function(v){return E(v)===l},$e.isFragment=function(v){return E(v)===n},$e.isLazy=function(v){return E(v)===m},$e.isMemo=function(v){return E(v)===g},$e.isPortal=function(v){return E(v)===r},$e.isProfiler=function(v){return E(v)===s},$e.isStrictMode=function(v){return E(v)===i},$e.isSuspense=function(v){return E(v)===u},$e.isSuspenseList=function(v){return E(v)===x},$e.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===m||v.$$typeof===g||v.$$typeof===d||v.$$typeof===a||v.$$typeof===l||v.$$typeof===S||v.getModuleId!==void 0)},$e.typeOf=E,$e}var Oe={};/**
133
133
  * @license React
134
134
  * react-is.development.js
135
135
  *
@@ -137,16 +137,16 @@ Valid keys: `+JSON.stringify(Object.keys(F),null," "));var Q=Be(W,ne,K,he,le+".
137
137
  *
138
138
  * This source code is licensed under the MIT license found in the
139
139
  * LICENSE file in the root directory of this source tree.
140
- */var Zi;function ac(){return Zi||(Zi=1,process.env.NODE_ENV!=="production"&&(function(){function e(v){if(typeof v=="object"&&v!==null){var x=v.$$typeof;switch(x){case r:switch(v=v.type,v){case i:case a:case s:case y:case g:case C:return v;default:switch(v=v&&v.$$typeof,v){case l:case u:case S:case m:return v;case c:return v;default:return x}}case n:return x}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),C=Symbol.for("react.view_transition"),D=Symbol.for("react.client.reference");Me.ContextConsumer=c,Me.ContextProvider=l,Me.Element=r,Me.ForwardRef=u,Me.Fragment=i,Me.Lazy=S,Me.Memo=m,Me.Portal=n,Me.Profiler=a,Me.StrictMode=s,Me.Suspense=y,Me.SuspenseList=g,Me.isContextConsumer=function(v){return e(v)===c},Me.isContextProvider=function(v){return e(v)===l},Me.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===r},Me.isForwardRef=function(v){return e(v)===u},Me.isFragment=function(v){return e(v)===i},Me.isLazy=function(v){return e(v)===S},Me.isMemo=function(v){return e(v)===m},Me.isPortal=function(v){return e(v)===n},Me.isProfiler=function(v){return e(v)===a},Me.isStrictMode=function(v){return e(v)===s},Me.isSuspense=function(v){return e(v)===y},Me.isSuspenseList=function(v){return e(v)===g},Me.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===i||v===a||v===s||v===y||v===g||typeof v=="object"&&v!==null&&(v.$$typeof===S||v.$$typeof===m||v.$$typeof===l||v.$$typeof===c||v.$$typeof===u||v.$$typeof===D||v.getModuleId!==void 0)},Me.typeOf=e})()),Me}var es;function lc(){return es||(es=1,process.env.NODE_ENV==="production"?Ko.exports=sc():Ko.exports=ac()),Ko.exports}var Fs=lc();function mr(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Vs(e){if(dn.isValidElement(e)||Fs.isValidElementType(e)||!mr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Vs(e[n])}),r}function vt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return mr(e)&&mr(r)&&Object.keys(r).forEach(s=>{dn.isValidElement(r[s])||Fs.isValidElementType(r[s])?i[s]=r[s]:mr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&mr(e[s])?i[s]=vt(e[s],r[s],n):n.clone?i[s]=mr(r[s])?Vs(r[s]):r[s]:i[s]=r[s]}),i}const cc=e=>{const r=Object.keys(e).map(n=>({key:n,val:e[n]}))||[];return r.sort((n,i)=>n.val-i.val),r.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function dc(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,a=cc(r),c=Object.keys(a);function l(S){return`@media (min-width:${typeof r[S]=="number"?r[S]:S}${n})`}function u(S){return`@media (max-width:${(typeof r[S]=="number"?r[S]:S)-i/100}${n})`}function y(S,C){const D=c.indexOf(C);return`@media (min-width:${typeof r[S]=="number"?r[S]:S}${n}) and (max-width:${(D!==-1&&typeof r[c[D]]=="number"?r[c[D]]:C)-i/100}${n})`}function g(S){return c.indexOf(S)+1<c.length?y(S,c[c.indexOf(S)+1]):l(S)}function m(S){const C=c.indexOf(S);return C===0?l(c[1]):C===c.length-1?u(c[C]):y(S,c[c.indexOf(S)+1]).replace("@media","@media not all and")}return{keys:c,values:a,up:l,down:u,between:y,only:g,not:m,unit:n,...s}}function ts(e,r){if(!e.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var c,l;const a=/min-width:\s*([0-9.]+)/;return+(((c=i.match(a))==null?void 0:c[1])||0)-+(((l=s.match(a))==null?void 0:l[1])||0)});return n.length?n.reduce((i,s)=>{const a=r[s];return delete i[s],i[s]=a,i},{...r}):r}function uc(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function pc(e,r){const n=r.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${r})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
141
- For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,a=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(a)}function hc(e){const r=(a,c)=>a.replace("@media",c?`@container ${c}`:"@container");function n(a,c){a.up=(...l)=>r(e.breakpoints.up(...l),c),a.down=(...l)=>r(e.breakpoints.down(...l),c),a.between=(...l)=>r(e.breakpoints.between(...l),c),a.only=(...l)=>r(e.breakpoints.only(...l),c),a.not=(...l)=>{const u=r(e.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=a=>(n(i,a),i);return n(s),{...e,containerQueries:s}}const mc={borderRadius:4},yr=process.env.NODE_ENV!=="production"?vo.oneOfType([vo.number,vo.string,vo.object,vo.array]):{};function Io(e,r){return r?vt(e,r,{clone:!1}):e}const mn={xs:0,sm:600,md:900,lg:1200,xl:1536},rs={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${mn[e]}px)`},fc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:mn[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function sr(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||rs;return r.reduce((c,l,u)=>(c[a.up(a.keys[u])]=n(r[u]),c),{})}if(typeof r=="object"){const a=i.breakpoints||rs;return Object.keys(r).reduce((c,l)=>{if(uc(a.keys,l)){const u=pc(i.containerQueries?i:fc,l);u&&(c[u]=n(r[l],l))}else if(Object.keys(a.values||mn).includes(l)){const u=a.up(l);c[u]=n(r[l],l)}else{const u=l;c[u]=r[u]}return c},{})}return n(r)}function xc(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function os(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function Hs(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Or(7));return e.charAt(0).toUpperCase()+e.slice(1)}function fn(e,r,n=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&n){const i=`vars.${r}`.split(".").reduce((s,a)=>s&&s[a]?s[a]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function ln(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=fn(e,n)||i,r&&(s=r(s,i,e)),s}function Ue(e){const{prop:r,cssProperty:n=e.prop,themeKey:i,transform:s}=e,a=c=>{if(c[r]==null)return null;const l=c[r],u=c.theme,y=fn(u,i)||{};return sr(c,l,m=>{let S=ln(y,s,m);return m===S&&typeof m=="string"&&(S=ln(y,s,`${r}${m==="default"?"":Hs(m)}`,m)),n===!1?S:{[n]:S}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:yr}:{},a.filterProps=[r],a}function gc(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const yc={m:"margin",p:"padding"},bc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},ns={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},vc=gc(e=>{if(e.length>2)if(ns[e])e=ns[e];else return[e];const[r,n]=e.split(""),i=yc[r],s=bc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),xn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],gn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],Sc=[...xn,...gn];function $o(e,r,n,i){const s=fn(e,r,!0)??n;return typeof s=="number"||typeof s=="string"?a=>typeof a=="string"?a:(process.env.NODE_ENV!=="production"&&typeof a!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${a}.`),typeof s=="string"?s.startsWith("var(")&&a===0?0:s.startsWith("var(")&&a===1?s:`calc(${a} * ${s})`:s*a):Array.isArray(s)?a=>{if(typeof a=="string")return a;const c=Math.abs(a);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(`
140
+ */var ts;function cc(){return ts||(ts=1,process.env.NODE_ENV!=="production"&&(function(){function e(v){if(typeof v=="object"&&v!==null){var y=v.$$typeof;switch(y){case r:switch(v=v.type,v){case i:case a:case s:case x:case g:case S:return v;default:switch(v=v&&v.$$typeof,v){case l:case u:case C:case m:return v;case d:return v;default:return y}}case n:return y}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),E=Symbol.for("react.client.reference");Oe.ContextConsumer=d,Oe.ContextProvider=l,Oe.Element=r,Oe.ForwardRef=u,Oe.Fragment=i,Oe.Lazy=C,Oe.Memo=m,Oe.Portal=n,Oe.Profiler=a,Oe.StrictMode=s,Oe.Suspense=x,Oe.SuspenseList=g,Oe.isContextConsumer=function(v){return e(v)===d},Oe.isContextProvider=function(v){return e(v)===l},Oe.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===r},Oe.isForwardRef=function(v){return e(v)===u},Oe.isFragment=function(v){return e(v)===i},Oe.isLazy=function(v){return e(v)===C},Oe.isMemo=function(v){return e(v)===m},Oe.isPortal=function(v){return e(v)===n},Oe.isProfiler=function(v){return e(v)===a},Oe.isStrictMode=function(v){return e(v)===s},Oe.isSuspense=function(v){return e(v)===x},Oe.isSuspenseList=function(v){return e(v)===g},Oe.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===i||v===a||v===s||v===x||v===g||typeof v=="object"&&v!==null&&(v.$$typeof===C||v.$$typeof===m||v.$$typeof===l||v.$$typeof===d||v.$$typeof===u||v.$$typeof===E||v.getModuleId!==void 0)},Oe.typeOf=e})()),Oe}var rs;function dc(){return rs||(rs=1,process.env.NODE_ENV==="production"?Qo.exports=lc():Qo.exports=cc()),Qo.exports}var Hs=dc();function fr(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Us(e){if(pn.isValidElement(e)||Hs.isValidElementType(e)||!fr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Us(e[n])}),r}function Ct(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return fr(e)&&fr(r)&&Object.keys(r).forEach(s=>{pn.isValidElement(r[s])||Hs.isValidElementType(r[s])?i[s]=r[s]:fr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&fr(e[s])?i[s]=Ct(e[s],r[s],n):n.clone?i[s]=fr(r[s])?Us(r[s]):r[s]:i[s]=r[s]}),i}const uc=e=>{const r=Object.keys(e).map(n=>({key:n,val:e[n]}))||[];return r.sort((n,i)=>n.val-i.val),r.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function pc(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,a=uc(r),d=Object.keys(a);function l(C){return`@media (min-width:${typeof r[C]=="number"?r[C]:C}${n})`}function u(C){return`@media (max-width:${(typeof r[C]=="number"?r[C]:C)-i/100}${n})`}function x(C,S){const E=d.indexOf(S);return`@media (min-width:${typeof r[C]=="number"?r[C]:C}${n}) and (max-width:${(E!==-1&&typeof r[d[E]]=="number"?r[d[E]]:S)-i/100}${n})`}function g(C){return d.indexOf(C)+1<d.length?x(C,d[d.indexOf(C)+1]):l(C)}function m(C){const S=d.indexOf(C);return S===0?l(d[1]):S===d.length-1?u(d[S]):x(C,d[d.indexOf(C)+1]).replace("@media","@media not all and")}return{keys:d,values:a,up:l,down:u,between:x,only:g,not:m,unit:n,...s}}function os(e,r){if(!e.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var d,l;const a=/min-width:\s*([0-9.]+)/;return+(((d=i.match(a))==null?void 0:d[1])||0)-+(((l=s.match(a))==null?void 0:l[1])||0)});return n.length?n.reduce((i,s)=>{const a=r[s];return delete i[s],i[s]=a,i},{...r}):r}function hc(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function mc(e,r){const n=r.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${r})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
141
+ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,a=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(a)}function fc(e){const r=(a,d)=>a.replace("@media",d?`@container ${d}`:"@container");function n(a,d){a.up=(...l)=>r(e.breakpoints.up(...l),d),a.down=(...l)=>r(e.breakpoints.down(...l),d),a.between=(...l)=>r(e.breakpoints.between(...l),d),a.only=(...l)=>r(e.breakpoints.only(...l),d),a.not=(...l)=>{const u=r(e.breakpoints.not(...l),d);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=a=>(n(i,a),i);return n(s),{...e,containerQueries:s}}const xc={borderRadius:4},yr=process.env.NODE_ENV!=="production"?Co.oneOfType([Co.number,Co.string,Co.object,Co.array]):{};function Do(e,r){return r?Ct(e,r,{clone:!1}):e}const xn={xs:0,sm:600,md:900,lg:1200,xl:1536},ns={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${xn[e]}px)`},gc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:xn[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function ir(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||ns;return r.reduce((d,l,u)=>(d[a.up(a.keys[u])]=n(r[u]),d),{})}if(typeof r=="object"){const a=i.breakpoints||ns;return Object.keys(r).reduce((d,l)=>{if(hc(a.keys,l)){const u=mc(i.containerQueries?i:gc,l);u&&(d[u]=n(r[l],l))}else if(Object.keys(a.values||xn).includes(l)){const u=a.up(l);d[u]=n(r[l],l)}else{const u=l;d[u]=r[u]}return d},{})}return n(r)}function yc(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function is(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function Gs(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Mr(7));return e.charAt(0).toUpperCase()+e.slice(1)}function gn(e,r,n=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&n){const i=`vars.${r}`.split(".").reduce((s,a)=>s&&s[a]?s[a]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function dn(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=gn(e,n)||i,r&&(s=r(s,i,e)),s}function Ue(e){const{prop:r,cssProperty:n=e.prop,themeKey:i,transform:s}=e,a=d=>{if(d[r]==null)return null;const l=d[r],u=d.theme,x=gn(u,i)||{};return ir(d,l,m=>{let C=dn(x,s,m);return m===C&&typeof m=="string"&&(C=dn(x,s,`${r}${m==="default"?"":Gs(m)}`,m)),n===!1?C:{[n]:C}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:yr}:{},a.filterProps=[r],a}function bc(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const vc={m:"margin",p:"padding"},Sc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},ss={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Cc=bc(e=>{if(e.length>2)if(ss[e])e=ss[e];else return[e];const[r,n]=e.split(""),i=vc[r],s=Sc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),yn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],bn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],wc=[...yn,...bn];function Mo(e,r,n,i){const s=gn(e,r,!0)??n;return typeof s=="number"||typeof s=="string"?a=>typeof a=="string"?a:(process.env.NODE_ENV!=="production"&&typeof a!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${a}.`),typeof s=="string"?s.startsWith("var(")&&a===0?0:s.startsWith("var(")&&a===1?s:`calc(${a} * ${s})`:s*a):Array.isArray(s)?a=>{if(typeof a=="string")return a;const d=Math.abs(a);process.env.NODE_ENV!=="production"&&(Number.isInteger(d)?d>s.length-1&&console.error([`MUI: The value provided (${d}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${d} > ${s.length-1}, you need to add the missing values.`].join(`
142
142
  `)):console.error([`MUI: The \`theme.${r}\` 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.${r}\` as a number.`].join(`
143
- `)));const l=s[c];return a>=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.${r}\` value (${s}) is invalid.`,"It should be a number, an array or a function."].join(`
144
- `)),()=>{})}function Si(e){return $o(e,"spacing",8,"spacing")}function Oo(e,r){return typeof r=="string"||r==null?r:e(r)}function Cc(e,r){return n=>e.reduce((i,s)=>(i[s]=Oo(r,n),i),{})}function wc(e,r,n,i){if(!r.includes(n))return null;const s=vc(n),a=Cc(s,i),c=e[n];return sr(e,c,a)}function Us(e,r){const n=Si(e.theme);return Object.keys(e).map(i=>wc(e,r,i,n)).reduce(Io,{})}function Le(e){return Us(e,xn)}Le.propTypes=process.env.NODE_ENV!=="production"?xn.reduce((e,r)=>(e[r]=yr,e),{}):{};Le.filterProps=xn;function Fe(e){return Us(e,gn)}Fe.propTypes=process.env.NODE_ENV!=="production"?gn.reduce((e,r)=>(e[r]=yr,e),{}):{};Fe.filterProps=gn;process.env.NODE_ENV!=="production"&&Sc.reduce((e,r)=>(e[r]=yr,e),{});function Gs(e=8,r=Si({spacing:e})){if(e.mui)return e;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(a=>{const c=r(a);return typeof c=="number"?`${c}px`:c}).join(" "));return n.mui=!0,n}function yn(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(a=>{i[a]=s}),i),{}),n=i=>Object.keys(i).reduce((s,a)=>r[a]?Io(s,r[a](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=e.reduce((i,s)=>i.concat(s.filterProps),[]),n}function Bt(e){return typeof e!="number"?e:`${e}px solid`}function Et(e,r){return Ue({prop:e,themeKey:"borders",transform:r})}const jc=Et("border",Bt),kc=Et("borderTop",Bt),zc=Et("borderRight",Bt),Bc=Et("borderBottom",Bt),Tc=Et("borderLeft",Bt),Ic=Et("borderColor"),Ec=Et("borderTopColor"),Dc=Et("borderRightColor"),_c=Et("borderBottomColor"),$c=Et("borderLeftColor"),Oc=Et("outline",Bt),Mc=Et("outlineColor"),bn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=$o(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Oo(r,i)});return sr(e,e.borderRadius,n)}return null};bn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:yr}:{};bn.filterProps=["borderRadius"];yn(jc,kc,zc,Bc,Tc,Ic,Ec,Dc,_c,$c,bn,Oc,Mc);const vn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=$o(e.theme,"spacing",8,"gap"),n=i=>({gap:Oo(r,i)});return sr(e,e.gap,n)}return null};vn.propTypes=process.env.NODE_ENV!=="production"?{gap:yr}:{};vn.filterProps=["gap"];const Sn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=$o(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Oo(r,i)});return sr(e,e.columnGap,n)}return null};Sn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:yr}:{};Sn.filterProps=["columnGap"];const Cn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=$o(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Oo(r,i)});return sr(e,e.rowGap,n)}return null};Cn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:yr}:{};Cn.filterProps=["rowGap"];const Ac=Ue({prop:"gridColumn"}),Wc=Ue({prop:"gridRow"}),Rc=Ue({prop:"gridAutoFlow"}),Pc=Ue({prop:"gridAutoColumns"}),Nc=Ue({prop:"gridAutoRows"}),Lc=Ue({prop:"gridTemplateColumns"}),Fc=Ue({prop:"gridTemplateRows"}),Vc=Ue({prop:"gridTemplateAreas"}),Hc=Ue({prop:"gridArea"});yn(vn,Sn,Cn,Ac,Wc,Rc,Pc,Nc,Lc,Fc,Vc,Hc);function ao(e,r){return r==="grey"?r:e}const Uc=Ue({prop:"color",themeKey:"palette",transform:ao}),Gc=Ue({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:ao}),Yc=Ue({prop:"backgroundColor",themeKey:"palette",transform:ao});yn(Uc,Gc,Yc);function bt(e){return e<=1&&e!==0?`${e*100}%`:e}const qc=Ue({prop:"width",transform:bt}),Ci=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,c,l,u;const i=((c=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:c[n])||mn[n];return i?((u=(l=e.theme)==null?void 0:l.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:bt(n)}};return sr(e,e.maxWidth,r)}return null};Ci.filterProps=["maxWidth"];const Jc=Ue({prop:"minWidth",transform:bt}),Kc=Ue({prop:"height",transform:bt}),Xc=Ue({prop:"maxHeight",transform:bt}),Qc=Ue({prop:"minHeight",transform:bt});Ue({prop:"size",cssProperty:"width",transform:bt});Ue({prop:"size",cssProperty:"height",transform:bt});const Zc=Ue({prop:"boxSizing"});yn(qc,Ci,Jc,Kc,Xc,Qc,Zc);const wn={border:{themeKey:"borders",transform:Bt},borderTop:{themeKey:"borders",transform:Bt},borderRight:{themeKey:"borders",transform:Bt},borderBottom:{themeKey:"borders",transform:Bt},borderLeft:{themeKey:"borders",transform:Bt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:Bt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:bn},color:{themeKey:"palette",transform:ao},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:ao},backgroundColor:{themeKey:"palette",transform:ao},p:{style:Fe},pt:{style:Fe},pr:{style:Fe},pb:{style:Fe},pl:{style:Fe},px:{style:Fe},py:{style:Fe},padding:{style:Fe},paddingTop:{style:Fe},paddingRight:{style:Fe},paddingBottom:{style:Fe},paddingLeft:{style:Fe},paddingX:{style:Fe},paddingY:{style:Fe},paddingInline:{style:Fe},paddingInlineStart:{style:Fe},paddingInlineEnd:{style:Fe},paddingBlock:{style:Fe},paddingBlockStart:{style:Fe},paddingBlockEnd:{style:Fe},m:{style:Le},mt:{style:Le},mr:{style:Le},mb:{style:Le},ml:{style:Le},mx:{style:Le},my:{style:Le},margin:{style:Le},marginTop:{style:Le},marginRight:{style:Le},marginBottom:{style:Le},marginLeft:{style:Le},marginX:{style:Le},marginY:{style:Le},marginInline:{style:Le},marginInlineStart:{style:Le},marginInlineEnd:{style:Le},marginBlock:{style:Le},marginBlockStart:{style:Le},marginBlockEnd:{style:Le},displayPrint:{cssProperty:!1,transform:e=>({"@media print":{display:e}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:vn},rowGap:{style:Cn},columnGap:{style:Sn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:bt},maxWidth:{style:Ci},minWidth:{transform:bt},height:{transform:bt},maxHeight:{transform:bt},minHeight:{transform:bt},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 ed(...e){const r=e.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(r);return e.every(i=>n.size===Object.keys(i).length)}function td(e,r){return typeof e=="function"?e(r):e}function rd(){function e(n,i,s,a){const c={[n]:i,theme:s},l=a[n];if(!l)return{[n]:i};const{cssProperty:u=n,themeKey:y,transform:g,style:m}=l;if(i==null)return null;if(y==="typography"&&i==="inherit")return{[n]:i};const S=fn(s,y)||{};return m?m(c):sr(c,i,D=>{let v=ln(S,g,D);return D===v&&typeof D=="string"&&(v=ln(S,g,`${n}${D==="default"?"":Hs(D)}`,D)),u===!1?v:{[u]:v}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const c=s.unstable_sxConfig??wn;function l(u){let y=u;if(typeof u=="function")y=u(s);else if(typeof u!="object")return u;if(!y)return null;const g=xc(s.breakpoints),m=Object.keys(g);let S=g;return Object.keys(y).forEach(C=>{const D=td(y[C],s);if(D!=null)if(typeof D=="object")if(c[C])S=Io(S,e(C,D,s,c));else{const v=sr({theme:s},D,x=>({[C]:x}));ed(v,D)?S[C]=r({sx:D,theme:s,nested:!0}):S=Io(S,v)}else S=Io(S,e(C,D,s,c))}),!a&&s.modularCssLayers?{"@layer sx":ts(s,os(m,S))}:ts(s,os(m,S))}return Array.isArray(i)?i.map(l):l(i)}return r}const jn=rd();jn.filterProps=["sx"];function od(e,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[e])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(e);return s==="&"?r:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:r})}return n.palette.mode===e?r:{}}function Ys(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...c}=e,l=dc(n),u=Gs(s);let y=vt({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...mc,...a}},c);return y=hc(y),y.applyStyles=od,y=r.reduce((g,m)=>vt(g,m),y),y.unstable_sxConfig={...wn,...c==null?void 0:c.unstable_sxConfig},y.unstable_sx=function(m){return jn({sx:m,theme:this})},y}function nd(e){return Object.keys(e).length===0}function id(e=null){const r=dn.useContext(Sa.ThemeContext);return!r||nd(r)?e:r}const sd=Ys();function ad(e=sd){return id(e)}const is=e=>e,ld=()=>{let e=is;return{configure(r){e=r},generate(r){return e(r)},reset(){e=is}}},cd=ld(),dd={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 ud(e,r,n="Mui"){const i=dd[r];return i?`${n}-${i}`:`${cd.generate(e)}-${r}`}function pd(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function wi(e,r=0,n=1){return process.env.NODE_ENV!=="production"&&(e<r||e>n)&&console.error(`MUI: The value provided ${e} is out of range [${r}, ${n}].`),pd(e,r,n)}function hd(e){e=e.slice(1);const r=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(r);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&e.length!==e.trim().length&&console.error(`MUI: The color: "${e}" 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 xr(e){if(e.type)return e;if(e.charAt(0)==="#")return xr(hd(e));const r=e.indexOf("("),n=e.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${e}\` color.
145
- The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Or(9,e));let i=e.substring(r+1,e.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.
146
- The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Or(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:n,values:i,colorSpace:s}}const md=e=>{const r=xr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},jo=(e,r)=>{try{return md(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function kn(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,a)=>a<3?parseInt(s,10):s):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function qs(e){e=xr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),c=(y,g=(y+n/30)%12)=>s-a*Math.max(Math.min(g-3,9-g,1),-1);let l="rgb";const u=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return e.type==="hsla"&&(l+="a",u.push(r[3])),kn({type:l,values:u})}function ai(e){e=xr(e);let r=e.type==="hsl"||e.type==="hsla"?xr(qs(e)).values:e.values;return r=r.map(n=>(e.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*r[0]+.7152*r[1]+.0722*r[2]).toFixed(3))}function ss(e,r){const n=ai(e),i=ai(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function $(e,r){return e=xr(e),r=wi(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,kn(e)}function Dr(e,r,n){try{return $(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function zn(e,r){if(e=xr(e),r=wi(r),e.type.includes("hsl"))e.values[2]*=1-r;else if(e.type.includes("rgb")||e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]*=1-r;return kn(e)}function De(e,r,n){try{return zn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function Bn(e,r){if(e=xr(e),r=wi(r),e.type.includes("hsl"))e.values[2]+=(100-e.values[2])*r;else if(e.type.includes("rgb"))for(let n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*r;else if(e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*r;return kn(e)}function _e(e,r,n){try{return Bn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function fd(e,r=.15){return ai(e)>.5?zn(e,r):Bn(e,r)}function Xo(e,r,n){try{return fd(e,r)}catch{return e}}function xd(e=""){function r(...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(--${e?`${e}-`:""}${s}${r(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${e?`${e}-`:""}${i}${r(...s)})`}const as=(e,r,n,i=[])=>{let s=e;r.forEach((a,c)=>{c===r.length-1?Array.isArray(s)?s[Number(a)]=n:s&&typeof s=="object"&&(s[a]=n):s&&typeof s=="object"&&(s[a]||(s[a]=i.includes(a)?[]:{}),s=s[a])})},gd=(e,r,n)=>{function i(s,a=[],c=[]){Object.entries(s).forEach(([l,u])=>{(!n||n&&!n([...a,l]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...a,l],Array.isArray(u)?[...c,l]:c):r([...a,l],u,c))})}i(e)},yd=(e,r)=>typeof r=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>e.includes(i))||e[e.length-1].toLowerCase().includes("opacity")?r:`${r}px`:r;function ti(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},a={},c={};return gd(e,(l,u,y)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(l,u))){const g=`--${n?`${n}-`:""}${l.join("-")}`,m=yd(l,u);Object.assign(s,{[g]:m}),as(a,l,`var(${g})`,y),as(c,l,`var(${g}, ${m})`,y)}},l=>l[0]==="vars"),{css:s,vars:a,varsWithDefaults:c}}function bd(e,r={}){const{getSelector:n=B,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:c={},components:l,defaultColorScheme:u="light",...y}=e,{vars:g,css:m,varsWithDefaults:S}=ti(y,r);let C=S;const D={},{[u]:v,...x}=c;if(Object.entries(x||{}).forEach(([T,b])=>{const{vars:R,css:H,varsWithDefaults:E}=ti(b,r);C=vt(C,E),D[T]={css:H,vars:R}}),v){const{css:T,vars:b,varsWithDefaults:R}=ti(v,r);C=vt(C,R),D[u]={css:T,vars:b}}function B(T,b){var H,E;let R=s;if(s==="class"&&(R=".%s"),s==="data"&&(R="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(R=`[${s}="%s"]`),T){if(R==="media")return e.defaultColorScheme===T?":root":{[`@media (prefers-color-scheme: ${((E=(H=c[T])==null?void 0:H.palette)==null?void 0:E.mode)||T})`]:{":root":b}};if(R)return e.defaultColorScheme===T?`:root, ${R.replace("%s",String(T))}`:R.replace("%s",String(T))}return":root"}return{vars:C,generateThemeVars:()=>{let T={...g};return Object.entries(D).forEach(([,{vars:b}])=>{T=vt(T,b)}),T},generateStyleSheets:()=>{var Y,Z;const T=[],b=e.defaultColorScheme||"light";function R(I,f){Object.keys(f).length&&T.push(typeof I=="string"?{[I]:{...f}}:I)}R(n(void 0,{...m}),m);const{[b]:H,...E}=D;if(H){const{css:I}=H,f=(Z=(Y=c[b])==null?void 0:Y.palette)==null?void 0:Z.mode,w=!i&&f?{colorScheme:f,...I}:{...I};R(n(b,{...w}),w)}return Object.entries(E).forEach(([I,{css:f}])=>{var te,d;const w=(d=(te=c[I])==null?void 0:te.palette)==null?void 0:d.mode,P=!i&&w?{colorScheme:w,...f}:{...f};R(n(I,{...P}),P)}),a&&T.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)"}}),T}}}function vd(e){return function(n){return e==="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})`):e?e.startsWith("data-")&&!e.includes("%s")?`[${e}="${n}"] &`:e==="class"?`.${n} &`:e==="data"?`[data-${n}] &`:`${e.replace("%s",n)} &`:"&"}}const Do={black:"#000",white:"#fff"},Sd={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"},to={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},ro={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},So={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},oo={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},no={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},io={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Js(){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:Do.white,default:Do.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 Ks=Js();function Xs(){return{text:{primary:Do.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:Do.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 li=Xs();function ls(e,r,n,i){const s=i.light||i,a=i.dark||i*1.5;e[r]||(e.hasOwnProperty(n)?e[r]=e[n]:r==="light"?e.light=Bn(e.main,s):r==="dark"&&(e.dark=zn(e.main,a)))}function cs(e,r,n,i,s){const a=s.light||s,c=s.dark||s*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(a*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(c*100).toFixed(0)}%)`))}function Cd(e="light"){return e==="dark"?{main:oo[200],light:oo[50],dark:oo[400]}:{main:oo[700],light:oo[400],dark:oo[800]}}function wd(e="light"){return e==="dark"?{main:to[200],light:to[50],dark:to[400]}:{main:to[500],light:to[300],dark:to[700]}}function jd(e="light"){return e==="dark"?{main:ro[500],light:ro[300],dark:ro[700]}:{main:ro[700],light:ro[400],dark:ro[800]}}function kd(e="light"){return e==="dark"?{main:no[400],light:no[300],dark:no[700]}:{main:no[700],light:no[500],dark:no[900]}}function zd(e="light"){return e==="dark"?{main:io[400],light:io[300],dark:io[700]}:{main:io[800],light:io[500],dark:io[900]}}function Bd(e="light"){return e==="dark"?{main:So[400],light:So[300],dark:So[700]}:{main:"#ed6c02",light:So[500],dark:So[900]}}function Td(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function ji(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...a}=e,c=e.primary||Cd(r),l=e.secondary||wd(r),u=e.error||jd(r),y=e.info||kd(r),g=e.success||zd(r),m=e.warning||Bd(r);function S(x){if(s)return Td(x);const B=ss(x,li.text.primary)>=n?li.text.primary:Ks.text.primary;if(process.env.NODE_ENV!=="production"){const h=ss(x,B);h<3&&console.error([`MUI: The contrast ratio of ${h}:1 for ${B} on ${x}`,"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(`
147
- `))}return B}const C=({color:x,name:B,mainShade:h=500,lightShade:k=300,darkShade:T=700})=>{if(x={...x},!x.main&&x[h]&&(x.main=x[h]),!x.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${B?` (${B})`:""} provided to augmentColor(color) is invalid.
148
- The color object needs to have a \`main\` property or a \`${h}\` property.`:Or(11,B?` (${B})`:"",h));if(typeof x.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${B?` (${B})`:""} provided to augmentColor(color) is invalid.
149
- \`color.main\` should be a string, but \`${JSON.stringify(x.main)}\` was provided instead.
143
+ `)));const l=s[d];return a>=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.${r}\` value (${s}) is invalid.`,"It should be a number, an array or a function."].join(`
144
+ `)),()=>{})}function Ci(e){return Mo(e,"spacing",8,"spacing")}function Ao(e,r){return typeof r=="string"||r==null?r:e(r)}function jc(e,r){return n=>e.reduce((i,s)=>(i[s]=Ao(r,n),i),{})}function kc(e,r,n,i){if(!r.includes(n))return null;const s=Cc(n),a=jc(s,i),d=e[n];return ir(e,d,a)}function Ys(e,r){const n=Ci(e.theme);return Object.keys(e).map(i=>kc(e,r,i,n)).reduce(Do,{})}function Le(e){return Ys(e,yn)}Le.propTypes=process.env.NODE_ENV!=="production"?yn.reduce((e,r)=>(e[r]=yr,e),{}):{};Le.filterProps=yn;function Fe(e){return Ys(e,bn)}Fe.propTypes=process.env.NODE_ENV!=="production"?bn.reduce((e,r)=>(e[r]=yr,e),{}):{};Fe.filterProps=bn;process.env.NODE_ENV!=="production"&&wc.reduce((e,r)=>(e[r]=yr,e),{});function qs(e=8,r=Ci({spacing:e})){if(e.mui)return e;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(a=>{const d=r(a);return typeof d=="number"?`${d}px`:d}).join(" "));return n.mui=!0,n}function vn(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(a=>{i[a]=s}),i),{}),n=i=>Object.keys(i).reduce((s,a)=>r[a]?Do(s,r[a](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=e.reduce((i,s)=>i.concat(s.filterProps),[]),n}function It(e){return typeof e!="number"?e:`${e}px solid`}function _t(e,r){return Ue({prop:e,themeKey:"borders",transform:r})}const zc=_t("border",It),Bc=_t("borderTop",It),Tc=_t("borderRight",It),Ic=_t("borderBottom",It),Ec=_t("borderLeft",It),Dc=_t("borderColor"),_c=_t("borderTopColor"),$c=_t("borderRightColor"),Oc=_t("borderBottomColor"),Mc=_t("borderLeftColor"),Ac=_t("outline",It),Wc=_t("outlineColor"),Sn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Mo(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Ao(r,i)});return ir(e,e.borderRadius,n)}return null};Sn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:yr}:{};Sn.filterProps=["borderRadius"];vn(zc,Bc,Tc,Ic,Ec,Dc,_c,$c,Oc,Mc,Sn,Ac,Wc);const Cn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Mo(e.theme,"spacing",8,"gap"),n=i=>({gap:Ao(r,i)});return ir(e,e.gap,n)}return null};Cn.propTypes=process.env.NODE_ENV!=="production"?{gap:yr}:{};Cn.filterProps=["gap"];const wn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Mo(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Ao(r,i)});return ir(e,e.columnGap,n)}return null};wn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:yr}:{};wn.filterProps=["columnGap"];const jn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Mo(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Ao(r,i)});return ir(e,e.rowGap,n)}return null};jn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:yr}:{};jn.filterProps=["rowGap"];const Rc=Ue({prop:"gridColumn"}),Pc=Ue({prop:"gridRow"}),Nc=Ue({prop:"gridAutoFlow"}),Lc=Ue({prop:"gridAutoColumns"}),Fc=Ue({prop:"gridAutoRows"}),Vc=Ue({prop:"gridTemplateColumns"}),Hc=Ue({prop:"gridTemplateRows"}),Uc=Ue({prop:"gridTemplateAreas"}),Gc=Ue({prop:"gridArea"});vn(Cn,wn,jn,Rc,Pc,Nc,Lc,Fc,Vc,Hc,Uc,Gc);function ao(e,r){return r==="grey"?r:e}const Yc=Ue({prop:"color",themeKey:"palette",transform:ao}),qc=Ue({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:ao}),Jc=Ue({prop:"backgroundColor",themeKey:"palette",transform:ao});vn(Yc,qc,Jc);function St(e){return e<=1&&e!==0?`${e*100}%`:e}const Kc=Ue({prop:"width",transform:St}),wi=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,d,l,u;const i=((d=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:d[n])||xn[n];return i?((u=(l=e.theme)==null?void 0:l.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:St(n)}};return ir(e,e.maxWidth,r)}return null};wi.filterProps=["maxWidth"];const Xc=Ue({prop:"minWidth",transform:St}),Qc=Ue({prop:"height",transform:St}),Zc=Ue({prop:"maxHeight",transform:St}),ed=Ue({prop:"minHeight",transform:St});Ue({prop:"size",cssProperty:"width",transform:St});Ue({prop:"size",cssProperty:"height",transform:St});const td=Ue({prop:"boxSizing"});vn(Kc,wi,Xc,Qc,Zc,ed,td);const kn={border:{themeKey:"borders",transform:It},borderTop:{themeKey:"borders",transform:It},borderRight:{themeKey:"borders",transform:It},borderBottom:{themeKey:"borders",transform:It},borderLeft:{themeKey:"borders",transform:It},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:It},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Sn},color:{themeKey:"palette",transform:ao},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:ao},backgroundColor:{themeKey:"palette",transform:ao},p:{style:Fe},pt:{style:Fe},pr:{style:Fe},pb:{style:Fe},pl:{style:Fe},px:{style:Fe},py:{style:Fe},padding:{style:Fe},paddingTop:{style:Fe},paddingRight:{style:Fe},paddingBottom:{style:Fe},paddingLeft:{style:Fe},paddingX:{style:Fe},paddingY:{style:Fe},paddingInline:{style:Fe},paddingInlineStart:{style:Fe},paddingInlineEnd:{style:Fe},paddingBlock:{style:Fe},paddingBlockStart:{style:Fe},paddingBlockEnd:{style:Fe},m:{style:Le},mt:{style:Le},mr:{style:Le},mb:{style:Le},ml:{style:Le},mx:{style:Le},my:{style:Le},margin:{style:Le},marginTop:{style:Le},marginRight:{style:Le},marginBottom:{style:Le},marginLeft:{style:Le},marginX:{style:Le},marginY:{style:Le},marginInline:{style:Le},marginInlineStart:{style:Le},marginInlineEnd:{style:Le},marginBlock:{style:Le},marginBlockStart:{style:Le},marginBlockEnd:{style:Le},displayPrint:{cssProperty:!1,transform:e=>({"@media print":{display:e}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:Cn},rowGap:{style:jn},columnGap:{style:wn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:St},maxWidth:{style:wi},minWidth:{transform:St},height:{transform:St},maxHeight:{transform:St},minHeight:{transform:St},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 rd(...e){const r=e.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(r);return e.every(i=>n.size===Object.keys(i).length)}function od(e,r){return typeof e=="function"?e(r):e}function nd(){function e(n,i,s,a){const d={[n]:i,theme:s},l=a[n];if(!l)return{[n]:i};const{cssProperty:u=n,themeKey:x,transform:g,style:m}=l;if(i==null)return null;if(x==="typography"&&i==="inherit")return{[n]:i};const C=gn(s,x)||{};return m?m(d):ir(d,i,E=>{let v=dn(C,g,E);return E===v&&typeof E=="string"&&(v=dn(C,g,`${n}${E==="default"?"":Gs(E)}`,E)),u===!1?v:{[u]:v}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const d=s.unstable_sxConfig??kn;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 g=yc(s.breakpoints),m=Object.keys(g);let C=g;return Object.keys(x).forEach(S=>{const E=od(x[S],s);if(E!=null)if(typeof E=="object")if(d[S])C=Do(C,e(S,E,s,d));else{const v=ir({theme:s},E,y=>({[S]:y}));rd(v,E)?C[S]=r({sx:E,theme:s,nested:!0}):C=Do(C,v)}else C=Do(C,e(S,E,s,d))}),!a&&s.modularCssLayers?{"@layer sx":os(s,is(m,C))}:os(s,is(m,C))}return Array.isArray(i)?i.map(l):l(i)}return r}const zn=nd();zn.filterProps=["sx"];function id(e,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[e])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(e);return s==="&"?r:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:r})}return n.palette.mode===e?r:{}}function Js(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...d}=e,l=pc(n),u=qs(s);let x=Ct({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...xc,...a}},d);return x=fc(x),x.applyStyles=id,x=r.reduce((g,m)=>Ct(g,m),x),x.unstable_sxConfig={...kn,...d==null?void 0:d.unstable_sxConfig},x.unstable_sx=function(m){return zn({sx:m,theme:this})},x}function sd(e){return Object.keys(e).length===0}function ad(e=null){const r=pn.useContext(wa.ThemeContext);return!r||sd(r)?e:r}const ld=Js();function cd(e=ld){return ad(e)}const as=e=>e,dd=()=>{let e=as;return{configure(r){e=r},generate(r){return e(r)},reset(){e=as}}},ud=dd(),pd={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 hd(e,r,n="Mui"){const i=pd[r];return i?`${n}-${i}`:`${ud.generate(e)}-${r}`}function md(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function ji(e,r=0,n=1){return process.env.NODE_ENV!=="production"&&(e<r||e>n)&&console.error(`MUI: The value provided ${e} is out of range [${r}, ${n}].`),md(e,r,n)}function fd(e){e=e.slice(1);const r=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(r);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&e.length!==e.trim().length&&console.error(`MUI: The color: "${e}" 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 gr(e){if(e.type)return e;if(e.charAt(0)==="#")return gr(fd(e));const r=e.indexOf("("),n=e.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${e}\` color.
145
+ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Mr(9,e));let i=e.substring(r+1,e.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.
146
+ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Mr(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:n,values:i,colorSpace:s}}const xd=e=>{const r=gr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},zo=(e,r)=>{try{return xd(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function Bn(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,a)=>a<3?parseInt(s,10):s):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function Ks(e){e=gr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),d=(x,g=(x+n/30)%12)=>s-a*Math.max(Math.min(g-3,9-g,1),-1);let l="rgb";const u=[Math.round(d(0)*255),Math.round(d(8)*255),Math.round(d(4)*255)];return e.type==="hsla"&&(l+="a",u.push(r[3])),Bn({type:l,values:u})}function li(e){e=gr(e);let r=e.type==="hsl"||e.type==="hsla"?gr(Ks(e)).values:e.values;return r=r.map(n=>(e.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*r[0]+.7152*r[1]+.0722*r[2]).toFixed(3))}function ls(e,r){const n=li(e),i=li(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function O(e,r){return e=gr(e),r=ji(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,Bn(e)}function _r(e,r,n){try{return O(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function Tn(e,r){if(e=gr(e),r=ji(r),e.type.includes("hsl"))e.values[2]*=1-r;else if(e.type.includes("rgb")||e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]*=1-r;return Bn(e)}function Ie(e,r,n){try{return Tn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function In(e,r){if(e=gr(e),r=ji(r),e.type.includes("hsl"))e.values[2]+=(100-e.values[2])*r;else if(e.type.includes("rgb"))for(let n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*r;else if(e.type.includes("color"))for(let n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*r;return Bn(e)}function Ee(e,r,n){try{return In(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function gd(e,r=.15){return li(e)>.5?Tn(e,r):In(e,r)}function Zo(e,r,n){try{return gd(e,r)}catch{return e}}function yd(e=""){function r(...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(--${e?`${e}-`:""}${s}${r(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${e?`${e}-`:""}${i}${r(...s)})`}const cs=(e,r,n,i=[])=>{let s=e;r.forEach((a,d)=>{d===r.length-1?Array.isArray(s)?s[Number(a)]=n:s&&typeof s=="object"&&(s[a]=n):s&&typeof s=="object"&&(s[a]||(s[a]=i.includes(a)?[]:{}),s=s[a])})},bd=(e,r,n)=>{function i(s,a=[],d=[]){Object.entries(s).forEach(([l,u])=>{(!n||n&&!n([...a,l]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...a,l],Array.isArray(u)?[...d,l]:d):r([...a,l],u,d))})}i(e)},vd=(e,r)=>typeof r=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>e.includes(i))||e[e.length-1].toLowerCase().includes("opacity")?r:`${r}px`:r;function ri(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},a={},d={};return bd(e,(l,u,x)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(l,u))){const g=`--${n?`${n}-`:""}${l.join("-")}`,m=vd(l,u);Object.assign(s,{[g]:m}),cs(a,l,`var(${g})`,x),cs(d,l,`var(${g}, ${m})`,x)}},l=>l[0]==="vars"),{css:s,vars:a,varsWithDefaults:d}}function Sd(e,r={}){const{getSelector:n=k,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:d={},components:l,defaultColorScheme:u="light",...x}=e,{vars:g,css:m,varsWithDefaults:C}=ri(x,r);let S=C;const E={},{[u]:v,...y}=d;if(Object.entries(y||{}).forEach(([T,b])=>{const{vars:R,css:H,varsWithDefaults:I}=ri(b,r);S=Ct(S,I),E[T]={css:H,vars:R}}),v){const{css:T,vars:b,varsWithDefaults:R}=ri(v,r);S=Ct(S,R),E[u]={css:T,vars:b}}function k(T,b){var H,I;let R=s;if(s==="class"&&(R=".%s"),s==="data"&&(R="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(R=`[${s}="%s"]`),T){if(R==="media")return e.defaultColorScheme===T?":root":{[`@media (prefers-color-scheme: ${((I=(H=d[T])==null?void 0:H.palette)==null?void 0:I.mode)||T})`]:{":root":b}};if(R)return e.defaultColorScheme===T?`:root, ${R.replace("%s",String(T))}`:R.replace("%s",String(T))}return":root"}return{vars:S,generateThemeVars:()=>{let T={...g};return Object.entries(E).forEach(([,{vars:b}])=>{T=Ct(T,b)}),T},generateStyleSheets:()=>{var J,Z;const T=[],b=e.defaultColorScheme||"light";function R(B,f){Object.keys(f).length&&T.push(typeof B=="string"?{[B]:{...f}}:B)}R(n(void 0,{...m}),m);const{[b]:H,...I}=E;if(H){const{css:B}=H,f=(Z=(J=d[b])==null?void 0:J.palette)==null?void 0:Z.mode,$=!i&&f?{colorScheme:f,...B}:{...B};R(n(b,{...$}),$)}return Object.entries(I).forEach(([B,{css:f}])=>{var ee,oe;const $=(oe=(ee=d[B])==null?void 0:ee.palette)==null?void 0:oe.mode,D=!i&&$?{colorScheme:$,...f}:{...f};R(n(B,{...D}),D)}),a&&T.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)"}}),T}}}function Cd(e){return function(n){return e==="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})`):e?e.startsWith("data-")&&!e.includes("%s")?`[${e}="${n}"] &`:e==="class"?`.${n} &`:e==="data"?`[data-${n}] &`:`${e.replace("%s",n)} &`:"&"}}const $o={black:"#000",white:"#fff"},wd={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"},to={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},ro={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},wo={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},oo={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},no={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},io={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Xs(){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:$o.white,default:$o.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 Qs=Xs();function Zs(){return{text:{primary:$o.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:$o.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 ci=Zs();function ds(e,r,n,i){const s=i.light||i,a=i.dark||i*1.5;e[r]||(e.hasOwnProperty(n)?e[r]=e[n]:r==="light"?e.light=In(e.main,s):r==="dark"&&(e.dark=Tn(e.main,a)))}function us(e,r,n,i,s){const a=s.light||s,d=s.dark||s*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(a*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(d*100).toFixed(0)}%)`))}function jd(e="light"){return e==="dark"?{main:oo[200],light:oo[50],dark:oo[400]}:{main:oo[700],light:oo[400],dark:oo[800]}}function kd(e="light"){return e==="dark"?{main:to[200],light:to[50],dark:to[400]}:{main:to[500],light:to[300],dark:to[700]}}function zd(e="light"){return e==="dark"?{main:ro[500],light:ro[300],dark:ro[700]}:{main:ro[700],light:ro[400],dark:ro[800]}}function Bd(e="light"){return e==="dark"?{main:no[400],light:no[300],dark:no[700]}:{main:no[700],light:no[500],dark:no[900]}}function Td(e="light"){return e==="dark"?{main:io[400],light:io[300],dark:io[700]}:{main:io[800],light:io[500],dark:io[900]}}function Id(e="light"){return e==="dark"?{main:wo[400],light:wo[300],dark:wo[700]}:{main:"#ed6c02",light:wo[500],dark:wo[900]}}function Ed(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function ki(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...a}=e,d=e.primary||jd(r),l=e.secondary||kd(r),u=e.error||zd(r),x=e.info||Bd(r),g=e.success||Td(r),m=e.warning||Id(r);function C(y){if(s)return Ed(y);const k=ls(y,ci.text.primary)>=n?ci.text.primary:Qs.text.primary;if(process.env.NODE_ENV!=="production"){const h=ls(y,k);h<3&&console.error([`MUI: The contrast ratio of ${h}:1 for ${k} on ${y}`,"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(`
147
+ `))}return k}const S=({color:y,name:k,mainShade:h=500,lightShade:j=300,darkShade:T=700})=>{if(y={...y},!y.main&&y[h]&&(y.main=y[h]),!y.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${k?` (${k})`:""} provided to augmentColor(color) is invalid.
148
+ The color object needs to have a \`main\` property or a \`${h}\` property.`:Mr(11,k?` (${k})`:"",h));if(typeof y.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${k?` (${k})`:""} provided to augmentColor(color) is invalid.
149
+ \`color.main\` should be a string, but \`${JSON.stringify(y.main)}\` was provided instead.
150
150
 
151
151
  Did you intend to use one of the following approaches?
152
152
 
@@ -158,17 +158,17 @@ const theme1 = createTheme({ palette: {
158
158
 
159
159
  const theme2 = createTheme({ palette: {
160
160
  primary: { main: green[500] },
161
- } });`:Or(12,B?` (${B})`:"",JSON.stringify(x.main)));return s?(cs(s,x,"light",k,i),cs(s,x,"dark",T,i)):(ls(x,"light",k,i),ls(x,"dark",T,i)),x.contrastText||(x.contrastText=S(x.main)),x};let D;return r==="light"?D=Js():r==="dark"&&(D=Xs()),process.env.NODE_ENV!=="production"&&(D||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),vt({common:{...Do},mode:r,primary:C({color:c,name:"primary"}),secondary:C({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:C({color:u,name:"error"}),warning:C({color:m,name:"warning"}),info:C({color:y,name:"info"}),success:C({color:g,name:"success"}),grey:Sd,contrastThreshold:n,getContrastText:S,augmentColor:C,tonalOffset:i,...D},a)}function Id(e){const r={};return Object.entries(e).forEach(i=>{const[s,a]=i;typeof a=="object"&&(r[s]=`${a.fontStyle?`${a.fontStyle} `:""}${a.fontVariant?`${a.fontVariant} `:""}${a.fontWeight?`${a.fontWeight} `:""}${a.fontStretch?`${a.fontStretch} `:""}${a.fontSize||""}${a.lineHeight?`/${a.lineHeight} `:""}${a.fontFamily||""}`)}),r}function Ed(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function Dd(e){return Math.round(e*1e5)/1e5}const ds={textTransform:"uppercase"},us='"Roboto", "Helvetica", "Arial", sans-serif';function _d(e,r){const{fontFamily:n=us,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:u=16,allVariants:y,pxToRem:g,...m}=typeof r=="function"?r(e):r;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 S=i/14,C=g||(x=>`${x/u*S}rem`),D=(x,B,h,k,T)=>({fontFamily:n,fontWeight:x,fontSize:C(B),lineHeight:h,...n===us?{letterSpacing:`${Dd(k/B)}em`}:{},...T,...y}),v={h1:D(s,96,1.167,-1.5),h2:D(s,60,1.2,-.5),h3:D(a,48,1.167,0),h4:D(a,34,1.235,.25),h5:D(a,24,1.334,0),h6:D(c,20,1.6,.15),subtitle1:D(a,16,1.75,.15),subtitle2:D(c,14,1.57,.1),body1:D(a,16,1.5,.15),body2:D(a,14,1.43,.15),button:D(c,14,1.75,.4,ds),caption:D(a,12,1.66,.4),overline:D(a,12,2.66,1,ds),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return vt({htmlFontSize:u,pxToRem:C,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:c,fontWeightBold:l,...v},m,{clone:!1})}const $d=.2,Od=.14,Md=.12;function Re(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${$d})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Od})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Md})`].join(",")}const Ad=["none",Re(0,2,1,-1,0,1,1,0,0,1,3,0),Re(0,3,1,-2,0,2,2,0,0,1,5,0),Re(0,3,3,-2,0,3,4,0,0,1,8,0),Re(0,2,4,-1,0,4,5,0,0,1,10,0),Re(0,3,5,-1,0,5,8,0,0,1,14,0),Re(0,3,5,-1,0,6,10,0,0,1,18,0),Re(0,4,5,-2,0,7,10,1,0,2,16,1),Re(0,5,5,-3,0,8,10,1,0,3,14,2),Re(0,5,6,-3,0,9,12,1,0,3,16,2),Re(0,6,6,-3,0,10,14,1,0,4,18,3),Re(0,6,7,-4,0,11,15,1,0,4,20,3),Re(0,7,8,-4,0,12,17,2,0,5,22,4),Re(0,7,8,-4,0,13,19,2,0,5,24,4),Re(0,7,9,-4,0,14,21,2,0,5,26,4),Re(0,8,9,-5,0,15,22,2,0,6,28,5),Re(0,8,10,-5,0,16,24,2,0,6,30,5),Re(0,8,11,-5,0,17,26,2,0,6,32,5),Re(0,9,11,-5,0,18,28,2,0,7,34,6),Re(0,9,12,-6,0,19,29,2,0,7,36,6),Re(0,10,13,-6,0,20,31,3,0,8,38,7),Re(0,10,13,-6,0,21,33,3,0,8,40,7),Re(0,10,14,-6,0,22,35,3,0,8,42,7),Re(0,11,14,-7,0,23,36,3,0,9,44,8),Re(0,11,15,-7,0,24,38,3,0,9,46,8)],Wd={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)"},Rd={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function ps(e){return`${Math.round(e)}ms`}function Pd(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function Nd(e){const r={...Wd,...e.easing},n={...Rd,...e.duration};return{getAutoHeightDuration:Pd,create:(s=["all"],a={})=>{const{duration:c=n.standard,easing:l=r.easeInOut,delay:u=0,...y}=a;if(process.env.NODE_ENV!=="production"){const g=S=>typeof S=="string",m=S=>!Number.isNaN(parseFloat(S));!g(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!m(c)&&!g(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),g(l)||console.error('MUI: Argument "easing" must be a string.'),!m(u)&&!g(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof a!="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(`
162
- `)),Object.keys(y).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(y).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(g=>`${g} ${typeof c=="string"?c:ps(c)} ${l} ${typeof u=="string"?u:ps(u)}`).join(",")},...e,easing:r,duration:n}}const Ld={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Fd(e){return mr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function Qs(e={}){const r={...e};function n(i){const s=Object.entries(i);for(let a=0;a<s.length;a++){const[c,l]=s[a];!Fd(l)||c.startsWith("unstable_")?delete i[c]:mr(l)&&(i[c]={...l},n(i[c]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
161
+ } });`:Mr(12,k?` (${k})`:"",JSON.stringify(y.main)));return s?(us(s,y,"light",j,i),us(s,y,"dark",T,i)):(ds(y,"light",j,i),ds(y,"dark",T,i)),y.contrastText||(y.contrastText=C(y.main)),y};let E;return r==="light"?E=Xs():r==="dark"&&(E=Zs()),process.env.NODE_ENV!=="production"&&(E||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),Ct({common:{...$o},mode:r,primary:S({color:d,name:"primary"}),secondary:S({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:S({color:u,name:"error"}),warning:S({color:m,name:"warning"}),info:S({color:x,name:"info"}),success:S({color:g,name:"success"}),grey:wd,contrastThreshold:n,getContrastText:C,augmentColor:S,tonalOffset:i,...E},a)}function Dd(e){const r={};return Object.entries(e).forEach(i=>{const[s,a]=i;typeof a=="object"&&(r[s]=`${a.fontStyle?`${a.fontStyle} `:""}${a.fontVariant?`${a.fontVariant} `:""}${a.fontWeight?`${a.fontWeight} `:""}${a.fontStretch?`${a.fontStretch} `:""}${a.fontSize||""}${a.lineHeight?`/${a.lineHeight} `:""}${a.fontFamily||""}`)}),r}function _d(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function $d(e){return Math.round(e*1e5)/1e5}const ps={textTransform:"uppercase"},hs='"Roboto", "Helvetica", "Arial", sans-serif';function Od(e,r){const{fontFamily:n=hs,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:d=500,fontWeightBold:l=700,htmlFontSize:u=16,allVariants:x,pxToRem:g,...m}=typeof r=="function"?r(e):r;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 C=i/14,S=g||(y=>`${y/u*C}rem`),E=(y,k,h,j,T)=>({fontFamily:n,fontWeight:y,fontSize:S(k),lineHeight:h,...n===hs?{letterSpacing:`${$d(j/k)}em`}:{},...T,...x}),v={h1:E(s,96,1.167,-1.5),h2:E(s,60,1.2,-.5),h3:E(a,48,1.167,0),h4:E(a,34,1.235,.25),h5:E(a,24,1.334,0),h6:E(d,20,1.6,.15),subtitle1:E(a,16,1.75,.15),subtitle2:E(d,14,1.57,.1),body1:E(a,16,1.5,.15),body2:E(a,14,1.43,.15),button:E(d,14,1.75,.4,ps),caption:E(a,12,1.66,.4),overline:E(a,12,2.66,1,ps),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Ct({htmlFontSize:u,pxToRem:S,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:d,fontWeightBold:l,...v},m,{clone:!1})}const Md=.2,Ad=.14,Wd=.12;function Re(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${Md})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Ad})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Wd})`].join(",")}const Rd=["none",Re(0,2,1,-1,0,1,1,0,0,1,3,0),Re(0,3,1,-2,0,2,2,0,0,1,5,0),Re(0,3,3,-2,0,3,4,0,0,1,8,0),Re(0,2,4,-1,0,4,5,0,0,1,10,0),Re(0,3,5,-1,0,5,8,0,0,1,14,0),Re(0,3,5,-1,0,6,10,0,0,1,18,0),Re(0,4,5,-2,0,7,10,1,0,2,16,1),Re(0,5,5,-3,0,8,10,1,0,3,14,2),Re(0,5,6,-3,0,9,12,1,0,3,16,2),Re(0,6,6,-3,0,10,14,1,0,4,18,3),Re(0,6,7,-4,0,11,15,1,0,4,20,3),Re(0,7,8,-4,0,12,17,2,0,5,22,4),Re(0,7,8,-4,0,13,19,2,0,5,24,4),Re(0,7,9,-4,0,14,21,2,0,5,26,4),Re(0,8,9,-5,0,15,22,2,0,6,28,5),Re(0,8,10,-5,0,16,24,2,0,6,30,5),Re(0,8,11,-5,0,17,26,2,0,6,32,5),Re(0,9,11,-5,0,18,28,2,0,7,34,6),Re(0,9,12,-6,0,19,29,2,0,7,36,6),Re(0,10,13,-6,0,20,31,3,0,8,38,7),Re(0,10,13,-6,0,21,33,3,0,8,40,7),Re(0,10,14,-6,0,22,35,3,0,8,42,7),Re(0,11,14,-7,0,23,36,3,0,9,44,8),Re(0,11,15,-7,0,24,38,3,0,9,46,8)],Pd={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)"},Nd={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function ms(e){return`${Math.round(e)}ms`}function Ld(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function Fd(e){const r={...Pd,...e.easing},n={...Nd,...e.duration};return{getAutoHeightDuration:Ld,create:(s=["all"],a={})=>{const{duration:d=n.standard,easing:l=r.easeInOut,delay:u=0,...x}=a;if(process.env.NODE_ENV!=="production"){const g=C=>typeof C=="string",m=C=>!Number.isNaN(parseFloat(C));!g(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!m(d)&&!g(d)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${d}.`),g(l)||console.error('MUI: Argument "easing" must be a string.'),!m(u)&&!g(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof a!="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(`
162
+ `)),Object.keys(x).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(x).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(g=>`${g} ${typeof d=="string"?d:ms(d)} ${l} ${typeof u=="string"?u:ms(u)}`).join(",")},...e,easing:r,duration:n}}const Vd={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Hd(e){return fr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function ea(e={}){const r={...e};function n(i){const s=Object.entries(i);for(let a=0;a<s.length;a++){const[d,l]=s[a];!Hd(l)||d.startsWith("unstable_")?delete i[d]:fr(l)&&(i[d]={...l},n(i[d]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
163
163
 
164
164
  const theme = ${JSON.stringify(r,null,2)};
165
165
 
166
166
  theme.breakpoints = createBreakpoints(theme.breakpoints || {});
167
167
  theme.transitions = createTransitions(theme.transitions || {});
168
168
 
169
- export default theme;`}function hs(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Vd=e=>{if(!Number.isNaN(+e))return+e;const r=e.match(/\d*\.?\d+/g);if(!r)return 0;let n=0;for(let i=0;i<r.length;i+=1)n+=+r[i];return n};function Hd(e){Object.assign(e,{alpha(r,n){const i=this||e;return i.colorSpace?`oklch(from ${r} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${r.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:$(r,Vd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${hs(n)})`:Bn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${hs(n)})`:zn(r,n)}})}function ci(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:c={},typography:l={},shape:u,colorSpace:y,...g}=e;if(e.vars&&e.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.":Or(20));const m=ji({...a,colorSpace:y}),S=Ys(e);let C=vt(S,{mixins:Ed(S.breakpoints,i),palette:m,shadows:Ad.slice(),typography:_d(m,l),transitions:Nd(c),zIndex:{...Ld}});if(C=vt(C,g),C=r.reduce((D,v)=>vt(D,v),C),process.env.NODE_ENV!=="production"){const D=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],v=(x,B)=>{let h;for(h in x){const k=x[h];if(D.includes(h)&&Object.keys(k).length>0){if(process.env.NODE_ENV!=="production"){const T=ud("",h);console.error([`MUI: The \`${B}\` component increases the CSS specificity of the \`${h}\` internal state.`,"You can not override it like this: ",JSON.stringify(x,null,2),"",`Instead, you need to use the '&.${T}' syntax:`,JSON.stringify({root:{[`&.${T}`]:k}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
- `))}x[h]={}}}};Object.keys(C.components).forEach(x=>{const B=C.components[x].styleOverrides;B&&x.startsWith("Mui")&&v(B,x)})}return C.unstable_sxConfig={...wn,...g==null?void 0:g.unstable_sxConfig},C.unstable_sx=function(v){return jn({sx:v,theme:this})},C.toRuntimeSource=Qs,Hd(C),C}function Ud(e){let r;return e<1?r=5.11916*e**2:r=4.5*Math.log(e+1)+2,Math.round(r*10)/1e3}const Gd=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Ud(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Zs(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function ea(e){return e==="dark"?Gd:[]}function Yd(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...a}=e,c=ji({...r,colorSpace:s});return{palette:c,opacity:{...Zs(c.mode),...n},overlays:i||ea(c.mode),...a}}function qd(e){var r;return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]==="palette"&&!!((r=e[1])!=null&&r.match(/(mode|contrastThreshold|tonalOffset)/))}const Jd=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Kd=e=>(r,n)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const c={};return Jd(e.cssVarPrefix).forEach(l=>{c[l]=n[l],delete n[l]}),a==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:c}}:a?{[a.replace("%s",r)]:c,[`${i}, ${a.replace("%s",r)}`]:n}:{[i]:{...n,...c}}}if(a&&a!=="media")return`${i}, ${a.replace("%s",String(r))}`}else if(r){if(a==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(a)return a.replace("%s",String(r))}return i};function Xd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function L(e,r,n){!e[r]&&n&&(e[r]=n)}function ko(e){return typeof e!="string"||!e.startsWith("hsl")?e:qs(e)}function nr(e,r){`${r}Channel`in e||(e[`${r}Channel`]=jo(ko(e[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
171
- To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function Qd(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Yt=e=>{try{return e()}catch{}},Zd=(e="mui")=>xd(e);function ri(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Yd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:c,...l}=ci({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:c,opacity:{...Zs(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||ea(a)},l}function eu(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=qd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:y=":root",...g}=e,m=Object.keys(n)[0],S=i||(n.light&&m!=="light"?"light":m),C=Zd(a),{[S]:D,light:v,dark:x,...B}=n,h={...B};let k=D;if((S==="dark"&&!("dark"in n)||S==="light"&&!("light"in n))&&(k=!0),!k)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${S}\` option is either missing or invalid.`:Or(21,S));let T;c&&(T="oklch");const b=ri(T,h,k,g,S);v&&!h.light&&ri(T,h,v,void 0,"light"),x&&!h.dark&&ri(T,h,x,void 0,"dark");let R={defaultColorScheme:S,...b,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:y,getCssVar:C,colorSchemes:h,font:{...Id(b.typography),...b.font},spacing:Qd(g.spacing)};Object.keys(R.colorSchemes).forEach(I=>{const f=R.colorSchemes[I].palette,w=te=>{const d=te.split("-"),J=d[1],re=d[2];return C(te,f[J][re])};f.mode==="light"&&(L(f.common,"background","#fff"),L(f.common,"onBackground","#000")),f.mode==="dark"&&(L(f.common,"background","#000"),L(f.common,"onBackground","#fff"));function P(te,d,J){if(T){let re;return te===Dr&&(re=`transparent ${((1-J)*100).toFixed(0)}%`),te===De&&(re=`#000 ${(J*100).toFixed(0)}%`),te===_e&&(re=`#fff ${(J*100).toFixed(0)}%`),`color-mix(in ${T}, ${d}, ${re})`}return te(d,J)}if(Xd(f,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),f.mode==="light"){L(f.Alert,"errorColor",P(De,f.error.light,.6)),L(f.Alert,"infoColor",P(De,f.info.light,.6)),L(f.Alert,"successColor",P(De,f.success.light,.6)),L(f.Alert,"warningColor",P(De,f.warning.light,.6)),L(f.Alert,"errorFilledBg",w("palette-error-main")),L(f.Alert,"infoFilledBg",w("palette-info-main")),L(f.Alert,"successFilledBg",w("palette-success-main")),L(f.Alert,"warningFilledBg",w("palette-warning-main")),L(f.Alert,"errorFilledColor",Yt(()=>f.getContrastText(f.error.main))),L(f.Alert,"infoFilledColor",Yt(()=>f.getContrastText(f.info.main))),L(f.Alert,"successFilledColor",Yt(()=>f.getContrastText(f.success.main))),L(f.Alert,"warningFilledColor",Yt(()=>f.getContrastText(f.warning.main))),L(f.Alert,"errorStandardBg",P(_e,f.error.light,.9)),L(f.Alert,"infoStandardBg",P(_e,f.info.light,.9)),L(f.Alert,"successStandardBg",P(_e,f.success.light,.9)),L(f.Alert,"warningStandardBg",P(_e,f.warning.light,.9)),L(f.Alert,"errorIconColor",w("palette-error-main")),L(f.Alert,"infoIconColor",w("palette-info-main")),L(f.Alert,"successIconColor",w("palette-success-main")),L(f.Alert,"warningIconColor",w("palette-warning-main")),L(f.AppBar,"defaultBg",w("palette-grey-100")),L(f.Avatar,"defaultBg",w("palette-grey-400")),L(f.Button,"inheritContainedBg",w("palette-grey-300")),L(f.Button,"inheritContainedHoverBg",w("palette-grey-A100")),L(f.Chip,"defaultBorder",w("palette-grey-400")),L(f.Chip,"defaultAvatarColor",w("palette-grey-700")),L(f.Chip,"defaultIconColor",w("palette-grey-700")),L(f.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),L(f.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),L(f.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),L(f.LinearProgress,"primaryBg",P(_e,f.primary.main,.62)),L(f.LinearProgress,"secondaryBg",P(_e,f.secondary.main,.62)),L(f.LinearProgress,"errorBg",P(_e,f.error.main,.62)),L(f.LinearProgress,"infoBg",P(_e,f.info.main,.62)),L(f.LinearProgress,"successBg",P(_e,f.success.main,.62)),L(f.LinearProgress,"warningBg",P(_e,f.warning.main,.62)),L(f.Skeleton,"bg",T?P(Dr,f.text.primary,.11):`rgba(${w("palette-text-primaryChannel")} / 0.11)`),L(f.Slider,"primaryTrack",P(_e,f.primary.main,.62)),L(f.Slider,"secondaryTrack",P(_e,f.secondary.main,.62)),L(f.Slider,"errorTrack",P(_e,f.error.main,.62)),L(f.Slider,"infoTrack",P(_e,f.info.main,.62)),L(f.Slider,"successTrack",P(_e,f.success.main,.62)),L(f.Slider,"warningTrack",P(_e,f.warning.main,.62));const te=T?P(De,f.background.default,.6825):Xo(f.background.default,.8);L(f.SnackbarContent,"bg",te),L(f.SnackbarContent,"color",Yt(()=>T?li.text.primary:f.getContrastText(te))),L(f.SpeedDialAction,"fabHoverBg",Xo(f.background.paper,.15)),L(f.StepConnector,"border",w("palette-grey-400")),L(f.StepContent,"border",w("palette-grey-400")),L(f.Switch,"defaultColor",w("palette-common-white")),L(f.Switch,"defaultDisabledColor",w("palette-grey-100")),L(f.Switch,"primaryDisabledColor",P(_e,f.primary.main,.62)),L(f.Switch,"secondaryDisabledColor",P(_e,f.secondary.main,.62)),L(f.Switch,"errorDisabledColor",P(_e,f.error.main,.62)),L(f.Switch,"infoDisabledColor",P(_e,f.info.main,.62)),L(f.Switch,"successDisabledColor",P(_e,f.success.main,.62)),L(f.Switch,"warningDisabledColor",P(_e,f.warning.main,.62)),L(f.TableCell,"border",P(_e,P(Dr,f.divider,1),.88)),L(f.Tooltip,"bg",P(Dr,f.grey[700],.92))}if(f.mode==="dark"){L(f.Alert,"errorColor",P(_e,f.error.light,.6)),L(f.Alert,"infoColor",P(_e,f.info.light,.6)),L(f.Alert,"successColor",P(_e,f.success.light,.6)),L(f.Alert,"warningColor",P(_e,f.warning.light,.6)),L(f.Alert,"errorFilledBg",w("palette-error-dark")),L(f.Alert,"infoFilledBg",w("palette-info-dark")),L(f.Alert,"successFilledBg",w("palette-success-dark")),L(f.Alert,"warningFilledBg",w("palette-warning-dark")),L(f.Alert,"errorFilledColor",Yt(()=>f.getContrastText(f.error.dark))),L(f.Alert,"infoFilledColor",Yt(()=>f.getContrastText(f.info.dark))),L(f.Alert,"successFilledColor",Yt(()=>f.getContrastText(f.success.dark))),L(f.Alert,"warningFilledColor",Yt(()=>f.getContrastText(f.warning.dark))),L(f.Alert,"errorStandardBg",P(De,f.error.light,.9)),L(f.Alert,"infoStandardBg",P(De,f.info.light,.9)),L(f.Alert,"successStandardBg",P(De,f.success.light,.9)),L(f.Alert,"warningStandardBg",P(De,f.warning.light,.9)),L(f.Alert,"errorIconColor",w("palette-error-main")),L(f.Alert,"infoIconColor",w("palette-info-main")),L(f.Alert,"successIconColor",w("palette-success-main")),L(f.Alert,"warningIconColor",w("palette-warning-main")),L(f.AppBar,"defaultBg",w("palette-grey-900")),L(f.AppBar,"darkBg",w("palette-background-paper")),L(f.AppBar,"darkColor",w("palette-text-primary")),L(f.Avatar,"defaultBg",w("palette-grey-600")),L(f.Button,"inheritContainedBg",w("palette-grey-800")),L(f.Button,"inheritContainedHoverBg",w("palette-grey-700")),L(f.Chip,"defaultBorder",w("palette-grey-700")),L(f.Chip,"defaultAvatarColor",w("palette-grey-300")),L(f.Chip,"defaultIconColor",w("palette-grey-300")),L(f.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),L(f.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),L(f.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),L(f.LinearProgress,"primaryBg",P(De,f.primary.main,.5)),L(f.LinearProgress,"secondaryBg",P(De,f.secondary.main,.5)),L(f.LinearProgress,"errorBg",P(De,f.error.main,.5)),L(f.LinearProgress,"infoBg",P(De,f.info.main,.5)),L(f.LinearProgress,"successBg",P(De,f.success.main,.5)),L(f.LinearProgress,"warningBg",P(De,f.warning.main,.5)),L(f.Skeleton,"bg",T?P(Dr,f.text.primary,.13):`rgba(${w("palette-text-primaryChannel")} / 0.13)`),L(f.Slider,"primaryTrack",P(De,f.primary.main,.5)),L(f.Slider,"secondaryTrack",P(De,f.secondary.main,.5)),L(f.Slider,"errorTrack",P(De,f.error.main,.5)),L(f.Slider,"infoTrack",P(De,f.info.main,.5)),L(f.Slider,"successTrack",P(De,f.success.main,.5)),L(f.Slider,"warningTrack",P(De,f.warning.main,.5));const te=T?P(_e,f.background.default,.985):Xo(f.background.default,.98);L(f.SnackbarContent,"bg",te),L(f.SnackbarContent,"color",Yt(()=>T?Ks.text.primary:f.getContrastText(te))),L(f.SpeedDialAction,"fabHoverBg",Xo(f.background.paper,.15)),L(f.StepConnector,"border",w("palette-grey-600")),L(f.StepContent,"border",w("palette-grey-600")),L(f.Switch,"defaultColor",w("palette-grey-300")),L(f.Switch,"defaultDisabledColor",w("palette-grey-600")),L(f.Switch,"primaryDisabledColor",P(De,f.primary.main,.55)),L(f.Switch,"secondaryDisabledColor",P(De,f.secondary.main,.55)),L(f.Switch,"errorDisabledColor",P(De,f.error.main,.55)),L(f.Switch,"infoDisabledColor",P(De,f.info.main,.55)),L(f.Switch,"successDisabledColor",P(De,f.success.main,.55)),L(f.Switch,"warningDisabledColor",P(De,f.warning.main,.55)),L(f.TableCell,"border",P(De,P(Dr,f.divider,1),.68)),L(f.Tooltip,"bg",P(Dr,f.grey[700],.92))}nr(f.background,"default"),nr(f.background,"paper"),nr(f.common,"background"),nr(f.common,"onBackground"),nr(f,"divider"),Object.keys(f).forEach(te=>{const d=f[te];te!=="tonalOffset"&&d&&typeof d=="object"&&(d.main&&L(f[te],"mainChannel",jo(ko(d.main))),d.light&&L(f[te],"lightChannel",jo(ko(d.light))),d.dark&&L(f[te],"darkChannel",jo(ko(d.dark))),d.contrastText&&L(f[te],"contrastTextChannel",jo(ko(d.contrastText))),te==="text"&&(nr(f[te],"primary"),nr(f[te],"secondary")),te==="action"&&(d.active&&nr(f[te],"active"),d.selected&&nr(f[te],"selected")))})}),R=r.reduce((I,f)=>vt(I,f),R);const H={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Kd(R),enableContrastVars:c},{vars:E,generateThemeVars:Y,generateStyleSheets:Z}=bd(R,H);return R.vars=E,Object.entries(R.colorSchemes[R.defaultColorScheme]).forEach(([I,f])=>{R[I]=f}),R.generateThemeVars=Y,R.generateStyleSheets=Z,R.generateSpacing=function(){return Gs(g.spacing,Si(this))},R.getColorSchemeSelector=vd(u),R.spacing=R.generateSpacing(),R.shouldSkipGeneratingVar=l,R.unstable_sxConfig={...wn,...g==null?void 0:g.unstable_sxConfig},R.unstable_sx=function(f){return jn({sx:f,theme:this})},R.toRuntimeSource=Qs,R}function ms(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:ji({...n===!0?{}:n.palette,mode:r})})}function tu(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:a=n==null?void 0:n.mode,...c}=e,l=a||"light",u=s==null?void 0:s[l],y={...s,...n?{[l]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return ci(e,...r);let g=n;"palette"in e||y[l]&&(y[l]!==!0?g=y[l].palette:l==="dark"&&(g={mode:"dark"}));const m=ci({...e,palette:g},...r);return m.defaultColorScheme=l,m.colorSchemes=y,m.palette.mode==="light"&&(m.colorSchemes.light={...y.light!==!0&&y.light,palette:m.palette},ms(m,"dark",y.dark)),m.palette.mode==="dark"&&(m.colorSchemes.dark={...y.dark!==!0&&y.dark,palette:m.palette},ms(m,"light",y.light)),m}return!n&&!("light"in y)&&l==="light"&&(y.light=!0),eu({...c,colorSchemes:y,defaultColorScheme:l,...typeof i!="boolean"&&i},...r)}const ru=tu();function ht(){const e=ad(ru);return process.env.NODE_ENV!=="production"&&dn.useDebugValue(e),e[Kl]||e}async function ou(e,r,n){try{new URL(e)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};r&&(i.Authorization=`Bearer ${r}`);const s=new AbortController,a=setTimeout(()=>s.abort(),3e4);let c;try{c=await fetch(e,{headers:i,signal:s.signal})}catch(y){throw clearTimeout(a),(y==null?void 0:y.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(a)}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 g=["data","results","items","records"].find(m=>l[m]&&Array.isArray(l[m]));if(g)u=l[g];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:e,fetchedAt:new Date().toISOString()}}function nu(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${$(e.palette.common.black,n.opacity)}`).join(", ")}const iu={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 ve(e,r){return nu(e,iu[r])}function ot(e){return`${Number(e.shape.borderRadius)*1.5}px`}function Mo(e){return`${Number(e.shape.borderRadius)}px`}function fs(e){const r=e.tokens;return{containerPad:`${(r==null?void 0:r.containerPad)??16}px`,cardGap:`${(r==null?void 0:r.cardGap)??12}px`}}function ct(e){const r=e.tokens,n=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:n,bg:`var(--highlight-bg, ${$(n,.08)})`,hoverBg:`var(--highlight-hover, ${$(n,.12)})`}}function de(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||ve(e,r),border:n!=null&&n.cardBodyBorder&&n.cardBodyBorder!=="none"?n.cardBodyBorder:"none"},header:{backgroundColor:(n==null?void 0:n.cardHdrBg)||"transparent",borderBottom:(n==null?void 0:n.cardHdrBorder)||"none",boxShadow:(n==null?void 0:n.cardHdrAccent)||"none"}}}function su({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,c]=p.useState(""),[l,u]=p.useState(!1),[y,g]=p.useState(""),[m,S]=p.useState(null),[C,D]=p.useState(null),[v,x]=p.useState(!1),[B,h]=p.useState(""),k=p.useRef(null),[T,b]=p.useState("json"),[R,H]=p.useState(""),[E,Y]=p.useState(""),[Z,I]=p.useState(""),[f,w]=p.useState("idle"),[P,te]=p.useState(""),[d,J]=p.useState(null),[re,we]=p.useState(0),F=async W=>{if(h(""),!W.name.endsWith(".json")){h("Only .json files are allowed");return}const ie=10*1024*1024;if(W.size>ie){h("File size exceeds 10MB limit");return}try{const U=await W.text();let ne;try{ne=JSON.parse(U)}catch{h("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ne)){h("JSON must be an array of objects");return}if(ne.length===0){h("No data rows found in JSON file");return}S(W),D(ne)}catch{h("Network error — please try again")}},X=W=>{W.preventDefault();const ie=W.dataTransfer.files[0];ie&&F(ie)},ue=async()=>{if(R.trim()){w("loading"),te("");try{const W=await ou(R.trim(),E.trim()||void 0,Z.trim()||void 0);J(W.data),we(W.data.length),w("ready")}catch(W){te((W==null?void 0:W.message)||"Connection failed"),w("error")}}},pe=()=>{if(!a.trim()){u(!0);return}const W=T==="api"?d:i||C;W&&(n(a.trim(),y.trim(),W),K())},K=()=>{c(""),u(!1),g(""),S(null),D(null),h(""),b("json"),H(""),Y(""),I(""),w("idle"),te(""),J(null),we(0),r()},he=i||C,le=l&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:K,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:W=>({borderRadius:ot(W),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...de(W).paper})},children:[t.jsxs(o.DialogTitle,{sx:W=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:ie=>ie.typography.h6.fontWeight||500,fontSize:ie=>ie.typography.h6.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...de(W).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:K,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsx(o.DialogContent,{sx:{px:3,pt:2,pb:2,overflowY:"auto"},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[t.jsx(o.TextField,{label:"Report name",required:!0,fullWidth:!0,value:a,onChange:W=>{c(W.target.value),l&&W.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:le,helperText:le?"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}}}}),t.jsx(o.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:y,onChange:W=>g(W.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}}}}),t.jsxs(o.Tabs,{value:T==="json"?0:1,onChange:(W,ie)=>{b(ie===0?"json":"api"),w("idle"),te("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40,"& .MuiTabs-indicator":{height:3,bgcolor:"primary.main"}},children:[t.jsx(o.Tab,{label:"Upload JSON",icon:t.jsx(O.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:W=>`var(--highlight-hover, ${$(W.palette.primary.main,.15)})`},"&:hover":{bgcolor:W=>`var(--highlight-hover, ${$(W.palette.primary.main,.08)})`}}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx(O.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:W=>`var(--highlight-hover, ${$(W.palette.primary.main,.15)})`},"&:hover":{bgcolor:W=>`var(--highlight-hover, ${$(W.palette.primary.main,.08)})`}}})]}),T==="json"&&t.jsx(o.Box,{children:i?t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:W=>$(W.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:W=>$(W.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),t.jsx(o.IconButton,{size:"small",onClick:()=>x(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(O.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:X,onDragOver:W=>W.preventDefault(),onPaste:W=>W.preventDefault(),onClick:()=>{var W;return(W=k.current)==null?void 0:W.click()},sx:{position:"relative",border:"1.5px",borderStyle:C?"solid":"dashed",borderColor:C?"success.main":B?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:C?W=>$(W.palette.success.main,.04):B?W=>$(W.palette.error.main,.04):W=>$(W.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:C?W=>$(W.palette.success.main,.08):B?W=>$(W.palette.error.main,.08):W=>$(W.palette.primary.main,.08),borderColor:C?"success.dark":B?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:k,type:"file",accept:".json",sx:{display:"none"},onChange:W=>{var ie;return((ie=W.target.files)==null?void 0:ie[0])&&F(W.target.files[0])}}),C?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:W=>$(W.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx(O.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:m==null?void 0:m.name}),t.jsx(o.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):t.jsxs(o.Box,{children:[t.jsx(o.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:W=>$(W.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx(O.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),B&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:W=>$(W.palette.error.main,.08),border:1,borderColor:W=>$(W.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:B})})]})]})]})}),T==="api"&&t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(o.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:R,onChange:W=>{H(W.target.value),w("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}}}}),t.jsx(o.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:E,onChange:W=>Y(W.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(O.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}}}}),t.jsx(o.TextField,{label:"Response data path (optional)",fullWidth:!0,size:"small",value:Z,onChange:W=>I(W.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}}}),t.jsx(o.Button,{variant:"outlined",fullWidth:!0,disabled:!R.trim()||f==="loading",onClick:ue,startIcon:f==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx(O.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:W=>$(W.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:f==="loading"?"Connecting...":"Test Connection & Load Data"}),f==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:W=>$(W.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(O.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[re.toLocaleString()," records loaded — ready to create"]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:R})]})]}),f==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:W=>$(W.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(O.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:P})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:K,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:W=>`${W.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:W=>$(W.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:pe,disabled:T==="json"&&!he||T==="api"&&f!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:W=>`${W.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:v,onClose:()=>x(!1),maxWidth:"sm",PaperProps:{sx:W=>({borderRadius:3,width:560,maxHeight:"80vh",...de(W).paper})},children:[t.jsxs(o.DialogTitle,{sx:W=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...de(W).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>x(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{sx:{px:3,py:2},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),t.jsx(o.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
169
+ export default theme;`}function fs(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Ud=e=>{if(!Number.isNaN(+e))return+e;const r=e.match(/\d*\.?\d+/g);if(!r)return 0;let n=0;for(let i=0;i<r.length;i+=1)n+=+r[i];return n};function Gd(e){Object.assign(e,{alpha(r,n){const i=this||e;return i.colorSpace?`oklch(from ${r} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${r.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:O(r,Ud(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${fs(n)})`:In(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${fs(n)})`:Tn(r,n)}})}function di(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:d={},typography:l={},shape:u,colorSpace:x,...g}=e;if(e.vars&&e.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.":Mr(20));const m=ki({...a,colorSpace:x}),C=Js(e);let S=Ct(C,{mixins:_d(C.breakpoints,i),palette:m,shadows:Rd.slice(),typography:Od(m,l),transitions:Fd(d),zIndex:{...Vd}});if(S=Ct(S,g),S=r.reduce((E,v)=>Ct(E,v),S),process.env.NODE_ENV!=="production"){const E=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],v=(y,k)=>{let h;for(h in y){const j=y[h];if(E.includes(h)&&Object.keys(j).length>0){if(process.env.NODE_ENV!=="production"){const T=hd("",h);console.error([`MUI: The \`${k}\` component increases the CSS specificity of the \`${h}\` internal state.`,"You can not override it like this: ",JSON.stringify(y,null,2),"",`Instead, you need to use the '&.${T}' syntax:`,JSON.stringify({root:{[`&.${T}`]:j}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
+ `))}y[h]={}}}};Object.keys(S.components).forEach(y=>{const k=S.components[y].styleOverrides;k&&y.startsWith("Mui")&&v(k,y)})}return S.unstable_sxConfig={...kn,...g==null?void 0:g.unstable_sxConfig},S.unstable_sx=function(v){return zn({sx:v,theme:this})},S.toRuntimeSource=ea,Gd(S),S}function Yd(e){let r;return e<1?r=5.11916*e**2:r=4.5*Math.log(e+1)+2,Math.round(r*10)/1e3}const qd=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Yd(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function ta(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function ra(e){return e==="dark"?qd:[]}function Jd(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...a}=e,d=ki({...r,colorSpace:s});return{palette:d,opacity:{...ta(d.mode),...n},overlays:i||ra(d.mode),...a}}function Kd(e){var r;return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]==="palette"&&!!((r=e[1])!=null&&r.match(/(mode|contrastThreshold|tonalOffset)/))}const Xd=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Qd=e=>(r,n)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const d={};return Xd(e.cssVarPrefix).forEach(l=>{d[l]=n[l],delete n[l]}),a==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:d}}:a?{[a.replace("%s",r)]:d,[`${i}, ${a.replace("%s",r)}`]:n}:{[i]:{...n,...d}}}if(a&&a!=="media")return`${i}, ${a.replace("%s",String(r))}`}else if(r){if(a==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(a)return a.replace("%s",String(r))}return i};function Zd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function L(e,r,n){!e[r]&&n&&(e[r]=n)}function Bo(e){return typeof e!="string"||!e.startsWith("hsl")?e:Ks(e)}function or(e,r){`${r}Channel`in e||(e[`${r}Channel`]=zo(Bo(e[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
171
+ To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function eu(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Yt=e=>{try{return e()}catch{}},tu=(e="mui")=>yd(e);function oi(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Jd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:d,...l}=di({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:d,opacity:{...ta(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||ra(a)},l}function ru(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:d=!1,shouldSkipGeneratingVar:l=Kd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:x=":root",...g}=e,m=Object.keys(n)[0],C=i||(n.light&&m!=="light"?"light":m),S=tu(a),{[C]:E,light:v,dark:y,...k}=n,h={...k};let j=E;if((C==="dark"&&!("dark"in n)||C==="light"&&!("light"in n))&&(j=!0),!j)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${C}\` option is either missing or invalid.`:Mr(21,C));let T;d&&(T="oklch");const b=oi(T,h,j,g,C);v&&!h.light&&oi(T,h,v,void 0,"light"),y&&!h.dark&&oi(T,h,y,void 0,"dark");let R={defaultColorScheme:C,...b,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:x,getCssVar:S,colorSchemes:h,font:{...Dd(b.typography),...b.font},spacing:eu(g.spacing)};Object.keys(R.colorSchemes).forEach(B=>{const f=R.colorSchemes[B].palette,$=ee=>{const oe=ee.split("-"),c=oe[1],re=oe[2];return S(ee,f[c][re])};f.mode==="light"&&(L(f.common,"background","#fff"),L(f.common,"onBackground","#000")),f.mode==="dark"&&(L(f.common,"background","#000"),L(f.common,"onBackground","#fff"));function D(ee,oe,c){if(T){let re;return ee===_r&&(re=`transparent ${((1-c)*100).toFixed(0)}%`),ee===Ie&&(re=`#000 ${(c*100).toFixed(0)}%`),ee===Ee&&(re=`#fff ${(c*100).toFixed(0)}%`),`color-mix(in ${T}, ${oe}, ${re})`}return ee(oe,c)}if(Zd(f,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),f.mode==="light"){L(f.Alert,"errorColor",D(Ie,f.error.light,.6)),L(f.Alert,"infoColor",D(Ie,f.info.light,.6)),L(f.Alert,"successColor",D(Ie,f.success.light,.6)),L(f.Alert,"warningColor",D(Ie,f.warning.light,.6)),L(f.Alert,"errorFilledBg",$("palette-error-main")),L(f.Alert,"infoFilledBg",$("palette-info-main")),L(f.Alert,"successFilledBg",$("palette-success-main")),L(f.Alert,"warningFilledBg",$("palette-warning-main")),L(f.Alert,"errorFilledColor",Yt(()=>f.getContrastText(f.error.main))),L(f.Alert,"infoFilledColor",Yt(()=>f.getContrastText(f.info.main))),L(f.Alert,"successFilledColor",Yt(()=>f.getContrastText(f.success.main))),L(f.Alert,"warningFilledColor",Yt(()=>f.getContrastText(f.warning.main))),L(f.Alert,"errorStandardBg",D(Ee,f.error.light,.9)),L(f.Alert,"infoStandardBg",D(Ee,f.info.light,.9)),L(f.Alert,"successStandardBg",D(Ee,f.success.light,.9)),L(f.Alert,"warningStandardBg",D(Ee,f.warning.light,.9)),L(f.Alert,"errorIconColor",$("palette-error-main")),L(f.Alert,"infoIconColor",$("palette-info-main")),L(f.Alert,"successIconColor",$("palette-success-main")),L(f.Alert,"warningIconColor",$("palette-warning-main")),L(f.AppBar,"defaultBg",$("palette-grey-100")),L(f.Avatar,"defaultBg",$("palette-grey-400")),L(f.Button,"inheritContainedBg",$("palette-grey-300")),L(f.Button,"inheritContainedHoverBg",$("palette-grey-A100")),L(f.Chip,"defaultBorder",$("palette-grey-400")),L(f.Chip,"defaultAvatarColor",$("palette-grey-700")),L(f.Chip,"defaultIconColor",$("palette-grey-700")),L(f.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),L(f.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),L(f.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),L(f.LinearProgress,"primaryBg",D(Ee,f.primary.main,.62)),L(f.LinearProgress,"secondaryBg",D(Ee,f.secondary.main,.62)),L(f.LinearProgress,"errorBg",D(Ee,f.error.main,.62)),L(f.LinearProgress,"infoBg",D(Ee,f.info.main,.62)),L(f.LinearProgress,"successBg",D(Ee,f.success.main,.62)),L(f.LinearProgress,"warningBg",D(Ee,f.warning.main,.62)),L(f.Skeleton,"bg",T?D(_r,f.text.primary,.11):`rgba(${$("palette-text-primaryChannel")} / 0.11)`),L(f.Slider,"primaryTrack",D(Ee,f.primary.main,.62)),L(f.Slider,"secondaryTrack",D(Ee,f.secondary.main,.62)),L(f.Slider,"errorTrack",D(Ee,f.error.main,.62)),L(f.Slider,"infoTrack",D(Ee,f.info.main,.62)),L(f.Slider,"successTrack",D(Ee,f.success.main,.62)),L(f.Slider,"warningTrack",D(Ee,f.warning.main,.62));const ee=T?D(Ie,f.background.default,.6825):Zo(f.background.default,.8);L(f.SnackbarContent,"bg",ee),L(f.SnackbarContent,"color",Yt(()=>T?ci.text.primary:f.getContrastText(ee))),L(f.SpeedDialAction,"fabHoverBg",Zo(f.background.paper,.15)),L(f.StepConnector,"border",$("palette-grey-400")),L(f.StepContent,"border",$("palette-grey-400")),L(f.Switch,"defaultColor",$("palette-common-white")),L(f.Switch,"defaultDisabledColor",$("palette-grey-100")),L(f.Switch,"primaryDisabledColor",D(Ee,f.primary.main,.62)),L(f.Switch,"secondaryDisabledColor",D(Ee,f.secondary.main,.62)),L(f.Switch,"errorDisabledColor",D(Ee,f.error.main,.62)),L(f.Switch,"infoDisabledColor",D(Ee,f.info.main,.62)),L(f.Switch,"successDisabledColor",D(Ee,f.success.main,.62)),L(f.Switch,"warningDisabledColor",D(Ee,f.warning.main,.62)),L(f.TableCell,"border",D(Ee,D(_r,f.divider,1),.88)),L(f.Tooltip,"bg",D(_r,f.grey[700],.92))}if(f.mode==="dark"){L(f.Alert,"errorColor",D(Ee,f.error.light,.6)),L(f.Alert,"infoColor",D(Ee,f.info.light,.6)),L(f.Alert,"successColor",D(Ee,f.success.light,.6)),L(f.Alert,"warningColor",D(Ee,f.warning.light,.6)),L(f.Alert,"errorFilledBg",$("palette-error-dark")),L(f.Alert,"infoFilledBg",$("palette-info-dark")),L(f.Alert,"successFilledBg",$("palette-success-dark")),L(f.Alert,"warningFilledBg",$("palette-warning-dark")),L(f.Alert,"errorFilledColor",Yt(()=>f.getContrastText(f.error.dark))),L(f.Alert,"infoFilledColor",Yt(()=>f.getContrastText(f.info.dark))),L(f.Alert,"successFilledColor",Yt(()=>f.getContrastText(f.success.dark))),L(f.Alert,"warningFilledColor",Yt(()=>f.getContrastText(f.warning.dark))),L(f.Alert,"errorStandardBg",D(Ie,f.error.light,.9)),L(f.Alert,"infoStandardBg",D(Ie,f.info.light,.9)),L(f.Alert,"successStandardBg",D(Ie,f.success.light,.9)),L(f.Alert,"warningStandardBg",D(Ie,f.warning.light,.9)),L(f.Alert,"errorIconColor",$("palette-error-main")),L(f.Alert,"infoIconColor",$("palette-info-main")),L(f.Alert,"successIconColor",$("palette-success-main")),L(f.Alert,"warningIconColor",$("palette-warning-main")),L(f.AppBar,"defaultBg",$("palette-grey-900")),L(f.AppBar,"darkBg",$("palette-background-paper")),L(f.AppBar,"darkColor",$("palette-text-primary")),L(f.Avatar,"defaultBg",$("palette-grey-600")),L(f.Button,"inheritContainedBg",$("palette-grey-800")),L(f.Button,"inheritContainedHoverBg",$("palette-grey-700")),L(f.Chip,"defaultBorder",$("palette-grey-700")),L(f.Chip,"defaultAvatarColor",$("palette-grey-300")),L(f.Chip,"defaultIconColor",$("palette-grey-300")),L(f.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),L(f.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),L(f.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),L(f.LinearProgress,"primaryBg",D(Ie,f.primary.main,.5)),L(f.LinearProgress,"secondaryBg",D(Ie,f.secondary.main,.5)),L(f.LinearProgress,"errorBg",D(Ie,f.error.main,.5)),L(f.LinearProgress,"infoBg",D(Ie,f.info.main,.5)),L(f.LinearProgress,"successBg",D(Ie,f.success.main,.5)),L(f.LinearProgress,"warningBg",D(Ie,f.warning.main,.5)),L(f.Skeleton,"bg",T?D(_r,f.text.primary,.13):`rgba(${$("palette-text-primaryChannel")} / 0.13)`),L(f.Slider,"primaryTrack",D(Ie,f.primary.main,.5)),L(f.Slider,"secondaryTrack",D(Ie,f.secondary.main,.5)),L(f.Slider,"errorTrack",D(Ie,f.error.main,.5)),L(f.Slider,"infoTrack",D(Ie,f.info.main,.5)),L(f.Slider,"successTrack",D(Ie,f.success.main,.5)),L(f.Slider,"warningTrack",D(Ie,f.warning.main,.5));const ee=T?D(Ee,f.background.default,.985):Zo(f.background.default,.98);L(f.SnackbarContent,"bg",ee),L(f.SnackbarContent,"color",Yt(()=>T?Qs.text.primary:f.getContrastText(ee))),L(f.SpeedDialAction,"fabHoverBg",Zo(f.background.paper,.15)),L(f.StepConnector,"border",$("palette-grey-600")),L(f.StepContent,"border",$("palette-grey-600")),L(f.Switch,"defaultColor",$("palette-grey-300")),L(f.Switch,"defaultDisabledColor",$("palette-grey-600")),L(f.Switch,"primaryDisabledColor",D(Ie,f.primary.main,.55)),L(f.Switch,"secondaryDisabledColor",D(Ie,f.secondary.main,.55)),L(f.Switch,"errorDisabledColor",D(Ie,f.error.main,.55)),L(f.Switch,"infoDisabledColor",D(Ie,f.info.main,.55)),L(f.Switch,"successDisabledColor",D(Ie,f.success.main,.55)),L(f.Switch,"warningDisabledColor",D(Ie,f.warning.main,.55)),L(f.TableCell,"border",D(Ie,D(_r,f.divider,1),.68)),L(f.Tooltip,"bg",D(_r,f.grey[700],.92))}or(f.background,"default"),or(f.background,"paper"),or(f.common,"background"),or(f.common,"onBackground"),or(f,"divider"),Object.keys(f).forEach(ee=>{const oe=f[ee];ee!=="tonalOffset"&&oe&&typeof oe=="object"&&(oe.main&&L(f[ee],"mainChannel",zo(Bo(oe.main))),oe.light&&L(f[ee],"lightChannel",zo(Bo(oe.light))),oe.dark&&L(f[ee],"darkChannel",zo(Bo(oe.dark))),oe.contrastText&&L(f[ee],"contrastTextChannel",zo(Bo(oe.contrastText))),ee==="text"&&(or(f[ee],"primary"),or(f[ee],"secondary")),ee==="action"&&(oe.active&&or(f[ee],"active"),oe.selected&&or(f[ee],"selected")))})}),R=r.reduce((B,f)=>Ct(B,f),R);const H={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Qd(R),enableContrastVars:d},{vars:I,generateThemeVars:J,generateStyleSheets:Z}=Sd(R,H);return R.vars=I,Object.entries(R.colorSchemes[R.defaultColorScheme]).forEach(([B,f])=>{R[B]=f}),R.generateThemeVars=J,R.generateStyleSheets=Z,R.generateSpacing=function(){return qs(g.spacing,Ci(this))},R.getColorSchemeSelector=Cd(u),R.spacing=R.generateSpacing(),R.shouldSkipGeneratingVar=l,R.unstable_sxConfig={...kn,...g==null?void 0:g.unstable_sxConfig},R.unstable_sx=function(f){return zn({sx:f,theme:this})},R.toRuntimeSource=ea,R}function xs(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:ki({...n===!0?{}:n.palette,mode:r})})}function ou(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:a=n==null?void 0:n.mode,...d}=e,l=a||"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 e))return di(e,...r);let g=n;"palette"in e||x[l]&&(x[l]!==!0?g=x[l].palette:l==="dark"&&(g={mode:"dark"}));const m=di({...e,palette:g},...r);return m.defaultColorScheme=l,m.colorSchemes=x,m.palette.mode==="light"&&(m.colorSchemes.light={...x.light!==!0&&x.light,palette:m.palette},xs(m,"dark",x.dark)),m.palette.mode==="dark"&&(m.colorSchemes.dark={...x.dark!==!0&&x.dark,palette:m.palette},xs(m,"light",x.light)),m}return!n&&!("light"in x)&&l==="light"&&(x.light=!0),ru({...d,colorSchemes:x,defaultColorScheme:l,...typeof i!="boolean"&&i},...r)}const nu=ou();function gt(){const e=cd(nu);return process.env.NODE_ENV!=="production"&&pn.useDebugValue(e),e[Ql]||e}async function iu(e,r,n){try{new URL(e)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};r&&(i.Authorization=`Bearer ${r}`);const s=new AbortController,a=setTimeout(()=>s.abort(),3e4);let d;try{d=await fetch(e,{headers:i,signal:s.signal})}catch(x){throw clearTimeout(a),(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(a)}if(d.status===401)throw new Error("Authentication failed (401) — check your API key");if(!d.ok)throw new Error(`API error ${d.status}: ${d.statusText}`);let l;try{l=await d.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 g=["data","results","items","records"].find(m=>l[m]&&Array.isArray(l[m]));if(g)u=l[g];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:e,fetchedAt:new Date().toISOString()}}function su(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${O(e.palette.common.black,n.opacity)}`).join(", ")}const au={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 be(e,r){return su(e,au[r])}function nt(e){return`${Number(e.shape.borderRadius)*1.5}px`}function Wo(e){return`${Number(e.shape.borderRadius)}px`}function gs(e){const r=e.tokens;return{containerPad:`${(r==null?void 0:r.containerPad)??16}px`,cardGap:`${(r==null?void 0:r.cardGap)??12}px`}}function ot(e){const r=e.tokens,n=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:n,bg:`var(--highlight-bg, ${O(n,.08)})`,hoverBg:`var(--highlight-hover, ${O(n,.12)})`}}function ce(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||be(e,r),border:n!=null&&n.cardBodyBorder&&n.cardBodyBorder!=="none"?n.cardBodyBorder:"none"},header:{backgroundColor:(n==null?void 0:n.cardHdrBg)||"transparent",borderBottom:(n==null?void 0:n.cardHdrBorder)||"none",boxShadow:(n==null?void 0:n.cardHdrAccent)||"none"}}}function lu({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,d]=p.useState(""),[l,u]=p.useState(!1),[x,g]=p.useState(""),[m,C]=p.useState(null),[S,E]=p.useState(null),[v,y]=p.useState(!1),[k,h]=p.useState(""),j=p.useRef(null),[T,b]=p.useState("json"),[R,H]=p.useState(""),[I,J]=p.useState(""),[Z,B]=p.useState(""),[f,$]=p.useState("idle"),[D,ee]=p.useState(""),[oe,c]=p.useState(null),[re,fe]=p.useState(0),U=async P=>{if(h(""),!P.name.endsWith(".json")){h("Only .json files are allowed");return}const se=10*1024*1024;if(P.size>se){h("File size exceeds 10MB limit");return}try{const G=await P.text();let ne;try{ne=JSON.parse(G)}catch{h("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ne)){h("JSON must be an array of objects");return}if(ne.length===0){h("No data rows found in JSON file");return}C(P),E(ne)}catch{h("Network error — please try again")}},K=P=>{P.preventDefault();const se=P.dataTransfer.files[0];se&&U(se)},de=async()=>{if(R.trim()){$("loading"),ee("");try{const P=await iu(R.trim(),I.trim()||void 0,Z.trim()||void 0);c(P.data),fe(P.data.length),$("ready")}catch(P){ee((P==null?void 0:P.message)||"Connection failed"),$("error")}}},ue=()=>{if(!a.trim()){u(!0);return}const P=T==="api"?oe:i||S;P&&(n(a.trim(),x.trim(),P),X())},X=()=>{d(""),u(!1),g(""),C(null),E(null),h(""),b("json"),H(""),J(""),B(""),$("idle"),ee(""),c(null),fe(0),r()},pe=i||S,le=l&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:X,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:P=>({borderRadius:nt(P),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...ce(P).paper})},children:[t.jsxs(o.DialogTitle,{sx:P=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:se=>se.typography.h6.fontWeight||500,fontSize:se=>se.typography.h6.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...ce(P).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:X,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:18}})})]}),t.jsx(o.DialogContent,{sx:{px:3,pt:2,pb:2,overflowY:"auto"},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[t.jsx(o.TextField,{label:"Report name",required:!0,fullWidth:!0,value:a,onChange:P=>{d(P.target.value),l&&P.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:le,helperText:le?"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}}}}),t.jsx(o.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:x,onChange:P=>g(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}}}}),t.jsxs(o.Tabs,{value:T==="json"?0:1,onChange:(P,se)=>{b(se===0?"json":"api"),$("idle"),ee("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40,"& .MuiTabs-indicator":{height:3,bgcolor:"primary.main"}},children:[t.jsx(o.Tab,{label:"Upload JSON",icon:t.jsx(M.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:P=>`var(--highlight-hover, ${O(P.palette.primary.main,.15)})`},"&:hover":{bgcolor:P=>`var(--highlight-hover, ${O(P.palette.primary.main,.08)})`}}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx(M.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:P=>`var(--highlight-hover, ${O(P.palette.primary.main,.15)})`},"&:hover":{bgcolor:P=>`var(--highlight-hover, ${O(P.palette.primary.main,.08)})`}}})]}),T==="json"&&t.jsx(o.Box,{children:i?t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:P=>O(P.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:P=>O(P.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(M.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),t.jsx(o.IconButton,{size:"small",onClick:()=>y(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(M.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:K,onDragOver:P=>P.preventDefault(),onPaste:P=>P.preventDefault(),onClick:()=>{var P;return(P=j.current)==null?void 0:P.click()},sx:{position:"relative",border:"1.5px",borderStyle:S?"solid":"dashed",borderColor:S?"success.main":k?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:S?P=>O(P.palette.success.main,.04):k?P=>O(P.palette.error.main,.04):P=>O(P.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:S?P=>O(P.palette.success.main,.08):k?P=>O(P.palette.error.main,.08):P=>O(P.palette.primary.main,.08),borderColor:S?"success.dark":k?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:j,type:"file",accept:".json",sx:{display:"none"},onChange:P=>{var se;return((se=P.target.files)==null?void 0:se[0])&&U(P.target.files[0])}}),S?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:P=>O(P.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx(M.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:m==null?void 0:m.name}),t.jsx(o.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):t.jsxs(o.Box,{children:[t.jsx(o.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:P=>O(P.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx(M.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),k&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:P=>O(P.palette.error.main,.08),border:1,borderColor:P=>O(P.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:k})})]})]})]})}),T==="api"&&t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(o.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:R,onChange:P=>{H(P.target.value),$("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}}}}),t.jsx(o.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:I,onChange:P=>J(P.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(M.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}}}}),t.jsx(o.TextField,{label:"Response data path (optional)",fullWidth:!0,size:"small",value:Z,onChange:P=>B(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}}}),t.jsx(o.Button,{variant:"outlined",fullWidth:!0,disabled:!R.trim()||f==="loading",onClick:de,startIcon:f==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx(M.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:P=>O(P.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:f==="loading"?"Connecting...":"Test Connection & Load Data"}),f==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:P=>O(P.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(M.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[re.toLocaleString()," records loaded — ready to create"]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:R})]})]}),f==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:P=>O(P.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(M.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:D})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:X,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:P=>O(P.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:ue,disabled:T==="json"&&!pe||T==="api"&&f!=="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"})]})]}),t.jsxs(o.Dialog,{open:v,onClose:()=>y(!1),maxWidth:"sm",PaperProps:{sx:P=>({borderRadius:3,width:560,maxHeight:"80vh",...ce(P).paper})},children:[t.jsxs(o.DialogTitle,{sx:P=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...ce(P).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>y(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{sx:{px:3,py:2},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),t.jsx(o.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
172
172
  {
173
173
  "id": 1,
174
174
  "customerName": "John Smith",
@@ -178,7 +178,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
178
178
  "memberSince": "2024-01-15",
179
179
  "status": "active"
180
180
  }
181
- ]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>x(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:W=>`${W.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function ta({isOpen:e,onClose:r,content:n}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:ot(i),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...de(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...de(i).header}),children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:n?typeof n=="string"?t.jsx(o.Typography,{variant:"body2",sx:{whiteSpace:"pre-wrap"},children:n}):n:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",t.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."]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
181
+ ]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>y(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function oa({isOpen:e,onClose:r,content:n}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:nt(i),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ce(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ce(i).header}),children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:n?typeof n=="string"?t.jsx(o.Typography,{variant:"body2",sx:{whiteSpace:"pre-wrap"},children:n}):n:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",t.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."]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
182
182
  {
183
183
  "Active Sessions": 33,
184
184
  "Active State": true,
@@ -188,10 +188,10 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
188
188
  "Region": "Europe",
189
189
  "Subscription Type": "Basic"
190
190
  }
191
- ]`})})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Number:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Boolean:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"String:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Date:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[t.jsx("li",{children:"Each object in the array represents one row in the report."}),t.jsx("li",{children:"The keys of the JSON objects become report columns."}),t.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),t.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,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=>ve(i,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:i=>ve(i,"hoverButton")},"&:active":{boxShadow:i=>ve(i,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function au({onFileUpload:e,onError:r,isUploading:n,jsonGuideContent:i}){const[s,a]=p.useState(!1),[c,l]=p.useState(""),[u,y]=p.useState(!1),g=p.useRef(null),m=async h=>{if(!h.name.endsWith(".json")){r("Only .json files are allowed");return}const k=10*1024*1024;if(h.size>k){r("File size exceeds 10MB limit");return}l(h.name);try{const T=await h.text();let b;try{b=JSON.parse(T)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(b)){r("JSON must be an array of objects");return}if(b.length===0){r("No data rows found in JSON file");return}e(b)}catch{r("Network error — please try again")}finally{l("")}},S=h=>{h.preventDefault(),a(!0)},C=h=>{h.preventDefault(),a(!1)},D=h=>{h.preventDefault(),a(!1);const k=h.dataTransfer.files[0];k&&m(k)},v=()=>{var h;(h=g.current)==null||h.click()},x=h=>{var T;const k=(T=h.target.files)==null?void 0:T[0];k&&m(k)},B=h=>{h.stopPropagation(),y(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:S,onDragLeave:C,onDrop:D,onPaste:h=>h.preventDefault(),onClick:v,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:s?"primary.main":"divider",bgcolor:s?h=>$(h.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:s?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:g,type:"file",accept:".json",onChange:x,sx:{display:"none"}}),n?t.jsxs(t.Fragment,{children:[t.jsx(o.CircularProgress,{size:32,sx:{mb:2}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||500,fontSize:h=>h.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),c&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:c})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:h=>$(h.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[t.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),t.jsx(o.IconButton,{onClick:B,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx(O.InfoOutlined,{sx:{fontSize:16}})})]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),t.jsx(ta,{isOpen:u,onClose:()=>y(!1),content:i})]})}function lu({schema:e,onConfirm:r,hasConflicts:n}){return t.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(o.Box,{sx:{mb:2},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1.25rem",mb:.5},children:"Schema Preview"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&t.jsxs(o.Alert,{severity:"warning",sx:{mb:2},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.subtitle2.fontSize||"0.875rem"},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),t.jsx(o.TableContainer,{sx:{mb:3},children:t.jsxs(o.Table,{children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:"action.hover"},children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),t.jsx(o.TableBody,{children:e.map(i=>t.jsxs(o.TableRow,{sx:{bgcolor:i.hasConflict?s=>$(s.palette.warning.main,.12):"transparent"},children:[t.jsxs(o.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&t.jsx(o.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(O.Lock,{sx:{fontSize:16}}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),t.jsx(o.Button,{variant:"contained",onClick:r,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function cu({error:e,onRetry:r}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>$(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>$(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:n=>n.typography.h6.fontWeight||600,fontSize:n=>n.typography.h6.fontSize||"1.25rem",mb:1},children:"Upload Failed"}),t.jsx(o.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:e}),t.jsx(o.Button,{variant:"contained",color:"error",startIcon:t.jsx(O.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function ra({title:e,description:r,showIcon:n=!0}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&t.jsx(o.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>$(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx(O.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:i=>i.typography.h5.fontWeight||500,mb:1,color:i=>i.typography.h5.color||"text.primary",fontSize:i=>i.typography.h5.fontSize||"1.125rem"},children:e}),t.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:i=>i.typography.body2.fontSize||"0.875rem",lineHeight:1.5},children:r})]})}function du({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:c}){const[l,u]=p.useState(!1),[y,g]=p.useState(!1),[m,S]=p.useState(-1),C=p.useRef(null),D=p.useRef(null);p.useEffect(()=>{function E(Y){C.current&&!C.current.contains(Y.target)&&(u(!1),g(!1))}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const v=p.useCallback(()=>{g(!0),S(-1),n.length>0&&u(!0)},[n.length]),x=p.useCallback(E=>{r(E),S(-1)},[r]),B=p.useCallback(E=>{var Y;r(E),i(E),u(!1),(Y=D.current)==null||Y.blur()},[r,i]),h=p.useCallback(E=>{S(-1),B(E)},[B]),k=p.useCallback(E=>{var Y;E.key==="Enter"?m>=0&&m<n.length?(E.preventDefault(),h(n[m].query)):e.trim()&&B(e.trim()):E.key==="Escape"?(u(!1),S(-1),(Y=D.current)==null||Y.blur()):E.key==="ArrowDown"?(E.preventDefault(),n.length>0&&(l||u(!0),S(Z=>Z<n.length-1?Z+1:Z))):E.key==="ArrowUp"&&(E.preventDefault(),S(Z=>Z>0?Z-1:-1))},[m,n,e,l,h,B]),T=p.useCallback(()=>{var E;r(""),(E=D.current)==null||E.focus()},[r]),b=p.useMemo(()=>n.filter(E=>E.isFavourite),[n]),R=p.useMemo(()=>n.filter(E=>!E.isFavourite),[n]),H=l&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:C,children:[t.jsx(o.TextField,{inputRef:D,size:"small",fullWidth:!0,value:e,onChange:E=>x(E.target.value),onFocus:v,onKeyDown:k,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:E=>$(E.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:E=>$(E.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:t.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx(O.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:T,edge:"end",sx:{mr:-.5},children:t.jsx(O.Close,{sx:{fontSize:16}})})}):null}}),H&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[b.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:E=>E.typography.caption.fontWeight||600,fontSize:E=>E.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),b.map((E,Y)=>t.jsx(xs,{entry:E,isSelected:m===Y,onClick:()=>h(E.query),onToggleFavourite:()=>s(E.query),onDelete:()=>a(E.query)},`fav-${E.query}`))]}),R.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[b.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:E=>E.typography.caption.fontWeight||600,fontSize:E=>E.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),R.map((E,Y)=>{const Z=b.length+Y;return t.jsx(xs,{entry:E,isSelected:m===Z,onClick:()=>h(E.query),onToggleFavourite:()=>s(E.query),onDelete:()=>a(E.query)},`recent-${E.query}`)})]})]})]})}const xs=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const c=p.useCallback(u=>{u.stopPropagation(),s()},[s]),l=p.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>$(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>$(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:c,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx(O.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx(O.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(o.IconButton,{size:"small",onClick:l,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(O.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function uu({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:c,onRestoreView:l,onPermanentDelete:u,onEditView:y,onCloneView:g,onCopyLink:m,onDeleteView:S,onPromoteToGlobal:C,onSetDefaultForAllUsers:D,isReadOnly:v,isAdmin:x=!1,hideViewMenuActions:B}){const h=ht(),[k,T]=p.useState(!1),[b,R]=p.useState(!1),[H,E]=p.useState({top:0,left:0}),[Y,Z]=p.useState(null),[I,f]=p.useState(null),w=p.useRef(null),P=p.useRef(null),te=e.find(U=>U.id===r),d=te==null?void 0:te.isDefault,J=(U,ne)=>U.name.localeCompare(ne.name),re=e.filter(U=>U.scope==="global"&&!U.isDeleted).sort(J),we=e.filter(U=>U.scope!=="global"&&!U.isDeleted).sort(J),F=e.filter(U=>U.isFavorite&&!U.isDeleted).sort(J),X=e.filter(U=>U.isDeleted);p.useEffect(()=>{if(k&&P.current){const U=P.current.getBoundingClientRect();E({top:U.bottom+window.scrollY+8,left:U.right+window.scrollX-320})}},[k]),p.useEffect(()=>{const U=ne=>{w.current&&!w.current.contains(ne.target)&&P.current&&!P.current.contains(ne.target)&&T(!1)};return k&&document.addEventListener("mousedown",U),()=>{document.removeEventListener("mousedown",U)}},[k]);const ue=U=>{if(n&&U!==r){Z(U),T(!1);return}i(U),T(!1)},pe=()=>{Y&&(i(Y),Z(null))},K=()=>{Z(null)},he=(U,ne=!1)=>{const Be=U.scope==="global",Q=!v&&(!Be||x),$e=x&&!Be;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===U.id?$(h.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===U.id?$(h.palette.primary.main,.12):h.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>ue(U.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:[r===U.id&&t.jsx(O.Check,{sx:{fontSize:16,flexShrink:0}}),r!==U.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===U.id?h.palette.primary.dark:h.palette.text.primary,fontWeight:r===U.id?Pe=>Pe.typography.body2.fontWeight||500:400,fontSize:Pe=>Pe.typography.body2.fontSize||"0.875rem"},children:U.name}),ne&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:h.palette.text.secondary,backgroundColor:h.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[Q&&c&&t.jsx(o.IconButton,{onClick:Pe=>{Pe.stopPropagation(),c(U.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:U.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(O.Star,{sx:{fontSize:16}})}),Q&&a&&!U.isDefault&&t.jsx(o.IconButton,{onClick:Pe=>{Pe.stopPropagation(),a(U.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Set as default",children:t.jsx(O.RadioButtonUnchecked,{sx:{fontSize:16}})}),(Q||$e)&&(y||g||m||S||$e&&C)&&t.jsx(o.IconButton,{onClick:Pe=>{Pe.stopPropagation(),f({el:Pe.currentTarget,view:U})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"More actions",children:t.jsx(O.MoreVert,{sx:{fontSize:16}})})]})]},U.id)},le=U=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:h.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:h.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:U.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[l&&t.jsx(o.IconButton,{onClick:ne=>{ne.stopPropagation(),l(U.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Restore view",children:t.jsx(O.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:ne=>{ne.stopPropagation(),u(U.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Delete permanently",children:t.jsx(O.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},U.id),W=n||!d,ie=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:P,onClick:()=>T(!k),variant:"outlined",size:"small",endIcon:t.jsx(O.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:W?"warning.main":"text.primary",borderColor:W?"warning.main":"divider",bgcolor:W?$(h.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:W?"warning.dark":"primary.main",bgcolor:W?$(h.palette.warning.main,.2):$(h.palette.text.primary,.06),color:W?"warning.dark":"text.primary"}},title:`View: ${(te==null?void 0:te.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(te==null?void 0:te.name)||"Default View"}),ie&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),k&&Bs.createPortal(t.jsxs(o.Box,{ref:w,sx:{position:"fixed",width:"320px",backgroundColor:h.palette.background.paper,border:`1px solid ${h.palette.divider}`,borderRadius:1,boxShadow:h.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:H.top,left:H.left},children:[re.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:U=>U.typography.caption.fontSize||"caption.fontSize",fontWeight:U=>U.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),re.map(U=>he(U,U.isDefault))]}),F.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(O.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),F.map(U=>he(U))]})]}),we.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:U=>U.typography.caption.fontSize||"caption.fontSize",fontWeight:U=>U.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),we.map(U=>he(U))]})]}),X.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>R(!b),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",X.length,")"]}),t.jsx(O.ChevronRight,{sx:{fontSize:16}})]}),b&&t.jsx(o.Box,{sx:{backgroundColor:h.palette.action.hover},children:X.map(U=>le(U))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),T(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:h.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsx(O.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!I,anchorEl:(I==null?void 0:I.el)||null,onClose:()=>f(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[y&&t.jsxs(o.MenuItem,{onClick:()=>{I&&y(I.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Edit,{sx:{fontSize:18}}),"Edit"]}),m&&t.jsxs(o.MenuItem,{onClick:()=>{I&&m(I.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Link,{sx:{fontSize:18}}),"Copy Link"]}),g&&t.jsxs(o.MenuItem,{onClick:()=>{I&&g(I.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),C&&x&&(I==null?void 0:I.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{I&&C(I.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Language,{sx:{fontSize:18}}),"Promote to Global"]}),D&&I&&!(B!=null&&B.includes("setDefaultForAllUsers"))?t.jsxs(o.MenuItem,{onClick:()=>{I&&D(I.view.id,!I.view.isDefaultForAllUsers),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(O.Star,{sx:{fontSize:18,color:I.view.isDefaultForAllUsers?"warning.main":"inherit"}}),I.view.isDefaultForAllUsers?"Remove from":"Set as"," Default for All Users"]}):null,S&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{I&&S(I.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx(O.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:Y!==null,onClose:K,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Mo(h)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx(O.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),t.jsx(o.DialogContent,{children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),t.jsxs(o.DialogActions,{sx:{px:3,pb:2,gap:1},children:[t.jsx(o.Button,{onClick:K,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:pe,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function pu({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:c=!1,position:l,onSortAscending:u,onSortDescending:y,onRemoveSort:g,onFilter:m,onClearFilter:S,onGroupByColumn:C,onHideColumn:D,onManageColumns:v,onResetLayout:x,onClose:B}){const h=ht(),k=h.palette,T=p.useRef(null);p.useEffect(()=>{if(!T.current)return;const Z=T.current,I=Z.getBoundingClientRect(),f=window.innerWidth,w=window.innerHeight;I.right>f-8&&(Z.style.left=`${f-I.width-8}px`),I.bottom>w-8&&(Z.style.top=`${w-I.height-8}px`)},[l]),p.useEffect(()=>{const Z=f=>{T.current&&!T.current.contains(f.target)&&B()},I=f=>{f.key==="Escape"&&B()};return document.addEventListener("mousedown",Z),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",I)}},[B]);const b=p.useCallback(Z=>()=>{Z(),B()},[B]),R=(n==null?void 0:n.direction)==="asc",H=(n==null?void 0:n.direction)==="desc",E=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",Y=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Bs.createPortal(t.jsxs(o.Paper,{ref:T,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:h.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:Mo(h),overflow:"hidden",boxShadow:`0 4px 20px ${$(k.common.black,.12)}, 0 1px 4px ${$(k.common.black,.06)}`},children:[!a&&t.jsxs(o.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(o.Typography,{sx:{fontSize:Z=>Z.typography.body2.fontSize||"0.8125rem",fontWeight:Z=>Z.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(o.Tooltip,{title:`Sort Ascending (${E})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:b(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?$(k.primary.main,.1):"transparent","&:hover":{bgcolor:$(k.primary.main,.08),color:"primary.main"}},children:t.jsx(O.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${Y})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:b(()=>y(e)),sx:{p:.625,borderRadius:"6px",color:H?"primary.main":"text.secondary",bgcolor:H?$(k.primary.main,.1):"transparent","&:hover":{bgcolor:$(k.primary.main,.08),color:"primary.main"}},children:t.jsx(O.ArrowDownward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:t.jsx("span",{children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:b(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(k.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx(O.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:b(()=>m(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!a&&t.jsxs(o.MenuItem,{onClick:b(()=>S(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(k.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!a&&C&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.25}}),t.jsx(o.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(o.MenuItem,{onClick:b(()=>C(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),t.jsx(o.Divider,{sx:{my:.25}}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[!a&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(o.MenuItem,{onClick:b(()=>D(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),t.jsx(o.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:b(v),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(k.primary.main,.08),color:"primary.main"}},children:t.jsx(O.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:b(v),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&c&&x&&t.jsxs(o.MenuItem,{onClick:b(x),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(k.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(O.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const hu=176,gs="COLUMN_HEADER",mu=p.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:c=!1,hasModifications:l=!1,width:u,onColumnClick:y,onMoveColumn:g,onColumnDragEnd:m,onResizeStart:S,onSortAscending:C,onSortDescending:D,onRemoveSort:v,onOpenFilterForColumn:x,onClearFiltersForColumn:B,onGroupByColumn:h,onHideColumn:k,onManageColumns:T,onResetLayout:b}){const H=ht().urmTable,E=p.useRef(null),[Y,Z]=p.useState(!1),[I,f]=p.useState({x:0,y:0}),[{handlerId:w,isOver:P},te]=ir.useDrop({accept:gs,collect(K){return{handlerId:K.getHandlerId(),isOver:K.isOver()}},hover(K,he){var Q;if(!E.current)return;const le=K.index,W=n;if(le===W)return;const ie=(Q=E.current)==null?void 0:Q.getBoundingClientRect(),U=(ie.right-ie.left)/2,ne=he.getClientOffset(),Be=((ne==null?void 0:ne.x)??0)-ie.left;le<W&&Be<U||le>W&&Be>U||(g(le,W),K.index=W)}}),[{isDragging:d},J]=ir.useDrag({type:gs,item:()=>({index:n,columnName:r.name}),collect:K=>({isDragging:K.isDragging()}),end:()=>{m==null||m()}});J(te(E));const re=p.useCallback(K=>{K.preventDefault(),K.stopPropagation(),f({x:K.clientX,y:K.clientY}),Z(!0)},[]),we=p.useCallback(()=>Z(!1),[]),F=p.useCallback(()=>{y(r.name)},[y,r.name]),X=p.useCallback(K=>{K.stopPropagation(),x(r.name)},[x,r.name]),ue=p.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx(O.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx(O.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),t.jsx(o.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]),pe=p.useCallback(()=>s?t.jsx(O.FilterList,{onClick:X,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,X]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:E,"data-handler-id":w,"data-column-index":n,onClick:F,onContextMenu:re,sx:{position:"sticky",top:0,zIndex:5,textAlign:(H==null?void 0:H.cellAlignH)??"left",verticalAlign:(H==null?void 0:H.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(H==null?void 0:H.headerColor)??"text.secondary",opacity:d?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:P?K=>$(K.palette.primary.main,.08):(H==null?void 0:H.headerBg)??"action.hover",boxShadow:K=>`0 1px 0 ${$(K.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(H==null?void 0:H.rowDivider)??"1px solid",borderRight:H==null?void 0:H.colDivider,borderColor:"divider",py:0,px:(H==null?void 0:H.cellPaddingX)??2,"&:hover":{bgcolor:K=>$(K.palette.primary.main,.1),color:"text.primary"},width:u?`${u}px`:`${hu}px`},children:[t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[dt(r.name),ue(),pe()]}),t.jsx(o.Box,{draggable:!1,onDragStart:K=>K.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:K=>{K.preventDefault(),K.stopPropagation(),S(K,r.name)},onClick:K=>K.stopPropagation(),children:t.jsx(o.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),P&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),Y&&t.jsx(pu,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:c,hasModifications:l,position:I,onSortAscending:C,onSortDescending:D,onRemoveSort:v,onFilter:x,onClearFilter:B,onGroupByColumn:h,onHideColumn:k,onManageColumns:T,onResetLayout:b,onClose:we})]})}),fu={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 cn(e,r){const n=fu[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.palette[n];return{bg:$(i.main,e.palette.mode==="dark"?.24:.12),color:e.palette.mode==="dark"?i.light:i.dark}}function xu(e,r){switch(r.toLowerCase().trim()){case"low":return e.palette.text.secondary;case"medium":return e.palette.warning.main;case"high":return e.palette.mode==="dark"?e.palette.warning.light:e.palette.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const gu={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"},rows:{hue:"primary",shade:"main"}};function ys(e,r){const n=gu[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function It(e){return $(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function yu(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>cn(n,r).bg,color:n=>cn(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function bu(e,r){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.875rem"},children:"—"});const n=String(r),i=e.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return yu(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:a=>{const c=xu(a,s);return c?{color:c,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:n})}return typeof r=="boolean"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:n})}function vu(e){const r=e.find(s=>{const a=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(a)})||e[0]||null,n=e.find(s=>{const a=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(a)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function Su({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:c,onOpenRowMenu:l,onToggleSelection:u,hideCheckbox:y}){const[g,m]=p.useState(!1),{primaryCol:S,idCol:C,bodyColumns:D}=p.useMemo(()=>vu(n),[n]),v=S?e[S.name]:null,x=C?e[C.name]:null,B=g||i;return t.jsxs(o.Box,{onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),onClick:h=>s(r,h),onDoubleClick:h=>a(e,r,h),onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),c(e,r,h)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:h=>{var T,b,R,H;const k=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.border;return i?"2px solid":k&&k!=="none"?k:"1px solid"},borderColor:i?h=>ct(h).main:h=>{var T,b,R,H;const k=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.border;return k&&k!=="none"?"inherit":$(h.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:h=>{var T,b,R,H;const k=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.borderRadius;return k!==void 0?typeof k=="number"?`${k}px`:k:`${h.shape.borderRadius}px`},cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?h=>`0 0 0 3px ${$(ct(h).main,.15)}, 0 2px 8px ${$(h.palette.common.black,.08)}`:g?h=>{var T,b,R,H;const k=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.boxShadow;return k&&k!=="none"?k:ve(h,"cardHover")}:h=>{var T,b,R,H;const k=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.boxShadow;return k&&k!=="none"?k:ve(h,"cardRest")},transform:g&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:h=>$(ct(h).main,.03)}},children:[t.jsxs(o.Box,{sx:h=>{var H,E,Y,Z;const k=((Y=(E=(H=h.components)==null?void 0:H.MuiCardHeader)==null?void 0:E.styleOverrides)==null?void 0:Y.root)||{},T=(k.backgroundColor&&k.backgroundColor!=="transparent"?k.backgroundColor:void 0)??((Z=h.tokens)==null?void 0:Z.cardHdrHex)??"transparent",b=k.borderBottom&&k.borderBottom!=="none"?k.borderBottom:void 0,R=k.boxShadow&&k.boxShadow!=="none"?k.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:T,borderBottom:b,boxShadow:R,display:"flex",alignItems:"center",gap:.5}},children:[!y&&B&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:h=>h.stopPropagation(),onChange:()=>u(e),sx:{p:.25}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||600,fontSize:h=>h.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:v!=null&&v!==""?String(v):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:h=>{var b,R,H;const k=((H=(R=(b=h.components)==null?void 0:b.MuiCardHeader)==null?void 0:R.styleOverrides)==null?void 0:H.root)||{};return k.borderBottom&&k.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[D.map(h=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:k=>k.typography.body2.fontWeight||500,fontSize:k=>k.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:dt(h.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[h.name]??""),children:bu(h,e[h.name])})]},h.name)),D.length===0&&t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]}),t.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:h=>$(h.palette.action.hover,.1),minHeight:40},children:[t.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:x?.85:0,userSelect:"none"},children:x?String(x):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:B?1:0,transition:"opacity 0.15s ease"},onClick:h=>h.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:h=>{h.stopPropagation(),l(e,r,h.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:h=>$(h.palette.text.primary,.08)}},children:t.jsx(O.MoreVert,{sx:{fontSize:17}})})})})]})]})}function Cu({row:e,grouping:r,onToggleCollapse:n}){var i;return t.jsxs(o.Box,{onClick:()=>n(e.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=>ve(s,"flatHover"),"&:hover":{bgcolor:s=>$(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx(O.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx(O.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:s=>s.typography.h5.fontWeight||600,color:s=>s.typography.h5.color||"text.primary"},children:Ja(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>$(s.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[e.rowCount," ",e.rowCount===1?"row":"rows"]}),Object.keys(e.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(e.aggregates).map(([s,a])=>$s(a)).filter(Boolean).join(" • ")})]})}function wu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:y,onToggleSelection:g,hideSelectionCheckboxes:m}){const S=p.useMemo(()=>{const C=new Set;return i.forEach(D=>{const v=D==null?void 0:D.__urm_row_id__;v!==void 0&&C.add(v)}),C},[i]);return e.length===0?t.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):t.jsx(o.Box,{sx:{fontFamily:C=>C.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:C=>fs(C).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:C=>fs(C).cardGap,alignContent:"start"},children:e.map((C,D)=>s&&C.isGroupHeader?t.jsx(Cu,{row:C,grouping:n,onToggleCollapse:a||(()=>{})},`group-${C.groupKey}`):t.jsx(Su,{row:C,rowIndex:D,visibleColumns:r,isSelected:S.has(C==null?void 0:C.__urm_row_id__),onCardClick:c,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:y,onToggleSelection:g,hideCheckbox:m},`card-${D}`))})})}const bs=[10,15,25,50,100];function ju(e,r){const n=e.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>r?"Entered page number is out of range":null}function ku({currentPage:e,pageSize:r,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:a}){const l=ht().palette,u=Math.ceil(n/r),[y,g]=p.useState(String(e)),[m,S]=p.useState(null),[C,D]=p.useState(!1),v=p.useRef(null);p.useEffect(()=>{C||(g(String(e)),S(null))},[e,C]);const x=p.useCallback(()=>{const w=ju(y,u);if(w){S(w);return}const P=parseInt(y.trim(),10);S(null),D(!1),P!==e&&s(P)},[y,u,e,s]),B=p.useCallback(w=>{var P;w.key==="Enter"?(w.preventDefault(),x()):w.key==="Escape"&&(g(String(e)),S(null),D(!1),(P=v.current)==null||P.blur())},[x,e]),h=p.useCallback(()=>{g(String(e)),S(null),D(!1)},[e]),k=p.useCallback(()=>{D(!0),S(null),setTimeout(()=>{var w;return(w=v.current)==null?void 0:w.select()},0)},[]);if(n<=Math.min(...bs))return null;const T=()=>{g(String(e)),S(null),D(!1)},b=()=>{T(),s(1)},R=()=>{T(),e>1&&s(e-1)},H=()=>{T(),e<u&&s(e+1)},E=()=>{T(),s(u)},Y=(e-1)*r+1,Z=Math.min(e*r,n),I=`${Math.max(2,String(u).length+.5)}ch`,f={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:w=>a(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:bs.map(w=>t.jsx(o.MenuItem,{value:w,sx:{fontSize:"0.8125rem"},children:w},w))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[Y,"–",Z," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[m&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:$(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${$(l.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:$(l.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:w=>w.typography.caption.fontSize||"0.6875rem",fontWeight:w=>w.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:m})}),t.jsx(o.InputBase,{inputRef:v,value:y,onChange:w=>{g(w.target.value),m&&S(null)},onKeyDown:B,onFocus:k,onBlur:h,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:I,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:m?"error.main":"text.primary",border:"1px solid",borderColor:m?"error.main":C?"primary.main":"divider",borderRadius:"4px",bgcolor:m?$(l.error.main,.04):C?$(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:m?"error.main":"text.secondary"},"&:focus-within":{boxShadow:m?`0 0 0 2px ${$(l.error.main,.2)}`:`0 0 0 2px ${$(l.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:b,disabled:e===1,size:"small",title:"First page",sx:f,children:t.jsx(O.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:R,disabled:e===1,size:"small",title:"Previous page",sx:f,children:t.jsx(O.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:H,disabled:e===u,size:"small",title:"Next page",sx:f,children:t.jsx(O.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:E,disabled:e===u,size:"small",title:"Last page",sx:f,children:t.jsx(O.LastPage,{sx:{fontSize:20}})})]})]})]})}function zu(){return t.jsx(o.Chip,{icon:t.jsx(O.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:e=>e.typography.caption.fontSize||"caption.fontSize",fontWeight:e=>e.typography.caption.fontWeight||500}})}const oa="urm_hint_seen_";function Bu(e){try{return localStorage.getItem(oa+e)==="true"}catch{return!1}}function Tu(e){try{localStorage.setItem(oa+e,"true")}catch{}}const na={"& .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 di(e,r){if(e==null||e==="")return"";if(r==="boolean")return e?"True":"False";if(r==="object"||r==="array")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function ia({row:e,schema:r}){const i=ht().palette,s=r.filter(l=>l.name in e),a=s.filter(l=>l.type!=="object"&&l.type!=="array"),c=s.filter(l=>l.type==="object"||l.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(l=>t.jsx(o.TextField,{label:dt(l.name),value:di(e[l.name],l.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:na},l.name)),c.map(l=>{const u=di(e[l.name],l.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:y=>y.typography.caption.fontWeight||500,fontSize:y=>y.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:dt(l.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:$(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:u?"text.primary":"text.disabled",fontStyle:u?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:u||"No value"})]},l.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:l=>l.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function Iu({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=ht(),c=a.palette;if(!n)return null;const l=i.filter(y=>y.name in n).length,u=de(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...u.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...u.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:$(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:y=>y.typography.h6.fontSize||"1rem",fontWeight:y=>y.typography.h6.fontWeight||600,color:y=>y.typography.h6.color||"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:y=>y.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",l," ",l===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:$(c.text.primary,.015)},children:t.jsx(ia,{row:n,schema:i})}),t.jsx(o.Divider,{}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:y=>`${y.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function Eu({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=ht(),c=de(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",...c.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...c.header},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:l=>$(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.h6.fontSize||"1.125rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:l=>l.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"This record will be permanently removed."})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.DialogContent,{sx:{px:3,pb:2,overflowY:"auto",flex:1,display:"flex",flexDirection:"column",gap:2},children:[i&&s&&t.jsx(ia,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>$(l.palette.error.main,.1),border:l=>`1px solid ${$(l.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:l=>l.typography.body2.fontWeight||500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx(O.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>ve(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>ve(l,"hoverButton")},"&:active":{boxShadow:l=>ve(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Du({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var B;const c=ht(),l=c.palette,[u,y]=p.useState({});if(p.useEffect(()=>{e&&i&&y({...i})},[e,i]),!i)return null;const g=s.filter(h=>h.name in i),m=g.filter(h=>h.type!=="object"&&h.type!=="array"),S=g.filter(h=>h.type==="object"||h.type==="array"),C=(h,k)=>{y(T=>({...T,[h]:k}))},D=()=>{const h={...u};g.forEach(k=>{const T=u[k.name];if(k.type==="number"){const b=Number(T);h[k.name]=isNaN(b)?i[k.name]:b}else k.type==="boolean"&&(h[k.name]=!!T)}),n(h),r()},v=g.length,x=de(c);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...x.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...x.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:$(((B=l.warning)==null?void 0:B.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:h=>h.typography.h6.fontSize||"1rem",fontWeight:h=>h.typography.h6.fontWeight||600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),a&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:h=>h.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a," · ",v," ",v===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:$(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[m.map(h=>{const k=u[h.name];return h.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:T=>T.typography.caption.fontWeight||500,fontSize:T=>T.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:dt(h.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!k,onChange:T=>C(h.name,T.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:T=>T.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:k?"Enabled":"Disabled"})]})]},h.name):t.jsx(o.TextField,{label:dt(h.name),value:k??"",onChange:T=>C(h.name,T.target.value),type:h.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:na},h.name)}),S.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:S.map(h=>{const k=di(i[h.name],h.type);return t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:T=>T.typography.caption.fontSize||"0.75rem",fontWeight:T=>T.typography.caption.fontWeight||500,color:"text.secondary"},children:dt(h.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:$(l.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(o.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx(O.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:$(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:k?"text.primary":"text.disabled",fontStyle:k?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:k||"No value"})]},h.name)})}),g.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx(O.EditOutlined,{sx:{fontSize:40,opacity:.4}}),t.jsx(o.Typography,{variant:"body2",children:"No editable fields"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:h=>`${h.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:D,variant:"contained",startIcon:t.jsx(O.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:h=>`${h.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const _u=176,$u=170,Ou=40;function sa(e){return e.type==="date"?180:_u}function Mu(e,r){return r!=null&&r!==$u&&r!==sa(e)}function Au(e,r,n){return p.useMemo(()=>{const i=e.map(m=>({name:m.name,width:r[m.name]??sa(m),explicit:Mu(m,r[m.name])})),s={};i.forEach(m=>{s[m.name]=m.width});const a=i.reduce((m,S)=>m+S.width,0),l=Math.max(0,n-Ou)-a;if(l<=0)return{widths:s,fillerWidth:0};const u=i.filter(m=>!m.explicit);if(u.length===0)return{widths:s,fillerWidth:l};const y=u.reduce((m,S)=>m+S.width,0)||1;let g=0;return u.forEach((m,S)=>{const D=S===u.length-1?m.width+l-g:Math.round(m.width+l*m.width/y);s[m.name]=D,g+=D-m.width}),{widths:s,fillerWidth:0}},[e,r,n])}const vs=176,Wu=At(),Ru={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Pu(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>cn(n,r).bg,color:n=>cn(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Nu(e){const r=e.toLowerCase().trim(),n=Ru[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Lu(e,r){const n=r.trim();if(!n)return e;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.split(new RegExp(`(${i})`,"gi"));return s.length===1?e:s.map((a,c)=>a.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},c):a)}function Fu(e,r,n,i=""){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(r);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(e.name.toLowerCase()))return Pu(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Nu(s);if(e.type==="date"){const l=e.dateFormat??"iso",u=Ra(r,l,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(e.type==="number"&&typeof r=="number")return r.toLocaleString();if(typeof r=="boolean")return r?"Yes":"No";if(Array.isArray(r)){if(r.length===0)return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const l=r.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return t.jsxs(o.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[l,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const l=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:l,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:l.length>40?l.slice(0,40)+"…":l})}return Lu(s,i)}function Vu({schema:e,data:r,sortStack:n=[],filters:i=Wu,views:s=[],activeViewId:a="",isDirty:c=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:y=[],columnWidths:g={},grouping:m=null,classTokens:S={},onSort:C,onSortAscending:D,onSortDescending:v,onOpenFilters:x,onOpenSort:B,onOpenFilterForColumn:h,onSelectView:k,onCreateView:T,onUpdateCurrentView:b,onSaveAsNewView:R,onDiscardChanges:H,onToggleDefault:E,onToggleFavorite:Y,onRestoreView:Z,onPermanentDelete:I,onEditView:f,onCloneView:w,onCopyLink:P,onDeleteView:te,onPromoteToGlobal:d,onSetDefaultForAllUsers:J,isAdmin:re=!1,hideViewMenuActions:we,onExport:F,onOpenColumns:X,onUpdateColumnWidth:ue,onUpdateColumnOrder:pe,onUpdateColumnVisibility:K,onClearFiltersForColumn:he,onResetLayout:le,onOpenGroup:W,onGroupByColumn:ie,onToggleGroupCollapse:U,onExpandAllGroups:ne,onCollapseAllGroups:Be,onOpenAuditHistory:Q,onOpenScheduledReports:$e,searchQuery:Pe,highlightQuery:Wt="",searchHistory:Kt=[],onAddToSearchHistory:Ar,onToggleSearchFavourite:Rt,onDeleteSearchHistory:mt,selectedRowIds:St=new Set,onSearchChange:Wr,onToggleRowSelection:Qe,onToggleAllRows:Dt,onRangeSelection:Xt,onClearSelection:Pt,onExportSelected:ar,currentPage:lr=1,pageSize:Rr=15,totalRowsBeforePagination:Qt=r.length,onPageChange:br,onPageSizeChange:Ct,isReadOnly:Je=!1,userRole:vr,reportName:ft,onEditRow:rt,onDuplicateRow:Nt,onDeleteRow:cr,showDevPanel:uo=!1,onOpenDevConfig:Pr,rowActions:dr,hideDefaultRowActions:Ke,hideToolbarActions:je,customSettingsActions:_t,jsonGuideContent:Sr,viewOptions:Nr,defaultViewMode:ur,bulkActions:Cr,hideSelectionCheckboxes:Lr,rowClickBehavior:pr="select",openModalOn:Ze,onRowClick:Lt,onRowRightClick:Ce}){var Ho;const fe=ht().urmTable,[wt,V]=p.useState(null),[xt,se]=p.useState(0),[st,wr]=p.useState(0),[jt,Fr]=p.useState(null),hr=gr(),jr=((Ho=hr.dates)==null?void 0:Ho.displayFormat)??null,[Ft,kr]=p.useState(null),[Vr,ke]=p.useState(null),[ut,ee]=p.useState(null),[ce,ye]=p.useState(!1),[po,zr]=p.useState(!1),[Br,Hr]=p.useState(null),[ho,Vt]=p.useState(!1),[mo,Ur]=p.useState(null),[$t,Tr]=p.useState(null),[ze,Ge]=p.useState(null),[Ir,at]=p.useState(null),Zt=p.useRef(null),me=p.useCallback(()=>{Zt.current&&(clearTimeout(Zt.current),Zt.current=null)},[]),xe=p.useCallback(()=>{me(),Zt.current=setTimeout(()=>at(null),200)},[me]);p.useEffect(()=>me,[me]);const[Ye,Ae]=p.useState(null),nt=p.useMemo(()=>Nr??["list","grid"],[Nr]),[it,Ot]=p.useState(()=>ur??nt[0]??"list"),[In,Wo]=p.useState(!1),[Gr,En]=p.useState(()=>!Bu("toolbar_search")),Yr=p.useRef(null),fo=p.useRef(null),[Dn,Ro]=p.useState(0);p.useLayoutEffect(()=>{const j=Yr.current;if(!j)return;Ro(j.clientWidth);const N=new ResizeObserver(oe=>{Ro(oe[0].contentRect.width)});return N.observe(j),()=>N.disconnect()},[]);const qr=p.useCallback(()=>{Tu("toolbar_search"),En(!1)},[]);p.useEffect(()=>{if(!Gr)return;const j=setTimeout(qr,2e3);return()=>clearTimeout(j)},[Gr,qr]);const Po=p.useMemo(()=>{const j=jt??y;return j.length>0?j.map(N=>e.find(oe=>oe.name===N)).filter(N=>N!==void 0):e},[jt,y,e]),Jr=p.useMemo(()=>Po.filter(j=>u[j.name]!==!1),[Po,u]),xo=p.useMemo(()=>new Set(((m==null?void 0:m.levels)??[]).map(j=>j.column)),[m]),No=!!(m!=null&&m.enabled&&(m!=null&&m.levels)&&m.levels.length>0),Kr=p.useMemo(()=>{if(!No)return Jr;const j=((m==null?void 0:m.levels)??[]).map(oe=>e.find(Te=>Te.name===oe.column)).filter(oe=>oe!==void 0),N=Jr.filter(oe=>!xo.has(oe.name));return[...j,...N]},[Jr,No,xo,m,e]),{widths:Xr}=Au(Kr,g,Dn),er=p.useMemo(()=>e.filter(j=>u[j.name]===!1).length,[e,u]),Lo=p.useMemo(()=>e.map(j=>j.name),[e]),Qr=p.useMemo(()=>y.length===0?!1:JSON.stringify(y)!==JSON.stringify(Lo),[y,Lo]),_n=p.useCallback((j,N)=>{j.preventDefault(),j.stopPropagation(),V(N),se(j.clientX),wr(g[N]||150)},[g]);p.useEffect(()=>{if(!wt)return;const j=oe=>{const Te=oe.clientX-xt,Ne=Math.max(100,Math.min(600,st+Te));ue==null||ue(wt,Ne)},N=()=>{V(null)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",N),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",N)}},[wt,xt,st,ue]);const $n=p.useCallback(j=>j==null?"-":typeof j=="object"?JSON.stringify(j):typeof j=="boolean"?j?"true":"false":String(j),[]);p.useCallback(j=>{const N=n.find(oe=>oe.column===j);return N?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[N.direction==="asc"?t.jsx(O.ArrowUpward,{sx:{fontSize:14}}):t.jsx(O.ArrowDownward,{sx:{fontSize:14}}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"caption.fontSize",fontWeight:"bold",borderRadius:"50%"},children:N.priority})]}):null},[n]),p.useCallback(j=>ni(i,j)?t.jsx(o.IconButton,{size:"small",onClick:oe=>{oe.stopPropagation(),h==null||h(j)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(O.FilterList,{sx:{fontSize:14}})}):null,[i,h]);const On=p.useCallback(j=>{C&&C(j)},[C]),Mn=p.useCallback((j,N)=>{Fr(oe=>{const Ne=[...oe??(y.length>0?y:e.map(tt=>tt.name))],[et]=Ne.splice(j,1);return Ne.splice(N,0,et),Ne})},[y,e]),An=p.useCallback(()=>{jt&&pe&&pe(jt),Fr(null)},[jt,pe]),Wn=p.useCallback(j=>{if(!C)return;const N=n.find(oe=>oe.column===j);(!N||N.direction!=="asc")&&C(j)},[C,n]),Rn=p.useCallback(j=>{if(!C)return;const N=n.find(oe=>oe.column===j);N?N.direction==="asc"&&C(j):(C(j),setTimeout(()=>C(j),0))},[C,n]),Pn=p.useCallback(j=>{if(!C)return;const N=n.find(oe=>oe.column===j);N&&(N.direction==="asc"?(C(j),setTimeout(()=>C(j),0)):N.direction==="desc"&&C(j))},[C,n]),Nn=p.useCallback(j=>{K&&K(j,!1)},[K]),Zr=!!(m!=null&&m.enabled&&(m!=null&&m.levels)&&m.levels.length>0),tr=p.useMemo(()=>Tt(i),[i]),Ln=n.length>0||tr>0||((m==null?void 0:m.enabled)??!1)||Object.values(u).some(j=>j===!1),Fn=(lr-1)*Rr,Ve=r,lt=p.useMemo(()=>{const j=new Set;return St.forEach(N=>{const oe=N==null?void 0:N.__urm_row_id__;oe!==void 0&&j.add(oe)}),j},[St]);p.useEffect(()=>{const j=N=>{!Dt||!Pt||N.target instanceof HTMLInputElement||N.target instanceof HTMLTextAreaElement||((N.ctrlKey||N.metaKey)&&N.key==="a"&&(N.preventDefault(),Dt(!0,Ve)),N.key==="Escape"&&(N.preventDefault(),Pt()))};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[Dt,Pt,Ve]);const go=p.useCallback((j,N)=>{Lt==null||Lt(Ve[j],j,N),(pr==="activate"||pr==="both")&&(ee(Ve[j]),ye(!0)),pr!=="activate"&&Qe&&(N.shiftKey&&Ft!==null?(N.preventDefault(),Xt&&Xt(Ft,j,Ve)):(Qe(Ve[j]),kr(j)))},[Qe,Ft,Xt,Ve,Lt,pr,ee,ye]),eo=p.useMemo(()=>Ve.filter(j=>!j.isGroupHeader),[Ve]),Fo=p.useMemo(()=>eo.length>0&&lt.size>0&&eo.every(j=>lt.has(j==null?void 0:j.__urm_row_id__)),[eo,lt]),Vn=!Fo&&eo.some(j=>lt.has(j==null?void 0:j.__urm_row_id__)),gt=!!(Qe&&Dt&&!Lr),rr=p.useMemo(()=>Kr,[Kr]),Er=p.useMemo(()=>{const j=new Map;if(!(m!=null&&m.enabled)||!Ve)return j;let N=[];for(const oe of Ve)if(oe.__isGroupHeader||oe.isGroupHeader){const Te=oe.groupLevel??0;N[Te]=oe.groupKey,N=N.slice(0,Te+1),j.has(oe.groupKey)||j.set(oe.groupKey,[])}else if(oe.__urm_is_grouped_data_row__)for(const Te of N)Te&&j.has(Te)&&j.get(Te).push(oe);return j},[m,Ve]),Hn=p.useCallback(j=>{const N=j.groupLevel,oe=N===0?S.groupRowLevel0||"urm-group-level-0":N===1?S.groupRowLevel1||"urm-group-level-1":S.groupRowLevel2||"urm-group-level-2",Te=N===0?We=>We.palette.mode==="dark"?$(We.palette.action.hover,.12):"#f1f5f9":We=>We.palette.mode==="dark"?$(We.palette.action.hover,.06):"#f8fafc",Ne=String(j.groupValue??"(empty)"),et=`${j.rowCount} ${j.rowCount===1?"item":"items"}`,tt=Er.get(j.groupKey)||[],ge=tt.filter(We=>lt.has(We==null?void 0:We.__urm_row_id__)).length,Ht=tt.length>0&&ge===tt.length,Ut=ge>0&&ge<tt.length;return t.jsxs(o.TableRow,{onClick:()=>U==null?void 0:U(j.groupKey),className:`urm-group-header-row urm-group-level-${N} ${oe} ${S.groupRow||""}`,sx:{bgcolor:Te,"&:hover":{bgcolor:We=>$(We.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[gt&&t.jsx(o.TableCell,{padding:"checkbox",onClick:We=>We.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Ht,indeterminate:Ut,onChange:()=>{if(!Qe)return;const We=!Ht;tt.forEach(or=>{const Uo=lt.has(or==null?void 0:or.__urm_row_id__);We!==Uo&&Qe(or)})}})}),t.jsxs(o.TableCell,{colSpan:rr.length,className:`urm-group-cell ${S.groupCellFirst||""} ${S.groupCell||""}`,sx:{pl:`${N*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[N>0&&t.jsx(o.Box,{sx:{position:"absolute",left:`${N*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(o.Box,{className:`urm-group-content ${S.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${S.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:j.isCollapsed?t.jsx(O.ChevronRight,{sx:{fontSize:18}}):t.jsx(O.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"h5",className:`urm-group-title ${S.groupTitle||""}`,sx:{fontWeight:N===0?600:500,fontSize:N===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Ne}),!j.isCollapsed&&t.jsx(o.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:We=>$(We.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:We=>$(We.palette.primary.main,.2),ml:.5},children:dt(j.groupColumn||"")}),!!j.__urm_is_continuation_header__&&t.jsx(o.Box,{className:"urm-group-continuation-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:We=>$(We.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(o.Box,{className:`urm-group-count ${S.groupBadge||""} ${S.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:We=>$(We.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:et}),Object.keys(j.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${S.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(j.aggregates).map(([We,or])=>$s(or)).filter(Boolean).join(" • "),")"]})]})]})]},j.groupKey)},[rr,gt,m,e,U,S,fe,Er,lt,Qe]),Vo=p.useCallback((j,N)=>{const oe=lt.has(j==null?void 0:j.__urm_row_id__),Te=Vr===N,Ne=ce&&(j==null?void 0:j.__urm_row_id__)===(ut==null?void 0:ut.__urm_row_id__),et=!!(j!=null&&j.__urm_is_grouped_data_row__),tt=et?j.__urm_group_level__??(m==null?void 0:m.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":N,className:et?`urm-data-row-grouped ${S.dataRowGrouped||""}`:"",onMouseEnter:()=>ke(N),onMouseLeave:()=>ke(null),onClick:ge=>{ge.target.closest("[data-row-action-btn]")||go(N,ge)},onDoubleClick:()=>{Ze!=null&&Ze.includes("doubleClick")&&(ee(j),ye(!0))},onContextMenu:ge=>{ge.preventDefault(),ge.stopPropagation(),Ce==null||Ce(j,N,ge),at(null),Ge({mouseX:ge.clientX,mouseY:ge.clientY,row:j,rowIndex:N}),Ze!=null&&Ze.includes("rightClick")&&(ee(j),ye(!0))},sx:{cursor:"pointer",bgcolor:oe?ge=>ct(ge).bg:Ne?ge=>$(ge.palette.info.main,.12):fe!=null&&fe.striped&&N%2===1?fe.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:oe?ge=>ct(ge).hoverBg:Ne?ge=>$(ge.palette.info.main,.2):ge=>`var(--highlight-hover-row, ${$(ct(ge).main,.04)})`},borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider"},children:[gt&&t.jsx(o.TableCell,{padding:"checkbox",onClick:ge=>ge.stopPropagation(),sx:{borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(fe==null?void 0:fe.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:oe,onChange:()=>Qe==null?void 0:Qe(j)})}),rr.map((ge,Ht)=>{const Ut=Ht===0;return t.jsxs(o.TableCell,{className:et&&Ut?`urm-data-cell-grouped ${S.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(fe==null?void 0:fe.rowPaddingY)??"6px",px:(fe==null?void 0:fe.cellPaddingX)??2,pl:et&&Ut?`${tt*24}px`:void 0,position:"relative",textAlign:(fe==null?void 0:fe.cellAlignH)??"left",verticalAlign:(fe==null?void 0:fe.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderRight:fe==null?void 0:fe.colDivider,borderColor:"divider",minWidth:g[ge.name]?`${g[ge.name]}px`:`${ge.type==="date"?Math.max(vs,180):vs}px`},children:[et&&Ut&&tt>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${S.itemTitle||""}`,children:Fu(ge,j[ge.name],jr,Wt)})})]},ge.name)}),t.jsx(o.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:0,minWidth:0,maxWidth:0,p:0,border:"none",background:"transparent",opacity:Te?1:0,transition:"opacity 0.12s ease",zIndex:10},children:t.jsx(o.Box,{sx:{position:"absolute",right:8,top:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"flex-end",zIndex:10},children:t.jsx(o.IconButton,{"data-row-action-btn":"true",size:"small",onClick:ge=>{ge.stopPropagation(),ge.preventDefault(),at(null),Ge({anchorEl:ge.currentTarget,row:j,rowIndex:N})},sx:{color:"text.secondary",opacity:Te?1:0,transition:"opacity 0.12s ease",pointerEvents:Te?"auto":"none","&:hover":{bgcolor:ge=>$(ge.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(O.MoreVert,{sx:{fontSize:18}})})})})]},N)},[St,Fn,Vr,go,Kr,g,Wt,$n,rt,Nt,cr,Qe,gt,ee,ye,ut,ce,Ge,Zr,xo,Ce,Ze,lt]);return t.jsxs(ir.DndProvider,{backend:ui.HTML5Backend,children:[t.jsxs(o.Box,{sx:j=>{var et,tt,ge;const N=((ge=(tt=(et=j.components)==null?void 0:et.MuiCard)==null?void 0:tt.styleOverrides)==null?void 0:ge.root)||{},oe=N.border&&N.border!=="none"?N.border:"1px solid",Te=N.borderRadius!==void 0?typeof N.borderRadius=="number"?`${N.borderRadius}px`:N.borderRadius:`${j.shape.borderRadius}px`,Ne=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:ve(j,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:oe,borderColor:oe!=="none"?"divider":void 0,borderRadius:Te,boxShadow:Ne,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:j=>{var et,tt,ge,Ht,Ut;const N=((ge=(tt=(et=j.components)==null?void 0:et.MuiCardHeader)==null?void 0:tt.styleOverrides)==null?void 0:ge.root)||{},oe=(N.backgroundColor&&N.backgroundColor!=="transparent"?N.backgroundColor:void 0)??((Ht=j.tokens)==null?void 0:Ht.cardHdrHex)??((Ut=j.urmTable)==null?void 0:Ut.headerBg)??j.palette.background.paper,Te=N.borderBottom&&N.borderBottom!=="none"?N.borderBottom:"1px solid",Ne=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:oe,borderBottom:Te,borderColor:Te!=="none"?"divider":void 0,boxShadow:Ne,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Je&&t.jsx(zu,{}),Wr&&Ar&&Rt&&mt&&!(je!=null&&je.includes("search"))&&t.jsx(o.Tooltip,{open:Gr,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",fontWeight:j=>j.typography.caption.fontWeight||500,mb:.25},children:"💡 Search tip"}),t.jsx(o.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:qr},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:t.jsx(o.Box,{component:"span",children:t.jsx(du,{value:Pe||"",onChange:j=>{Gr&&qr(),Wr(j)},searchHistory:Kt,onAddToHistory:Ar,onToggleFavourite:Rt,onDeleteHistory:mt,disabled:Je})})}),!(je!=null&&je.includes("jsonGuide"))&&t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>Wo(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:j=>$(j.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:20}})})}),k&&T&&b&&s.length>0&&t.jsx(uu,{views:s||[],activeViewId:a||"",isDirty:c,onSelectView:k,onCreateView:T,onToggleDefault:E,onToggleFavorite:Y,onRestoreView:Z,onPermanentDelete:I,onEditView:f,onCloneView:w,onCopyLink:P,onDeleteView:te,onPromoteToGlobal:d,onSetDefaultForAllUsers:J,isAdmin:re,hideViewMenuActions:we,isReadOnly:Je}),c&&!Je&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[b&&t.jsx(o.Button,{onClick:b,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:j=>`var(--urm-btn-save-current-bg, ${j.palette.primary.main})`,color:j=>`var(--urm-btn-save-current-color, ${j.palette.primary.contrastText})`,textTransform:"none",boxShadow:j=>ve(j,"restButton"),"&:hover":{bgcolor:j=>`var(--urm-btn-save-current-hover-bg, ${j.palette.primary.dark})`,boxShadow:j=>ve(j,"hoverButton")}},children:"Save current view"}),R&&t.jsx(o.Button,{onClick:R,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:j=>`var(--urm-btn-save-new-border, ${j.palette.primary.main})`,color:j=>`var(--urm-btn-save-new-color, ${j.palette.primary.main})`,bgcolor:j=>`var(--urm-btn-save-new-bg, ${j.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:j=>`var(--urm-btn-save-new-hover-border, ${j.palette.primary.dark})`,bgcolor:j=>`var(--urm-btn-save-new-hover-bg, ${$(j.palette.primary.main,.08)})`}},children:"Save new view"}),H&&t.jsx(o.Button,{onClick:H,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:j=>`var(--urm-btn-discard-bg, ${$(j.palette.text.primary,.12)})`,color:j=>`var(--urm-btn-discard-color, ${j.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:j=>`var(--urm-btn-discard-hover-bg, ${$(j.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),uo&&Pr&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:Pr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:j=>$(j.palette.text.secondary,.3),"&:hover":{bgcolor:j=>$(j.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx(O.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!Je&&B&&!(je!=null&&je.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:B,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?j=>It(j):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?j=>$(j.palette.primary.main,.2):j=>$(j.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx(O.SwapVert,{sx:{fontSize:20}}),n.length>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!Je&&x&&!(je!=null&&je.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:x,size:"small",sx:{position:"relative",color:tr>0?"primary.main":"text.secondary",bgcolor:tr>0?j=>It(j):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:tr>0?j=>$(j.palette.primary.main,.2):j=>$(j.palette.text.primary,.06),color:tr>0?"primary.main":"text.primary"}},children:[t.jsx(O.FilterList,{sx:{fontSize:20}}),tr>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:tr})]})}),!Je&&X&&!(je!=null&&je.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:X,size:"small",sx:{position:"relative",color:er>0||Qr?"primary.main":"text.secondary",bgcolor:er>0||Qr?j=>It(j):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:er>0||Qr?j=>$(j.palette.primary.main,.2):j=>$(j.palette.text.primary,.06),color:er>0||Qr?"primary.main":"text.primary"}},children:[t.jsx(O.ViewColumn,{sx:{fontSize:20}}),er>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:er})]})}),Zr&&(ne||Be)&&(()=>{var oe;const j=(((oe=m==null?void 0:m.collapsedGroups)==null?void 0:oe.length)??0)>0,N=j?ne:Be;return N?t.jsx(o.Tooltip,{title:j?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:N,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:Te=>$(Te.palette.text.primary,.06),color:"text.primary"}},children:j?t.jsx(O.UnfoldMore,{sx:{fontSize:20}}):t.jsx(O.UnfoldLess,{sx:{fontSize:20}})})}):null})(),nt.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),nt.map(j=>{const N=it===j,oe=j==="list"?t.jsx(O.TableRows,{sx:{fontSize:20}}):t.jsx(O.GridView,{sx:{fontSize:20}}),Te=j==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:Te,children:t.jsx(o.IconButton,{size:"small",onClick:()=>Ot(j),sx:{borderRadius:1,color:N?"primary.main":"text.secondary",bgcolor:N?Ne=>It(Ne):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:N?Ne=>$(Ne.palette.primary.main,.2):Ne=>$(Ne.palette.text.primary,.06),color:N?"primary.main":"text.primary"}},children:oe})},j)})]}),!(je!=null&&je.includes("settings"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"Settings",children:t.jsx(o.IconButton,{onClick:j=>Ae(j.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:j=>$(j.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!Ye,anchorEl:Ye,onClose:()=>Ae(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:[F&&!(je!=null&&je.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{F(),Ae(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Je&&W&&!(je!=null&&je.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{W(),Ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),Q&&!(je!=null&&je.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Q(),Ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),$e&&!(je!=null&&je.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{$e(),Ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]}),_t==null?void 0:_t.map(j=>t.jsxs(o.MenuItem,{dense:!0,disabled:j.disabled,onClick:()=>{j.onClick(),Ae(null)},sx:{py:1,px:2,gap:1.5},children:[j.icon,t.jsx(o.Typography,{variant:"body2",children:j.label})]},j.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Cr&&Cr.length>0&&lt.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:j=>ct(j).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:j=>j.typography.body2.fontWeight||600,mr:1},children:[lt.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>Pt==null?void 0:Pt(),children:"Clear"}),Cr.map(j=>{var oe,Te;const N=Array.from(St);return(oe=j.hidden)!=null&&oe.call(j,N)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:j.icon,disabled:(Te=j.disabled)==null?void 0:Te.call(j,N),onClick:()=>j.onClick(N),children:j.label},j.key)})]}),it!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(wu,{data:Ve,visibleColumns:Jr,grouping:m,selectedRowIds:St,isGrouped:!!Zr,onToggleGroupCollapse:U,onCardClick:(j,N)=>go(j,N),onCardDoubleClick:j=>{Ze!=null&&Ze.includes("doubleClick")&&(ee(j),ye(!0))},onCardContextMenu:(j,N,oe)=>{Ce==null||Ce(j,N,oe),at(null),Ge({mouseX:oe.clientX,mouseY:oe.clientY,row:j,rowIndex:N}),Ze!=null&&Ze.includes("rightClick")&&(ee(j),ye(!0))},onOpenRowMenu:(j,N,oe)=>Ge({anchorEl:oe,row:j,rowIndex:N}),onToggleSelection:j=>Qe==null?void 0:Qe(j),hideSelectionCheckboxes:Lr})}),it==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Yr,onScroll:j=>{fo.current&&(fo.current.scrollLeft=j.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Xr).reduce((j,N)=>j+N,0)}px`},children:[t.jsxs("colgroup",{children:[gt&&t.jsx("col",{style:{width:"40px"}}),rr.map(j=>t.jsx("col",{style:{width:`${Xr[j.name]}px`}},j.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(fe==null?void 0:fe.headerBg)??"action.hover",borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider"},children:[gt&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(fe==null?void 0:fe.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Fo,indeterminate:Vn,onChange:j=>Dt==null?void 0:Dt(j.target.checked,Ve)})}),rr.map((j,N)=>t.jsx(mu,{column:j,index:N,sortRule:n.find(oe=>oe.column===j.name),hasFilters:ni(i,j.name),isInSortStack:n.some(oe=>oe.column===j.name),isReadOnly:Je,hasModifications:Ln,width:g[j.name],onColumnClick:On,onMoveColumn:Mn,onColumnDragEnd:An,onResizeStart:_n,onSortAscending:D||Wn,onSortDescending:v||Rn,onRemoveSort:Pn,onOpenFilterForColumn:h||(()=>{}),onClearFiltersForColumn:he||(()=>{}),onGroupByColumn:ie,onHideColumn:Nn,onManageColumns:X||(()=>{}),onResetLayout:le},j.name))]})})]})}),t.jsx(o.Box,{ref:fo,onScroll:j=>{Yr.current&&(Yr.current.scrollLeft=j.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:j=>$(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>$(j.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Xr).reduce((j,N)=>j+N,0)}px`},children:[t.jsxs("colgroup",{children:[gt&&t.jsx("col",{style:{width:"40px"}}),rr.map(j=>t.jsx("col",{style:{width:`${Xr[j.name]}px`}},j.name))]}),t.jsx(o.TableBody,{children:Ve.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:rr.length,align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Zr?Ve.map((j,N)=>j.isGroupHeader?Hn(j):Vo(j,N)):Ve.map((j,N)=>Vo(j,N))})]})})]}),br&&Ct&&t.jsx(ku,{currentPage:lr,pageSize:Rr,totalRows:Qt,totalFields:e.length,onPageChange:br,onPageSizeChange:Ct}),!(br&&Ct)&&t.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",Ve.length," ",Ve.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!ze,onClose:()=>{Ge(null),at(null)},anchorEl:(ze==null?void 0:ze.anchorEl)||null,anchorReference:ze!=null&&ze.anchorEl?"anchorEl":"anchorPosition",anchorPosition:ze&&!ze.anchorEl?{top:ze.mouseY,left:ze.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:ze!=null&&ze.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(Ke!=null&&Ke.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ze&&(ee(ze.row),ye(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(Ke!=null&&Ke.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ze&&(Ur(ze.row),Tr(ze.rowIndex),Vt(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(Ke!=null&&Ke.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ze&&(Nt==null||Nt(ze.rowIndex,ze.row)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),ze&&(dr==null?void 0:dr.map(j=>{var N,oe;return(N=j.hidden)!=null&&N.call(j,ze.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(oe=j.disabled)==null?void 0:oe.call(j,ze.row),onClick:()=>{j.onClick(ze.row,ze.rowIndex),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[j.icon,t.jsx(o.Typography,{variant:"body2",children:j.label})]},j.key)})),lt.size>0&&ar&&!(Ke!=null&&Ke.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:j=>{me(),at(j.currentTarget)},onMouseLeave:xe,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(O.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",lt.size,")"]})]}),t.jsx(O.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!Ir,anchorEl:Ir,placement:"right-start",transition:!0,sx:{zIndex:j=>j.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:j})=>t.jsx(o.Grow,{...j,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:me,onMouseLeave:xe,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:t.jsxs(o.MenuList,{dense:!0,autoFocusItem:!1,children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ar("csv"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ar("excel"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ar("json"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]}),hr.export.allowedFormats.includes("pdf")&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ar("pdf"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(O.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(Ke!=null&&Ke.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ze&&(Hr(ze.row),zr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx(O.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(Iu,{open:ce,onClose:()=>{ye(!1),ee(null)},row:ut,schema:e,reportName:ft}),t.jsx(Du,{open:ho,onClose:()=>{Vt(!1),Ur(null),Tr(null)},onSave:j=>{$t!==null&&(rt==null||rt($t,j))},row:mo,schema:e,reportName:ft}),t.jsx(Eu,{open:po,onClose:()=>{zr(!1),Hr(null)},onConfirm:()=>{Br!==null&&(cr==null||cr(Br))},row:Br,schema:e}),t.jsx(ta,{isOpen:In,onClose:()=>Wo(!1),content:Sr})]})}function pt({content:e,isDev:r=!1}){const[n,i]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${e.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>$(s.palette.primary.main,.08)}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(o.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:[t.jsx(o.Box,{sx:{px:2,py:1.5,bgcolor:s=>$(s.palette.primary.main,.06)},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||600,color:"primary.main",fontSize:s=>s.typography.body2.fontSize||"0.875rem"},children:e.title})}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.8125rem",lineHeight:1.6},children:e.description}),e.tips&&e.tips.length>0&&t.jsx(o.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:e.tips.map((s,a)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},a))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>$(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>$(s.palette.warning.main,.2)},children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:s=>s.typography.caption.fontWeight||500,fontSize:s=>s.typography.caption.fontSize||"0.75rem",display:"block",mb:.25},children:"Dev note"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontSize:s=>s.typography.caption.fontSize||"0.75rem",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}const Mr={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","24-hour format · Tab must be open for the schedule to fire","Opens your device's email app when the schedule fires. If you added email."],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."}},oi=40;function Hu({operator:e,onSelect:r}){return t.jsxs(o.Select,{value:e,onChange:n=>r(n.target.value),size:"small",variant:"outlined",sx:{position:"relative",zIndex:1,mt:1,width:58,height:24,fontSize:"0.6875rem",fontWeight:700,color:"primary.main",bgcolor:"background.paper",borderRadius:"6px","& .MuiSelect-select":{py:0,px:1,display:"flex",alignItems:"center"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}},children:[t.jsx(o.MenuItem,{value:"and",sx:{fontSize:"0.75rem",fontWeight:600},children:"AND"}),t.jsx(o.MenuItem,{value:"or",sx:{fontSize:"0.75rem",fontWeight:600},children:"OR"})]})}function Uu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),c=p.useMemo(()=>{const u=a?an(a.type):[],y=i.filter.allowedOperators;return y.length>0?u.filter(g=>y.includes(g.value)):u},[a,i]),l=Ml(e.operator);return t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(o.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(o.Select,{value:e.column,onChange:u=>{var m;const y=r.find(S=>S.name===u.target.value),g=y?an(y.type):[];s({column:u.target.value,operator:((m=g[0])==null?void 0:m.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(u=>t.jsx(o.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:dt(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:c.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),l&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:u=>s({value:u.target.value}),sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}}),l&&(a==null?void 0:a.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function aa({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}){const u=c>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((y,g)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:oi,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[g<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),g>0&&t.jsx(Hu,{operator:e.operator,onSelect:m=>l(S=>mi(S,e.id,m))}),g>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:oi/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:g>0?1:0},children:Xe(y)?t.jsx(Gu,{group:y,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}):t.jsx(Uu,{condition:y,schema:n,availableColumns:i,devConfig:s,onUpdate:m=>l(S=>hi(S,y.id,m))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>l(m=>fi(m,y.id)),sx:{mt:g>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(O.Close,{sx:{fontSize:16}})})]},y.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${oi}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>l(y=>{var g,m,S;return co(y,e.id,{id:lo(),column:((g=i[0])==null?void 0:g.name)??"",operator:((S=an(((m=i[0])==null?void 0:m.type)??"string")[0])==null?void 0:S.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>l(y=>co(y,e.id,At())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Gu(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>$(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>$(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(aa,{...e})})}function Yu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[c,l]=p.useState(r??At()),u=gr(),y=p.useMemo(()=>e.filter(B=>B.type!=="mixed"&&B.type!=="null"&&B.type!=="array"&&B.type!=="object"),[e]);p.useEffect(()=>{var h;const B=r??At();if(s&&B.children.length===0){const k=e.find(T=>T.name===s);if(k){l(co(B,B.id,{id:lo(),column:s,operator:((h=an(k.type)[0])==null?void 0:h.value)??"equals"}));return}}l(B)},[r,s,e]);const g=Tt(c),m=u.filter.maxConditions,S=p.useCallback(B=>{l(h=>B(h))},[]),C=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r??At()),[c,r]),D=p.useCallback(()=>{n(c),i()},[c,n,i]),v=p.useCallback(()=>{l(r??At()),i()},[r,i]),x=p.useCallback(()=>{n(At()),i()},[n,i]);return t.jsx(o.Box,{onClick:v,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:B=>$(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:t.jsxs(o.Paper,{onClick:B=>B.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:B=>ot(B),bgcolor:"background.paper",outline:"none",boxShadow:B=>de(B).paper.boxShadow,border:B=>de(B).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:B=>de(B).header.backgroundColor,borderBottom:B=>de(B).header.borderBottom,boxShadow:B=>de(B).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:B=>B.typography.h6.fontSize||"1.125rem",fontWeight:B=>B.typography.h6.fontWeight||500,color:B=>B.typography.h6.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(pt,{content:Mr.filter,isDev:process.env.NODE_ENV==="development"}),a&&t.jsx(o.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:v,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:B=>$(B.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:B=>$(B.palette.text.primary,.3)}}},children:[g===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:B=>B.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${dt(s)}"`:"","."]}),t.jsx(aa,{group:c,depth:0,schema:e,availableColumns:y,devConfig:u,maxConditions:m,totalConditions:g,onChange:S}),g>=m&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:B=>B.typography.caption.fontSize||"0.75rem",fontWeight:B=>B.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",m," conditions allowed. Remove one to add another."]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",alignItems:"center",gap:1.5,justifyContent:"space-between",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:x,disabled:g===0,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"Clear all"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[t.jsx(o.Button,{onClick:v,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:B=>`${B.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:D,disabled:!C,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:B=>`${B.shape.borderRadius}px`,boxShadow:B=>ve(B,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const Ss="SORT_RULE";function qu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=p.useRef(null),[{handlerId:c},l]=ir.useDrop({accept:Ss,collect(g){return{handlerId:g.getHandlerId()}},hover(g,m){var h;if(!a.current)return;const S=g.index,C=r;if(S===C)return;const D=(h=a.current)==null?void 0:h.getBoundingClientRect(),v=(D.bottom-D.top)/2,x=m.getClientOffset(),B=((x==null?void 0:x.y)??0)-D.top;S<C&&B<v||S>C&&B>v||(s(S,C),g.index=C)}}),[{isDragging:u},y]=ir.useDrag({type:Ss,item:()=>({index:r}),collect:g=>({isDragging:g.isDragging()})});return y(l(a)),t.jsxs(o.Box,{ref:a,"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:g=>ve(g,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(o.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:g=>`0 1px 2px 0 ${$(g.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:g=>g.typography.body2.fontSize||"0.875rem",fontWeight:g=>g.typography.body2.fontWeight||400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:e.column}),t.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:t.jsxs(o.Select,{value:e.direction,onChange:g=>n(r,g.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:[t.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>It(g),"&:hover":{bgcolor:g=>$(g.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>It(g),"&:hover":{bgcolor:g=>$(g.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:g=>$(g.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]})}function Ju({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i,onOpenDevConfig:s}){const[a,c]=p.useState(""),[l,u]=p.useState([]);p.useEffect(()=>{u([...r])},[r]);const y=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r),[l,r]),g=gr(),m=p.useCallback(k=>{if(!k||l.length>=g.sort.maxLevels)return;const T={column:k,direction:"asc",priority:l.length+1};u([...l,T]),c(""),setTimeout(()=>{var b;return(b=document.activeElement)==null?void 0:b.blur()},0)},[l,g.sort.maxLevels]),S=p.useCallback(k=>{const b=l.filter((R,H)=>H!==k).map((R,H)=>({...R,priority:H+1}));u(b)},[l]),C=p.useCallback((k,T)=>{const b=[...l];b[k]={...b[k],direction:T},u(b)},[l]),D=p.useCallback((k,T)=>{const b=[...l],[R]=b.splice(k,1);b.splice(T,0,R);const H=b.map((E,Y)=>({...E,priority:Y+1}));u(H)},[l]),v=p.useCallback(()=>{n([]),i()},[n,i]),x=p.useCallback(()=>{n(l),i()},[l,n,i]),B=p.useCallback(()=>{u([...r]),c(""),i()},[r,i]),h=e.filter(k=>!l.some(T=>T.column===k.name));return t.jsx(ir.DndProvider,{backend:ui.HTML5Backend,children:t.jsx(o.Box,{onClick:B,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:k=>$(k.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:k=>k.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:k=>k.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:k=>ot(k),bgcolor:"background.paper",outline:"none",boxShadow:k=>de(k).paper.boxShadow,border:k=>de(k).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:k=>de(k).header.backgroundColor,borderBottom:k=>de(k).header.borderBottom,boxShadow:k=>de(k).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:k=>k.typography.h6.fontSize||"1.125rem",fontWeight:k=>k.typography.h6.fontWeight||500,color:k=>k.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(pt,{content:Mr.sort,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:B,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:k=>$(k.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:k=>$(k.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:k=>k.typography.caption.fontSize||"0.6875rem",fontWeight:k=>k.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=g.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:a,onChange:k=>m(k.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:h.map(k=>t.jsx(o.MenuItem,{value:k.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:T=>It(T),"&:hover":{bgcolor:T=>$(T.palette.primary.main,.2)}}},children:dt(k.name)},k.name))})]}),l.length>=g.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:k=>k.typography.caption.fontSize||"0.75rem",fontWeight:k=>k.typography.caption.fontWeight||500},children:["Maximum ",g.sort.maxLevels," sort levels allowed"]})]}),l.length>0&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Typography,{variant:"overline",sx:{fontSize:k=>k.typography.caption.fontSize||"0.6875rem",fontWeight:k=>k.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",g.sort.maxLevels,")"]}),t.jsx(o.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"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((k,T)=>t.jsx(qu,{rule:k,index:T,onToggleDirection:C,onRemove:S,onMove:D},`${k.column}-${T}`))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:B,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:x,variant:"contained",disabled:!y||l.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,boxShadow:k=>ve(k,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:k=>ve(k,"hoverButton")},"&:active":{boxShadow:k=>ve(k,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const Qo=50;function Cs({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:u=10}){const[y,g]=p.useState(s),[m,S]=p.useState(!1),[C,D]=p.useState(a),[v,x]=p.useState(c),B=()=>{if(!y.trim()){S(!0);return}if(y.trim().length>Qo){S(!0);return}r(y.trim(),C.trim(),v),n()},h=T=>{T.key==="Enter"&&!T.shiftKey?B():T.key==="Escape"&&n()},k=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:T=>({mt:8,borderRadius:ot(T),...de(T).paper})},children:[t.jsxs(o.DialogTitle,{sx:T=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...de(T).header}),children:[k(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[l&&!i&&t.jsxs(o.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."]}),t.jsx(o.TextField,{label:"View Name",required:!0,value:y,onChange:T=>{T.target.value.length<=Qo&&g(T.target.value),m&&T.target.value.trim()&&S(!1)},onKeyDown:h,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:Qo},error:m&&!y.trim(),helperText:m&&!y.trim()?"View name is required":`${y.length} / ${Qo}`}),t.jsx(o.TextField,{label:"Description (optional)",value:C,onChange:T=>D(T.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),t.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:T=>T.typography.body2.fontWeight||500,mb:1},children:"This view will capture:"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[t.jsxs("li",{children:[Tt(e.filters)," filter",Tt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",Qa(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:v,onChange:T=>x(T.target.checked),size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Set as default view"})})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,variant:"contained",disabled:l&&!i,startIcon:t.jsx(O.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,boxShadow:T=>ve(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>ve(T,"hoverButton")},"&:active":{boxShadow:T=>ve(T,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Ku({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:ot(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...de(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...de(i).header}),children:["Delete View",t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[t.jsx(O.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",t.jsxs("strong",{children:['"',e,'"']}),"?"]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.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"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>ve(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ve(i,"hoverButton")},"&:active":{boxShadow:i=>ve(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const ws="COLUMN";function Xu({column:e,index:r,isVisible:n,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:c,onToggleVisibility:l,onWidthChange:u,moveColumn:y}){const g=p.useRef(null),[m,S]=p.useState(i.toString());p.useEffect(()=>{S(i.toString())},[i]);const[{handlerId:C},D]=ir.useDrop({accept:ws,collect(b){return{handlerId:b.getHandlerId()}},hover(b,R){var w;if(!g.current)return;const H=b.index,E=r;if(H===E)return;const Y=(w=g.current)==null?void 0:w.getBoundingClientRect(),Z=(Y.bottom-Y.top)/2,I=R.getClientOffset(),f=((I==null?void 0:I.y)??0)-Y.top;H<E&&f<Z||H>E&&f>Z||(y(H,E),b.index=E)}}),[{isDragging:v},x]=ir.useDrag({type:ws,item:()=>({index:r}),collect:b=>({isDragging:b.isDragging()})});x(D(g));const B=()=>{const b=parseInt(m);if(isNaN(b)){S(i.toString()),u(e.name,i);return}const R=Math.max(s,Math.min(a,b));S(R.toString()),u(e.name,R)},h=b=>{if(b===""||/^\d+$/.test(b)){S(b);const R=parseInt(b);if(!isNaN(R)&&R>=s){const H=Math.min(a,R);u(e.name,H)}}},k=b=>{b.key==="Enter"&&(b.preventDefault(),B(),b.target.blur())},T=b=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[b]||"text.secondary";return t.jsxs(o.TableRow,{ref:g,"data-handler-id":C,sx:{opacity:v?.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:[t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx(O.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:b=>b.typography.body2.fontWeight||400,fontSize:b=>b.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:dt(e.name)})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(o.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${T(e.type)}15`,color:T(e.type),border:`1px solid ${T(e.type)}30`,"& .MuiChip-label":{px:1}}})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.TextField,{type:"number",value:m,onChange:b=>h(b.target.value),onBlur:B,onKeyDown:k,placeholder:"150",size:"small",inputProps:{min:s,max:a,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}}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"px"})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.IconButton,{onClick:()=>l(e.name,!n),disabled:!n&&!c,title:n?"Hide column":c?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:n?t.jsx(O.Visibility,{sx:{fontSize:20}}):t.jsx(O.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?b=>$(b.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Qu({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:y,onClose:g}){const m=gr(),[S,C]=p.useState(!1),[D,v]=p.useState(n),[x,B]=p.useState(i),[h,k]=p.useState("all");p.useEffect(()=>{v(n)},[n]),p.useEffect(()=>{B(i)},[i]);const T=(w,P)=>{B(te=>({...te,[w]:P})),u==null||u(w,P)},b=(w,P)=>{const te=[...D],[d]=te.splice(w,1);te.splice(P,0,d),v(te),l(te)},R=()=>{y(),C(!1)},E=D.map(w=>e.find(P=>P.name===w)).filter(w=>w!==void 0).filter(w=>{const P=r[w.name]??!0;return h==="active"?P:h==="hidden"?!P:!0}),Y=Object.values(r).filter(w=>w).length,Z=e.length,I=s.find(w=>w.id===a),f=p.useMemo(()=>{if(!I)return!1;const w=I.snapshot,P=w.columnVisibility??{},te=JSON.stringify(r)!==JSON.stringify(P),d=w.columnOrder??[],J=n??[],re=JSON.stringify(J)!==JSON.stringify(d)&&!(J.length===0&&d.length===0),we=w.columnWidths??{},F=JSON.stringify(x)!==JSON.stringify(we);return te||re||F},[I,r,n,x]);return t.jsx(ir.DndProvider,{backend:ui.HTML5Backend,children:t.jsx(o.Box,{onClick:g,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:w=>$(w.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:w=>w.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:w=>w.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:w=>ot(w),bgcolor:"background.paper",outline:"none",boxShadow:w=>de(w).paper.boxShadow,border:w=>de(w).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,flexShrink:0,bgcolor:w=>de(w).header.backgroundColor,borderBottom:w=>de(w).header.borderBottom,boxShadow:w=>de(w).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsx(o.Box,{sx:{flex:1},children:t.jsxs(o.Typography,{variant:"h6",sx:{fontSize:w=>w.typography.h6.fontSize||"1.125rem",fontWeight:w=>w.typography.h6.fontWeight||500,color:w=>w.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx(pt,{content:Mr.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:g,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:h,onChange:(w,P)=>k(P),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:w=>ct(w).main,height:3}},children:[t.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{borderBottomColor:"text.primary",fontWeight:600,bgcolor:w=>ct(w).hoverBg},"&:hover":{color:"text.primary",bgcolor:w=>ct(w).bg}}}),t.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:w=>ct(w).hoverBg},"&:hover":{color:"text.primary",bgcolor:w=>ct(w).bg}}}),t.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:w=>ct(w).hoverBg},"&:hover":{color:"text.primary",bgcolor:w=>ct(w).bg}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:w=>$(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>$(w.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(o.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"}),t.jsx(o.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"}),t.jsx(o.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:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(o.Tooltip,{title:`Column width in pixels (min: ${m.columns.minColumnWidth}px, max: ${m.columns.maxColumnWidth}px)`,arrow:!0,placement:"top",children:t.jsx(O.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),t.jsx(o.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"})]})}),t.jsx(o.TableBody,{children:E.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:w=>w.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):E.map((w,P)=>{const te=r[w.name]??!0,d=te||Y<m.columns.maxVisible;return t.jsx(Xu,{column:w,index:P,isVisible:te,width:x[w.name]||170,minColumnWidth:m.columns.minColumnWidth,maxColumnWidth:m.columns.maxColumnWidth,canToggleOn:d,onToggleVisibility:c,onWidthChange:T,moveColumn:b},w.name)})})]})}),t.jsx(o.Box,{sx:{px:3,py:1,borderTop:"1px solid divider",bgcolor:"background.default",flexShrink:0},children:t.jsxs(o.Typography,{variant:"body2",sx:{fontSize:w=>w.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[Y," of ",Z," columns visible • Drag to reorder"]})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:t.jsx(o.Button,{onClick:()=>C(!0),disabled:!f,variant:"outlined",startIcon:t.jsx(O.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:w=>`${w.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),S&&t.jsx(o.Box,{onClick:()=>C(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:w=>$(w.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:w=>w.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:w=>w.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:w=>Mo(w),bgcolor:"background.paper",boxShadow:w=>de(w).paper.boxShadow,border:w=>de(w).paper.border},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>C(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:w=>`${w.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:w=>`${w.shape.borderRadius}px`,boxShadow:w=>ve(w,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:w=>ve(w,"hoverButton")},"&:active":{boxShadow:w=>ve(w,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function Zu({schema:e,grouping:r,onApply:n,onClose:i,onOpenDevConfig:s}){var H;const[a,c]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,u]=p.useState(""),[y,g]=p.useState(null),m=p.useMemo(()=>Ua(e),[e]),S=p.useMemo(()=>m.filter(E=>!a.levels.some((Y,Z)=>Y.column===E.name&&Z!==y)),[m,a.levels,y]),C=gr(),D=a.levels.length<C.grouping.maxLevels&&S.length>0&&(C.grouping.allowNested||a.levels.length===0),v=p.useCallback(E=>{!D||!E||(c({...a,levels:[...a.levels,{column:E}],enabled:!0}),u(""),setTimeout(()=>{var Y;return(Y=document.activeElement)==null?void 0:Y.blur()},0))},[D,a]),x=p.useCallback(E=>{const Y=a.levels.filter((Z,I)=>I!==E);if(Y.length===0){n(null),i();return}c({...a,levels:Y,enabled:Y.length>0})},[a,n,i]),B=p.useCallback(E=>{g(E),u(a.levels[E].column)},[a.levels]),h=p.useCallback(()=>{if(y===null||!l)return;const E=[...a.levels];E[y]={column:l},c({...a,levels:E}),g(null),u("")},[y,l,a]),k=p.useCallback(()=>{g(null),u("")},[]),T=p.useCallback((E,Y)=>{const Z=Y==="up"?E-1:E+1;if(Z<0||Z>=a.levels.length)return;const I=[...a.levels],[f]=I.splice(E,1);I.splice(Z,0,f),c({...a,levels:I})},[a]),b=p.useCallback(()=>{n(null),i()},[n,i]),R=p.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:E=>$(E.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:E=>E.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:E=>E.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:E=>ot(E),bgcolor:"background.paper",outline:"none",boxShadow:E=>de(E).paper.boxShadow,border:E=>de(E).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:E=>de(E).header.backgroundColor,borderBottom:E=>de(E).header.borderBottom,boxShadow:E=>de(E).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:E=>E.typography.h6.fontSize||"1.125rem",fontWeight:E=>E.typography.h6.fontWeight||500,color:E=>E.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(pt,{content:Mr.grouping,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:E=>$(E.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:E=>$(E.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[y===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:E=>E.typography.caption.fontSize||"0.6875rem",fontWeight:E=>E.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:E=>v(E.target.value),disabled:!D,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:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),S.map(E=>t.jsxs(o.MenuItem,{value:E.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:Y=>It(Y),"&:hover":{bgcolor:Y=>$(Y.palette.primary.main,.2)}}},children:[dt(E.name)," (",E.type.toUpperCase(),")"]},E.name))]})}),a.levels.length>=C.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:E=>E.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),m.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),y!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:E=>`1px solid ${$(E.palette.warning.main,.5)}`,bgcolor:E=>$(E.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:E=>E.typography.body2.fontWeight||500,mb:1.5,fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",y+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:E=>u(E.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:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[y].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:E=>It(E)}},children:[a.levels[y].column," (",(H=e.find(E=>E.name===a.levels[y].column))==null?void 0:H.type.toUpperCase(),")"]}),S.filter(E=>E.name!==a.levels[y].column).map(E=>t.jsxs(o.MenuItem,{value:E.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:Y=>It(Y)}},children:[dt(E.name)," (",E.type.toUpperCase(),")"]},E.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:h,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:E=>ve(E,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:k,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"})]})]}),a.levels.length>0&&y===null&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:E=>E.typography.caption.fontSize||"0.6875rem",fontWeight:E=>E.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:b,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((E,Y)=>{const Z=e.find(I=>I.name===E.column);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:I=>ve(I,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${Y+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:I=>`0 1px 2px 0 ${$(I.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:I=>I.typography.body2.fontWeight||500,fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:E.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:I=>I.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:Z==null?void 0:Z.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>T(Y,"up"),disabled:Y===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(O.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>T(Y,"down"),disabled:Y===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(O.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>B(Y),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx(O.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>x(Y),sx:{color:"text.secondary","&:hover":{bgcolor:I=>$(I.palette.error.main,.08),color:"error.main"}},children:t.jsx(O.Delete,{sx:{fontSize:18}})})]})]},Y)})})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,boxShadow:E=>ve(E,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:E=>ve(E,"hoverButton")},"&:active":{boxShadow:E=>ve(E,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function ep({onExportAnyway:e,onSaveAndExport:r,onCancel:n}){return t.jsx(o.Box,{sx:{mb:2,mx:3,mt:2},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(O.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx(O.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1rem",mb:.5},children:"You are exporting with unsaved view changes"}),t.jsx(o.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,variant:"contained",color:"primary",startIcon:t.jsx(O.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx(O.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const js=[{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 tp(e,r){if(r===null)return e.length;const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()>=n).length}function rp(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function op({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=ht(),s=i.palette,[a,c]=p.useState("1h"),[l,u]=p.useState(!1),[y,g]=p.useState("all"),[m,S]=p.useState(!0),[C,D]=p.useState(!1),[v,x]=p.useState(!1),B=[...e].sort((I,f)=>{const w=new Date(I.timestamp).getTime()-new Date(f.timestamp).getTime();return C?w:-w}),h=B.reduce((I,f)=>(I[f.feature]=(I[f.feature]??0)+1,I),{}),k=Object.keys(h).sort((I,f)=>(h[f]??0)-(h[I]??0)),T=y==="all"?B:B.filter(I=>I.feature===y),b=js.find(I=>I.key===a),R=tp(e,b.ms),H=()=>u(!0),E=()=>{n&&(n(rp(e,b.ms)),u(!1))},Y=I=>{const f=ys(i,I.feature),{summary:w,detail:P}=pl(I);return t.jsxs(o.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:$(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:qn(I.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:$(f,.1),color:f,border:`1px solid ${$(f,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:w}),P&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:P}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(O.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:fl(I.timestamp)})]}),I.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(O.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:I.user})]})]})]})]},I.id)},Z=v?k.map(I=>({feature:I,events:T.filter(f=>f.feature===I)})).filter(I=>I.events.length>0):[];return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:$(s.common.black,.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:t.jsxs(o.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:ot(i),bgcolor:"background.paper",overflow:"hidden",...de(i).paper,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:[t.jsxs(o.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,...de(i).header},children:[t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:I=>I.typography.body1.fontSize||"0.9375rem",fontWeight:I=>I.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx(pt,{content:Mr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:I=>I.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[T.length," event",T.length!==1?"s":""," recorded"]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Select,{value:a,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:$(s.text.primary,.3)}},children:js.map(I=>t.jsx(o.MenuItem,{value:I.key,sx:{fontSize:"0.8125rem"},children:I.label},I.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(O.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:H,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:$(s.error.main,.5),"&:hover":{bgcolor:$(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),k.length>1&&t.jsx(o.IconButton,{onClick:()=>S(I=>!I),size:"small",title:m?"Hide category filter":"Show category filter",sx:{color:m?"primary.main":"text.secondary",bgcolor:m?$(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:m?$(s.primary.main,.16):"action.hover"}},children:t.jsx(O.FilterAltOutlined,{sx:{fontSize:17}})}),t.jsx(o.IconButton,{onClick:()=>D(I=>!I),size:"small",title:C?"Sorted oldest first":"Sorted newest first",sx:{color:C?"primary.main":"text.secondary",bgcolor:C?$(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:C?$(s.primary.main,.16):"action.hover"}},children:t.jsx(O.SortOutlined,{sx:{fontSize:17,transform:C?"scaleY(-1)":"none"}})}),t.jsx(o.IconButton,{onClick:()=>x(I=>!I),size:"small",title:v?"Ungroup events":"Group by category",sx:{color:v?"primary.main":"text.secondary",bgcolor:v?$(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:v?$(s.primary.main,.16):"action.hover"}},children:t.jsx(O.WorkspacesOutlined,{sx:{fontSize:17}})}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:17}})})]})]}),k.length>1&&m&&t.jsxs(o.Tabs,{value:y,onChange:(I,f)=>g(f),variant:"scrollable",scrollButtons:"auto",sx:{minHeight:36,flexShrink:0,borderBottom:"1px solid",borderColor:"divider",px:1.5,"& .MuiTabs-indicator":{height:2}},children:[t.jsx(o.Tab,{value:"all",label:`All (${B.length})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}}),k.map(I=>t.jsx(o.Tab,{value:I,label:`${qn(I)} (${h[I]})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}},I))]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:$(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$(s.text.primary,.14),borderRadius:3}},children:T.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx(O.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:I=>I.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:I=>I.typography.body2.fontWeight||500},children:B.length===0?"No audit events yet":"No events in this category"}),t.jsx(o.Typography,{sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:B.length===0?"Changes to this report will appear here":"Try a different category tab"})]}):v?t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:Z.map(({feature:I,events:f})=>t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75,px:.25},children:[t.jsx(o.Box,{sx:{width:6,height:6,borderRadius:"50%",bgcolor:ys(i,I)}}),t.jsxs(o.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"text.secondary"},children:[qn(I)," (",f.length,")"]})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:f.map(Y)})]},I))}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:T.map(Y)})})]})}),t.jsxs(o.Dialog,{open:l,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Mo(i),...de(i).paper}},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:$(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:I=>I.typography.body1.fontSize||"0.9375rem",fontWeight:I=>I.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:I=>I.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[R," audit record",R!==1?"s":""]})," ",b.key==="all"?"from all time":`from the ${b.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:E,variant:"contained",color:"error",startIcon:t.jsx(O.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",R," Record",R!==1?"s":""]})]})]})]})}function np({onSave:e,onClose:r}){const[n,i]=p.useState(""),[s,a]=p.useState(""),[c,l]=p.useState(""),[u,y]=p.useState([]),[g,m]=p.useState(""),[S,C]=p.useState(""),D=b=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b),v=()=>{const b=c.trim();if(b){if(!D(b)){C("Please enter a valid email address");return}if(u.includes(b)){C("This email is already added");return}y([...u,b]),l(""),C("")}},x=b=>{y(u.filter(R=>R!==b))},B=b=>{b.key==="Enter"&&(b.preventDefault(),v())},h=()=>{if(!n.trim()){m("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},k=b=>{i(b),g&&m("")},T=b=>{l(b),S&&C("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:b=>$(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:t.jsxs(o.Paper,{onClick:b=>b.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:b=>ot(b),bgcolor:"background.paper",outline:"none",boxShadow:b=>de(b).paper.boxShadow,border:b=>de(b).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:b=>de(b).header.backgroundColor,borderBottom:b=>de(b).header.borderBottom,boxShadow:b=>de(b).header.boxShadow,flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:b=>b.typography.h6.fontSize||"1.125rem",fontWeight:b=>b.typography.h6.fontWeight||500,color:b=>b.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:b=>$(b.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:b=>$(b.palette.text.primary,.3)}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(o.Alert,{severity:"info",icon:t.jsx(O.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:b=>`1px solid ${$(b.palette.primary.main,.3)}`,bgcolor:b=>It(b),"& .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."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:b=>b.typography.body2.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."}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.6875rem",fontWeight:b=>b.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(o.TextField,{required:!0,value:n,onChange:b=>k(b.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!g,helperText:g,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"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}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.6875rem",fontWeight:b=>b.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(o.TextField,{value:s,onChange:b=>a(b.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}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.6875rem",fontWeight:b=>b.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[t.jsx(o.TextField,{value:c,onChange:b=>T(b.target.value),onKeyPress:B,placeholder:"Enter email address",error:!!S,helperText:S,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx(O.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}}}),t.jsx(o.Button,{onClick:v,variant:"outlined",startIcon:t.jsx(O.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:b=>`${b.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(b=>t.jsx(o.Chip,{label:b,onDelete:()=>x(b),deleteIcon:t.jsx(O.Delete,{sx:{fontSize:16}}),sx:{bgcolor:R=>It(R),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},b))}),t.jsx(o.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"})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:r,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"}),t.jsx(o.Button,{onClick:h,variant:"contained",startIcon:t.jsx(O.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:b=>`${b.shape.borderRadius}px`,boxShadow:b=>ve(b,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:b=>ve(b,"hoverButton")},"&:active":{boxShadow:b=>ve(b,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function ip({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx(O.Link,{sx:{fontSize:14}}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600},children:e})]}),onDelete:r,deleteIcon:t.jsx(o.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:t.jsx(O.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>$(n.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function sp({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const a=c=>new Date(c).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:c=>$(c.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:c=>c.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:c=>c.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:c=>ot(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>de(c).paper.boxShadow,border:c=>de(c).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:c=>de(c).header.backgroundColor,borderBottom:c=>de(c).header.borderBottom,boxShadow:c=>de(c).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:c=>c.typography.h6.fontSize||"1.125rem",fontWeight:c=>c.typography.h6.fontWeight||500,color:c=>c.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:c=>c.typography.caption.fontSize||"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[e.length," saved ",e.length===1?"preset":"presets"]})]}),t.jsx(o.IconButton,{onClick:s,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"divider",borderRadius:4,"&:hover":{bgcolor:c=>$(c.palette.text.primary,.2)}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(O.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(o.Typography,{variant:"body1",sx:{fontSize:c=>c.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:c=>c.typography.body2.fontSize||"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(c=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:l=>ve(l,"restButtonLight")}},children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.body1.fontSize||"0.9375rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:c.name}),c.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:c.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${a(c.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${c.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",gap:1},children:t.jsx(o.Button,{onClick:()=>i(c.id,c.name),variant:"outlined",size:"small",startIcon:t.jsx(O.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:l=>$(l.palette.error.main,.04)}},children:"Delete"})})]},c.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:c=>`${c.shape.borderRadius}px`,boxShadow:c=>ve(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>ve(c,"hoverButton")},"&:active":{boxShadow:c=>ve(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const la={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},ap=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],lp=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function cp(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=lp.some(l=>l.test(i.name));let a=!1;const c=r.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);c.length>0&&(a=c.filter(u=>ap.some(y=>y.test(u))).length/c.length>.6),(s||a)&&n.push(i.name)}return n}function Tn(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(c=>{const l=n.map(y=>String(y[c]??"")).filter(y=>y.length>0);if(l.length===0)return 5;const u=l.reduce((y,g)=>y+g.length,0);return Math.ceil(u/l.length)+1}).reduce((c,l)=>c+l,0)+1;return r.reduce((c,l)=>c+l.length+1,0)+s*e.length}function dp(e,r){const n=Tn(e,r);return Math.ceil(n*3.5)}function up(e,r){const n=Tn(e,r);return Math.ceil(n*.7)}function pp(e,r){const n=Tn(e,r);return Math.ceil(n*2)}function hp(e,r,n){switch(e){case"csv":return Tn(r,n);case"excel":return up(r,n);case"json":return dp(r,n);case"pdf":return pp(r,n)}}function ks(e,r){return Math.ceil(e/r)}function mp(e,r,n,i,s=la){const a=[],c=hp(e,r,n),l=r.length;if(l>s.maxRowsHard){const g=ks(l,s.maxRows);a.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 ${g} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const g=ks(l,s.maxRows);a.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 ${g} smaller export${g>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${zo(c)} exceeds the ${zo(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&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${zo(c)}`,detail:`This exceeds the recommended ${zo(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),e!=="excel"){const g=cp(i.filter(m=>n.includes(m.name)),r);if(g.length>0){const m=g.length>s.maxImageColumns;a.push({type:"image_columns",severity:m?"error":"warning",message:`Image column${g.length>1?"s":""} detected: ${g.map(S=>`"${S.replace(/_/g," ")}"`).join(", ")}`,detail:m?`Exporting ${g.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:g.length,limit:s.maxImageColumns})}}const u=a.some(g=>g.severity==="error"),y=a.some(g=>g.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:y,estimatedBytes:c}}function zo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function fp({violation:e}){const n=ht().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=$(i?n.error.main:n.warning.main,.06),c=i?$(n.error.main,.25):$(n.warning.main,.3),l=i?O.ErrorOutline:O.WarningAmberOutlined;return t.jsxs(o.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:a,border:"1px solid",borderColor:c},children:[t.jsx(l,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx(O.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function xp({format:e}){const r=ht(),n={csv:{color:r.palette.primary.main,bg:r.palette.primary.main,label:"CSV"},excel:{color:r.palette.success.main,bg:r.palette.success.main,label:"XLSX"},json:{color:r.palette.text.secondary,bg:r.palette.text.secondary,label:"JSON"},pdf:{color:r.palette.error.main,bg:r.palette.error.main,label:"PDF"}}[e];return t.jsxs(o.Box,{sx:{width:44,height:52,position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",mb:1},children:[t.jsxs("svg",{width:"38",height:"46",viewBox:"0 0 38 46",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M5 2C3.34315 2 2 3.34315 2 5V41C2 42.6569 3.34315 44 5 44H33C34.6569 44 36 42.6569 36 41V13L25 2H5Z",fill:r.palette.background.paper,stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M24 2V13H36",fill:$(r.palette.text.primary,.05),stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"})]}),t.jsx(o.Box,{sx:{position:"absolute",bottom:8,left:3,right:3,bgcolor:n.bg,color:r.palette.primary.contrastText,fontSize:"0.625rem",fontWeight:800,py:.25,borderRadius:"3px",textAlign:"center",letterSpacing:"0.05em"},children:n.label})]})}function zs({checked:e}){const r=ht();return t.jsx(o.Box,{sx:{width:20,height:20,borderRadius:"50%",border:e?`2px solid var(--urm-export-card-selected-border, ${r.palette.primary.main})`:`2px solid var(--urm-export-radio-border, ${r.palette.divider})`,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:r.palette.background.paper,transition:"all 0.15s ease",flexShrink:0},children:e&&t.jsx(o.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:`var(--urm-export-card-selected-border, ${r.palette.primary.main})`}})})}function gp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:c=[],allRows:l=[],processedRows:u=[],initialFormat:y,initialScope:g="visible",initialColumnScope:m="visible",classTokens:S={},onExport:C,onClose:D}){const v=ht(),x=v.palette,B=gr(),h=p.useMemo(()=>{var ue,pe,K,he,le;const J=((K=(pe=(ue=v.components)==null?void 0:ue.MuiCard)==null?void 0:pe.styleOverrides)==null?void 0:K.root)||{},re=J.border&&J.border!=="none"?J.border:(he=v.tokens)!=null&&he.cardBodyBorder&&v.tokens.cardBodyBorder!=="none"?v.tokens.cardBodyBorder:x.divider,we=J.borderRadius!==void 0?typeof J.borderRadius=="number"?`${J.borderRadius}px`:J.borderRadius:`${v.shape.borderRadius}px`,F=J.boxShadow&&J.boxShadow!=="none"?J.boxShadow:((le=v.tokens)==null?void 0:le.cardBodyShadow)||ve(v,"menu"),X=ct(v);return{sectionBorder:`var(--urm-export-section-border, ${re})`,sectionTitleColor:`var(--urm-export-section-title-color, ${x.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${x.background.paper})`,cardBg:`var(--urm-export-card-bg, ${x.background.paper})`,cardBorder:`var(--urm-export-card-border, ${re})`,cardRadius:we,cardShadow:F,cardHoverBg:`var(--urm-export-card-hover-bg, ${x.mode==="dark"?$(x.common.white,.08):$(x.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${$(X.main,x.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${X.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${x.mode==="dark"?x.primary.light:x.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${x.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${x.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${x.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${v.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${v.spacing(1.5)})`}},[x,v]),k=y||(B.export.allowedFormats.includes("pdf")?"pdf":B.export.allowedFormats[0]||"csv"),[T,b]=p.useState(k),[R,H]=p.useState(g),[E,Y]=p.useState(m),Z=R==="visible"?r:e,I=E==="visible"?i:s,f=p.useMemo(()=>R==="visible"?u.length>0?u:new Array(r):l.length>0?l:new Array(e),[R,r,e,u,l]),w=p.useMemo(()=>E==="all"?a.map(J=>J.name):a.map(J=>J.name).slice(0,i),[E,a,i]),P=p.useMemo(()=>mp(T,f,w,a,la),[T,f,w,a]),te=()=>{P.hasBlockingViolation||(C({format:T,scope:R,columnScope:E}),D())},d={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:D,className:`urm-export-backdrop ${S.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:$(x.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:v.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:J=>J.stopPropagation(),elevation:0,className:`urm-export-paper ${S.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:ot(v),bgcolor:h.sectionTitleBg,overflow:"hidden",border:`1px solid ${h.cardBorder}`,boxShadow:h.cardShadow,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:[t.jsxs(o.Box,{className:`urm-export-header ${S.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:J=>de(J).header.backgroundColor,borderBottom:J=>de(J).header.borderBottom,boxShadow:J=>de(J).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${S.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:x.text.primary},children:"Export Report"}),t.jsx(pt,{content:Mr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:D,size:"small",className:`urm-export-close ${S.modalCloseButton||""}`,sx:{color:x.text.secondary,borderRadius:"50%","&:hover":{bgcolor:x.action.hover,color:x.text.primary}},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${S.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:h.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$(x.text.primary,.15),borderRadius:3}},children:[P.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:P.violations.map((J,re)=>t.jsx(fp,{violation:J},re))}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:h.optionGap},children:[{id:"csv",title:"CSV",info:"Comma-separated values, compatible with Excel",allowed:B.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:B.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:B.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:B.export.allowedFormats.includes("pdf")}].filter(J=>J.allowed).map(J=>{const re=T===J.id;return t.jsxs(o.Box,{onClick:()=>b(J.id),className:`urm-export-format-card ${re?S.formatCardSelected||"":S.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:$(x.text.primary,.25),bgcolor:re?h.cardSelectedBg:h.cardHoverBg}},children:[re&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:h.cardSelectedBorder,color:x.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${$(x.primary.main,.3)}`},children:t.jsx(O.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(xp,{format:J.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:re?h.cardSelectedColor:x.text.primary},children:J.title}),t.jsx(o.Tooltip,{title:J.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:we=>we.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:x.text.secondary,"&:hover":{color:x.text.primary}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:13}})})})]})]},J.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:h.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx(O.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx(O.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(J=>{const re=R===J.value;return t.jsxs(o.Box,{onClick:()=>H(J.value),className:`urm-export-row-card ${re?S.rowCardSelected||"":S.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:$(x.text.primary,.25),bgcolor:re?h.cardSelectedBg:h.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(zs,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:x.text.secondary,display:"flex"},children:J.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:x.text.primary},children:J.label})]}),t.jsx(o.Tooltip,{title:J.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:we=>we.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:x.text.secondary,"&:hover":{color:x.text.primary}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:16}})})})]},J.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:h.optionGap},children:[{value:"visible",label:"Visible columns",icon:t.jsx(O.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx(O.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(J=>{const re=E===J.value;return t.jsxs(o.Box,{onClick:()=>Y(J.value),className:`urm-export-column-card ${re?S.columnCardSelected||"":S.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:$(x.text.primary,.25),bgcolor:re?h.cardSelectedBg:h.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(zs,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:x.text.secondary,display:"flex"},children:J.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:x.text.primary},children:J.label})]}),t.jsx(o.Tooltip,{title:J.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:we=>we.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:x.text.secondary,"&:hover":{color:x.text.primary}},children:t.jsx(O.InfoOutlined,{sx:{fontSize:16}})})})]},J.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${S.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx(O.InsertDriveFileOutlined,{sx:{fontSize:18,color:x.text.secondary}}),label:"Format",value:d[T]},{icon:t.jsx(O.FormatListNumberedOutlined,{sx:{fontSize:18,color:x.text.secondary}}),label:"Rows to Export",value:Z.toLocaleString()},{icon:t.jsx(O.SwapVertOutlined,{sx:{fontSize:18,color:x.text.secondary}}),label:"Columns to Export",value:String(I)},{icon:t.jsx(O.InsertDriveFileOutlined,{sx:{fontSize:18,color:x.text.secondary}}),label:"Estimated File Size",value:`~${zo(P.estimatedBytes)}`,highlight:P.hasBlockingViolation?"error.main":P.hasWarning?"warning.main":void 0}].map(({icon:J,label:re,value:we,highlight:F})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${S.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[J,t.jsx(o.Typography,{className:`urm-export-summary-label ${S.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:x.text.secondary,fontWeight:500},children:re})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${S.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:F??x.text.primary},children:we})]},re))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${S.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[P.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx(O.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:J=>J.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:J=>J.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:D,variant:"outlined",className:`urm-export-cancel-btn ${S.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:x.text.primary,borderColor:h.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:h.cardHoverBg,borderColor:$(x.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:te,disabled:P.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${S.downloadButton||""}`,startIcon:t.jsx(O.Download,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:h.primaryBtnBg,color:h.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${$(x.primary.main,.25)}`,"&:hover":{bgcolor:h.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:$(x.primary.main,.4),color:h.primaryBtnColor}},children:["Download ",d[T]]})]})]})})}function yp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(O.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx(O.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:e.message}),t.jsxs(o.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some"," ",e.type==="filter"?"filters":e.type==="sort"?"sort levels":"grouping levels"," ","before adding more."]})]})})}function bp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=3e4}){p.useEffect(()=>{if(n){const l=setTimeout(()=>{r()},i);return()=>clearTimeout(l)}},[n,i,r]);const a=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx(O.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx(O.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx(O.InfoOutlined,{sx:{fontSize:20}})}}})(),c=zl(e);return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx(O.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${a.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:l=>l.typography.h6.fontWeight||600,fontSize:l=>l.typography.subtitle2.fontSize||"0.875rem"},children:[e.context.charAt(0).toUpperCase()+e.context.slice(1)," Error"]}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:c}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.details,null,2)})]})})}class vp extends p.Component{constructor(n){super(n);Ii(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){Jt.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:t.jsx(o.Paper,{sx:{bgcolor:s=>$(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(O.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:s=>s.typography.h6.fontWeight||600,fontSize:s=>s.typography.h6.fontSize||"1.25rem"},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(o.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"&&t.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>$(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),t.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx(O.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Sp({feature:e}){const[r,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),t.jsx(o.Collapse,{in:r,unmountOnExit:!0,children:t.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:t.jsx(O.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx(O.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Zo({children:e,feature:r,onError:n}){return t.jsx(vp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(Sp,{feature:r}),children:e})}const Cp=[{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"}],wp=[{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"},{value:"pdf",label:"PDF",desc:"Print-ready PDF document"}],_r={sortMaxLevels:{title:"Maximum Sort Levels",description:"Limits the number of columns users can sort by simultaneously. Restricts multi-level sort depth.",tips:['"Add sort column" button is disabled at this limit',"Prevents adding more sort levels to the active sort stack","Default: 5 levels (range: 1–10)"]},filterMaxConditions:{title:"Maximum Filter Conditions",description:"Limits the total number of active filter conditions users can apply at once.",tips:['"Add condition" button is disabled at this limit',"Prevents performance degradation on large datasets","Default: 3 conditions (range: 1–20)"]},filterAllowedOperators:{title:"Allowed Filter Operators",description:"Controls which comparison operators appear in the filter UI. Unchecked operators are hidden from all dropdowns.",tips:["Simplifies the UI by hiding advanced operators your users don't need","At least one operator per data type must remain checked","Operators grouped by type: Text, Numeric, Boolean, Null checks"]},columnsMaxVisible:{title:"Maximum Visible Columns",description:"Limits the number of columns users can display at once in the data table.",tips:["Column visibility toggle is disabled when this limit is reached","Forces users to be selective about which columns to show","Default: 20 columns (range: 1–50)"]},columnsWidthRange:{title:"Column Width Constraints",description:"Sets minimum and maximum pixel widths for column resizing. Prevents columns from becoming too narrow or too wide.",tips:["Users cannot drag column borders outside this range","Min default: 60px, Max default: 800px","Ensures readable content and consistent layout"]},exportAllowedFormats:{title:"Allowed Export Formats",description:"Determines which export formats appear in the Export dialog and row-level export menus. At least one must be enabled.",tips:["Disabled formats don't appear in any export UI","PDF is now available as a print-ready export option","Unchecked formats are completely hidden from end users"]},groupingMaxLevels:{title:"Maximum Group Levels",description:"Limits how deeply users can nest grouped data. Enforced when adding new group levels.",tips:['"Add group level" button is hidden at this limit',"Range: 1 (single group only) to 3 (triple nested groups)","Prevents overly complex grouping hierarchies"]}};function Co({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5,height:"200px",width:"100%"},children:e})}function jp({open:e,onClose:r,config:n,onApply:i}){const[s,a]=p.useState(0),[c,l]=p.useState(n),u=()=>l(n),y=()=>l(yt),g=()=>{i(c),r()},m={sort:x=>l(B=>({...B,sort:{...B.sort,...x}})),filter:x=>l(B=>({...B,filter:{...B.filter,...x}})),columns:x=>l(B=>({...B,columns:{...B.columns,...x}})),grouping:x=>l(B=>({...B,grouping:{...B.grouping,...x}})),export:x=>l(B=>({...B,export:{...B.export,...x}}))},S=x=>{const B=c.filter.allowedOperators,h=B.includes(x)?B.filter(k=>k!==x):[...B,x];h.length!==0&&m.filter({allowedOperators:h})},C=x=>{const B=c.export.allowedFormats,h=B.includes(x)?B.filter(k=>k!==x):[...B,x];h.length!==0&&m.export({allowedFormats:h})},D=[{label:"Sort",icon:t.jsx(O.SwapVert,{sx:{fontSize:x=>x.typography.body1.fontSize}})},{label:"Filter",icon:t.jsx(O.FilterList,{sx:{fontSize:x=>x.typography.body1.fontSize}})},{label:"Columns",icon:t.jsx(O.ViewColumn,{sx:{fontSize:x=>x.typography.body1.fontSize}})},{label:"Grouping",icon:t.jsx(O.Layers,{sx:{fontSize:x=>x.typography.body1.fontSize}})},{label:"Export",icon:t.jsx(O.Download,{sx:{fontSize:x=>x.typography.body1.fontSize}})}],v=x=>JSON.stringify(c[x])===JSON.stringify(yt[x]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:x=>ot(x),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:x=>x.shadows[8]}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:x=>x.shape.borderRadius,bgcolor:x=>$(x.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:x=>x.typography.h5.fontSize},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:t.jsx(O.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:t.jsx(o.Tabs,{value:s,onChange:(x,B)=>a(B),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:x=>x.typography.caption.fontSize,textTransform:"none",fontWeight:x=>x.typography.button.fontWeight,gap:.5}},children:D.map((x,B)=>t.jsx(o.Tab,{label:x.label,icon:x.icon,iconPosition:"start"},B))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0,minHeight:300},children:[t.jsx(Co,{active:s===0,children:t.jsxs(o.Box,{children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),t.jsx(pt,{content:_r.sortMaxLevels,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.Slider,{value:c.sort.maxLevels,onChange:(x,B)=>m.sort({maxLevels:B}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]})}),t.jsxs(Co,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),t.jsx(pt,{content:_r.filterMaxConditions,isDev:process.env.NODE_ENV==="development"})]}),!v("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Slider,{value:c.filter.maxConditions,onChange:(x,B)=>m.filter({maxConditions:B}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed filter operators"}),t.jsx(pt,{content:_r.filterAllowedOperators,isDev:process.env.NODE_ENV==="development"})]}),["Text","Numeric","Boolean","Null checks"].map(x=>t.jsxs(o.Box,{sx:{mb:1.5},children:[t.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:B=>B.typography.overline.fontSize,display:"block",mb:.5},children:x}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:Cp.filter(B=>B.group===x).map(B=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(B.value),onChange:()=>S(B.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:B.label}),sx:{mr:1.5}},B.value))})]},x))]})]}),t.jsxs(Co,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),t.jsx(pt,{content:_r.columnsMaxVisible,isDev:process.env.NODE_ENV==="development"})]}),!v("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Slider,{value:c.columns.maxVisible,onChange:(x,B)=>m.columns({maxVisible:B}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:2},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Column width range (px)"}),t.jsx(pt,{content:_r.columnsWidthRange,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:c.columns.minColumnWidth,onChange:(x,B)=>m.columns({minColumnWidth:B}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:x=>`${x}px`})]}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(o.Slider,{value:c.columns.maxColumnWidth,onChange:(x,B)=>m.columns({maxColumnWidth:B}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:x=>`${x}px`})]})]})]})]}),t.jsx(Co,{active:s===3,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),t.jsx(pt,{content:_r.groupingMaxLevels,isDev:process.env.NODE_ENV==="development"})]}),!v("grouping")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(x=>t.jsxs(o.Box,{onClick:()=>m.grouping({maxLevels:x}),sx:{flex:1,py:2.5,borderRadius:B=>Number(B.shape.borderRadius||0)*1.25,border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===x?"primary.main":"divider",bgcolor:c.grouping.maxLevels===x?B=>$(B.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:B=>$(B.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===x?"primary.main":"text.secondary"},children:x}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][x-1]})]},x))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowNested,onChange:x=>m.grouping({allowNested:x.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowCollapse,onChange:x=>m.grouping({allowCollapse:x.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]})}),t.jsx(Co,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),t.jsx(pt,{content:_r.exportAllowedFormats,isDev:process.env.NODE_ENV==="development"})]}),!v("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.FormGroup,{sx:{gap:1},children:wp.map(x=>t.jsxs(o.Box,{onClick:()=>C(x.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:B=>B.shape.borderRadius,border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:c.export.allowedFormats.includes(x.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(x.value)?B=>$(B.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(x.value),onChange:()=>C(x.value),onClick:B=>B.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:x.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:x.desc})]})]},x.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:x=>$(x.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx(O.RestartAlt,{sx:{fontSize:18}}),onClick:y,size:"small",sx:{fontSize:x=>x.typography.body2.fontSize,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:x=>$(x.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:x=>x.typography.body2.fontSize,color:"text.secondary",px:2,borderRadius:x=>Number(x.shape.borderRadius)*2.25},children:"Cancel"}),t.jsx(o.Button,{onClick:g,size:"small",variant:"contained",sx:{fontSize:x=>x.typography.body2.fontSize,px:2.5,borderRadius:x=>Number(x.shape.borderRadius)*2.25},children:"Apply"})]})]})]})}const kp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],zp={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 tn(e,r,n,i,s=new Date){const[a,c]=r.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(a,c,0,0),e==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(e==="weekly"){const u=n??1,y=l.getDay();let g=u-y;return g<0&&(g+=7),g===0&&l<=s&&(g=7),l.setDate(l.getDate()+g),l.toISOString()}if(e==="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 Bp(e){const r=ca(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${kp[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${zp[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function ca(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function Tp(e){const r=new Date(e).getTime()-Date.now();if(r<=0)return"now";const n=Math.floor(r/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${a}m`:a>0?`in ${a}m`:"in less than a minute"}function Ip(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=ca(`${String(r.getHours()).padStart(2,"0")}:${String(r.getMinutes()).padStart(2,"0")}`);return i?`Today at ${s}`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${s}`}function da(e){return`urm_schedules_${e}`}function ua(e){try{const r=localStorage.getItem(da(e));return r?JSON.parse(r).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 pa(e,r){try{localStorage.setItem(da(e),JSON.stringify(r))}catch{}}const Ep=[{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"}],Dp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ha={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",email:""},$r={"& .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 _p({initial:e=ha,isEditing:r=!1,onSave:n,onBack:i}){const[s,a]=p.useState(e),[c,l]=p.useState(!1),[u,y]=p.useState(!1),g=(C,D)=>a(v=>({...v,[C]:D})),m=s.email.trim().length>0&&!Dp.test(s.email.trim()),S=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!m;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:C=>$(C.palette.text.primary,.06)}},children:t.jsx(O.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:C=>C.typography.body2.fontWeight||600,fontSize:C=>C.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:C=>{g("name",C.target.value),c&&C.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:$r}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:$r,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:C=>g("frequency",C.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:$r,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:C=>g("dayOfWeek",Number(C.target.value)),children:Ep.map(C=>t.jsx(o.MenuItem,{value:C.value,children:C.label},C.value))})]}),s.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:C=>g("dayOfMonth",Number(C.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:$r}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:C=>g("time",C.target.value),InputLabelProps:{shrink:!0},sx:$r}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:$r,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:C=>g("format",C.target.value),children:[t.jsx(o.MenuItem,{value:"pdf",children:"PDF — Print-ready document"}),t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:C=>g("scope",C.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsx(o.Box,{children:t.jsx(o.TextField,{label:"Email reminder",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:C=>g("email",C.target.value),onBlur:()=>y(!0),placeholder:"user@company.com",error:u&&m,helperText:u&&m?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx(O.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:$r})}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:C=>$(C.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>S&&n(s),disabled:!S,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function $p({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:Mo(i),...de(i).paper})},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>$(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(O.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:i=>i.typography.body1.fontSize||"0.9375rem",fontWeight:i=>i.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(o.Typography,{sx:{fontSize:i=>i.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',e,'"']}),"? This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Op({schedule:e,tick:r,onToggle:n,onRunNow:i,onEdit:s,onDelete:a}){const c=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:c?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:c?l=>$(l.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:c?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:c?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:c?l=>$(l.palette.success.main,.1):l=>$(l.palette.text.primary,.06),color:c?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Bp(e)}),t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[t.jsx(o.Chip,{label:e.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:l=>$(l.palette.primary.main,.08),color:"primary.main"}}),t.jsx(o.Chip,{label:e.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:l=>$(l.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx(O.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>$(l.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[c&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",Tp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Ip(e.lastRunAt)," · ",e.runCount," run",e.runCount!==1?"s":""]}):t.jsx(o.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[t.jsx(o.Tooltip,{title:"Edit",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>s(e),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:l=>$(l.palette.primary.main,.08)}},children:t.jsx(O.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:c?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:c?"warning.main":"success.main","&:hover":{bgcolor:c?l=>$(l.palette.warning.main,.08):l=>$(l.palette.success.main,.08)}},children:c?t.jsx(O.Pause,{sx:{fontSize:15}}):t.jsx(O.PlayArrow,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Export now",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>i(e),sx:{color:"primary.main","&:hover":{bgcolor:l=>$(l.palette.primary.main,.08)}},children:t.jsx(O.Download,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Delete",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>a(e.id),sx:{color:"error.main","&:hover":{bgcolor:l=>$(l.palette.error.main,.08)}},children:t.jsx(O.Delete,{sx:{fontSize:15}})})})]})]})]})}function Mp({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,schedulerConfig:a}){const l=((a==null?void 0:a.mode)??"local")==="api",[u,y]=p.useState([]),g=l?(a==null?void 0:a.schedules)??[]:u,[m,S]=p.useState({type:"list"}),[C,D]=p.useState(0),[v,x]=p.useState(null);p.useEffect(()=>{e&&(l||y(ua(n)),S({type:"list"}))},[e,n,l]),p.useEffect(()=>{if(!e)return;const I=setInterval(()=>D(f=>f+1),3e4);return()=>clearInterval(I)},[e]);const B=p.useCallback(I=>{y(I),pa(n,I)},[n]),h=I=>{var P;const f=tn(I.frequency,I.time,I.dayOfWeek,I.dayOfMonth),w={id:`sched-${Date.now()}`,reportId:n,name:I.name.trim(),frequency:I.frequency,dayOfWeek:I.frequency==="weekly"?I.dayOfWeek:void 0,dayOfMonth:I.frequency==="monthly"?I.dayOfMonth:void 0,time:I.time,format:I.format,scope:I.scope,email:I.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:f,runCount:0};l?(P=a==null?void 0:a.onScheduleCreate)==null||P.call(a,w):B([...g,w]),S({type:"list"})},k=I=>{var te;if(m.type!=="edit")return;const f=m.schedule,w=tn(I.frequency,I.time,I.dayOfWeek,I.dayOfMonth),P={...f,name:I.name.trim(),frequency:I.frequency,dayOfWeek:I.frequency==="weekly"?I.dayOfWeek:void 0,dayOfMonth:I.frequency==="monthly"?I.dayOfMonth:void 0,time:I.time,format:I.format,scope:I.scope,email:I.email.trim()||void 0,nextRunAt:w};l?(te=a==null?void 0:a.onScheduleUpdate)==null||te.call(a,P):B(g.map(d=>d.id===f.id?P:d)),S({type:"list"})},T=I=>{var d;const f=g.find(J=>J.id===I);if(!f)return;const w=!f.isActive,P=w?tn(f.frequency,f.time,f.dayOfWeek,f.dayOfMonth):f.nextRunAt,te={...f,isActive:w,nextRunAt:P};l?(d=a==null?void 0:a.onScheduleToggle)==null||d.call(a,I,w):B(g.map(J=>J.id===I?te:J))},b=I=>{if(s(I),!l){const f=new Date().toISOString();B(g.map(w=>w.id===I.id?{...w,lastRunAt:f,runCount:w.runCount+1}:w))}},R=I=>{const f=g.find(w=>w.id===I)??null;x(f)},H=()=>{var I;v&&(l?(I=a==null?void 0:a.onScheduleDelete)==null||I.call(a,v.id):B(g.filter(f=>f.id!==v.id)),x(null))},E=I=>({name:I.name,frequency:I.frequency,dayOfWeek:I.dayOfWeek??1,dayOfMonth:I.dayOfMonth??1,time:I.time,format:I.format,scope:I.scope,email:I.email??""}),Y=m.type!=="list",Z=g.filter(I=>I.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:Y,PaperProps:{sx:I=>({borderRadius:ot(I),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...de(I).paper})},children:[t.jsxs(o.DialogTitle,{sx:I=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...de(I).header}),children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:I=>$(I.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(O.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:I=>I.typography.h6.fontWeight||600,fontSize:I=>I.typography.subtitle2.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx(pt,{content:Mr.schedule,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary","&:hover":{bgcolor:I=>$(I.palette.text.primary,.06)}},children:t.jsx(O.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[Y&&t.jsx(_p,{initial:m.type==="edit"?E(m.schedule):ha,isEditing:m.type==="edit",onSave:m.type==="edit"?k:h,onBack:()=>S({type:"list"})}),m.type==="list"&&t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:g.length===0?"No schedules yet":`${Z} of ${g.length} active`}),t.jsx(o.Button,{startIcon:t.jsx(O.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>S({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),g.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx(O.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:I=>I.typography.body2.fontWeight||500,fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:g.map(I=>t.jsx(Op,{schedule:I,tick:C,onToggle:T,onRunNow:b,onEdit:f=>S({type:"edit",schedule:f}),onDelete:R},I.id))})]})]}),m.type==="list"&&t.jsx(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:I=>$(I.palette.text.primary,.06)}},children:"Close"})})]}),v&&t.jsx($p,{scheduleName:v.name,onConfirm:H,onCancel:()=>x(null)})]})}const Ap=6e4;function Wp({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:y,onFired:g,schedulerConfig:m}){const S=(m==null?void 0:m.mode)??"local",C=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:y,onFired:g,schedulerConfig:m,schedulerMode:S});p.useEffect(()=>{C.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:u,sortStack:y,onFired:g,schedulerConfig:m,schedulerMode:S}});const D=p.useCallback(v=>{var I,f,w,P,te;const{reportName:x,uploadedData:B,processedData:h,schema:k,activeView:T,columnVisibility:b,columnOrder:R,filters:H,sortStack:E,schedulerConfig:Y,schedulerMode:Z}=C.current;try{const d=v.scope==="all"?B:h;if(Z==="api"){const we=(R.length>0?R:k.map(X=>X.name)).filter(X=>b[X]!==!1),F={schedule:v,triggeredAt:new Date().toISOString(),rows:d,columns:we,format:v.format,reportName:x};(I=Y==null?void 0:Y.onScheduleFire)==null||I.call(Y,F),(w=(f=C.current).onFired)==null||w.call(f,v);return}const J=rn(d,k,H,E,T,b,R),re=`${v.name}_scheduled`;switch(v.format){case"csv":on(J,re,{scope:v.scope});break;case"excel":nn(J,re,{scope:v.scope});break;case"json":sn(J,re,{scope:v.scope});break;case"pdf":yi(J,re,{scope:v.scope});break}if(Y!=null&&Y.onScheduleFire){const we=(R.length>0?R:k.map(F=>F.name)).filter(F=>b[F]!==!1);Y.onScheduleFire({schedule:v,triggeredAt:new Date().toISOString(),rows:d,columns:we,format:v.format,reportName:x})}if(v.email){const we=encodeURIComponent(`Scheduled Report: ${v.name}`),F=encodeURIComponent(`Your scheduled report "${v.name}" has been generated.
191
+ ]`})})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Number:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Boolean:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"String:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Date:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[t.jsx("li",{children:"Each object in the array represents one row in the report."}),t.jsx("li",{children:"The keys of the JSON objects become report columns."}),t.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),t.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,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=>be(i,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:i=>be(i,"hoverButton")},"&:active":{boxShadow:i=>be(i,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function cu({onFileUpload:e,onError:r,isUploading:n,jsonGuideContent:i}){const[s,a]=p.useState(!1),[d,l]=p.useState(""),[u,x]=p.useState(!1),g=p.useRef(null),m=async h=>{if(!h.name.endsWith(".json")){r("Only .json files are allowed");return}const j=10*1024*1024;if(h.size>j){r("File size exceeds 10MB limit");return}l(h.name);try{const T=await h.text();let b;try{b=JSON.parse(T)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(b)){r("JSON must be an array of objects");return}if(b.length===0){r("No data rows found in JSON file");return}e(b)}catch{r("Network error — please try again")}finally{l("")}},C=h=>{h.preventDefault(),a(!0)},S=h=>{h.preventDefault(),a(!1)},E=h=>{h.preventDefault(),a(!1);const j=h.dataTransfer.files[0];j&&m(j)},v=()=>{var h;(h=g.current)==null||h.click()},y=h=>{var T;const j=(T=h.target.files)==null?void 0:T[0];j&&m(j)},k=h=>{h.stopPropagation(),x(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:C,onDragLeave:S,onDrop:E,onPaste:h=>h.preventDefault(),onClick:v,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:s?"primary.main":"divider",bgcolor:s?h=>O(h.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:s?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:g,type:"file",accept:".json",onChange:y,sx:{display:"none"}}),n?t.jsxs(t.Fragment,{children:[t.jsx(o.CircularProgress,{size:32,sx:{mb:2}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||500,fontSize:h=>h.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),d&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:d})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:h=>O(h.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(M.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[t.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),t.jsx(o.IconButton,{onClick:k,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx(M.InfoOutlined,{sx:{fontSize:16}})})]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),t.jsx(oa,{isOpen:u,onClose:()=>x(!1),content:i})]})}function du({schema:e,onConfirm:r,hasConflicts:n}){return t.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(o.Box,{sx:{mb:2},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1.25rem",mb:.5},children:"Schema Preview"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),n&&t.jsxs(o.Alert,{severity:"warning",sx:{mb:2},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.subtitle2.fontSize||"0.875rem"},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),t.jsx(o.TableContainer,{sx:{mb:3},children:t.jsxs(o.Table,{children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:"action.hover"},children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),t.jsx(o.TableBody,{children:e.map(i=>t.jsxs(o.TableRow,{sx:{bgcolor:i.hasConflict?s=>O(s.palette.warning.main,.12):"transparent"},children:[t.jsxs(o.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&t.jsx(o.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(M.Lock,{sx:{fontSize:16}}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),t.jsx(o.Button,{variant:"contained",onClick:r,disabled:n,sx:{fontWeight:500},children:"Generate Table"})]})]})}function uu({error:e,onRetry:r}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>O(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>O(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(M.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:n=>n.typography.h6.fontWeight||600,fontSize:n=>n.typography.h6.fontSize||"1.25rem",mb:1},children:"Upload Failed"}),t.jsx(o.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:e}),t.jsx(o.Button,{variant:"contained",color:"error",startIcon:t.jsx(M.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function na({title:e,description:r,showIcon:n=!0}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&t.jsx(o.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>O(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx(M.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:i=>i.typography.h5.fontWeight||500,mb:1,color:i=>i.typography.h5.color||"text.primary",fontSize:i=>i.typography.h5.fontSize||"1.125rem"},children:e}),t.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:i=>i.typography.body2.fontSize||"0.875rem",lineHeight:1.5},children:r})]})}function pu({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:d}){const[l,u]=p.useState(!1),[x,g]=p.useState(!1),[m,C]=p.useState(-1),S=p.useRef(null),E=p.useRef(null);p.useEffect(()=>{function I(J){S.current&&!S.current.contains(J.target)&&(u(!1),g(!1))}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]);const v=p.useCallback(()=>{g(!0),C(-1),n.length>0&&u(!0)},[n.length]),y=p.useCallback(I=>{r(I),C(-1)},[r]),k=p.useCallback(I=>{var J;r(I),i(I),u(!1),(J=E.current)==null||J.blur()},[r,i]),h=p.useCallback(I=>{C(-1),k(I)},[k]),j=p.useCallback(I=>{var J;I.key==="Enter"?m>=0&&m<n.length?(I.preventDefault(),h(n[m].query)):e.trim()&&k(e.trim()):I.key==="Escape"?(u(!1),C(-1),(J=E.current)==null||J.blur()):I.key==="ArrowDown"?(I.preventDefault(),n.length>0&&(l||u(!0),C(Z=>Z<n.length-1?Z+1:Z))):I.key==="ArrowUp"&&(I.preventDefault(),C(Z=>Z>0?Z-1:-1))},[m,n,e,l,h,k]),T=p.useCallback(()=>{var I;r(""),(I=E.current)==null||I.focus()},[r]),b=p.useMemo(()=>n.filter(I=>I.isFavourite),[n]),R=p.useMemo(()=>n.filter(I=>!I.isFavourite),[n]),H=l&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:S,children:[t.jsx(o.TextField,{inputRef:E,size:"small",fullWidth:!0,value:e,onChange:I=>y(I.target.value),onFocus:v,onKeyDown:j,placeholder:"Search data...",disabled:d,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:I=>O(I.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:I=>O(I.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:t.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx(M.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:T,edge:"end",sx:{mr:-.5},children:t.jsx(M.Close,{sx:{fontSize:16}})})}):null}}),H&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[b.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:I=>I.typography.caption.fontWeight||600,fontSize:I=>I.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),b.map((I,J)=>t.jsx(ys,{entry:I,isSelected:m===J,onClick:()=>h(I.query),onToggleFavourite:()=>s(I.query),onDelete:()=>a(I.query)},`fav-${I.query}`))]}),R.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[b.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:I=>I.typography.caption.fontWeight||600,fontSize:I=>I.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),R.map((I,J)=>{const Z=b.length+J;return t.jsx(ys,{entry:I,isSelected:m===Z,onClick:()=>h(I.query),onToggleFavourite:()=>s(I.query),onDelete:()=>a(I.query)},`recent-${I.query}`)})]})]})]})}const ys=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const d=p.useCallback(u=>{u.stopPropagation(),s()},[s]),l=p.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>O(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>O(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:d,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx(M.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx(M.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(o.IconButton,{size:"small",onClick:l,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(M.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function hu({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:d,onRestoreView:l,onPermanentDelete:u,onEditView:x,onCloneView:g,onCopyLink:m,onDeleteView:C,onPromoteToGlobal:S,onSetDefaultForAllUsers:E,isReadOnly:v,isAdmin:y=!1,hideViewMenuActions:k}){const h=gt(),[j,T]=p.useState(!1),[b,R]=p.useState(!1),[H,I]=p.useState({top:0,left:0}),[J,Z]=p.useState(null),[B,f]=p.useState(null),$=p.useRef(null),D=p.useRef(null),ee=e.find(G=>G.id===r),oe=ee==null?void 0:ee.isDefault,c=(G,ne)=>G.name.localeCompare(ne.name),re=e.filter(G=>G.scope==="global"&&!G.isDeleted).sort(c),fe=e.filter(G=>G.scope!=="global"&&!G.isDeleted).sort(c),U=e.filter(G=>G.isFavorite&&!G.isDeleted).sort(c),K=e.filter(G=>G.isDeleted);p.useEffect(()=>{if(j&&D.current){const G=D.current.getBoundingClientRect();I({top:G.bottom+window.scrollY+8,left:G.right+window.scrollX-320})}},[j]),p.useEffect(()=>{const G=ne=>{$.current&&!$.current.contains(ne.target)&&D.current&&!D.current.contains(ne.target)&&T(!1)};return j&&document.addEventListener("mousedown",G),()=>{document.removeEventListener("mousedown",G)}},[j]);const de=G=>{if(n&&G!==r){Z(G),T(!1);return}i(G),T(!1)},ue=()=>{J&&(i(J),Z(null))},X=()=>{Z(null)},pe=(G,ne=!1)=>{const De=G.scope==="global",Q=!v&&(!De||y),Pe=y&&!De;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===G.id?ot(h).bg:"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===G.id?ot(h).hoverBg:h.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>de(G.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:[r===G.id&&t.jsx(M.Check,{sx:{fontSize:16,flexShrink:0}}),r!==G.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===G.id?h.palette.primary.dark:h.palette.text.primary,fontWeight:r===G.id?Te=>Te.typography.body2.fontWeight||500:400,fontSize:Te=>Te.typography.body2.fontSize||"0.875rem"},children:G.name}),ne&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:h.palette.text.secondary,backgroundColor:h.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[Q&&d&&t.jsx(o.IconButton,{onClick:Te=>{Te.stopPropagation(),d(G.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:G.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(M.Star,{sx:{fontSize:16}})}),Q&&a&&!G.isDefault&&t.jsx(o.IconButton,{onClick:Te=>{Te.stopPropagation(),a(G.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Set as default",children:t.jsx(M.RadioButtonUnchecked,{sx:{fontSize:16}})}),(Q||Pe)&&(x||g||m||C||Pe&&S)&&t.jsx(o.IconButton,{onClick:Te=>{Te.stopPropagation(),f({el:Te.currentTarget,view:G})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"More actions",children:t.jsx(M.MoreVert,{sx:{fontSize:16}})})]})]},G.id)},le=G=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:h.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:h.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:G.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[l&&t.jsx(o.IconButton,{onClick:ne=>{ne.stopPropagation(),l(G.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Restore view",children:t.jsx(M.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:ne=>{ne.stopPropagation(),u(G.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Delete permanently",children:t.jsx(M.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},G.id),P=n||!oe,se=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:D,onClick:()=>T(!j),variant:"outlined",size:"small",endIcon:t.jsx(M.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:P?"warning.main":"text.primary",borderColor:P?"warning.main":"divider",bgcolor:P?O(h.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:P?"warning.dark":"primary.main",bgcolor:P?O(h.palette.warning.main,.2):O(h.palette.text.primary,.06),color:P?"warning.dark":"text.primary"}},title:`View: ${(ee==null?void 0:ee.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(ee==null?void 0:ee.name)||"Default View"}),se&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),j&&Is.createPortal(t.jsxs(o.Box,{ref:$,sx:{position:"fixed",width:"320px",backgroundColor:h.palette.background.paper,border:`1px solid ${h.palette.divider}`,borderRadius:1,boxShadow:h.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:H.top,left:H.left},children:[re.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:G=>G.typography.caption.fontSize||"caption.fontSize",fontWeight:G=>G.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),re.map(G=>pe(G,G.isDefault))]}),U.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(M.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),U.map(G=>pe(G))]})]}),fe.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:G=>G.typography.caption.fontSize||"caption.fontSize",fontWeight:G=>G.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),fe.map(G=>pe(G))]})]}),K.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>R(!b),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",K.length,")"]}),t.jsx(M.ChevronRight,{sx:{fontSize:16}})]}),b&&t.jsx(o.Box,{sx:{backgroundColor:h.palette.action.hover},children:K.map(G=>le(G))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),T(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:h.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsx(M.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!B,anchorEl:(B==null?void 0:B.el)||null,onClose:()=>f(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[x&&t.jsxs(o.MenuItem,{onClick:()=>{B&&x(B.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(M.Edit,{sx:{fontSize:18}}),"Edit"]}),m&&t.jsxs(o.MenuItem,{onClick:()=>{B&&m(B.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(M.Link,{sx:{fontSize:18}}),"Copy Link"]}),g&&t.jsxs(o.MenuItem,{onClick:()=>{B&&g(B.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(M.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),S&&y&&(B==null?void 0:B.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{B&&S(B.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(M.Language,{sx:{fontSize:18}}),"Promote to Global"]}),E&&B&&!(k!=null&&k.includes("setDefaultForAllUsers"))?t.jsxs(o.MenuItem,{onClick:()=>{B&&E(B.view.id,!B.view.isDefaultForAllUsers),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(M.Star,{sx:{fontSize:18,color:B.view.isDefaultForAllUsers?"warning.main":"inherit"}}),B.view.isDefaultForAllUsers?"Remove from":"Set as"," Default for All Users"]}):null,C&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{B&&C(B.view.id),f(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx(M.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:J!==null,onClose:X,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Wo(h)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx(M.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),t.jsx(o.DialogContent,{children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),t.jsxs(o.DialogActions,{sx:{px:3,pb:2,gap:1},children:[t.jsx(o.Button,{onClick:X,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:ue,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function mu({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:d=!1,position:l,onSortAscending:u,onSortDescending:x,onRemoveSort:g,onFilter:m,onClearFilter:C,onGroupByColumn:S,onHideColumn:E,onManageColumns:v,onResetLayout:y,onClose:k}){const h=gt(),j=h.palette,T=p.useRef(null);p.useEffect(()=>{if(!T.current)return;const Z=T.current,B=Z.getBoundingClientRect(),f=window.innerWidth,$=window.innerHeight;B.right>f-8&&(Z.style.left=`${f-B.width-8}px`),B.bottom>$-8&&(Z.style.top=`${$-B.height-8}px`)},[l]),p.useEffect(()=>{const Z=f=>{T.current&&!T.current.contains(f.target)&&k()},B=f=>{f.key==="Escape"&&k()};return document.addEventListener("mousedown",Z),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",B)}},[k]);const b=p.useCallback(Z=>()=>{Z(),k()},[k]),R=(n==null?void 0:n.direction)==="asc",H=(n==null?void 0:n.direction)==="desc",I=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",J=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Is.createPortal(t.jsxs(o.Paper,{ref:T,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:h.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:Wo(h),overflow:"hidden",boxShadow:`0 4px 20px ${O(j.common.black,.12)}, 0 1px 4px ${O(j.common.black,.06)}`},children:[!a&&t.jsxs(o.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(o.Typography,{sx:{fontSize:Z=>Z.typography.body2.fontSize||"0.8125rem",fontWeight:Z=>Z.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(o.Tooltip,{title:`Sort Ascending (${I})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:b(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:R?"primary.main":"text.secondary",bgcolor:R?O(j.primary.main,.1):"transparent","&:hover":{bgcolor:O(j.primary.main,.08),color:"primary.main"}},children:t.jsx(M.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${J})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:b(()=>x(e)),sx:{p:.625,borderRadius:"6px",color:H?"primary.main":"text.secondary",bgcolor:H?O(j.primary.main,.1):"transparent","&:hover":{bgcolor:O(j.primary.main,.08),color:"primary.main"}},children:t.jsx(M.ArrowDownward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:t.jsx("span",{children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:b(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:O(j.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx(M.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:b(()=>m(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(M.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!a&&t.jsxs(o.MenuItem,{onClick:b(()=>C(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:O(j.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(M.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!a&&S&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.25}}),t.jsx(o.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(o.MenuItem,{onClick:b(()=>S(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(M.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),t.jsx(o.Divider,{sx:{my:.25}}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[!a&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(o.MenuItem,{onClick:b(()=>E(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(M.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),t.jsx(o.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:b(v),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:O(j.primary.main,.08),color:"primary.main"}},children:t.jsx(M.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:b(v),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(M.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&d&&y&&t.jsxs(o.MenuItem,{onClick:b(y),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:O(j.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(M.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const fu=176,bs="COLUMN_HEADER",xu=p.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:d=!1,hasModifications:l=!1,width:u,onColumnClick:x,onMoveColumn:g,onColumnDragEnd:m,onResizeStart:C,onSortAscending:S,onSortDescending:E,onRemoveSort:v,onOpenFilterForColumn:y,onClearFiltersForColumn:k,onGroupByColumn:h,onHideColumn:j,onManageColumns:T,onResetLayout:b}){const H=gt().urmTable,I=p.useRef(null),[J,Z]=p.useState(!1),[B,f]=p.useState({x:0,y:0}),[{handlerId:$,isOver:D},ee]=nr.useDrop({accept:bs,collect(X){return{handlerId:X.getHandlerId(),isOver:X.isOver()}},hover(X,pe){var Q;if(!I.current)return;const le=X.index,P=n;if(le===P)return;const se=(Q=I.current)==null?void 0:Q.getBoundingClientRect(),G=(se.right-se.left)/2,ne=pe.getClientOffset(),De=((ne==null?void 0:ne.x)??0)-se.left;le<P&&De<G||le>P&&De>G||(g(le,P),X.index=P)}}),[{isDragging:oe},c]=nr.useDrag({type:bs,item:()=>({index:n,columnName:r.name}),collect:X=>({isDragging:X.isDragging()}),end:()=>{m==null||m()}});c(ee(I));const re=p.useCallback(X=>{X.preventDefault(),X.stopPropagation(),f({x:X.clientX,y:X.clientY}),Z(!0)},[]),fe=p.useCallback(()=>Z(!1),[]),U=p.useCallback(()=>{x(r.name)},[x,r.name]),K=p.useCallback(X=>{X.stopPropagation(),y(r.name)},[y,r.name]),de=p.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx(M.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx(M.ArrowDownward,{sx:{fontSize:13,color:"primary.main"}}),t.jsx(o.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]),ue=p.useCallback(()=>s?t.jsx(M.FilterList,{onClick:K,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,K]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:I,"data-handler-id":$,"data-column-index":n,onClick:U,onContextMenu:re,sx:{position:"sticky",top:0,zIndex:5,textAlign:(H==null?void 0:H.cellAlignH)??"left",verticalAlign:(H==null?void 0:H.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(H==null?void 0:H.headerColor)??"text.secondary",opacity:oe?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:D?X=>O(X.palette.primary.main,.08):(H==null?void 0:H.headerBg)??"action.hover",boxShadow:X=>`0 1px 0 ${O(X.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(H==null?void 0:H.rowDivider)??"1px solid",borderRight:H==null?void 0:H.colDivider,borderColor:"divider",py:0,px:(H==null?void 0:H.cellPaddingX)??2,"&:hover":{bgcolor:X=>O(X.palette.primary.main,.1),color:"text.primary"},width:u?`${u}px`:`${fu}px`},children:[t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[ct(r.name),de(),ue()]}),t.jsx(o.Box,{draggable:!1,onDragStart:X=>X.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:X=>{X.preventDefault(),X.stopPropagation(),C(X,r.name)},onClick:X=>X.stopPropagation(),children:t.jsx(o.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),D&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),J&&t.jsx(mu,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:d,hasModifications:l,position:B,onSortAscending:S,onSortDescending:E,onRemoveSort:v,onFilter:y,onClearFilter:k,onGroupByColumn:h,onHideColumn:j,onManageColumns:T,onResetLayout:b,onClose:fe})]})}),gu={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"},yu={error:"err",warning:"warn",info:"info",success:"suc"};function un(e,r){var d,l;const n=gu[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.tokens,s=yu[n],a=e.palette[n];return{bg:((d=i==null?void 0:i.status)==null?void 0:d[`${s}Soft`])??O(a.main,e.palette.mode==="dark"?.24:.12),color:((l=i==null?void 0:i.status)==null?void 0:l[`${s}Txt`])??(e.palette.mode==="dark"?a.light:a.dark)}}function bu(e,r){switch(r.toLowerCase().trim()){case"low":return e.palette.text.secondary;case"medium":return e.palette.warning.main;case"high":return e.palette.mode==="dark"?e.palette.warning.light:e.palette.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const vu={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"},rows:{hue:"primary",shade:"main"}};function vs(e,r){const n=vu[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function Dt(e){return O(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function Su(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>un(n,r).bg,color:n=>un(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function Cu(e,r){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.875rem"},children:"—"});const n=String(r),i=e.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Su(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:a=>{const d=bu(a,s);return d?{color:d,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:n})}return typeof r=="boolean"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:n})}function wu(e){const r=e.find(s=>{const a=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(a)})||e[0]||null,n=e.find(s=>{const a=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(a)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function ju({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:d,onOpenRowMenu:l,onToggleSelection:u,hideCheckbox:x}){const[g,m]=p.useState(!1),{primaryCol:C,idCol:S,bodyColumns:E}=p.useMemo(()=>wu(n),[n]),v=C?e[C.name]:null,y=S?e[S.name]:null,k=g||i;return t.jsxs(o.Box,{onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),onClick:h=>s(r,h),onDoubleClick:h=>a(e,r,h),onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),d(e,r,h)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:h=>{var T,b,R,H;const j=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.border;return i?"2px solid":j&&j!=="none"?j:"1px solid"},borderColor:i?h=>ot(h).main:h=>{var T,b,R,H;const j=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.border;return j&&j!=="none"?"inherit":O(h.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:h=>{var T,b,R,H;const j=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.borderRadius;return j!==void 0?typeof j=="number"?`${j}px`:j:`${h.shape.borderRadius}px`},cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?h=>`0 0 0 3px ${O(ot(h).main,.15)}, 0 2px 8px ${O(h.palette.common.black,.08)}`:g?h=>{var T,b,R,H;const j=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.boxShadow;return j&&j!=="none"?j:be(h,"cardHover")}:h=>{var T,b,R,H;const j=(H=(R=(b=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:b.styleOverrides)==null?void 0:R.root)==null?void 0:H.boxShadow;return j&&j!=="none"?j:be(h,"cardRest")},transform:g&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:h=>O(ot(h).main,.03)}},children:[t.jsxs(o.Box,{sx:h=>{var H,I,J,Z;const j=((J=(I=(H=h.components)==null?void 0:H.MuiCardHeader)==null?void 0:I.styleOverrides)==null?void 0:J.root)||{},T=(j.backgroundColor&&j.backgroundColor!=="transparent"?j.backgroundColor:void 0)??((Z=h.tokens)==null?void 0:Z.cardHdrHex)??"transparent",b=j.borderBottom&&j.borderBottom!=="none"?j.borderBottom:void 0,R=j.boxShadow&&j.boxShadow!=="none"?j.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:T,borderBottom:b,boxShadow:R,display:"flex",alignItems:"center",gap:.5}},children:[!x&&k&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:h=>h.stopPropagation(),onChange:()=>u(e),sx:{p:.25}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||600,fontSize:h=>h.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:v!=null&&v!==""?String(v):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:h=>{var b,R,H;const j=((H=(R=(b=h.components)==null?void 0:b.MuiCardHeader)==null?void 0:R.styleOverrides)==null?void 0:H.root)||{};return j.borderBottom&&j.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[E.map(h=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:j=>j.typography.body2.fontWeight||500,fontSize:j=>j.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:ct(h.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[h.name]??""),children:Cu(h,e[h.name])})]},h.name)),E.length===0&&t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]}),t.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:h=>O(h.palette.action.hover,.1),minHeight:40},children:[t.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:y?.85:0,userSelect:"none"},children:y?String(y):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:k?1:0,transition:"opacity 0.15s ease"},onClick:h=>h.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:h=>{h.stopPropagation(),l(e,r,h.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:h=>O(h.palette.text.primary,.08)}},children:t.jsx(M.MoreVert,{sx:{fontSize:17}})})})})]})]})}function ku({row:e,grouping:r,onToggleCollapse:n}){var i;return t.jsxs(o.Box,{onClick:()=>n(e.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=>be(s,"flatHover"),"&:hover":{bgcolor:s=>O(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx(M.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx(M.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:s=>s.typography.h5.fontWeight||600,color:s=>s.typography.h5.color||"text.primary"},children:Xa(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>O(s.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[e.rowCount," ",e.rowCount===1?"row":"rows"]}),Object.keys(e.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(e.aggregates).map(([s,a])=>Os(a)).filter(Boolean).join(" • ")})]})}function zu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:d,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:x,onToggleSelection:g,hideSelectionCheckboxes:m}){const C=p.useMemo(()=>{const S=new Set;return i.forEach(E=>{const v=E==null?void 0:E.__urm_row_id__;v!==void 0&&S.add(v)}),S},[i]);return e.length===0?t.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):t.jsx(o.Box,{sx:{fontFamily:S=>S.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:S=>gs(S).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:S=>gs(S).cardGap,alignContent:"start"},children:e.map((S,E)=>s&&S.isGroupHeader?t.jsx(ku,{row:S,grouping:n,onToggleCollapse:a||(()=>{})},`group-${S.groupKey}`):t.jsx(ju,{row:S,rowIndex:E,visibleColumns:r,isSelected:C.has(S==null?void 0:S.__urm_row_id__),onCardClick:d,onCardDoubleClick:l,onCardContextMenu:u,onOpenRowMenu:x,onToggleSelection:g,hideCheckbox:m},`card-${E}`))})})}const Ss=[10,15,25,50,100];function Bu(e,r){const n=e.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>r?"Entered page number is out of range":null}function Tu({currentPage:e,pageSize:r,totalRows:n,totalPages:i,totalFields:s,onPageChange:a,onPageSizeChange:d}){const u=gt().palette,x=i??Math.max(1,Math.ceil(n/r)),[g,m]=p.useState(String(e)),[C,S]=p.useState(null),[E,v]=p.useState(!1),y=p.useRef(null);p.useEffect(()=>{E||(m(String(e)),S(null))},[e,E]);const k=p.useCallback(()=>{const D=Bu(g,x);if(D){S(D);return}const ee=parseInt(g.trim(),10);S(null),v(!1),ee!==e&&a(ee)},[g,x,e,a]),h=p.useCallback(D=>{var ee;D.key==="Enter"?(D.preventDefault(),k()):D.key==="Escape"&&(m(String(e)),S(null),v(!1),(ee=y.current)==null||ee.blur())},[k,e]),j=p.useCallback(()=>{m(String(e)),S(null),v(!1)},[e]),T=p.useCallback(()=>{v(!0),S(null),setTimeout(()=>{var D;return(D=y.current)==null?void 0:D.select()},0)},[]);if(n<=Math.min(...Ss))return null;const b=()=>{m(String(e)),S(null),v(!1)},R=()=>{b(),a(1)},H=()=>{b(),e>1&&a(e-1)},I=()=>{b(),e<x&&a(e+1)},J=()=>{b(),a(x)},Z=(e-1)*r+1,B=Math.min(e*r,n),f=`${Math.max(2,String(x).length+.5)}ch`,$={p:.75,color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"action.disabled"}};return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:3,px:2,py:1,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",minHeight:48},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:D=>D.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),s!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:D=>D.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:s})]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:D=>D.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:D=>d(Number(D.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:Ss.map(D=>t.jsx(o.MenuItem,{value:D,sx:{fontSize:"0.8125rem"},children:D},D))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:D=>D.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[Z,"–",B," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:D=>D.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[C&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:O(u.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${O(u.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:O(u.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:D=>D.typography.caption.fontSize||"0.6875rem",fontWeight:D=>D.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:C})}),t.jsx(o.InputBase,{inputRef:y,value:g,onChange:D=>{m(D.target.value),C&&S(null)},onKeyDown:h,onFocus:T,onBlur:j,inputProps:{"aria-label":`Page number, 1 to ${x}`,style:{textAlign:"center",padding:"2px 0",width:f,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:C?"error.main":"text.primary",border:"1px solid",borderColor:C?"error.main":E?"primary.main":"divider",borderRadius:"4px",bgcolor:C?O(u.error.main,.04):E?O(u.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:C?"error.main":"text.secondary"},"&:focus-within":{boxShadow:C?`0 0 0 2px ${O(u.error.main,.2)}`:`0 0 0 2px ${O(u.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:D=>D.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",x]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:R,disabled:e===1,size:"small",title:"First page",sx:$,children:t.jsx(M.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:H,disabled:e===1,size:"small",title:"Previous page",sx:$,children:t.jsx(M.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:I,disabled:e===x,size:"small",title:"Next page",sx:$,children:t.jsx(M.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:J,disabled:e===x,size:"small",title:"Last page",sx:$,children:t.jsx(M.LastPage,{sx:{fontSize:20}})})]})]})]})}function Iu(){return t.jsx(o.Chip,{icon:t.jsx(M.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:e=>e.typography.caption.fontSize||"caption.fontSize",fontWeight:e=>e.typography.caption.fontWeight||500}})}const ia="urm_hint_seen_";function Eu(e){try{return localStorage.getItem(ia+e)==="true"}catch{return!1}}function Du(e){try{localStorage.setItem(ia+e,"true")}catch{}}const sa={"& .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 ui(e,r){if(e==null||e==="")return"";if(r==="boolean")return e?"True":"False";if(r==="object"||r==="array")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function aa({row:e,schema:r}){const i=gt().palette,s=r.filter(l=>l.name in e),a=s.filter(l=>l.type!=="object"&&l.type!=="array"),d=s.filter(l=>l.type==="object"||l.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(l=>t.jsx(o.TextField,{label:ct(l.name),value:ui(e[l.name],l.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:sa},l.name)),d.map(l=>{const u=ui(e[l.name],l.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:x=>x.typography.caption.fontWeight||500,fontSize:x=>x.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:ct(l.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:O(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:u?"text.primary":"text.disabled",fontStyle:u?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:u||"No value"})]},l.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:l=>l.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function _u({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=gt(),d=a.palette;if(!n)return null;const l=i.filter(x=>x.name in n).length,u=ce(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:nt(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...u.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...u.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:O(d.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(M.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:x=>x.typography.h6.fontSize||"1rem",fontWeight:x=>x.typography.h6.fontWeight||600,color:x=>x.typography.h6.color||"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:x=>x.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",l," ",l===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:O(d.text.primary,.015)},children:t.jsx(aa,{row:n,schema:i})}),t.jsx(o.Divider,{}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:x=>`${x.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function $u({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=gt(),d=ce(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:nt(a),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",...d.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...d.header},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:l=>O(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(M.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.h6.fontSize||"1.125rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:l=>l.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"This record will be permanently removed."})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.DialogContent,{sx:{px:3,pb:2,overflowY:"auto",flex:1,display:"flex",flexDirection:"column",gap:2},children:[i&&s&&t.jsx(aa,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>O(l.palette.error.main,.1),border:l=>`1px solid ${O(l.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:l=>l.typography.body2.fontWeight||500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx(M.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>be(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>be(l,"hoverButton")},"&:active":{boxShadow:l=>be(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Ou({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var k;const d=gt(),l=d.palette,[u,x]=p.useState({});if(p.useEffect(()=>{e&&i&&x({...i})},[e,i]),!i)return null;const g=s.filter(h=>h.name in i),m=g.filter(h=>h.type!=="object"&&h.type!=="array"),C=g.filter(h=>h.type==="object"||h.type==="array"),S=(h,j)=>{x(T=>({...T,[h]:j}))},E=()=>{const h={...u};g.forEach(j=>{const T=u[j.name];if(j.type==="number"){const b=Number(T);h[j.name]=isNaN(b)?i[j.name]:b}else j.type==="boolean"&&(h[j.name]=!!T)}),n(h),r()},v=g.length,y=ce(d);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:nt(d),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...y.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...y.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:O(((k=l.warning)==null?void 0:k.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(M.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:h=>h.typography.h6.fontSize||"1rem",fontWeight:h=>h.typography.h6.fontWeight||600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),a&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:h=>h.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a," · ",v," ",v===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:O(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[m.map(h=>{const j=u[h.name];return h.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:T=>T.typography.caption.fontWeight||500,fontSize:T=>T.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:ct(h.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!j,onChange:T=>S(h.name,T.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:T=>T.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:j?"Enabled":"Disabled"})]})]},h.name):t.jsx(o.TextField,{label:ct(h.name),value:j??"",onChange:T=>S(h.name,T.target.value),type:h.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:sa},h.name)}),C.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:C.map(h=>{const j=ui(i[h.name],h.type);return t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:T=>T.typography.caption.fontSize||"0.75rem",fontWeight:T=>T.typography.caption.fontWeight||500,color:"text.secondary"},children:ct(h.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:O(l.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(o.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx(M.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:O(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:j?"text.primary":"text.disabled",fontStyle:j?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:j||"No value"})]},h.name)})}),g.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx(M.EditOutlined,{sx:{fontSize:40,opacity:.4}}),t.jsx(o.Typography,{variant:"body2",children:"No editable fields"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,bgcolor:"background.paper",gap:1,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:h=>`${h.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:E,variant:"contained",startIcon:t.jsx(M.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:h=>`${h.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Mu=176,Au=170,Wu=40;function la(e){return e.type==="date"?180:Mu}function Ru(e,r){return r!=null&&r!==Au&&r!==la(e)}function Pu(e,r,n){return p.useMemo(()=>{const i=e.map(m=>({name:m.name,width:r[m.name]??la(m),explicit:Ru(m,r[m.name])})),s={};i.forEach(m=>{s[m.name]=m.width});const a=i.reduce((m,C)=>m+C.width,0),l=Math.max(0,n-Wu)-a;if(l<=0)return{widths:s,fillerWidth:0};const u=i.filter(m=>!m.explicit);if(u.length===0)return{widths:s,fillerWidth:l};const x=u.reduce((m,C)=>m+C.width,0)||1;let g=0;return u.forEach((m,C)=>{const E=C===u.length-1?m.width+l-g:Math.round(m.width+l*m.width/x);s[m.name]=E,g+=E-m.width}),{widths:s,fillerWidth:0}},[e,r,n])}const Cs=176,Nu=Pt(),Lu={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Fu(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>un(n,r).bg,color:n=>un(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Vu(e){const r=e.toLowerCase().trim(),n=Lu[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Hu(e,r){const n=r.trim();if(!n)return e;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.split(new RegExp(`(${i})`,"gi"));return s.length===1?e:s.map((a,d)=>a.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},d):a)}function Uu(e,r,n,i=""){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(r);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(e.name.toLowerCase()))return Fu(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Vu(s);if(e.type==="date"){const l=e.dateFormat??"iso",u=Na(r,l,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(e.type==="number"&&typeof r=="number")return r.toLocaleString();if(typeof r=="boolean")return r?"Yes":"No";if(Array.isArray(r)){if(r.length===0)return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const l=r.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return t.jsxs(o.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[l,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const l=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:l,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:l.length>40?l.slice(0,40)+"…":l})}return Hu(s,i)}function Gu({schema:e,data:r,sortStack:n=[],filters:i=Nu,views:s=[],activeViewId:a="",isDirty:d=!1,isExporting:l=!1,columnVisibility:u={},columnOrder:x=[],columnWidths:g={},grouping:m=null,classTokens:C={},onSort:S,onSortAscending:E,onSortDescending:v,onOpenFilters:y,onOpenSort:k,onOpenFilterForColumn:h,onSelectView:j,onCreateView:T,onUpdateCurrentView:b,onSaveAsNewView:R,onDiscardChanges:H,onToggleDefault:I,onToggleFavorite:J,onRestoreView:Z,onPermanentDelete:B,onEditView:f,onCloneView:$,onCopyLink:D,onDeleteView:ee,onPromoteToGlobal:oe,onSetDefaultForAllUsers:c,isAdmin:re=!1,hideViewMenuActions:fe,onExport:U,onOpenColumns:K,onUpdateColumnWidth:de,onUpdateColumnOrder:ue,onUpdateColumnVisibility:X,onClearFiltersForColumn:pe,onResetLayout:le,onOpenGroup:P,onGroupByColumn:se,onToggleGroupCollapse:G,onExpandAllGroups:ne,onCollapseAllGroups:De,onOpenAuditHistory:Q,onOpenScheduledReports:Pe,searchQuery:Te,highlightQuery:$t="",searchHistory:Rr=[],onAddToSearchHistory:Kt,onToggleSearchFavourite:br,onDeleteSearchHistory:Ot,selectedRowIds:dt=new Set,onSearchChange:Xt,onToggleRowSelection:Qe,onToggleAllRows:Mt,onRangeSelection:vr,onClearSelection:wt,onExportSelected:Qt,currentPage:uo=1,pageSize:sr=15,totalRowsBeforePagination:po=r.length,totalPagesOverride:Zt,onPageChange:Sr,onPageSizeChange:jt,isReadOnly:qe=!1,userRole:Cr,reportName:ut,onEditRow:tt,onDuplicateRow:Nt,onDeleteRow:ar,showDevPanel:ho=!1,onOpenDevConfig:Pr,rowActions:lr,hideDefaultRowActions:Je,hideToolbarActions:we,customSettingsActions:At,jsonGuideContent:wr,viewOptions:Nr,defaultViewMode:cr,bulkActions:jr,hideSelectionCheckboxes:Lr,rowClickBehavior:dr="select",openModalOn:Ze,onRowClick:Lt,onRowRightClick:Se}){var Go;const he=gt().urmTable,[kt,F]=p.useState(null),[yt,ie]=p.useState(0),[st,kr]=p.useState(0),[zt,Fr]=p.useState(null),ur=Ar(),zr=((Go=ur.dates)==null?void 0:Go.displayFormat)??null,[Ft,pr]=p.useState(null),[Br,Ce]=p.useState(null),[pt,ht]=p.useState(null),[V,Me]=p.useState(!1),[Ae,Tr]=p.useState(!1),[Ir,Vr]=p.useState(null),[mo,Vt]=p.useState(!1),[fo,Hr]=p.useState(null),[Wt,Er]=p.useState(null),[je,Ge]=p.useState(null),[Dr,at]=p.useState(null),er=p.useRef(null),me=p.useCallback(()=>{er.current&&(clearTimeout(er.current),er.current=null)},[]),xe=p.useCallback(()=>{me(),er.current=setTimeout(()=>at(null),200)},[me]);p.useEffect(()=>me,[me]);const[et,_e]=p.useState(null),it=p.useMemo(()=>Nr??["list","grid"],[Nr]),[mt,bt]=p.useState(()=>cr??it[0]??"list"),[Dn,Po]=p.useState(!1),[Ur,_n]=p.useState(()=>!Eu("toolbar_search")),Gr=p.useRef(null),xo=p.useRef(null),[$n,No]=p.useState(0);p.useLayoutEffect(()=>{const w=Gr.current;if(!w)return;No(w.clientWidth);const N=new ResizeObserver(te=>{No(te[0].contentRect.width)});return N.observe(w),()=>N.disconnect()},[]);const Yr=p.useCallback(()=>{Du("toolbar_search"),_n(!1)},[]);p.useEffect(()=>{if(!Ur)return;const w=setTimeout(Yr,2e3);return()=>clearTimeout(w)},[Ur,Yr]);const Lo=p.useMemo(()=>{const w=zt??x;return w.length>0?w.map(N=>e.find(te=>te.name===N)).filter(N=>N!==void 0):e},[zt,x,e]),qr=p.useMemo(()=>Lo.filter(w=>u[w.name]!==!1),[Lo,u]),go=p.useMemo(()=>new Set(((m==null?void 0:m.levels)??[]).map(w=>w.column)),[m]),Fo=!!(m!=null&&m.enabled&&(m!=null&&m.levels)&&m.levels.length>0),Jr=p.useMemo(()=>{if(!Fo)return qr;const w=((m==null?void 0:m.levels)??[]).map(te=>e.find(ke=>ke.name===te.column)).filter(te=>te!==void 0),N=qr.filter(te=>!go.has(te.name));return[...w,...N]},[qr,Fo,go,m,e]),{widths:Kr}=Pu(Jr,g,$n),hr=p.useMemo(()=>e.filter(w=>u[w.name]===!1).length,[e,u]),yo=p.useMemo(()=>e.map(w=>w.name),[e]),Xr=p.useMemo(()=>x.length===0?!1:JSON.stringify(x)!==JSON.stringify(yo),[x,yo]),On=p.useCallback((w,N)=>{w.preventDefault(),w.stopPropagation(),F(N),ie(w.clientX),kr(g[N]||150)},[g]);p.useEffect(()=>{if(!kt)return;const w=te=>{const ke=te.clientX-yt,Ne=Math.max(100,Math.min(600,st+ke));de==null||de(kt,Ne)},N=()=>{F(null)};return document.addEventListener("mousemove",w),document.addEventListener("mouseup",N),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",N)}},[kt,yt,st,de]);const Mn=p.useCallback(w=>w==null?"-":typeof w=="object"?JSON.stringify(w):typeof w=="boolean"?w?"true":"false":String(w),[]);p.useCallback(w=>{const N=n.find(te=>te.column===w);return N?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[N.direction==="asc"?t.jsx(M.ArrowUpward,{sx:{fontSize:14}}):t.jsx(M.ArrowDownward,{sx:{fontSize:14}}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"caption.fontSize",fontWeight:"bold",borderRadius:"50%"},children:N.priority})]}):null},[n]),p.useCallback(w=>ii(i,w)?t.jsx(o.IconButton,{size:"small",onClick:te=>{te.stopPropagation(),h==null||h(w)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(M.FilterList,{sx:{fontSize:14}})}):null,[i,h]);const An=p.useCallback(w=>{S&&S(w)},[S]),Wn=p.useCallback((w,N)=>{Fr(te=>{const Ne=[...te??(x.length>0?x:e.map(Ke=>Ke.name))],[rt]=Ne.splice(w,1);return Ne.splice(N,0,rt),Ne})},[x,e]),Rn=p.useCallback(()=>{zt&&ue&&ue(zt),Fr(null)},[zt,ue]),Pn=p.useCallback(w=>{if(!S)return;const N=n.find(te=>te.column===w);(!N||N.direction!=="asc")&&S(w)},[S,n]),Nn=p.useCallback(w=>{if(!S)return;const N=n.find(te=>te.column===w);N?N.direction==="asc"&&S(w):(S(w),setTimeout(()=>S(w),0))},[S,n]),Ln=p.useCallback(w=>{if(!S)return;const N=n.find(te=>te.column===w);N&&(N.direction==="asc"?(S(w),setTimeout(()=>S(w),0)):N.direction==="desc"&&S(w))},[S,n]),Fn=p.useCallback(w=>{X&&X(w,!1)},[X]),Qr=!!(m!=null&&m.enabled&&(m!=null&&m.levels)&&m.levels.length>0),tr=p.useMemo(()=>Et(i),[i]),Vn=n.length>0||tr>0||((m==null?void 0:m.enabled)??!1)||Object.values(u).some(w=>w===!1),Hn=(uo-1)*sr,Ve=r,lt=p.useMemo(()=>{const w=new Set;return dt.forEach(N=>{const te=N==null?void 0:N.__urm_row_id__;te!==void 0&&w.add(te)}),w},[dt]);p.useEffect(()=>{const w=N=>{!Mt||!wt||N.target instanceof HTMLInputElement||N.target instanceof HTMLTextAreaElement||((N.ctrlKey||N.metaKey)&&N.key==="a"&&(N.preventDefault(),Mt(!0,Ve)),N.key==="Escape"&&(N.preventDefault(),wt()))};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[Mt,wt,Ve]);const bo=p.useCallback((w,N)=>{Lt==null||Lt(Ve[w],w,N),(dr==="activate"||dr==="both")&&(ht(Ve[w]),Me(!0)),dr!=="activate"&&Qe&&(N.shiftKey&&Ft!==null?(N.preventDefault(),vr&&vr(Ft,w,Ve)):(Qe(Ve[w]),pr(w)))},[Qe,Ft,vr,Ve,Lt,dr,ht,Me]),Zr=p.useMemo(()=>Ve.filter(w=>!w.isGroupHeader),[Ve]),Vo=p.useMemo(()=>Zr.length>0&&lt.size>0&&Zr.every(w=>lt.has(w==null?void 0:w.__urm_row_id__)),[Zr,lt]),Un=!Vo&&Zr.some(w=>lt.has(w==null?void 0:w.__urm_row_id__)),rr=!!(Qe&&Mt&&!Lr),vt=p.useMemo(()=>Jr,[Jr]),Ho=p.useMemo(()=>{const w=new Map;if(!(m!=null&&m.enabled)||!Ve)return w;let N=[];for(const te of Ve)if(te.__isGroupHeader||te.isGroupHeader){const ke=te.groupLevel??0;N[ke]=te.groupKey,N=N.slice(0,ke+1),w.has(te.groupKey)||w.set(te.groupKey,[])}else if(te.__urm_is_grouped_data_row__)for(const ke of N)ke&&w.has(ke)&&w.get(ke).push(te);return w},[m,Ve]),eo=p.useCallback(w=>{const N=w.groupLevel,te=N===0?C.groupRowLevel0||"urm-group-level-0":N===1?C.groupRowLevel1||"urm-group-level-1":C.groupRowLevel2||"urm-group-level-2",ke=N===0?We=>We.palette.mode==="dark"?O(We.palette.action.hover,.12):"#f1f5f9":We=>We.palette.mode==="dark"?O(We.palette.action.hover,.06):"#f8fafc",Ne=String(w.groupValue??"(empty)"),rt=`${w.rowCount} ${w.rowCount===1?"item":"items"}`,Ke=Ho.get(w.groupKey)||[],ge=Ke.filter(We=>lt.has(We==null?void 0:We.__urm_row_id__)).length,Ht=Ke.length>0&&ge===Ke.length,Ut=ge>0&&ge<Ke.length;return t.jsxs(o.TableRow,{onClick:()=>G==null?void 0:G(w.groupKey),className:`urm-group-header-row urm-group-level-${N} ${te} ${C.groupRow||""}`,sx:{bgcolor:ke,"&:hover":{bgcolor:We=>O(We.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[rr&&t.jsx(o.TableCell,{padding:"checkbox",onClick:We=>We.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Ht,indeterminate:Ut,onChange:()=>{if(!Qe)return;const We=!Ht;Ke.forEach(mr=>{const Yo=lt.has(mr==null?void 0:mr.__urm_row_id__);We!==Yo&&Qe(mr)})}})}),t.jsxs(o.TableCell,{colSpan:vt.length,className:`urm-group-cell ${C.groupCellFirst||""} ${C.groupCell||""}`,sx:{pl:`${N*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[N>0&&t.jsx(o.Box,{sx:{position:"absolute",left:`${N*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(o.Box,{className:`urm-group-content ${C.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${C.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:w.isCollapsed?t.jsx(M.ChevronRight,{sx:{fontSize:18}}):t.jsx(M.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"h5",className:`urm-group-title ${C.groupTitle||""}`,sx:{fontWeight:N===0?600:500,fontSize:N===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Ne}),!w.isCollapsed&&t.jsx(o.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:We=>O(We.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:We=>O(We.palette.primary.main,.2),ml:.5},children:ct(w.groupColumn||"")}),!!w.__urm_is_continuation_header__&&t.jsx(o.Box,{className:"urm-group-continuation-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:We=>O(We.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(o.Box,{className:`urm-group-count ${C.groupBadge||""} ${C.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:We=>O(We.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:rt}),Object.keys(w.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${C.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(w.aggregates).map(([We,mr])=>Os(mr)).filter(Boolean).join(" • "),")"]})]})]})]},w.groupKey)},[vt,rr,m,e,G,C,he,Ho,lt,Qe]),Uo=p.useCallback((w,N)=>{const te=lt.has(w==null?void 0:w.__urm_row_id__),ke=Br===N,Ne=V&&(w==null?void 0:w.__urm_row_id__)===(pt==null?void 0:pt.__urm_row_id__),rt=!!(w!=null&&w.__urm_is_grouped_data_row__),Ke=rt?w.__urm_group_level__??(m==null?void 0:m.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":N,className:rt?`urm-data-row-grouped ${C.dataRowGrouped||""}`:"",onMouseEnter:()=>Ce(N),onMouseLeave:()=>Ce(null),onClick:ge=>{ge.target.closest("[data-row-action-btn]")||bo(N,ge)},onDoubleClick:()=>{Ze!=null&&Ze.includes("doubleClick")&&(ht(w),Me(!0))},onContextMenu:ge=>{ge.preventDefault(),ge.stopPropagation(),Se==null||Se(w,N,ge),at(null),Ge({mouseX:ge.clientX,mouseY:ge.clientY,row:w,rowIndex:N}),Ze!=null&&Ze.includes("rightClick")&&(ht(w),Me(!0))},sx:{cursor:"pointer",bgcolor:te?ge=>ot(ge).bg:Ne?ge=>O(ge.palette.info.main,.12):he!=null&&he.striped&&N%2===1?he.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:te?ge=>ot(ge).hoverBg:Ne?ge=>O(ge.palette.info.main,.2):ge=>`var(--highlight-hover-row, ${O(ot(ge).main,.04)})`},borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider"},children:[rr&&t.jsx(o.TableCell,{padding:"checkbox",onClick:ge=>ge.stopPropagation(),sx:{borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(he==null?void 0:he.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:te,onChange:()=>Qe==null?void 0:Qe(w)})}),vt.map((ge,Ht)=>{const Ut=Ht===0;return t.jsxs(o.TableCell,{className:rt&&Ut?`urm-data-cell-grouped ${C.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(he==null?void 0:he.rowPaddingY)??"6px",px:(he==null?void 0:he.cellPaddingX)??2,pl:rt&&Ut?`${Ke*24}px`:void 0,position:"relative",textAlign:(he==null?void 0:he.cellAlignH)??"left",verticalAlign:(he==null?void 0:he.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderRight:he==null?void 0:he.colDivider,borderColor:"divider",minWidth:g[ge.name]?`${g[ge.name]}px`:`${ge.type==="date"?Math.max(Cs,180):Cs}px`},children:[rt&&Ut&&Ke>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%"},children:t.jsx("span",{className:`urm-item-title ${C.itemTitle||""}`,children:Uu(ge,w[ge.name],zr,$t)})})]},ge.name)}),t.jsx(o.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:0,minWidth:0,maxWidth:0,p:0,border:"none",background:"transparent",opacity:ke?1:0,transition:"opacity 0.12s ease",zIndex:10},children:t.jsx(o.Box,{sx:{position:"absolute",right:8,top:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"flex-end",zIndex:10},children:t.jsx(o.IconButton,{"data-row-action-btn":"true",size:"small",onClick:ge=>{ge.stopPropagation(),ge.preventDefault(),at(null),Ge({anchorEl:ge.currentTarget,row:w,rowIndex:N})},sx:{color:"text.secondary",opacity:ke?1:0,transition:"opacity 0.12s ease",pointerEvents:ke?"auto":"none","&:hover":{bgcolor:ge=>O(ge.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(M.MoreVert,{sx:{fontSize:18}})})})})]},N)},[dt,Hn,Br,bo,Jr,g,$t,Mn,tt,Nt,ar,Qe,rr,ht,Me,pt,V,Ge,Qr,go,Se,Ze,lt,he,C]);return t.jsxs(nr.DndProvider,{backend:pi.HTML5Backend,children:[t.jsxs(o.Box,{sx:w=>{var rt,Ke,ge;const N=((ge=(Ke=(rt=w.components)==null?void 0:rt.MuiCard)==null?void 0:Ke.styleOverrides)==null?void 0:ge.root)||{},te=N.border&&N.border!=="none"?N.border:"1px solid",ke=N.borderRadius!==void 0?typeof N.borderRadius=="number"?`${N.borderRadius}px`:N.borderRadius:`${w.shape.borderRadius}px`,Ne=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:be(w,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:te,borderColor:te!=="none"?"divider":void 0,borderRadius:ke,boxShadow:Ne,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:w=>{var rt,Ke,ge,Ht,Ut;const N=((ge=(Ke=(rt=w.components)==null?void 0:rt.MuiCardHeader)==null?void 0:Ke.styleOverrides)==null?void 0:ge.root)||{},te=(N.backgroundColor&&N.backgroundColor!=="transparent"?N.backgroundColor:void 0)??((Ht=w.tokens)==null?void 0:Ht.cardHdrHex)??((Ut=w.urmTable)==null?void 0:Ut.headerBg)??w.palette.background.paper,ke=N.borderBottom&&N.borderBottom!=="none"?N.borderBottom:"1px solid",Ne=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:te,borderBottom:ke,borderColor:ke!=="none"?"divider":void 0,boxShadow:Ne,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[qe&&t.jsx(Iu,{}),Xt&&Kt&&br&&Ot&&!(we!=null&&we.includes("search"))&&t.jsx(o.Tooltip,{open:Ur,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",fontWeight:w=>w.typography.caption.fontWeight||500,mb:.25},children:"💡 Search tip"}),t.jsx(o.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:Yr},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:t.jsx(o.Box,{component:"span",children:t.jsx(pu,{value:Te||"",onChange:w=>{Ur&&Yr(),Xt(w)},searchHistory:Rr,onAddToHistory:Kt,onToggleFavourite:br,onDeleteHistory:Ot,disabled:qe})})}),!(we!=null&&we.includes("jsonGuide"))&&t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>Po(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:w=>O(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(M.InfoOutlined,{sx:{fontSize:20}})})}),j&&T&&b&&s.length>0&&t.jsx(hu,{views:s||[],activeViewId:a||"",isDirty:d,onSelectView:j,onCreateView:T,onToggleDefault:I,onToggleFavorite:J,onRestoreView:Z,onPermanentDelete:B,onEditView:f,onCloneView:$,onCopyLink:D,onDeleteView:ee,onPromoteToGlobal:oe,onSetDefaultForAllUsers:c,isAdmin:re,hideViewMenuActions:fe,isReadOnly:qe}),d&&!qe&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[b&&t.jsx(o.Button,{onClick:b,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:w=>`var(--urm-btn-save-current-bg, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-current-color, ${w.palette.primary.contrastText})`,textTransform:"none",boxShadow:w=>be(w,"restButton"),"&:hover":{bgcolor:w=>`var(--urm-btn-save-current-hover-bg, ${w.palette.primary.dark})`,boxShadow:w=>be(w,"hoverButton")}},children:"Save current view"}),R&&t.jsx(o.Button,{onClick:R,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:w=>`var(--urm-btn-save-new-border, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-new-color, ${w.palette.primary.main})`,bgcolor:w=>`var(--urm-btn-save-new-bg, ${w.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:w=>`var(--urm-btn-save-new-hover-border, ${w.palette.primary.dark})`,bgcolor:w=>`var(--urm-btn-save-new-hover-bg, ${O(w.palette.primary.main,.08)})`}},children:"Save new view"}),H&&t.jsx(o.Button,{onClick:H,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:w=>`var(--urm-btn-discard-bg, ${O(w.palette.text.primary,.12)})`,color:w=>`var(--urm-btn-discard-color, ${w.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:w=>`var(--urm-btn-discard-hover-bg, ${O(w.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),ho&&Pr&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:Pr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:w=>O(w.palette.text.secondary,.3),"&:hover":{bgcolor:w=>O(w.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx(M.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!qe&&k&&!(we!=null&&we.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:k,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?w=>Dt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?w=>O(w.palette.primary.main,.2):w=>O(w.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx(M.SwapVert,{sx:{fontSize:20}}),n.length>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:n.length})]})}),!qe&&y&&!(we!=null&&we.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:y,size:"small",sx:{position:"relative",color:tr>0?"primary.main":"text.secondary",bgcolor:tr>0?w=>Dt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:tr>0?w=>O(w.palette.primary.main,.2):w=>O(w.palette.text.primary,.06),color:tr>0?"primary.main":"text.primary"}},children:[t.jsx(M.FilterList,{sx:{fontSize:20}}),tr>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:tr})]})}),!qe&&K&&!(we!=null&&we.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:K,size:"small",sx:{position:"relative",color:hr>0||Xr?"primary.main":"text.secondary",bgcolor:hr>0||Xr?w=>Dt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:hr>0||Xr?w=>O(w.palette.primary.main,.2):w=>O(w.palette.text.primary,.06),color:hr>0||Xr?"primary.main":"text.primary"}},children:[t.jsx(M.ViewColumn,{sx:{fontSize:20}}),hr>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:hr})]})}),Qr&&(ne||De)&&(()=>{var te;const w=(((te=m==null?void 0:m.collapsedGroups)==null?void 0:te.length)??0)>0,N=w?ne:De;return N?t.jsx(o.Tooltip,{title:w?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:N,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:ke=>O(ke.palette.text.primary,.06),color:"text.primary"}},children:w?t.jsx(M.UnfoldMore,{sx:{fontSize:20}}):t.jsx(M.UnfoldLess,{sx:{fontSize:20}})})}):null})(),it.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),it.map(w=>{const N=mt===w,te=w==="list"?t.jsx(M.TableRows,{sx:{fontSize:20}}):t.jsx(M.GridView,{sx:{fontSize:20}}),ke=w==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:ke,children:t.jsx(o.IconButton,{size:"small",onClick:()=>bt(w),sx:{borderRadius:1,color:N?"primary.main":"text.secondary",bgcolor:N?Ne=>Dt(Ne):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:N?Ne=>O(Ne.palette.primary.main,.2):Ne=>O(Ne.palette.text.primary,.06),color:N?"primary.main":"text.primary"}},children:te})},w)})]}),!(we!=null&&we.includes("settings"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"Settings",children:t.jsx(o.IconButton,{onClick:w=>_e(w.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:w=>O(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(M.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!et,anchorEl:et,onClose:()=>_e(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:[U&&!(we!=null&&we.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{U(),_e(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!qe&&P&&!(we!=null&&we.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{P(),_e(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),Q&&!(we!=null&&we.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Q(),_e(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),Pe&&!(we!=null&&we.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Pe(),_e(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]}),At==null?void 0:At.map(w=>t.jsxs(o.MenuItem,{dense:!0,disabled:w.disabled,onClick:()=>{w.onClick(),_e(null)},sx:{py:1,px:2,gap:1.5},children:[w.icon,t.jsx(o.Typography,{variant:"body2",children:w.label})]},w.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[jr&&jr.length>0&&lt.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:w=>ot(w).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:w=>w.typography.body2.fontWeight||600,mr:1},children:[lt.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>wt==null?void 0:wt(),children:"Clear"}),jr.map(w=>{var te,ke;const N=Array.from(dt);return(te=w.hidden)!=null&&te.call(w,N)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:w.icon,disabled:(ke=w.disabled)==null?void 0:ke.call(w,N),onClick:()=>w.onClick(N),children:w.label},w.key)})]}),mt!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(zu,{data:Ve,visibleColumns:qr,grouping:m,selectedRowIds:dt,isGrouped:!!Qr,onToggleGroupCollapse:G,onCardClick:(w,N)=>bo(w,N),onCardDoubleClick:w=>{Ze!=null&&Ze.includes("doubleClick")&&(ht(w),Me(!0))},onCardContextMenu:(w,N,te)=>{Se==null||Se(w,N,te),at(null),Ge({mouseX:te.clientX,mouseY:te.clientY,row:w,rowIndex:N}),Ze!=null&&Ze.includes("rightClick")&&(ht(w),Me(!0))},onOpenRowMenu:(w,N,te)=>Ge({anchorEl:te,row:w,rowIndex:N}),onToggleSelection:w=>Qe==null?void 0:Qe(w),hideSelectionCheckboxes:Lr})}),mt==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Gr,onScroll:w=>{xo.current&&(xo.current.scrollLeft=w.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Kr).reduce((w,N)=>w+N,0)}px`},children:[t.jsxs("colgroup",{children:[rr&&t.jsx("col",{style:{width:"40px"}}),vt.map(w=>t.jsx("col",{style:{width:`${Kr[w.name]}px`}},w.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(he==null?void 0:he.headerBg)??"action.hover",borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider"},children:[rr&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(he==null?void 0:he.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(he==null?void 0:he.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Vo,indeterminate:Un,onChange:w=>Mt==null?void 0:Mt(w.target.checked,Ve)})}),vt.map((w,N)=>t.jsx(xu,{column:w,index:N,sortRule:n.find(te=>te.column===w.name),hasFilters:ii(i,w.name),isInSortStack:n.some(te=>te.column===w.name),isReadOnly:qe,hasModifications:Vn,width:g[w.name],onColumnClick:An,onMoveColumn:Wn,onColumnDragEnd:Rn,onResizeStart:On,onSortAscending:E||Pn,onSortDescending:v||Nn,onRemoveSort:Ln,onOpenFilterForColumn:h||(()=>{}),onClearFiltersForColumn:pe||(()=>{}),onGroupByColumn:se,onHideColumn:Fn,onManageColumns:K||(()=>{}),onResetLayout:le},w.name))]})})]})}),t.jsx(o.Box,{ref:xo,onScroll:w=>{Gr.current&&(Gr.current.scrollLeft=w.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:w=>O(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>O(w.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Kr).reduce((w,N)=>w+N,0)}px`},children:[t.jsxs("colgroup",{children:[rr&&t.jsx("col",{style:{width:"40px"}}),vt.map(w=>t.jsx("col",{style:{width:`${Kr[w.name]}px`}},w.name))]}),t.jsx(o.TableBody,{children:Ve.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:vt.length,align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Qr?Ve.map((w,N)=>w.isGroupHeader?eo(w):Uo(w,N)):Ve.map((w,N)=>Uo(w,N))})]})})]}),Sr&&jt&&t.jsx(Tu,{currentPage:uo,pageSize:sr,totalRows:po,totalPages:Zt,totalFields:e.length,onPageChange:Sr,onPageSizeChange:jt}),!(Sr&&jt)&&t.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",Ve.length," ",Ve.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!je,onClose:()=>{Ge(null),at(null)},anchorEl:(je==null?void 0:je.anchorEl)||null,anchorReference:je!=null&&je.anchorEl?"anchorEl":"anchorPosition",anchorPosition:je&&!je.anchorEl?{top:je.mouseY,left:je.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:je!=null&&je.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(Je!=null&&Je.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(ht(je.row),Me(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(Je!=null&&Je.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(Hr(je.row),Er(je.rowIndex),Vt(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(Je!=null&&Je.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(Nt==null||Nt(je.rowIndex,je.row)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),je&&(lr==null?void 0:lr.map(w=>{var N,te;return(N=w.hidden)!=null&&N.call(w,je.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(te=w.disabled)==null?void 0:te.call(w,je.row),onClick:()=>{w.onClick(je.row,je.rowIndex),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[w.icon,t.jsx(o.Typography,{variant:"body2",children:w.label})]},w.key)})),lt.size>0&&Qt&&!(Je!=null&&Je.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:w=>{me(),at(w.currentTarget)},onMouseLeave:xe,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(M.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",lt.size,")"]})]}),t.jsx(M.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!Dr,anchorEl:Dr,placement:"right-start",transition:!0,sx:{zIndex:w=>w.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:w})=>t.jsx(o.Grow,{...w,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:me,onMouseLeave:xe,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:t.jsxs(o.MenuList,{dense:!0,autoFocusItem:!1,children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Qt("csv"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Qt("excel"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Qt("json"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]}),ur.export.allowedFormats.includes("pdf")&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Qt("pdf"),at(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(M.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(Je!=null&&Je.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(Vr(je.row),Tr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx(M.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(_u,{open:V,onClose:()=>{Me(!1),ht(null)},row:pt,schema:e,reportName:ut}),t.jsx(Ou,{open:mo,onClose:()=>{Vt(!1),Hr(null),Er(null)},onSave:w=>{Wt!==null&&(tt==null||tt(Wt,w))},row:fo,schema:e,reportName:ut}),t.jsx($u,{open:Ae,onClose:()=>{Tr(!1),Vr(null)},onConfirm:()=>{Ir!==null&&(ar==null||ar(Ir))},row:Ir,schema:e}),t.jsx(oa,{isOpen:Dn,onClose:()=>Po(!1),content:wr})]})}function xt({content:e,isDev:r=!1}){const[n,i]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${e.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>O(s.palette.primary.main,.08)}},children:t.jsx(M.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(o.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:[t.jsx(o.Box,{sx:{px:2,py:1.5,bgcolor:s=>O(s.palette.primary.main,.06)},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||600,color:"primary.main",fontSize:s=>s.typography.body2.fontSize||"0.875rem"},children:e.title})}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.8125rem",lineHeight:1.6},children:e.description}),e.tips&&e.tips.length>0&&t.jsx(o.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:e.tips.map((s,a)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},a))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>O(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>O(s.palette.warning.main,.2)},children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:s=>s.typography.caption.fontWeight||500,fontSize:s=>s.typography.caption.fontSize||"0.75rem",display:"block",mb:.25},children:"Dev note"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontSize:s=>s.typography.caption.fontSize||"0.75rem",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}const Wr={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","24-hour format · Tab must be open for the schedule to fire","Opens your device's email app when the schedule fires. If you added email."],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."}},ni=40;function Yu({operator:e,onSelect:r}){return t.jsxs(o.Select,{value:e,onChange:n=>r(n.target.value),size:"small",variant:"outlined",sx:{position:"relative",zIndex:1,mt:1,width:58,height:24,fontSize:"0.6875rem",fontWeight:700,color:"primary.main",bgcolor:"background.paper",borderRadius:"6px","& .MuiSelect-select":{py:0,px:1,display:"flex",alignItems:"center"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}},children:[t.jsx(o.MenuItem,{value:"and",sx:{fontSize:"0.75rem",fontWeight:600},children:"AND"}),t.jsx(o.MenuItem,{value:"or",sx:{fontSize:"0.75rem",fontWeight:600},children:"OR"})]})}function qu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),d=p.useMemo(()=>{const u=a?cn(a.type):[],x=i.filter.allowedOperators;return x.length>0?u.filter(g=>x.includes(g.value)):u},[a,i]),l=Wl(e.operator);return t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(o.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(o.Select,{value:e.column,onChange:u=>{var m;const x=r.find(C=>C.name===u.target.value),g=x?cn(x.type):[];s({column:u.target.value,operator:((m=g[0])==null?void 0:m.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(u=>t.jsx(o.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:ct(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:d.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),l&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:u=>s({value:u.target.value}),sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}}),l&&(a==null?void 0:a.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function ca({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:d,onChange:l}){const u=d>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((x,g)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:ni,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[g<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),g>0&&t.jsx(Yu,{operator:e.operator,onSelect:m=>l(C=>fi(C,e.id,m))}),g>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:ni/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:g>0?1:0},children:Xe(x)?t.jsx(Ju,{group:x,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:d,onChange:l}):t.jsx(qu,{condition:x,schema:n,availableColumns:i,devConfig:s,onUpdate:m=>l(C=>mi(C,x.id,m))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>l(m=>xi(m,x.id)),sx:{mt:g>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(M.Close,{sx:{fontSize:16}})})]},x.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${ni}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>l(x=>{var g,m,C;return co(x,e.id,{id:lo(),column:((g=i[0])==null?void 0:g.name)??"",operator:((C=cn(((m=i[0])==null?void 0:m.type)??"string")[0])==null?void 0:C.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>l(x=>co(x,e.id,Pt())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Ju(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>O(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>O(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(ca,{...e})})}function Ku({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[d,l]=p.useState(r??Pt()),u=Ar(),x=p.useMemo(()=>e.filter(k=>k.type!=="mixed"&&k.type!=="null"&&k.type!=="array"&&k.type!=="object"),[e]);p.useEffect(()=>{var h;const k=r??Pt();if(s&&k.children.length===0){const j=e.find(T=>T.name===s);if(j){l(co(k,k.id,{id:lo(),column:s,operator:((h=cn(j.type)[0])==null?void 0:h.value)??"equals"}));return}}l(k)},[r,s,e]);const g=Et(d),m=u.filter.maxConditions,C=p.useCallback(k=>{l(h=>k(h))},[]),S=p.useMemo(()=>JSON.stringify(d)!==JSON.stringify(r??Pt()),[d,r]),E=p.useCallback(()=>{n(d),i()},[d,n,i]),v=p.useCallback(()=>{l(r??Pt()),i()},[r,i]),y=p.useCallback(()=>{n(Pt()),i()},[n,i]);return t.jsx(o.Box,{onClick:v,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:k=>O(k.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:k=>k.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:k=>k.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:k=>nt(k),bgcolor:"background.paper",outline:"none",boxShadow:k=>ce(k).paper.boxShadow,border:k=>ce(k).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:k=>ce(k).header.backgroundColor,borderBottom:k=>ce(k).header.borderBottom,boxShadow:k=>ce(k).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:k=>k.typography.h6.fontSize||"1.125rem",fontWeight:k=>k.typography.h6.fontWeight||500,color:k=>k.typography.h6.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(xt,{content:Wr.filter,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[a&&t.jsx(o.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Settings,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{onClick:v,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:20}})})]})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:k=>O(k.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:k=>O(k.palette.text.primary,.3)}}},children:[g===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:k=>k.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${ct(s)}"`:"","."]}),t.jsx(ca,{group:d,depth:0,schema:e,availableColumns:x,devConfig:u,maxConditions:m,totalConditions:g,onChange:C}),g>=m&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:k=>k.typography.caption.fontSize||"0.75rem",fontWeight:k=>k.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",m," conditions allowed. Remove one to add another."]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",alignItems:"center",gap:1.5,justifyContent:"space-between",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:y,disabled:g===0,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"Clear all"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[t.jsx(o.Button,{onClick:v,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:E,disabled:!S,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,boxShadow:k=>be(k,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const ws="SORT_RULE";function Xu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=p.useRef(null),[{handlerId:d},l]=nr.useDrop({accept:ws,collect(g){return{handlerId:g.getHandlerId()}},hover(g,m){var h;if(!a.current)return;const C=g.index,S=r;if(C===S)return;const E=(h=a.current)==null?void 0:h.getBoundingClientRect(),v=(E.bottom-E.top)/2,y=m.getClientOffset(),k=((y==null?void 0:y.y)??0)-E.top;C<S&&k<v||C>S&&k>v||(s(C,S),g.index=S)}}),[{isDragging:u},x]=nr.useDrag({type:ws,item:()=>({index:r}),collect:g=>({isDragging:g.isDragging()})});return x(l(a)),t.jsxs(o.Box,{ref:a,"data-handler-id":d,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:g=>be(g,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(o.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:g=>`0 1px 2px 0 ${O(g.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:g=>g.typography.body2.fontSize||"0.875rem",fontWeight:g=>g.typography.body2.fontWeight||400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:e.column}),t.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:t.jsxs(o.Select,{value:e.direction,onChange:g=>n(r,g.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:[t.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>Dt(g),"&:hover":{bgcolor:g=>O(g.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>Dt(g),"&:hover":{bgcolor:g=>O(g.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:g=>O(g.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(M.Close,{sx:{fontSize:18}})})]})}function Qu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i,onOpenDevConfig:s}){const[a,d]=p.useState(""),[l,u]=p.useState([]);p.useEffect(()=>{u([...r])},[r]);const x=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r),[l,r]),g=Ar(),m=p.useCallback(j=>{if(!j||l.length>=g.sort.maxLevels)return;const T={column:j,direction:"asc",priority:l.length+1};u([...l,T]),d(""),setTimeout(()=>{var b;return(b=document.activeElement)==null?void 0:b.blur()},0)},[l,g.sort.maxLevels]),C=p.useCallback(j=>{const b=l.filter((R,H)=>H!==j).map((R,H)=>({...R,priority:H+1}));u(b)},[l]),S=p.useCallback((j,T)=>{const b=[...l];b[j]={...b[j],direction:T},u(b)},[l]),E=p.useCallback((j,T)=>{const b=[...l],[R]=b.splice(j,1);b.splice(T,0,R);const H=b.map((I,J)=>({...I,priority:J+1}));u(H)},[l]),v=p.useCallback(()=>{n([]),i()},[n,i]),y=p.useCallback(()=>{n(l),i()},[l,n,i]),k=p.useCallback(()=>{u([...r]),d(""),i()},[r,i]),h=e.filter(j=>!l.some(T=>T.column===j.name));return t.jsx(nr.DndProvider,{backend:pi.HTML5Backend,children:t.jsx(o.Box,{onClick:k,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:j=>O(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:t.jsxs(o.Paper,{onClick:j=>j.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:j=>nt(j),bgcolor:"background.paper",outline:"none",boxShadow:j=>ce(j).paper.boxShadow,border:j=>ce(j).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:j=>ce(j).header.backgroundColor,borderBottom:j=>ce(j).header.borderBottom,boxShadow:j=>ce(j).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:j=>j.typography.h6.fontSize||"1.125rem",fontWeight:j=>j.typography.h6.fontWeight||500,color:j=>j.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(xt,{content:Wr.sort,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Settings,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{onClick:k,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:20}})})]})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:j=>O(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>O(j.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=g.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:a,onChange:j=>m(j.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:h.map(j=>t.jsx(o.MenuItem,{value:j.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:T=>Dt(T),"&:hover":{bgcolor:T=>O(T.palette.primary.main,.2)}}},children:ct(j.name)},j.name))})]}),l.length>=g.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:j=>j.typography.caption.fontSize||"0.75rem",fontWeight:j=>j.typography.caption.fontWeight||500},children:["Maximum ",g.sort.maxLevels," sort levels allowed"]})]}),l.length>0&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Typography,{variant:"overline",sx:{fontSize:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",g.sort.maxLevels,")"]}),t.jsx(o.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"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((j,T)=>t.jsx(Xu,{rule:j,index:T,onToggleDirection:S,onRemove:C,onMove:E},`${j.column}-${T}`))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:k,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"}),t.jsx(o.Button,{onClick:y,variant:"contained",disabled:!x||l.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,boxShadow:j=>be(j,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:j=>be(j,"hoverButton")},"&:active":{boxShadow:j=>be(j,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const en=50;function js({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:d=!1,atViewLimit:l=!1,maxViews:u=10}){const[x,g]=p.useState(s),[m,C]=p.useState(!1),[S,E]=p.useState(a),[v,y]=p.useState(d),k=()=>{if(!x.trim()){C(!0);return}if(x.trim().length>en){C(!0);return}r(x.trim(),S.trim(),v),n()},h=T=>{T.key==="Enter"&&!T.shiftKey?k():T.key==="Escape"&&n()},j=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:T=>({mt:8,borderRadius:nt(T),...ce(T).paper})},children:[t.jsxs(o.DialogTitle,{sx:T=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ce(T).header}),children:[j(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[l&&!i&&t.jsxs(o.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."]}),t.jsx(o.TextField,{label:"View Name",required:!0,value:x,onChange:T=>{T.target.value.length<=en&&g(T.target.value),m&&T.target.value.trim()&&C(!1)},onKeyDown:h,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:en},error:m&&!x.trim(),helperText:m&&!x.trim()?"View name is required":`${x.length} / ${en}`}),t.jsx(o.TextField,{label:"Description (optional)",value:S,onChange:T=>E(T.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),t.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:T=>T.typography.body2.fontWeight||500,mb:1},children:"This view will capture:"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[t.jsxs("li",{children:[Et(e.filters)," filter",Et(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",el(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:v,onChange:T=>y(T.target.checked),size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Set as default view"})})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:k,variant:"contained",disabled:l&&!i,startIcon:t.jsx(M.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,boxShadow:T=>be(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>be(T,"hoverButton")},"&:active":{boxShadow:T=>be(T,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Zu({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:nt(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...ce(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ce(i).header}),children:["Delete View",t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[t.jsx(M.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),t.jsxs(o.Box,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",t.jsxs("strong",{children:['"',e,'"']}),"?"]}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.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"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>be(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>be(i,"hoverButton")},"&:active":{boxShadow:i=>be(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const ks="COLUMN";function ep({column:e,index:r,isVisible:n,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:d,onToggleVisibility:l,onWidthChange:u,moveColumn:x}){const g=p.useRef(null),[m,C]=p.useState(i.toString());p.useEffect(()=>{C(i.toString())},[i]);const[{handlerId:S},E]=nr.useDrop({accept:ks,collect(b){return{handlerId:b.getHandlerId()}},hover(b,R){var $;if(!g.current)return;const H=b.index,I=r;if(H===I)return;const J=($=g.current)==null?void 0:$.getBoundingClientRect(),Z=(J.bottom-J.top)/2,B=R.getClientOffset(),f=((B==null?void 0:B.y)??0)-J.top;H<I&&f<Z||H>I&&f>Z||(x(H,I),b.index=I)}}),[{isDragging:v},y]=nr.useDrag({type:ks,item:()=>({index:r}),collect:b=>({isDragging:b.isDragging()})});y(E(g));const k=()=>{const b=parseInt(m);if(isNaN(b)){C(i.toString()),u(e.name,i);return}const R=Math.max(s,Math.min(a,b));C(R.toString()),u(e.name,R)},h=b=>{if(b===""||/^\d+$/.test(b)){C(b);const R=parseInt(b);if(!isNaN(R)&&R>=s){const H=Math.min(a,R);u(e.name,H)}}},j=b=>{b.key==="Enter"&&(b.preventDefault(),k(),b.target.blur())},T=b=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[b]||"text.secondary";return t.jsxs(o.TableRow,{ref:g,"data-handler-id":S,sx:{opacity:v?.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:[t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx(M.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:b=>b.typography.body2.fontWeight||400,fontSize:b=>b.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:ct(e.name)})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(o.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${T(e.type)}15`,color:T(e.type),border:`1px solid ${T(e.type)}30`,"& .MuiChip-label":{px:1}}})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.TextField,{type:"number",value:m,onChange:b=>h(b.target.value),onBlur:k,onKeyDown:j,placeholder:"150",size:"small",inputProps:{min:s,max:a,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}}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"px"})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.IconButton,{onClick:()=>l(e.name,!n),disabled:!n&&!d,title:n?"Hide column":d?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:n?t.jsx(M.Visibility,{sx:{fontSize:20}}):t.jsx(M.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?b=>O(b.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function tp({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:d,onUpdateColumnOrder:l,onUpdateColumnWidth:u,onResetLayout:x,onClose:g}){const m=Ar(),[C,S]=p.useState(!1),[E,v]=p.useState(n),[y,k]=p.useState(i),[h,j]=p.useState("all");p.useEffect(()=>{v(n)},[n]),p.useEffect(()=>{k(i)},[i]);const T=($,D)=>{k(ee=>({...ee,[$]:D})),u==null||u($,D)},b=($,D)=>{const ee=[...E],[oe]=ee.splice($,1);ee.splice(D,0,oe),v(ee),l(ee)},R=()=>{x(),S(!1)},I=E.map($=>e.find(D=>D.name===$)).filter($=>$!==void 0).filter($=>{const D=r[$.name]??!0;return h==="active"?D:h==="hidden"?!D:!0}),J=Object.values(r).filter($=>$).length,Z=e.length,B=s.find($=>$.id===a),f=p.useMemo(()=>{if(!B)return!1;const $=B.snapshot,D=$.columnVisibility??{},ee=JSON.stringify(r)!==JSON.stringify(D),oe=$.columnOrder??[],c=n??[],re=JSON.stringify(c)!==JSON.stringify(oe)&&!(c.length===0&&oe.length===0),fe=$.columnWidths??{},U=JSON.stringify(y)!==JSON.stringify(fe);return ee||re||U},[B,r,n,y]);return t.jsx(nr.DndProvider,{backend:pi.HTML5Backend,children:t.jsx(o.Box,{onClick:g,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:$=>O($.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:$=>$.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:$=>$.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:$=>nt($),bgcolor:"background.paper",outline:"none",boxShadow:$=>ce($).paper.boxShadow,border:$=>ce($).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,flexShrink:0,bgcolor:$=>ce($).header.backgroundColor,borderBottom:$=>ce($).header.borderBottom,boxShadow:$=>ce($).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsx(o.Box,{sx:{flex:1},children:t.jsxs(o.Typography,{variant:"h6",sx:{fontSize:$=>$.typography.h6.fontSize||"1.125rem",fontWeight:$=>$.typography.h6.fontWeight||500,color:$=>$.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx(xt,{content:Wr.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:g,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:h,onChange:($,D)=>j(D),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:$=>ot($).main,height:3}},children:[t.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{borderBottomColor:"text.primary",fontWeight:600,bgcolor:$=>ot($).hoverBg},"&:hover":{color:"text.primary",bgcolor:$=>ot($).bg}}}),t.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:$=>ot($).hoverBg},"&:hover":{color:"text.primary",bgcolor:$=>ot($).bg}}}),t.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:$=>ot($).hoverBg},"&:hover":{color:"text.primary",bgcolor:$=>ot($).bg}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$=>O($.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:$=>O($.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(o.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"}),t.jsx(o.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"}),t.jsx(o.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:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(o.Tooltip,{title:`Column width in pixels (min: ${m.columns.minColumnWidth}px, max: ${m.columns.maxColumnWidth}px)`,arrow:!0,placement:"top",children:t.jsx(M.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),t.jsx(o.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"})]})}),t.jsx(o.TableBody,{children:I.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:$=>$.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):I.map(($,D)=>{const ee=r[$.name]??!0,oe=ee||J<m.columns.maxVisible;return t.jsx(ep,{column:$,index:D,isVisible:ee,width:y[$.name]||170,minColumnWidth:m.columns.minColumnWidth,maxColumnWidth:m.columns.maxColumnWidth,canToggleOn:oe,onToggleVisibility:d,onWidthChange:T,moveColumn:b},$.name)})})]})}),t.jsx(o.Box,{sx:{px:3,py:1,borderTop:"1px solid divider",bgcolor:"background.default",flexShrink:0},children:t.jsxs(o.Typography,{variant:"body2",sx:{fontSize:$=>$.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[J," of ",Z," columns visible • Drag to reorder"]})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:t.jsx(o.Button,{onClick:()=>S(!0),disabled:!f,variant:"outlined",startIcon:t.jsx(M.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:$=>`${$.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),C&&t.jsx(o.Box,{onClick:()=>S(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:$=>O($.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:$=>$.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:$=>$.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:$=>Wo($),bgcolor:"background.paper",boxShadow:$=>ce($).paper.boxShadow,border:$=>ce($).paper.border},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>S(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:$=>`${$.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:$=>`${$.shape.borderRadius}px`,boxShadow:$=>be($,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:$=>be($,"hoverButton")},"&:active":{boxShadow:$=>be($,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function rp({schema:e,grouping:r,onApply:n,onClose:i,onOpenDevConfig:s}){var H;const[a,d]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,u]=p.useState(""),[x,g]=p.useState(null),m=p.useMemo(()=>Ya(e),[e]),C=p.useMemo(()=>m.filter(I=>!a.levels.some((J,Z)=>J.column===I.name&&Z!==x)),[m,a.levels,x]),S=Ar(),E=a.levels.length<S.grouping.maxLevels&&C.length>0&&(S.grouping.allowNested||a.levels.length===0),v=p.useCallback(I=>{!E||!I||(d({...a,levels:[...a.levels,{column:I}],enabled:!0}),u(""),setTimeout(()=>{var J;return(J=document.activeElement)==null?void 0:J.blur()},0))},[E,a]),y=p.useCallback(I=>{const J=a.levels.filter((Z,B)=>B!==I);if(J.length===0){n(null),i();return}d({...a,levels:J,enabled:J.length>0})},[a,n,i]),k=p.useCallback(I=>{g(I),u(a.levels[I].column)},[a.levels]),h=p.useCallback(()=>{if(x===null||!l)return;const I=[...a.levels];I[x]={column:l},d({...a,levels:I}),g(null),u("")},[x,l,a]),j=p.useCallback(()=>{g(null),u("")},[]),T=p.useCallback((I,J)=>{const Z=J==="up"?I-1:I+1;if(Z<0||Z>=a.levels.length)return;const B=[...a.levels],[f]=B.splice(I,1);B.splice(Z,0,f),d({...a,levels:B})},[a]),b=p.useCallback(()=>{n(null),i()},[n,i]),R=p.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:I=>O(I.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:I=>I.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:I=>nt(I),bgcolor:"background.paper",outline:"none",boxShadow:I=>ce(I).paper.boxShadow,border:I=>ce(I).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:I=>ce(I).header.backgroundColor,borderBottom:I=>ce(I).header.borderBottom,boxShadow:I=>ce(I).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:I=>I.typography.h6.fontSize||"1.125rem",fontWeight:I=>I.typography.h6.fontWeight||500,color:I=>I.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(xt,{content:Wr.grouping,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Settings,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:20}})})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:1,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:I=>O(I.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:I=>O(I.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[x===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:I=>I.typography.caption.fontSize||"0.6875rem",fontWeight:I=>I.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:I=>v(I.target.value),disabled:!E,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:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),C.map(I=>t.jsxs(o.MenuItem,{value:I.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:J=>Dt(J),"&:hover":{bgcolor:J=>O(J.palette.primary.main,.2)}}},children:[ct(I.name)," (",I.type.toUpperCase(),")"]},I.name))]})}),a.levels.length>=S.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:I=>I.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),m.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),x!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:I=>`1px solid ${O(I.palette.warning.main,.5)}`,bgcolor:I=>O(I.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:I=>I.typography.body2.fontWeight||500,mb:1.5,fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",x+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:I=>u(I.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[x].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:I=>Dt(I)}},children:[a.levels[x].column," (",(H=e.find(I=>I.name===a.levels[x].column))==null?void 0:H.type.toUpperCase(),")"]}),C.filter(I=>I.name!==a.levels[x].column).map(I=>t.jsxs(o.MenuItem,{value:I.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:J=>Dt(J)}},children:[ct(I.name)," (",I.type.toUpperCase(),")"]},I.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:h,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:I=>be(I,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:j,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"})]})]}),a.levels.length>0&&x===null&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:I=>I.typography.caption.fontSize||"0.6875rem",fontWeight:I=>I.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:b,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((I,J)=>{const Z=e.find(B=>B.name===I.column);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:B=>be(B,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${J+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:B=>`0 1px 2px 0 ${O(B.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:B=>B.typography.body2.fontWeight||500,fontSize:B=>B.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:I.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:B=>B.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:Z==null?void 0:Z.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>T(J,"up"),disabled:J===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(M.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>T(J,"down"),disabled:J===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(M.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>k(J),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx(M.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>y(J),sx:{color:"text.secondary","&:hover":{bgcolor:B=>O(B.palette.error.main,.08),color:"error.main"}},children:t.jsx(M.Delete,{sx:{fontSize:18}})})]})]},J)})})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:R,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,boxShadow:I=>be(I,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:I=>be(I,"hoverButton")},"&:active":{boxShadow:I=>be(I,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function op({onExportAnyway:e,onSaveAndExport:r,onCancel:n}){return t.jsx(o.Box,{sx:{mb:2,mx:3,mt:2},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(M.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx(M.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1rem",mb:.5},children:"You are exporting with unsaved view changes"}),t.jsx(o.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,variant:"contained",color:"primary",startIcon:t.jsx(M.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx(M.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const zs=[{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 np(e,r){if(r===null)return e.length;const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()>=n).length}function ip(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function sp({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=gt(),s=i.palette,[a,d]=p.useState("1h"),[l,u]=p.useState(!1),[x,g]=p.useState("all"),[m,C]=p.useState(!0),[S,E]=p.useState(!1),[v,y]=p.useState(!1),k=[...e].sort((B,f)=>{const $=new Date(B.timestamp).getTime()-new Date(f.timestamp).getTime();return S?$:-$}),h=k.reduce((B,f)=>(B[f.feature]=(B[f.feature]??0)+1,B),{}),j=Object.keys(h).sort((B,f)=>(h[f]??0)-(h[B]??0)),T=x==="all"?k:k.filter(B=>B.feature===x),b=zs.find(B=>B.key===a),R=np(e,b.ms),H=()=>u(!0),I=()=>{n&&(n(ip(e,b.ms)),u(!1))},J=B=>{const f=vs(i,B.feature),{summary:$,detail:D}=ml(B);return t.jsxs(o.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:O(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:Jn(B.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:O(f,.1),color:f,border:`1px solid ${O(f,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:$}),D&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:D}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(M.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:gl(B.timestamp)})]}),B.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(M.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:B.user})]})]})]})]},B.id)},Z=v?j.map(B=>({feature:B,events:T.filter(f=>f.feature===B)})).filter(B=>B.events.length>0):[];return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:O(s.common.black,.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:t.jsxs(o.Paper,{onClick:B=>B.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:nt(i),bgcolor:"background.paper",overflow:"hidden",...ce(i).paper,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:[t.jsxs(o.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,...ce(i).header},children:[t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx(xt,{content:Wr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[T.length," event",T.length!==1?"s":""," recorded"]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Select,{value:a,onChange:B=>d(B.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:O(s.text.primary,.3)}},children:zs.map(B=>t.jsx(o.MenuItem,{value:B.key,sx:{fontSize:"0.8125rem"},children:B.label},B.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(M.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:H,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:O(s.error.main,.5),"&:hover":{bgcolor:O(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),j.length>1&&t.jsx(o.IconButton,{onClick:()=>C(B=>!B),size:"small",title:m?"Hide category filter":"Show category filter",sx:{color:m?"primary.main":"text.secondary",bgcolor:m?O(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:m?O(s.primary.main,.16):"action.hover"}},children:t.jsx(M.FilterAltOutlined,{sx:{fontSize:17}})}),t.jsx(o.IconButton,{onClick:()=>E(B=>!B),size:"small",title:S?"Sorted oldest first":"Sorted newest first",sx:{color:S?"primary.main":"text.secondary",bgcolor:S?O(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:S?O(s.primary.main,.16):"action.hover"}},children:t.jsx(M.SortOutlined,{sx:{fontSize:17,transform:S?"scaleY(-1)":"none"}})}),t.jsx(o.IconButton,{onClick:()=>y(B=>!B),size:"small",title:v?"Ungroup events":"Group by category",sx:{color:v?"primary.main":"text.secondary",bgcolor:v?O(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:v?O(s.primary.main,.16):"action.hover"}},children:t.jsx(M.WorkspacesOutlined,{sx:{fontSize:17}})}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:17}})})]})]}),j.length>1&&m&&t.jsxs(o.Tabs,{value:x,onChange:(B,f)=>g(f),variant:"scrollable",scrollButtons:"auto",sx:{minHeight:36,flexShrink:0,borderBottom:"1px solid",borderColor:"divider",px:1.5,"& .MuiTabs-indicator":{height:2}},children:[t.jsx(o.Tab,{value:"all",label:`All (${k.length})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}}),j.map(B=>t.jsx(o.Tab,{value:B,label:`${Jn(B)} (${h[B]})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}},B))]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:O(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:O(s.text.primary,.14),borderRadius:3}},children:T.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx(M.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:B=>B.typography.body2.fontWeight||500},children:k.length===0?"No audit events yet":"No events in this category"}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:k.length===0?"Changes to this report will appear here":"Try a different category tab"})]}):v?t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:Z.map(({feature:B,events:f})=>t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75,px:.25},children:[t.jsx(o.Box,{sx:{width:6,height:6,borderRadius:"50%",bgcolor:vs(i,B)}}),t.jsxs(o.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"text.secondary"},children:[Jn(B)," (",f.length,")"]})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:f.map(J)})]},B))}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:T.map(J)})})]})}),t.jsxs(o.Dialog,{open:l,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Wo(i),...ce(i).paper}},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:O(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(M.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[R," audit record",R!==1?"s":""]})," ",b.key==="all"?"from all time":`from the ${b.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:I,variant:"contained",color:"error",startIcon:t.jsx(M.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",R," Record",R!==1?"s":""]})]})]})]})}function ap({onSave:e,onClose:r}){const[n,i]=p.useState(""),[s,a]=p.useState(""),[d,l]=p.useState(""),[u,x]=p.useState([]),[g,m]=p.useState(""),[C,S]=p.useState(""),E=b=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b),v=()=>{const b=d.trim();if(b){if(!E(b)){S("Please enter a valid email address");return}if(u.includes(b)){S("This email is already added");return}x([...u,b]),l(""),S("")}},y=b=>{x(u.filter(R=>R!==b))},k=b=>{b.key==="Enter"&&(b.preventDefault(),v())},h=()=>{if(!n.trim()){m("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},j=b=>{i(b),g&&m("")},T=b=>{l(b),C&&S("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:b=>O(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:t.jsxs(o.Paper,{onClick:b=>b.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:b=>nt(b),bgcolor:"background.paper",outline:"none",boxShadow:b=>ce(b).paper.boxShadow,border:b=>ce(b).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:b=>ce(b).header.backgroundColor,borderBottom:b=>ce(b).header.borderBottom,boxShadow:b=>ce(b).header.boxShadow,flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:b=>b.typography.h6.fontSize||"1.125rem",fontWeight:b=>b.typography.h6.fontWeight||500,color:b=>b.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Create shareable preset"}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:b=>O(b.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:b=>O(b.palette.text.primary,.3)}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(o.Alert,{severity:"info",icon:t.jsx(M.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:b=>`1px solid ${O(b.palette.primary.main,.3)}`,bgcolor:b=>Dt(b),"& .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."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:b=>b.typography.body2.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."}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.6875rem",fontWeight:b=>b.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(o.TextField,{required:!0,value:n,onChange:b=>j(b.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!g,helperText:g,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"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}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.6875rem",fontWeight:b=>b.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(o.TextField,{value:s,onChange:b=>a(b.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}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:b=>b.typography.caption.fontSize||"0.6875rem",fontWeight:b=>b.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[t.jsx(o.TextField,{value:d,onChange:b=>T(b.target.value),onKeyPress:k,placeholder:"Enter email address",error:!!C,helperText:C,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx(M.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}}}),t.jsx(o.Button,{onClick:v,variant:"outlined",startIcon:t.jsx(M.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:b=>`${b.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(b=>t.jsx(o.Chip,{label:b,onDelete:()=>y(b),deleteIcon:t.jsx(M.Delete,{sx:{fontSize:16}}),sx:{bgcolor:R=>Dt(R),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},b))}),t.jsx(o.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"})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:r,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"}),t.jsx(o.Button,{onClick:h,variant:"contained",startIcon:t.jsx(M.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:b=>`${b.shape.borderRadius}px`,boxShadow:b=>be(b,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:b=>be(b,"hoverButton")},"&:active":{boxShadow:b=>be(b,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function lp({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx(M.Link,{sx:{fontSize:14}}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600},children:e})]}),onDelete:r,deleteIcon:t.jsx(o.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:t.jsx(M.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>O(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 cp({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const a=d=>new Date(d).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:d=>O(d.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:d=>d.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:d=>d.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:d=>nt(d),bgcolor:"background.paper",outline:"none",boxShadow:d=>ce(d).paper.boxShadow,border:d=>ce(d).paper.border,overflow:"hidden",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:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:d=>ce(d).header.backgroundColor,borderBottom:d=>ce(d).header.borderBottom,boxShadow:d=>ce(d).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:d=>d.typography.h6.fontSize||"1.125rem",fontWeight:d=>d.typography.h6.fontWeight||500,color:d=>d.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:d=>d.typography.caption.fontSize||"0.8125rem",color:"text.secondary",mt:.5,display:"block"},children:[e.length," saved ",e.length===1?"preset":"presets"]})]}),t.jsx(o.IconButton,{onClick:s,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"divider",borderRadius:4,"&:hover":{bgcolor:d=>O(d.palette.text.primary,.2)}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(M.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(o.Typography,{variant:"body1",sx:{fontSize:d=>d.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:d=>d.typography.body2.fontSize||"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(d=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:l=>be(l,"restButtonLight")}},children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:l=>l.typography.body1.fontSize||"0.9375rem",fontWeight:l=>l.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:d.name}),d.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:d.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${a(d.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${d.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",gap:1},children:t.jsx(o.Button,{onClick:()=>i(d.id,d.name),variant:"outlined",size:"small",startIcon:t.jsx(M.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:l=>O(l.palette.error.main,.04)}},children:"Delete"})})]},d.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:d=>`${d.shape.borderRadius}px`,boxShadow:d=>be(d,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:d=>be(d,"hoverButton")},"&:active":{boxShadow:d=>be(d,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const da={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},dp=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],up=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function pp(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=up.some(l=>l.test(i.name));let a=!1;const d=r.slice(0,10).map(l=>l[i.name]).filter(l=>typeof l=="string"&&l.length>0);d.length>0&&(a=d.filter(u=>dp.some(x=>x.test(u))).length/d.length>.6),(s||a)&&n.push(i.name)}return n}function En(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(d=>{const l=n.map(x=>String(x[d]??"")).filter(x=>x.length>0);if(l.length===0)return 5;const u=l.reduce((x,g)=>x+g.length,0);return Math.ceil(u/l.length)+1}).reduce((d,l)=>d+l,0)+1;return r.reduce((d,l)=>d+l.length+1,0)+s*e.length}function hp(e,r){const n=En(e,r);return Math.ceil(n*3.5)}function mp(e,r){const n=En(e,r);return Math.ceil(n*.7)}function fp(e,r){const n=En(e,r);return Math.ceil(n*2)}function xp(e,r,n){switch(e){case"csv":return En(r,n);case"excel":return mp(r,n);case"json":return hp(r,n);case"pdf":return fp(r,n)}}function Bs(e,r){return Math.ceil(e/r)}function gp(e,r,n,i,s=da){const a=[],d=xp(e,r,n),l=r.length;if(l>s.maxRowsHard){const g=Bs(l,s.maxRows);a.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 ${g} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const g=Bs(l,s.maxRows);a.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 ${g} smaller export${g>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:l,limit:s.maxRows})}if(d>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${To(d)} 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:d,limit:s.maxFileSizeHardBytes}):d>s.maxFileSizeBytes&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${To(d)}`,detail:`This exceeds the recommended ${To(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:d,limit:s.maxFileSizeBytes}),e!=="excel"){const g=pp(i.filter(m=>n.includes(m.name)),r);if(g.length>0){const m=g.length>s.maxImageColumns;a.push({type:"image_columns",severity:m?"error":"warning",message:`Image column${g.length>1?"s":""} detected: ${g.map(C=>`"${C.replace(/_/g," ")}"`).join(", ")}`,detail:m?`Exporting ${g.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:g.length,limit:s.maxImageColumns})}}const u=a.some(g=>g.severity==="error"),x=a.some(g=>g.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:x,estimatedBytes:d}}function To(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function yp({violation:e}){const n=gt().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=O(i?n.error.main:n.warning.main,.06),d=i?O(n.error.main,.25):O(n.warning.main,.3),l=i?M.ErrorOutline:M.WarningAmberOutlined;return t.jsxs(o.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:a,border:"1px solid",borderColor:d},children:[t.jsx(l,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx(M.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function bp({format:e}){const r=gt(),n={csv:{color:r.palette.primary.main,bg:r.palette.primary.main,label:"CSV"},excel:{color:r.palette.success.main,bg:r.palette.success.main,label:"XLSX"},json:{color:r.palette.text.secondary,bg:r.palette.text.secondary,label:"JSON"},pdf:{color:r.palette.error.main,bg:r.palette.error.main,label:"PDF"}}[e];return t.jsxs(o.Box,{sx:{width:44,height:52,position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",mb:1},children:[t.jsxs("svg",{width:"38",height:"46",viewBox:"0 0 38 46",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M5 2C3.34315 2 2 3.34315 2 5V41C2 42.6569 3.34315 44 5 44H33C34.6569 44 36 42.6569 36 41V13L25 2H5Z",fill:r.palette.background.paper,stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M24 2V13H36",fill:O(r.palette.text.primary,.05),stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"})]}),t.jsx(o.Box,{sx:{position:"absolute",bottom:8,left:3,right:3,bgcolor:n.bg,color:r.palette.primary.contrastText,fontSize:"0.625rem",fontWeight:800,py:.25,borderRadius:"3px",textAlign:"center",letterSpacing:"0.05em"},children:n.label})]})}function Ts({checked:e}){const r=gt();return t.jsx(o.Box,{sx:{width:20,height:20,borderRadius:"50%",border:e?`2px solid var(--urm-export-card-selected-border, ${r.palette.primary.main})`:`2px solid var(--urm-export-radio-border, ${r.palette.divider})`,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:r.palette.background.paper,transition:"all 0.15s ease",flexShrink:0},children:e&&t.jsx(o.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:`var(--urm-export-card-selected-border, ${r.palette.primary.main})`}})})}function vp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:d=[],allRows:l=[],processedRows:u=[],initialFormat:x,initialScope:g="visible",initialColumnScope:m="visible",classTokens:C={},onExport:S,onClose:E}){const v=gt(),y=v.palette,k=Ar(),h=p.useMemo(()=>{var de,ue,X,pe,le;const c=((X=(ue=(de=v.components)==null?void 0:de.MuiCard)==null?void 0:ue.styleOverrides)==null?void 0:X.root)||{},re=c.border&&c.border!=="none"?c.border:(pe=v.tokens)!=null&&pe.cardBodyBorder&&v.tokens.cardBodyBorder!=="none"?v.tokens.cardBodyBorder:y.divider,fe=c.borderRadius!==void 0?typeof c.borderRadius=="number"?`${c.borderRadius}px`:c.borderRadius:`${v.shape.borderRadius}px`,U=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:((le=v.tokens)==null?void 0:le.cardBodyShadow)||be(v,"menu"),K=ot(v);return{sectionBorder:`var(--urm-export-section-border, ${re})`,sectionTitleColor:`var(--urm-export-section-title-color, ${y.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${y.background.paper})`,cardBg:`var(--urm-export-card-bg, ${y.background.paper})`,cardBorder:`var(--urm-export-card-border, ${re})`,cardRadius:fe,cardShadow:U,cardHoverBg:`var(--urm-export-card-hover-bg, ${y.mode==="dark"?O(y.common.white,.08):O(y.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${O(K.main,y.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${K.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${y.mode==="dark"?y.primary.light:y.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${y.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${y.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${y.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${v.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${v.spacing(1.5)})`}},[y,v]),j=x||(k.export.allowedFormats.includes("pdf")?"pdf":k.export.allowedFormats[0]||"csv"),[T,b]=p.useState(j),[R,H]=p.useState(g),[I,J]=p.useState(m),Z=R==="visible"?r:e,B=I==="visible"?i:s,f=p.useMemo(()=>R==="visible"?u.length>0?u:new Array(r):l.length>0?l:new Array(e),[R,r,e,u,l]),$=p.useMemo(()=>I==="all"?a.map(c=>c.name):a.map(c=>c.name).slice(0,i),[I,a,i]),D=p.useMemo(()=>gp(T,f,$,a,da),[T,f,$,a]),ee=()=>{D.hasBlockingViolation||(S({format:T,scope:R,columnScope:I}),E())},oe={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:E,className:`urm-export-backdrop ${C.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:O(y.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:v.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:c=>c.stopPropagation(),elevation:0,className:`urm-export-paper ${C.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:nt(v),bgcolor:h.sectionTitleBg,overflow:"hidden",border:`1px solid ${h.cardBorder}`,boxShadow:h.cardShadow,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:[t.jsxs(o.Box,{className:`urm-export-header ${C.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:c=>ce(c).header.backgroundColor,borderBottom:c=>ce(c).header.borderBottom,boxShadow:c=>ce(c).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${C.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:y.text.primary},children:"Export Report"}),t.jsx(xt,{content:Wr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:E,size:"small",className:`urm-export-close ${C.modalCloseButton||""}`,sx:{color:y.text.secondary,borderRadius:"50%","&:hover":{bgcolor:y.action.hover,color:y.text.primary}},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${C.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:h.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:O(y.text.primary,.15),borderRadius:3}},children:[D.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:D.violations.map((c,re)=>t.jsx(yp,{violation:c},re))}),t.jsxs(o.Box,{className:`urm-export-section ${C.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${C.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:h.optionGap},children:[{id:"csv",title:"CSV",info:"Comma-separated values, compatible with Excel",allowed:k.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:k.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:k.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:k.export.allowedFormats.includes("pdf")}].filter(c=>c.allowed).map(c=>{const re=T===c.id;return t.jsxs(o.Box,{onClick:()=>b(c.id),className:`urm-export-format-card ${re?C.formatCardSelected||"":C.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:O(y.text.primary,.25),bgcolor:re?h.cardSelectedBg:h.cardHoverBg}},children:[re&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:h.cardSelectedBorder,color:y.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${O(y.primary.main,.3)}`},children:t.jsx(M.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(bp,{format:c.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:re?h.cardSelectedColor:y.text.primary},children:c.title}),t.jsx(o.Tooltip,{title:c.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:fe=>fe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.text.primary}},children:t.jsx(M.InfoOutlined,{sx:{fontSize:13}})})})]})]},c.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${C.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${C.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:h.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx(M.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx(M.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(c=>{const re=R===c.value;return t.jsxs(o.Box,{onClick:()=>H(c.value),className:`urm-export-row-card ${re?C.rowCardSelected||"":C.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:O(y.text.primary,.25),bgcolor:re?h.cardSelectedBg:h.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(Ts,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:y.text.secondary,display:"flex"},children:c.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:y.text.primary},children:c.label})]}),t.jsx(o.Tooltip,{title:c.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:fe=>fe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.text.primary}},children:t.jsx(M.InfoOutlined,{sx:{fontSize:16}})})})]},c.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${C.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${C.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:h.optionGap},children:[{value:"visible",label:"Visible columns",icon:t.jsx(M.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx(M.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(c=>{const re=I===c.value;return t.jsxs(o.Box,{onClick:()=>J(c.value),className:`urm-export-column-card ${re?C.columnCardSelected||"":C.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:O(y.text.primary,.25),bgcolor:re?h.cardSelectedBg:h.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(Ts,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:y.text.secondary,display:"flex"},children:c.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:y.text.primary},children:c.label})]}),t.jsx(o.Tooltip,{title:c.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:fe=>fe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.text.primary}},children:t.jsx(M.InfoOutlined,{sx:{fontSize:16}})})})]},c.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${C.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${C.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx(M.InsertDriveFileOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Format",value:oe[T]},{icon:t.jsx(M.FormatListNumberedOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Rows to Export",value:Z.toLocaleString()},{icon:t.jsx(M.SwapVertOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Columns to Export",value:String(B)},{icon:t.jsx(M.InsertDriveFileOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Estimated File Size",value:`~${To(D.estimatedBytes)}`,highlight:D.hasBlockingViolation?"error.main":D.hasWarning?"warning.main":void 0}].map(({icon:c,label:re,value:fe,highlight:U})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${C.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[c,t.jsx(o.Typography,{className:`urm-export-summary-label ${C.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:y.text.secondary,fontWeight:500},children:re})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${C.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:U??y.text.primary},children:fe})]},re))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${C.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[D.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx(M.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:c=>c.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:c=>c.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:E,variant:"outlined",className:`urm-export-cancel-btn ${C.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:y.text.primary,borderColor:h.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:h.cardHoverBg,borderColor:O(y.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:ee,disabled:D.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${C.downloadButton||""}`,startIcon:t.jsx(M.Download,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:h.primaryBtnBg,color:h.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${O(y.primary.main,.25)}`,"&:hover":{bgcolor:h.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:O(y.primary.main,.4),color:h.primaryBtnColor}},children:["Download ",oe[T]]})]})]})})}function Sp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(M.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx(M.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[t.jsx(o.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:e.message}),t.jsxs(o.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some"," ",e.type==="filter"?"filters":e.type==="sort"?"sort levels":"grouping levels"," ","before adding more."]})]})})}function Cp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=3e4}){p.useEffect(()=>{if(n){const l=setTimeout(()=>{r()},i);return()=>clearTimeout(l)}},[n,i,r]);const a=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx(M.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx(M.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx(M.InfoOutlined,{sx:{fontSize:20}})}}})(),d=Tl(e);return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx(M.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${a.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:l=>l.typography.h6.fontWeight||600,fontSize:l=>l.typography.subtitle2.fontSize||"0.875rem"},children:[e.context.charAt(0).toUpperCase()+e.context.slice(1)," Error"]}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:d}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.details,null,2)})]})})}class wp extends p.Component{constructor(n){super(n);Di(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){Jt.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:t.jsx(o.Paper,{sx:{bgcolor:s=>O(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(M.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:s=>s.typography.h6.fontWeight||600,fontSize:s=>s.typography.h6.fontSize||"1.25rem"},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(o.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"&&t.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>O(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),t.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx(M.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function jp({feature:e}){const[r,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),t.jsx(o.Collapse,{in:r,unmountOnExit:!0,children:t.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:t.jsx(M.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx(M.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function tn({children:e,feature:r,onError:n}){return t.jsx(wp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(jp,{feature:r}),children:e})}const kp=[{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"}],zp=[{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"},{value:"pdf",label:"PDF",desc:"Print-ready PDF document"}],$r={sortMaxLevels:{title:"Maximum Sort Levels",description:"Limits the number of columns users can sort by simultaneously. Restricts multi-level sort depth.",tips:['"Add sort column" button is disabled at this limit',"Prevents adding more sort levels to the active sort stack","Default: 5 levels (range: 1–10)"]},filterMaxConditions:{title:"Maximum Filter Conditions",description:"Limits the total number of active filter conditions users can apply at once.",tips:['"Add condition" button is disabled at this limit',"Prevents performance degradation on large datasets","Default: 3 conditions (range: 1–20)"]},filterAllowedOperators:{title:"Allowed Filter Operators",description:"Controls which comparison operators appear in the filter UI. Unchecked operators are hidden from all dropdowns.",tips:["Simplifies the UI by hiding advanced operators your users don't need","At least one operator per data type must remain checked","Operators grouped by type: Text, Numeric, Boolean, Null checks"]},columnsMaxVisible:{title:"Maximum Visible Columns",description:"Limits the number of columns users can display at once in the data table.",tips:["Column visibility toggle is disabled when this limit is reached","Forces users to be selective about which columns to show","Default: 20 columns (range: 1–50)"]},columnsWidthRange:{title:"Column Width Constraints",description:"Sets minimum and maximum pixel widths for column resizing. Prevents columns from becoming too narrow or too wide.",tips:["Users cannot drag column borders outside this range","Min default: 60px, Max default: 800px","Ensures readable content and consistent layout"]},exportAllowedFormats:{title:"Allowed Export Formats",description:"Determines which export formats appear in the Export dialog and row-level export menus. At least one must be enabled.",tips:["Disabled formats don't appear in any export UI","PDF is now available as a print-ready export option","Unchecked formats are completely hidden from end users"]},groupingMaxLevels:{title:"Maximum Group Levels",description:"Limits how deeply users can nest grouped data. Enforced when adding new group levels.",tips:['"Add group level" button is hidden at this limit',"Range: 1 (single group only) to 3 (triple nested groups)","Prevents overly complex grouping hierarchies"]}};function jo({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5,height:"200px",width:"100%"},children:e})}function Bp({open:e,onClose:r,config:n,onApply:i}){const[s,a]=p.useState(0),[d,l]=p.useState(n),u=()=>l(n),x=()=>l(ft),g=()=>{i(d),r()},m={sort:y=>l(k=>({...k,sort:{...k.sort,...y}})),filter:y=>l(k=>({...k,filter:{...k.filter,...y}})),columns:y=>l(k=>({...k,columns:{...k.columns,...y}})),grouping:y=>l(k=>({...k,grouping:{...k.grouping,...y}})),export:y=>l(k=>({...k,export:{...k.export,...y}}))},C=y=>{const k=d.filter.allowedOperators,h=k.includes(y)?k.filter(j=>j!==y):[...k,y];h.length!==0&&m.filter({allowedOperators:h})},S=y=>{const k=d.export.allowedFormats,h=k.includes(y)?k.filter(j=>j!==y):[...k,y];h.length!==0&&m.export({allowedFormats:h})},E=[{label:"Sort",icon:t.jsx(M.SwapVert,{sx:{fontSize:y=>y.typography.body1.fontSize}})},{label:"Filter",icon:t.jsx(M.FilterList,{sx:{fontSize:y=>y.typography.body1.fontSize}})},{label:"Columns",icon:t.jsx(M.ViewColumn,{sx:{fontSize:y=>y.typography.body1.fontSize}})},{label:"Grouping",icon:t.jsx(M.Layers,{sx:{fontSize:y=>y.typography.body1.fontSize}})},{label:"Export",icon:t.jsx(M.Download,{sx:{fontSize:y=>y.typography.body1.fontSize}})}],v=y=>JSON.stringify(d[y])===JSON.stringify(ft[y]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:y=>nt(y),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:y=>y.shadows[8]}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:y=>y.shape.borderRadius,bgcolor:y=>O(y.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:y=>y.typography.h5.fontSize},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:t.jsx(M.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:t.jsx(o.Tabs,{value:s,onChange:(y,k)=>a(k),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:y=>y.typography.caption.fontSize,textTransform:"none",fontWeight:y=>y.typography.button.fontWeight,gap:.5}},children:E.map((y,k)=>t.jsx(o.Tab,{label:y.label,icon:y.icon,iconPosition:"start"},k))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0,minHeight:300},children:[t.jsx(jo,{active:s===0,children:t.jsxs(o.Box,{children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),t.jsx(xt,{content:$r.sortMaxLevels,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.Slider,{value:d.sort.maxLevels,onChange:(y,k)=>m.sort({maxLevels:k}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]})}),t.jsxs(jo,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),t.jsx(xt,{content:$r.filterMaxConditions,isDev:process.env.NODE_ENV==="development"})]}),!v("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Slider,{value:d.filter.maxConditions,onChange:(y,k)=>m.filter({maxConditions:k}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed filter operators"}),t.jsx(xt,{content:$r.filterAllowedOperators,isDev:process.env.NODE_ENV==="development"})]}),["Text","Numeric","Boolean","Null checks"].map(y=>t.jsxs(o.Box,{sx:{mb:1.5},children:[t.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:k=>k.typography.overline.fontSize,display:"block",mb:.5},children:y}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:kp.filter(k=>k.group===y).map(k=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:d.filter.allowedOperators.includes(k.value),onChange:()=>C(k.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:k.label}),sx:{mr:1.5}},k.value))})]},y))]})]}),t.jsxs(jo,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),t.jsx(xt,{content:$r.columnsMaxVisible,isDev:process.env.NODE_ENV==="development"})]}),!v("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Slider,{value:d.columns.maxVisible,onChange:(y,k)=>m.columns({maxVisible:k}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:2},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Column width range (px)"}),t.jsx(xt,{content:$r.columnsWidthRange,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:d.columns.minColumnWidth,onChange:(y,k)=>m.columns({minColumnWidth:k}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}px`})]}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(o.Slider,{value:d.columns.maxColumnWidth,onChange:(y,k)=>m.columns({maxColumnWidth:k}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}px`})]})]})]})]}),t.jsx(jo,{active:s===3,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),t.jsx(xt,{content:$r.groupingMaxLevels,isDev:process.env.NODE_ENV==="development"})]}),!v("grouping")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(y=>t.jsxs(o.Box,{onClick:()=>m.grouping({maxLevels:y}),sx:{flex:1,py:2.5,borderRadius:k=>Number(k.shape.borderRadius||0)*1.25,border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:d.grouping.maxLevels===y?"primary.main":"divider",bgcolor:d.grouping.maxLevels===y?k=>O(k.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:k=>O(k.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:d.grouping.maxLevels===y?"primary.main":"text.secondary"},children:y}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][y-1]})]},y))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:d.grouping.allowNested,onChange:y=>m.grouping({allowNested:y.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:d.grouping.allowCollapse,onChange:y=>m.grouping({allowCollapse:y.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]})}),t.jsx(jo,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),t.jsx(xt,{content:$r.exportAllowedFormats,isDev:process.env.NODE_ENV==="development"})]}),!v("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.FormGroup,{sx:{gap:1},children:zp.map(y=>t.jsxs(o.Box,{onClick:()=>S(y.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:k=>k.shape.borderRadius,border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:d.export.allowedFormats.includes(y.value)?"primary.main":"divider",bgcolor:d.export.allowedFormats.includes(y.value)?k=>O(k.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:d.export.allowedFormats.includes(y.value),onChange:()=>S(y.value),onClick:k=>k.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:y.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:y.desc})]})]},y.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:y=>O(y.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx(M.RestartAlt,{sx:{fontSize:18}}),onClick:x,size:"small",sx:{fontSize:y=>y.typography.body2.fontSize,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:y=>O(y.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:y=>y.typography.body2.fontSize,color:"text.secondary",px:2,borderRadius:y=>Number(y.shape.borderRadius)*2.25},children:"Cancel"}),t.jsx(o.Button,{onClick:g,size:"small",variant:"contained",sx:{fontSize:y=>y.typography.body2.fontSize,px:2.5,borderRadius:y=>Number(y.shape.borderRadius)*2.25},children:"Apply"})]})]})]})}const Tp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ip={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 on(e,r,n,i,s=new Date){const[a,d]=r.split(":").map(Number),l=new Date(s);if(l.setSeconds(0,0),l.setHours(a,d,0,0),e==="daily")return l<=s&&l.setDate(l.getDate()+1),l.toISOString();if(e==="weekly"){const u=n??1,x=l.getDay();let g=u-x;return g<0&&(g+=7),g===0&&l<=s&&(g=7),l.setDate(l.getDate()+g),l.toISOString()}if(e==="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 Ep(e){const r=ua(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${Tp[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${Ip[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function ua(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function Dp(e){const r=new Date(e).getTime()-Date.now();if(r<=0)return"now";const n=Math.floor(r/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${a}m`:a>0?`in ${a}m`:"in less than a minute"}function _p(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=ua(`${String(r.getHours()).padStart(2,"0")}:${String(r.getMinutes()).padStart(2,"0")}`);return i?`Today at ${s}`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric"})} at ${s}`}function pa(e){return`urm_schedules_${e}`}function ha(e){try{const r=localStorage.getItem(pa(e));return r?JSON.parse(r).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 ma(e,r){try{localStorage.setItem(pa(e),JSON.stringify(r))}catch{}}const $p=[{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"}],Op=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,fa={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",email:""},Or={"& .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 Mp({initial:e=fa,isEditing:r=!1,onSave:n,onBack:i}){const[s,a]=p.useState(e),[d,l]=p.useState(!1),[u,x]=p.useState(!1),g=(S,E)=>a(v=>({...v,[S]:E})),m=s.email.trim().length>0&&!Op.test(s.email.trim()),C=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!m;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:S=>O(S.palette.text.primary,.06)}},children:t.jsx(M.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:S=>S.typography.body2.fontWeight||600,fontSize:S=>S.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:S=>{g("name",S.target.value),d&&S.target.value.trim()&&l(!1)},onBlur:()=>l(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:d&&!s.name.trim(),helperText:d&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:Or}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Or,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:S=>g("frequency",S.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Or,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:S=>g("dayOfWeek",Number(S.target.value)),children:$p.map(S=>t.jsx(o.MenuItem,{value:S.value,children:S.label},S.value))})]}),s.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:S=>g("dayOfMonth",Number(S.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:Or}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:S=>g("time",S.target.value),InputLabelProps:{shrink:!0},sx:Or}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Or,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:S=>g("format",S.target.value),children:[t.jsx(o.MenuItem,{value:"pdf",children:"PDF — Print-ready document"}),t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:S=>g("scope",S.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsx(o.Box,{children:t.jsx(o.TextField,{label:"Email reminder",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:S=>g("email",S.target.value),onBlur:()=>x(!0),placeholder:"user@company.com",error:u&&m,helperText:u&&m?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx(M.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Or})}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:S=>O(S.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>C&&n(s),disabled:!C,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Ap({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:Wo(i),...ce(i).paper})},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>O(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(M.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:i=>i.typography.body1.fontSize||"0.9375rem",fontWeight:i=>i.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(o.Typography,{sx:{fontSize:i=>i.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',e,'"']}),"? This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsx(o.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Wp({schedule:e,tick:r,onToggle:n,onRunNow:i,onEdit:s,onDelete:a}){const d=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:d?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:d?l=>O(l.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:d?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:d?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:d?l=>O(l.palette.success.main,.1):l=>O(l.palette.text.primary,.06),color:d?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Ep(e)}),t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[t.jsx(o.Chip,{label:e.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:l=>O(l.palette.primary.main,.08),color:"primary.main"}}),t.jsx(o.Chip,{label:e.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:l=>O(l.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx(M.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>O(l.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[d&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",Dp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",_p(e.lastRunAt)," · ",e.runCount," run",e.runCount!==1?"s":""]}):t.jsx(o.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[t.jsx(o.Tooltip,{title:"Edit",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>s(e),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:l=>O(l.palette.primary.main,.08)}},children:t.jsx(M.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:d?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:d?"warning.main":"success.main","&:hover":{bgcolor:d?l=>O(l.palette.warning.main,.08):l=>O(l.palette.success.main,.08)}},children:d?t.jsx(M.Pause,{sx:{fontSize:15}}):t.jsx(M.PlayArrow,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Export now",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>i(e),sx:{color:"primary.main","&:hover":{bgcolor:l=>O(l.palette.primary.main,.08)}},children:t.jsx(M.Download,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Delete",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>a(e.id),sx:{color:"error.main","&:hover":{bgcolor:l=>O(l.palette.error.main,.08)}},children:t.jsx(M.Delete,{sx:{fontSize:15}})})})]})]})]})}function Rp({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,schedulerConfig:a}){const l=((a==null?void 0:a.mode)??"local")==="api",[u,x]=p.useState([]),g=l?(a==null?void 0:a.schedules)??[]:u,[m,C]=p.useState({type:"list"}),[S,E]=p.useState(0),[v,y]=p.useState(null);p.useEffect(()=>{e&&(l||x(ha(n)),C({type:"list"}))},[e,n,l]),p.useEffect(()=>{if(!e)return;const B=setInterval(()=>E(f=>f+1),3e4);return()=>clearInterval(B)},[e]);const k=p.useCallback(B=>{x(B),ma(n,B)},[n]),h=B=>{var D;const f=on(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth),$={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:f,runCount:0};l?(D=a==null?void 0:a.onScheduleCreate)==null||D.call(a,$):k([...g,$]),C({type:"list"})},j=B=>{var ee;if(m.type!=="edit")return;const f=m.schedule,$=on(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth),D={...f,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:$};l?(ee=a==null?void 0:a.onScheduleUpdate)==null||ee.call(a,D):k(g.map(oe=>oe.id===f.id?D:oe)),C({type:"list"})},T=B=>{var oe;const f=g.find(c=>c.id===B);if(!f)return;const $=!f.isActive,D=$?on(f.frequency,f.time,f.dayOfWeek,f.dayOfMonth):f.nextRunAt,ee={...f,isActive:$,nextRunAt:D};l?(oe=a==null?void 0:a.onScheduleToggle)==null||oe.call(a,B,$):k(g.map(c=>c.id===B?ee:c))},b=B=>{if(s(B),!l){const f=new Date().toISOString();k(g.map($=>$.id===B.id?{...$,lastRunAt:f,runCount:$.runCount+1}:$))}},R=B=>{const f=g.find($=>$.id===B)??null;y(f)},H=()=>{var B;v&&(l?(B=a==null?void 0:a.onScheduleDelete)==null||B.call(a,v.id):k(g.filter(f=>f.id!==v.id)),y(null))},I=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=m.type!=="list",Z=g.filter(B=>B.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:J,PaperProps:{sx:B=>({borderRadius:nt(B),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ce(B).paper})},children:[t.jsxs(o.DialogTitle,{sx:B=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...ce(B).header}),children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:B=>O(B.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(M.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:B=>B.typography.h6.fontWeight||600,fontSize:B=>B.typography.subtitle2.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx(xt,{content:Wr.schedule,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary","&:hover":{bgcolor:B=>O(B.palette.text.primary,.06)}},children:t.jsx(M.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[J&&t.jsx(Mp,{initial:m.type==="edit"?I(m.schedule):fa,isEditing:m.type==="edit",onSave:m.type==="edit"?j:h,onBack:()=>C({type:"list"})}),m.type==="list"&&t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:g.length===0?"No schedules yet":`${Z} of ${g.length} active`}),t.jsx(o.Button,{startIcon:t.jsx(M.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>C({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),g.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx(M.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:B=>B.typography.body2.fontWeight||500,fontSize:B=>B.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:g.map(B=>t.jsx(Wp,{schedule:B,tick:S,onToggle:T,onRunNow:b,onEdit:f=>C({type:"edit",schedule:f}),onDelete:R},B.id))})]})]}),m.type==="list"&&t.jsx(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:B=>O(B.palette.text.primary,.06)}},children:"Close"})})]}),v&&t.jsx(Ap,{scheduleName:v.name,onConfirm:H,onCancel:()=>y(null)})]})}const Pp=6e4;function Np({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:d,columnOrder:l,filters:u,sortStack:x,onFired:g,schedulerConfig:m}){const C=(m==null?void 0:m.mode)??"local",S=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:d,columnOrder:l,filters:u,sortStack:x,onFired:g,schedulerConfig:m,schedulerMode:C});p.useEffect(()=>{S.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:d,columnOrder:l,filters:u,sortStack:x,onFired:g,schedulerConfig:m,schedulerMode:C}});const E=p.useCallback(v=>{var B,f,$,D,ee;const{reportName:y,uploadedData:k,processedData:h,schema:j,activeView:T,columnVisibility:b,columnOrder:R,filters:H,sortStack:I,schedulerConfig:J,schedulerMode:Z}=S.current;try{const oe=v.scope==="all"?k:h;if(Z==="api"){const fe=(R.length>0?R:j.map(K=>K.name)).filter(K=>b[K]!==!1),U={schedule:v,triggeredAt:new Date().toISOString(),rows:oe,columns:fe,format:v.format,reportName:y};(B=J==null?void 0:J.onScheduleFire)==null||B.call(J,U),($=(f=S.current).onFired)==null||$.call(f,v);return}const c=nn(oe,j,H,I,T,b,R),re=`${v.name}_scheduled`;switch(v.format){case"csv":sn(c,re,{scope:v.scope});break;case"excel":an(c,re,{scope:v.scope});break;case"json":ln(c,re,{scope:v.scope});break;case"pdf":bi(c,re,{scope:v.scope});break}if(J!=null&&J.onScheduleFire){const fe=(R.length>0?R:j.map(U=>U.name)).filter(U=>b[U]!==!1);J.onScheduleFire({schedule:v,triggeredAt:new Date().toISOString(),rows:oe,columns:fe,format:v.format,reportName:y})}if(v.email){const fe=encodeURIComponent(`Scheduled Report: ${v.name}`),U=encodeURIComponent(`Your scheduled report "${v.name}" has been generated.
192
192
 
193
- Report: ${x}
193
+ Report: ${y}
194
194
  Format: ${v.format.toUpperCase()}
195
195
  Generated: ${new Date().toLocaleString()}
196
196
 
197
- The file has been downloaded to your device.`);window.open(`mailto:${v.email}?subject=${we}&body=${F}`,"_blank")}(te=(P=C.current).onFired)==null||te.call(P,v)}catch(d){Jt.error("urm:scheduler",`Export failed for schedule: ${v.name}`,d)}},[]);p.useEffect(()=>{if(!e)return;const v=()=>{const{reportId:B,schedulerMode:h,schedulerConfig:k}=C.current;if(!B)return;const T=h==="api"?(k==null?void 0:k.schedules)??[]:ua(B),b=new Date;let R=!1;const H=T.map(E=>{if(!E.isActive)return E;if(new Date(E.nextRunAt)<=b){D(E);const Z=tn(E.frequency,E.time,E.dayOfWeek,E.dayOfMonth,b);return R=!0,{...E,lastRunAt:b.toISOString(),nextRunAt:Z,runCount:E.runCount+1}}return E});R&&h==="local"&&pa(B,H)};v();const x=setInterval(v,Ap);return()=>clearInterval(x)},[e,D])}function ma({reportEngine:e}){var Tr,ze,Ge,Ir,at,Zt;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:c,isDirty:l,currentTableState:u,showFilterPanel:y,setShowFilterPanel:g,filterFocusColumn:m,handleReplaceFilters:S,handleOpenFilterForColumn:C,handleCloseFilterPanel:D,handleClearFiltersForColumn:v,showSortPanel:x,setShowSortPanel:B,handleSort:h,handleUpdateSortStack:k,handleSortAscending:T,handleSortDescending:b,showCreateViewModal:R,setShowCreateViewModal:H,showEditViewModal:E,setShowEditViewModal:Y,showDeleteConfirmation:Z,setShowDeleteConfirmation:I,editingView:f,deletingView:w,handleSelectView:P,handleCreateView:te,handleUpdateCurrentView:d,handleSaveAsNewView:J,handleRevertChanges:re,handleToggleDefault:we,handleToggleFavorite:F,handleSoftDelete:X,handleRestoreView:ue,handlePermanentDelete:pe,handleEditView:K,handleCloneView:he,handleCopyViewLink:le,handleSaveEditView:W,handleConfirmDelete:ie,handlePromoteToGlobal:U,handleSetDefaultForAllUsers:ne,showManageColumns:Be,setShowManageColumns:Q,handleUpdateColumnVisibility:$e,handleUpdateColumnOrder:Pe,handleUpdateColumnWidth:Wt,handleResetColumnLayout:Kt,showGroupPanel:Ar,setShowGroupPanel:Rt,handleGroup:mt,handleToggleGroupCollapse:St,handleExpandAllGroups:Wr,handleCollapseAllGroups:Qe,searchQuery:Dt,debouncedSearchQuery:Xt,searchHistory:Pt,handleSearchChange:ar,handleAddToSearchHistory:lr,handleToggleSearchFavourite:Rr,handleDeleteSearchHistory:Qt,selectedRowIds:br,handleToggleRowSelection:Ct,handleToggleAllRows:Je,handleRangeSelection:vr,handleClearSelection:ft,handleUpdateSelectionAfterDelete:rt,currentPage:Nt,pageSize:cr,paginationTotalRows:uo,handlePageChange:Pr,handlePageSizeChange:dr,isExporting:Ke,showExportModal:je,setShowExportModal:_t,showDirtyExportWarning:Sr,handleExport:Nr,handleExportWithConfig:ur,handleExportSelected:Cr,handleExportAnyway:Lr,handleSaveAndExport:pr,handleCancelExport:Ze,showAuditHistory:Lt,setShowAuditHistory:Ce,showCreatePreset:Ao,setShowCreatePreset:fe,showManagePresets:wt,setShowManagePresets:V,activePreset:xt,handleCreatePreset:se,handleClearActivePreset:st,handleOpenPresetById:wr,handleDeletePresetById:jt,isViewerRole:Fr,userRole:hr,featureLimitWarning:jr,setFeatureLimitWarning:Ft,reportError:kr,setReportError:Vr,handleError:ke,updateReport:ut,showSnack:ee,config:ce,scheduler:ye}=e,[po,zr]=p.useState(!1);Wp({reportId:r==null?void 0:r.id,reportName:(r==null?void 0:r.name)||"Report",uploadedData:(r==null?void 0:r.uploadedData)||[],processedData:i||[],schema:(r==null?void 0:r.schema)||[],activeView:c,columnVisibility:(r==null?void 0:r.columnVisibility)||((Tr=c==null?void 0:c.snapshot)==null?void 0:Tr.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((ze=c==null?void 0:c.snapshot)==null?void 0:ze.columnOrder)||[],filters:He(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:me=>{ee(`Scheduled export "${me.name}" completed`,"success")},schedulerConfig:ye});const Br=p.useCallback((me,xe)=>{if(!(r!=null&&r.uploadedData))return;const Ye=r.uploadedData[me],Ae=[...r.uploadedData];Ae[me]=xe;const nt=Bo(r.id,"user","rows","row_edited",Ye,xe),it=To(r.auditHistory||[],nt);ut(r.id,{uploadedData:Ae,auditHistory:it})},[r,ut]),Hr=p.useCallback(me=>{if(!(r!=null&&r.uploadedData))return;const xe=r.uploadedData.indexOf(me);if(xe===-1)return;const Ye=r.uploadedData.filter((it,Ot)=>Ot!==xe),Ae=Bo(r.id,"user","rows","row_deleted",me,null),nt=To(r.auditHistory||[],Ae);ut(r.id,{uploadedData:Ye,auditHistory:nt}),rt(me)},[r,ut,rt]),ho=p.useCallback((me,xe)=>{if(!(r!=null&&r.uploadedData))return;const Ye=r.uploadedData.indexOf(xe),Ae=Ye!==-1?Ye+1:me+1,nt=[...r.uploadedData];nt.splice(Ae,0,{...xe});const it=Bo(r.id,"user","rows","row_duplicated",xe,{...xe}),Ot=To(r.auditHistory||[],it);ut(r.id,{uploadedData:nt,auditHistory:Ot})},[r,ut]),Vt=gr(),{handleDevConfigChange:mo}=hn(),[Ur,$t]=p.useState(!1);return p.useEffect(()=>{const me=xe=>{xe.ctrlKey&&xe.shiftKey&&xe.key==="D"&&(xe.preventDefault(),$t(!0))};return document.addEventListener("keydown",me),()=>document.removeEventListener("keydown",me)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[jr&&t.jsx(yp,{warning:jr,onDismiss:()=>Ft(null)}),kr&&t.jsx(bp,{error:kr,onDismiss:()=>Vr(null)}),Sr&&t.jsx(ep,{onExportAnyway:Lr,onSaveAndExport:pr,onCancel:Ze}),t.jsx(Vu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:l,isExporting:Ke,columnVisibility:r.columnVisibility||(c==null?void 0:c.snapshot.columnVisibility),columnOrder:r.columnOrder||(c==null?void 0:c.snapshot.columnOrder),columnWidths:r.columnWidths||(c==null?void 0:c.snapshot.columnWidths),grouping:r.grouping,onSort:h,onSortAscending:T,onSortDescending:b,onOpenFilters:()=>g(!0),onOpenSort:()=>B(!0),onOpenFilterForColumn:C,onSelectView:P,onCreateView:()=>H(!0),onUpdateCurrentView:d,onSaveAsNewView:J,onDiscardChanges:re,onToggleDefault:we,onToggleFavorite:F,onRestoreView:ue,onPermanentDelete:pe,onEditView:K,onCloneView:he,onCopyLink:le,onDeleteView:X,onPromoteToGlobal:U,onSetDefaultForAllUsers:ne,isAdmin:((Ge=Vt.views)==null?void 0:Ge.isAdmin)??!1,hideViewMenuActions:ce==null?void 0:ce.hideViewMenuActions,onExport:Nr,onOpenColumns:()=>Q(!0),onUpdateColumnWidth:Wt,onUpdateColumnOrder:Pe,onUpdateColumnVisibility:$e,onClearFiltersForColumn:v,onResetLayout:Kt,onOpenGroup:()=>Rt(!0),onGroupByColumn:(Ir=ce==null?void 0:ce.hideToolbarActions)!=null&&Ir.includes("grouping")?void 0:me=>{var Ae;const xe=r==null?void 0:r.grouping;if(!((xe==null?void 0:xe.enabled)&&(xe==null?void 0:xe.levels)&&xe.levels.length>0))mt({enabled:!0,levels:[{column:me}],collapsedGroups:[]});else{if(xe.levels.some(Ot=>Ot.column===me))return;const it=((Ae=Vt.grouping)==null?void 0:Ae.maxLevels)??3;if(xe.levels.length>=it)return;mt({enabled:!0,levels:[...xe.levels,{column:me}],collapsedGroups:xe.collapsedGroups})}},onToggleGroupCollapse:St,onExpandAllGroups:Wr,onCollapseAllGroups:Qe,onOpenAuditHistory:()=>Ce(!0),onOpenScheduledReports:()=>zr(!0),searchQuery:Dt,highlightQuery:Xt,searchHistory:Pt,onAddToSearchHistory:lr,onToggleSearchFavourite:Rr,onDeleteSearchHistory:Qt,selectedRowIds:br,onSearchChange:ar,onToggleRowSelection:Ct,onToggleAllRows:Je,onRangeSelection:vr,onClearSelection:ft,onExportSelected:Cr,currentPage:Nt,pageSize:cr,onPageChange:Pr,onPageSizeChange:dr,totalRowsBeforePagination:uo,isReadOnly:Fr,userRole:hr,reportName:r.name,onEditRow:Br,onDeleteRow:Hr,onDuplicateRow:ho,rowActions:ce==null?void 0:ce.rowActions,hideDefaultRowActions:ce==null?void 0:ce.hideDefaultRowActions,hideToolbarActions:ce==null?void 0:ce.hideToolbarActions,customSettingsActions:ce==null?void 0:ce.customSettingsActions,jsonGuideContent:ce==null?void 0:ce.jsonGuideContent,viewOptions:ce==null?void 0:ce.viewOptions,defaultViewMode:ce==null?void 0:ce.defaultViewMode,bulkActions:ce==null?void 0:ce.bulkActions,hideSelectionCheckboxes:ce==null?void 0:ce.hideSelectionCheckboxes,rowClickBehavior:ce==null?void 0:ce.rowClickBehavior,openModalOn:ce==null?void 0:ce.openModalOn,onRowClick:ce==null?void 0:ce.onRowClick,onRowRightClick:ce==null?void 0:ce.onRowRightClick,showDevPanel:Vt.display.showDevPanel,onOpenDevConfig:()=>$t(!0)})]}),y&&t.jsx(Zo,{feature:"Filters",onError:me=>{const xe=fr("ui","filters",me);ke(xe)},children:t.jsx(Yu,{schema:r.schema,filters:r.filters,onReplaceFilters:S,onClose:D,focusColumn:m,onOpenDevConfig:()=>$t(!0)})}),x&&t.jsx(Zo,{feature:"Sorting",onError:me=>{const xe=fr("ui","sorting",me);ke(xe)},children:t.jsx(Ju,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:k,onClose:()=>B(!1),onOpenDevConfig:()=>$t(!0)})}),R&&u&&(()=>{var Ye;const me=(r.views??[]).filter(Ae=>!Ae.isDeleted).length,xe=((Ye=Vt.views)==null?void 0:Ye.maxViews)??10;return t.jsx(Cs,{currentSnapshot:u,onSave:te,onClose:()=>H(!1),atViewLimit:me>=xe,maxViews:xe})})(),E&&f&&t.jsx(Cs,{currentSnapshot:f.snapshot,onSave:W,onClose:()=>{Y(!1)},isEditMode:!0,initialName:f.name,initialDescription:f.description,initialIsDefault:f.isDefault}),Z&&w&&t.jsx(Ku,{viewName:w.name,onConfirm:ie,onCancel:()=>{I(!1)}}),Be&&c&&t.jsx(Qu,{schema:r.schema,columnVisibility:r.columnVisibility||c.snapshot.columnVisibility,columnOrder:r.columnOrder||c.snapshot.columnOrder,columnWidths:r.columnWidths||c.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:$e,onUpdateColumnOrder:Pe,onUpdateColumnWidth:Wt,onResetLayout:Kt,onClose:()=>Q(!1)}),Ar&&t.jsx(Zo,{feature:"Grouping",onError:me=>{const xe=fr("ui","grouping",me);ke(xe)},children:t.jsx(Zu,{schema:r.schema,grouping:r.grouping||null,onApply:mt,onClose:()=>Rt(!1),onOpenDevConfig:()=>$t(!0)})}),Lt&&t.jsx(op,{auditHistory:r.auditHistory||[],onClose:()=>Ce(!1)}),Ao&&t.jsx(np,{onSave:se,onClose:()=>fe(!1)}),wt&&t.jsx(sp,{presets:r.presets||[],reportId:r.id,onOpenPreset:wr,onDeletePreset:jt,onClose:()=>V(!1)}),xt&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(ip,{presetName:xt.name,onClear:st})}),je&&t.jsx(Zo,{feature:"Export",onError:me=>{const xe=fr("ui","export",me);ke(xe)},children:t.jsx(gp,{totalRows:(s==null?void 0:s.totalRows)||((at=r.uploadedData)==null?void 0:at.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((Zt=a==null?void 0:a.columnEngine)==null?void 0:Zt.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:r.schema,allRows:r.uploadedData||[],processedRows:i||[],onExport:ur,onClose:()=>{_t(!1)}})}),r&&t.jsx(Mp,{open:po,onClose:()=>zr(!1),reportId:r.id,reportName:r.name,schedulerConfig:ye,onRunNow:me=>{var nt;const xe=(ye==null?void 0:ye.mode)??"local",Ye=me.scope==="all"?r.uploadedData||[]:i||[],Ae=rn(Ye,r.schema||[],He(r.filters),r.sortStack||[],c,r.columnVisibility,r.columnOrder);if(xe==="api"){const it=(r.columnOrder||[]).filter(Ot=>(r.columnVisibility??{})[Ot]!==!1);(nt=ye==null?void 0:ye.onScheduleFire)==null||nt.call(ye,{schedule:me,triggeredAt:new Date().toISOString(),rows:Ye,columns:it,format:me.format,reportName:r.name})}else me.format==="csv"&&on(Ae,me.name),me.format==="excel"&&nn(Ae,me.name),me.format==="json"&&sn(Ae,me.name),me.format==="pdf"&&yi(Ae,me.name);ee(`"${me.name}" exported successfully`,"success")}}),t.jsx(jp,{open:Ur,onClose:()=>$t(!1),config:Vt,onApply:mo})]})}const Rp={error:"err",warning:"warn",info:"info",success:"suc"};function fa({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var k,T,b,R;const a=o.useTheme(),c=a.tokens,l=(c==null?void 0:c.notifPosition)??"bottom-right",u=(c==null?void 0:c.notifStyle)??"toast",y=(c==null?void 0:c.notifAccent)??"severity",g=(c==null?void 0:c.notifAutoDismiss)??!0,m=(c==null?void 0:c.toastW)??252,S=l.startsWith("top")?"top":"bottom",C=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",D=Rp[n],v=((k=c==null?void 0:c.status)==null?void 0:k[`${D}Soft`])??a.palette[n].light,x=((T=c==null?void 0:c.status)==null?void 0:T[`${D}Txt`])??a.palette[n].dark,B=y==="primary"?a.palette.primary.main:y==="mono"?a.palette.text.secondary:x,h=u==="toast"?(c==null?void 0:c.toastBg)??a.palette.background.paper:v;return t.jsx(o.Snackbar,{open:e,autoHideDuration:g?s??(c!=null&&c.autoDismissSec?c.autoDismissSec*1e3:3e4):void 0,onClose:(H,E)=>{E!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:S,horizontal:C},children:t.jsx(o.Alert,{severity:n,icon:u==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((b=c==null?void 0:c.status)==null?void 0:b[`${D}Soft`])??a.palette[n].light,color:((R=c==null?void 0:c.status)==null?void 0:R[`${D}Txt`])??a.palette[n].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:n==="error"||n==="warning"?"!":n==="success"?"✓":"i"}):void 0,action:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[g&&(c==null?void 0:c.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:$(B,.14),color:B,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${c.autoDismissSec}s`}),t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",p:.25},children:t.jsx(O.Close,{sx:{fontSize:16}})})]}),sx:{width:m,alignItems:"flex-start",bgcolor:h,color:x,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 ${B}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:B}},children:t.jsxs(o.Box,{children:[u==="toast"&&t.jsx(o.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:n==="error"?"Error":n==="warning"?"Warning":n==="success"?"Success":"Info"}),t.jsx(o.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function xa({hasExternalData:e=!1}){const r=hn(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:u,setActiveReportId:y,createReport:g,handleFileUpload:m,handleUploadError:S,handleRetry:C,handleConfirm:D,snack:v,handleSnackClose:x,snackDurationMs:B,config:h}=r,k=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Jl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:y}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:k?t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[t.jsx(o.CircularProgress,{size:40,thickness:3}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?t.jsx(ra,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?t.jsx(t.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?t.jsx(ma,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(lu,{schema:s.schema,onConfirm:D,hasConflicts:c}):s.uploadError?t.jsx(cu,{error:s.uploadError,onRetry:C}):t.jsx(au,{onFileUpload:m,onError:S,isUploading:a==="uploading",jsonGuideContent:h==null?void 0:h.jsonGuideContent})})}):null}),!e&&t.jsx(su,{isOpen:l,onClose:()=>u(!1),onCreate:g}),t.jsx(fa,{open:v.open,message:v.message,severity:v.severity,onClose:x,autoHideDurationMs:B})]})}function Pp({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c=!0,config:l}={}){return t.jsx(bi,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c,config:l,children:t.jsx(xa,{hasExternalData:!!(e||r)})})}function ga(){const e=hn(),{snack:r,handleSnackClose:n,snackDurationMs:i}=e;return t.jsxs(o.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsx(o.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:e.activeReport?t.jsx(ma,{reportEngine:e}):t.jsx(ra,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(fa,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Np({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(bi,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(ga,{})})}exports.URMBuilder=Pp;exports.URMBuilderRaw=xa;exports.URMProvider=bi;exports.URMViewer=Np;exports.URMViewerRaw=ga;exports.useURMContext=hn;
197
+ The file has been downloaded to your device.`);window.open(`mailto:${v.email}?subject=${fe}&body=${U}`,"_blank")}(ee=(D=S.current).onFired)==null||ee.call(D,v)}catch(oe){Jt.error("urm:scheduler",`Export failed for schedule: ${v.name}`,oe)}},[]);p.useEffect(()=>{if(!e)return;const v=()=>{const{reportId:k,schedulerMode:h,schedulerConfig:j}=S.current;if(!k)return;const T=h==="api"?(j==null?void 0:j.schedules)??[]:ha(k),b=new Date;let R=!1;const H=T.map(I=>{if(!I.isActive)return I;if(new Date(I.nextRunAt)<=b){E(I);const Z=on(I.frequency,I.time,I.dayOfWeek,I.dayOfMonth,b);return R=!0,{...I,lastRunAt:b.toISOString(),nextRunAt:Z,runCount:I.runCount+1}}return I});R&&h==="local"&&ma(k,H)};v();const y=setInterval(v,Pp);return()=>clearInterval(y)},[e,E])}function xa({reportEngine:e}){var Er,je,Ge,Dr,at,er;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:d,isDirty:l,currentTableState:u,showFilterPanel:x,setShowFilterPanel:g,filterFocusColumn:m,handleReplaceFilters:C,handleOpenFilterForColumn:S,handleCloseFilterPanel:E,handleClearFiltersForColumn:v,showSortPanel:y,setShowSortPanel:k,handleSort:h,handleUpdateSortStack:j,handleSortAscending:T,handleSortDescending:b,showCreateViewModal:R,setShowCreateViewModal:H,showEditViewModal:I,setShowEditViewModal:J,showDeleteConfirmation:Z,setShowDeleteConfirmation:B,editingView:f,deletingView:$,handleSelectView:D,handleCreateView:ee,handleUpdateCurrentView:oe,handleSaveAsNewView:c,handleRevertChanges:re,handleToggleDefault:fe,handleToggleFavorite:U,handleSoftDelete:K,handleRestoreView:de,handlePermanentDelete:ue,handleEditView:X,handleCloneView:pe,handleCopyViewLink:le,handleSaveEditView:P,handleConfirmDelete:se,handlePromoteToGlobal:G,handleSetDefaultForAllUsers:ne,showManageColumns:De,setShowManageColumns:Q,handleUpdateColumnVisibility:Pe,handleUpdateColumnOrder:Te,handleUpdateColumnWidth:$t,handleResetColumnLayout:Rr,showGroupPanel:Kt,setShowGroupPanel:br,handleGroup:Ot,handleToggleGroupCollapse:dt,handleExpandAllGroups:Xt,handleCollapseAllGroups:Qe,searchQuery:Mt,debouncedSearchQuery:vr,searchHistory:wt,handleSearchChange:Qt,handleAddToSearchHistory:uo,handleToggleSearchFavourite:sr,handleDeleteSearchHistory:po,selectedRowIds:Zt,handleToggleRowSelection:Sr,handleToggleAllRows:jt,handleRangeSelection:qe,handleClearSelection:Cr,handleUpdateSelectionAfterDelete:ut,currentPage:tt,pageSize:Nt,paginationTotalRows:ar,paginationTotalPages:ho,handlePageChange:Pr,handlePageSizeChange:lr,isExporting:Je,showExportModal:we,setShowExportModal:At,showDirtyExportWarning:wr,handleExport:Nr,handleExportWithConfig:cr,handleExportSelected:jr,handleExportAnyway:Lr,handleSaveAndExport:dr,handleCancelExport:Ze,showAuditHistory:Lt,setShowAuditHistory:Se,showCreatePreset:Ro,setShowCreatePreset:he,showManagePresets:kt,setShowManagePresets:F,activePreset:yt,handleCreatePreset:ie,handleClearActivePreset:st,handleOpenPresetById:kr,handleDeletePresetById:zt,isViewerRole:Fr,userRole:ur,featureLimitWarning:zr,setFeatureLimitWarning:Ft,reportError:pr,setReportError:Br,handleError:Ce,updateReport:pt,showSnack:ht,config:V,scheduler:Me}=e,[Ae,Tr]=p.useState(!1);Np({reportId:r==null?void 0:r.id,reportName:(r==null?void 0:r.name)||"Report",uploadedData:(r==null?void 0:r.uploadedData)||[],processedData:i||[],schema:(r==null?void 0:r.schema)||[],activeView:d,columnVisibility:(r==null?void 0:r.columnVisibility)||((Er=d==null?void 0:d.snapshot)==null?void 0:Er.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((je=d==null?void 0:d.snapshot)==null?void 0:je.columnOrder)||[],filters:He(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:me=>{ht(`Scheduled export "${me.name}" completed`,"success")},schedulerConfig:Me});const Ir=p.useCallback((me,xe)=>{if(!(r!=null&&r.uploadedData))return;const et=r.uploadedData[me],_e=[...r.uploadedData];_e[me]=xe;const it=Io(r.id,"user","rows","row_edited",et,xe),mt=Eo(r.auditHistory||[],it);pt(r.id,{uploadedData:_e,auditHistory:mt})},[r,pt]),Vr=p.useCallback(me=>{if(!(r!=null&&r.uploadedData))return;const xe=r.uploadedData.indexOf(me);if(xe===-1)return;const et=r.uploadedData.filter((mt,bt)=>bt!==xe),_e=Io(r.id,"user","rows","row_deleted",me,null),it=Eo(r.auditHistory||[],_e);pt(r.id,{uploadedData:et,auditHistory:it}),ut(me)},[r,pt,ut]),mo=p.useCallback((me,xe)=>{if(!(r!=null&&r.uploadedData))return;const et=r.uploadedData.indexOf(xe),_e=et!==-1?et+1:me+1,it=[...r.uploadedData];it.splice(_e,0,{...xe});const mt=Io(r.id,"user","rows","row_duplicated",xe,{...xe}),bt=Eo(r.auditHistory||[],mt);pt(r.id,{uploadedData:it,auditHistory:bt})},[r,pt]),Vt=Ar(),{handleDevConfigChange:fo}=fn(),[Hr,Wt]=p.useState(!1);return p.useEffect(()=>{const me=xe=>{xe.ctrlKey&&xe.shiftKey&&xe.key==="D"&&(xe.preventDefault(),Wt(!0))};return document.addEventListener("keydown",me),()=>document.removeEventListener("keydown",me)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[zr&&t.jsx(Sp,{warning:zr,onDismiss:()=>Ft(null)}),pr&&t.jsx(Cp,{error:pr,onDismiss:()=>Br(null)}),wr&&t.jsx(op,{onExportAnyway:Lr,onSaveAndExport:dr,onCancel:Ze}),t.jsx(Gu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:l,isExporting:Je,columnVisibility:r.columnVisibility||(d==null?void 0:d.snapshot.columnVisibility),columnOrder:r.columnOrder||(d==null?void 0:d.snapshot.columnOrder),columnWidths:r.columnWidths||(d==null?void 0:d.snapshot.columnWidths),grouping:r.grouping,onSort:h,onSortAscending:T,onSortDescending:b,onOpenFilters:()=>g(!0),onOpenSort:()=>k(!0),onOpenFilterForColumn:S,onSelectView:D,onCreateView:()=>H(!0),onUpdateCurrentView:oe,onSaveAsNewView:c,onDiscardChanges:re,onToggleDefault:fe,onToggleFavorite:U,onRestoreView:de,onPermanentDelete:ue,onEditView:X,onCloneView:pe,onCopyLink:le,onDeleteView:K,onPromoteToGlobal:G,onSetDefaultForAllUsers:ne,isAdmin:((Ge=Vt.views)==null?void 0:Ge.isAdmin)??!1,hideViewMenuActions:V==null?void 0:V.hideViewMenuActions,onExport:Nr,onOpenColumns:()=>Q(!0),onUpdateColumnWidth:$t,onUpdateColumnOrder:Te,onUpdateColumnVisibility:Pe,onClearFiltersForColumn:v,onResetLayout:Rr,onOpenGroup:()=>br(!0),onGroupByColumn:(Dr=V==null?void 0:V.hideToolbarActions)!=null&&Dr.includes("grouping")?void 0:me=>{var _e;const xe=r==null?void 0:r.grouping;if(!((xe==null?void 0:xe.enabled)&&(xe==null?void 0:xe.levels)&&xe.levels.length>0))Ot({enabled:!0,levels:[{column:me}],collapsedGroups:[]});else{if(xe.levels.some(bt=>bt.column===me))return;const mt=((_e=Vt.grouping)==null?void 0:_e.maxLevels)??3;if(xe.levels.length>=mt)return;Ot({enabled:!0,levels:[...xe.levels,{column:me}],collapsedGroups:xe.collapsedGroups})}},onToggleGroupCollapse:dt,onExpandAllGroups:Xt,onCollapseAllGroups:Qe,onOpenAuditHistory:()=>Se(!0),onOpenScheduledReports:()=>Tr(!0),searchQuery:Mt,highlightQuery:vr,searchHistory:wt,onAddToSearchHistory:uo,onToggleSearchFavourite:sr,onDeleteSearchHistory:po,selectedRowIds:Zt,onSearchChange:Qt,onToggleRowSelection:Sr,onToggleAllRows:jt,onRangeSelection:qe,onClearSelection:Cr,onExportSelected:jr,currentPage:tt,pageSize:Nt,onPageChange:Pr,onPageSizeChange:lr,totalRowsBeforePagination:ar,totalPagesOverride:ho,isReadOnly:Fr,userRole:ur,reportName:r.name,onEditRow:Ir,onDeleteRow:Vr,onDuplicateRow:mo,rowActions:V==null?void 0:V.rowActions,hideDefaultRowActions:V==null?void 0:V.hideDefaultRowActions,hideToolbarActions:V==null?void 0:V.hideToolbarActions,customSettingsActions:V==null?void 0:V.customSettingsActions,jsonGuideContent:V==null?void 0:V.jsonGuideContent,viewOptions:V==null?void 0:V.viewOptions,defaultViewMode:V==null?void 0:V.defaultViewMode,bulkActions:V==null?void 0:V.bulkActions,hideSelectionCheckboxes:V==null?void 0:V.hideSelectionCheckboxes,rowClickBehavior:V==null?void 0:V.rowClickBehavior,openModalOn:V==null?void 0:V.openModalOn,onRowClick:V==null?void 0:V.onRowClick,onRowRightClick:V==null?void 0:V.onRowRightClick,showDevPanel:Vt.display.showDevPanel,onOpenDevConfig:()=>Wt(!0)})]}),x&&t.jsx(tn,{feature:"Filters",onError:me=>{const xe=xr("ui","filters",me);Ce(xe)},children:t.jsx(Ku,{schema:r.schema,filters:r.filters,onReplaceFilters:C,onClose:E,focusColumn:m,onOpenDevConfig:()=>Wt(!0)})}),y&&t.jsx(tn,{feature:"Sorting",onError:me=>{const xe=xr("ui","sorting",me);Ce(xe)},children:t.jsx(Qu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:j,onClose:()=>k(!1),onOpenDevConfig:()=>Wt(!0)})}),R&&u&&(()=>{var et;const me=(r.views??[]).filter(_e=>!_e.isDeleted).length,xe=((et=Vt.views)==null?void 0:et.maxViews)??10;return t.jsx(js,{currentSnapshot:u,onSave:ee,onClose:()=>H(!1),atViewLimit:me>=xe,maxViews:xe})})(),I&&f&&t.jsx(js,{currentSnapshot:f.snapshot,onSave:P,onClose:()=>{J(!1)},isEditMode:!0,initialName:f.name,initialDescription:f.description,initialIsDefault:f.isDefault}),Z&&$&&t.jsx(Zu,{viewName:$.name,onConfirm:se,onCancel:()=>{B(!1)}}),De&&d&&t.jsx(tp,{schema:r.schema,columnVisibility:r.columnVisibility||d.snapshot.columnVisibility,columnOrder:r.columnOrder||d.snapshot.columnOrder,columnWidths:r.columnWidths||d.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:Pe,onUpdateColumnOrder:Te,onUpdateColumnWidth:$t,onResetLayout:Rr,onClose:()=>Q(!1)}),Kt&&t.jsx(tn,{feature:"Grouping",onError:me=>{const xe=xr("ui","grouping",me);Ce(xe)},children:t.jsx(rp,{schema:r.schema,grouping:r.grouping||null,onApply:Ot,onClose:()=>br(!1),onOpenDevConfig:()=>Wt(!0)})}),Lt&&t.jsx(sp,{auditHistory:r.auditHistory||[],onClose:()=>Se(!1)}),Ro&&t.jsx(ap,{onSave:ie,onClose:()=>he(!1)}),kt&&t.jsx(cp,{presets:r.presets||[],reportId:r.id,onOpenPreset:kr,onDeletePreset:zt,onClose:()=>F(!1)}),yt&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(lp,{presetName:yt.name,onClear:st})}),we&&t.jsx(tn,{feature:"Export",onError:me=>{const xe=xr("ui","export",me);Ce(xe)},children:t.jsx(vp,{totalRows:(s==null?void 0:s.totalRows)||((at=r.uploadedData)==null?void 0:at.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((er=a==null?void 0:a.columnEngine)==null?void 0:er.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:r.schema,allRows:r.uploadedData||[],processedRows:i||[],onExport:cr,onClose:()=>{At(!1)}})}),r&&t.jsx(Rp,{open:Ae,onClose:()=>Tr(!1),reportId:r.id,reportName:r.name,schedulerConfig:Me,onRunNow:me=>{var it;const xe=(Me==null?void 0:Me.mode)??"local",et=me.scope==="all"?r.uploadedData||[]:i||[],_e=nn(et,r.schema||[],He(r.filters),r.sortStack||[],d,r.columnVisibility,r.columnOrder);if(xe==="api"){const mt=(r.columnOrder||[]).filter(bt=>(r.columnVisibility??{})[bt]!==!1);(it=Me==null?void 0:Me.onScheduleFire)==null||it.call(Me,{schedule:me,triggeredAt:new Date().toISOString(),rows:et,columns:mt,format:me.format,reportName:r.name})}else me.format==="csv"&&sn(_e,me.name),me.format==="excel"&&an(_e,me.name),me.format==="json"&&ln(_e,me.name),me.format==="pdf"&&bi(_e,me.name);ht(`"${me.name}" exported successfully`,"success")}}),t.jsx(Bp,{open:Hr,onClose:()=>Wt(!1),config:Vt,onApply:fo})]})}const Lp={error:"err",warning:"warn",info:"info",success:"suc"};function ga({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var j,T,b,R;const a=o.useTheme(),d=a.tokens,l=(d==null?void 0:d.notifPosition)??"bottom-right",u=(d==null?void 0:d.notifStyle)??"toast",x=(d==null?void 0:d.notifAccent)??"severity",g=(d==null?void 0:d.notifAutoDismiss)??!0,m=(d==null?void 0:d.toastW)??252,C=l.startsWith("top")?"top":"bottom",S=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",E=Lp[n],v=((j=d==null?void 0:d.status)==null?void 0:j[`${E}Soft`])??a.palette[n].light,y=((T=d==null?void 0:d.status)==null?void 0:T[`${E}Txt`])??a.palette[n].dark,k=x==="primary"?a.palette.primary.main:x==="mono"?a.palette.text.secondary:y,h=u==="toast"?(d==null?void 0:d.toastBg)??a.palette.background.paper:v;return t.jsx(o.Snackbar,{open:e,autoHideDuration:g?s??(d!=null&&d.autoDismissSec?d.autoDismissSec*1e3:3e4):void 0,onClose:(H,I)=>{I!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:C,horizontal:S},children:t.jsx(o.Alert,{severity:n,icon:u==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((b=d==null?void 0:d.status)==null?void 0:b[`${E}Soft`])??a.palette[n].light,color:((R=d==null?void 0:d.status)==null?void 0:R[`${E}Txt`])??a.palette[n].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:n==="error"||n==="warning"?"!":n==="success"?"✓":"i"}):void 0,action:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[g&&(d==null?void 0:d.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:O(k,.14),color:k,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${d.autoDismissSec}s`}),t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",p:.25},children:t.jsx(M.Close,{sx:{fontSize:16}})})]}),sx:{width:m,alignItems:"flex-start",bgcolor:h,color:y,boxShadow:u==="inline"?"none":(d==null?void 0:d.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(d==null?void 0:d.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${k}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:k}},children:t.jsxs(o.Box,{children:[u==="toast"&&t.jsx(o.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:n==="error"?"Error":n==="warning"?"Warning":n==="success"?"Success":"Info"}),t.jsx(o.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function ya({hasExternalData:e=!1}){const r=fn(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:d,isModalOpen:l,setIsModalOpen:u,setActiveReportId:x,createReport:g,handleFileUpload:m,handleUploadError:C,handleRetry:S,handleConfirm:E,snack:v,handleSnackClose:y,snackDurationMs:k,config:h}=r,j=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Xl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:x}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:j?t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[t.jsx(o.CircularProgress,{size:40,thickness:3}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?t.jsx(na,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?t.jsx(t.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?t.jsx(xa,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(du,{schema:s.schema,onConfirm:E,hasConflicts:d}):s.uploadError?t.jsx(uu,{error:s.uploadError,onRetry:S}):t.jsx(cu,{onFileUpload:m,onError:C,isUploading:a==="uploading",jsonGuideContent:h==null?void 0:h.jsonGuideContent})})}):null}),!e&&t.jsx(lu,{isOpen:l,onClose:()=>u(!1),onCreate:g}),t.jsx(ga,{open:v.open,message:v.message,severity:v.severity,onClose:y,autoHideDurationMs:k})]})}function Fp({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:d=!0,config:l}={}){return t.jsx(vi,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:d,config:l,children:t.jsx(ya,{hasExternalData:!!(e||r)})})}function ba(){const e=fn(),{snack:r,handleSnackClose:n,snackDurationMs:i}=e;return t.jsxs(o.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsx(o.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:e.activeReport?t.jsx(xa,{reportEngine:e}):t.jsx(na,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(ga,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Vp({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(vi,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(ba,{})})}exports.URMBuilder=Fp;exports.URMBuilderRaw=ya;exports.URMProvider=vi;exports.URMViewer=Vp;exports.URMViewerRaw=ba;exports.useURMContext=fn;