dts-universal-report-module 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.esm.js +4104 -4066
  2. package/dist/index.js +24 -24
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var pa=Object.defineProperty;var ha=(e,r,n)=>r in e?pa(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Ci=(e,r,n)=>ha(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),f=require("react"),fa=require("xlsx"),$=require("@mui/icons-material"),o=require("@mui/material"),bs=require("react-dom"),ma=require("@emotion/react"),Zt=require("react-dnd"),ni=require("react-dnd-html5-backend");function vs(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 sn=vs(f),No=vs(fa),ht={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}},Ss="urm_dev_config";function xa(){try{const e=localStorage.getItem(Ss);if(!e)return ht;const r=JSON.parse(e),n={sort:{...ht.sort,...r.sort},filter:{...ht.filter,...r.filter},columns:{...ht.columns,...r.columns},grouping:{...ht.grouping,...r.grouping},export:{...ht.export,...r.export},views:{...ht.views,...r.views},dates:{...ht.dates,...r.dates},display:{...ht.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return ht}}function ga(e){try{localStorage.setItem(Ss,JSON.stringify(e))}catch{}}function ya(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 Cs=f.createContext(ht);function Dr(){return f.useContext(Cs)}const ba=/^\d{4}-\d{2}-\d{2}$/,va=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Sa=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Ca=9783072e5,ja=41024448e5,wa=978307200,ka=4102444800;function za(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=Ca&&e<=ja?"timestamp_ms":Number.isInteger(e)&&e>=wa&&e<=ka?"timestamp_s":"unknown":typeof e!="string"?"unknown":va.test(e)||ba.test(e)?"iso":Sa.test(e.trim())?"locale_string":"unknown"}function Ta(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=za(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 Ba(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 ji=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ia=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ue(e){return String(e).padStart(2,"0")}function Ea(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),p=Math.floor(l/7),x=Math.floor(l/30),y=Math.floor(l/365);let g;return s<60?g="just now":a<60?g=`${a} minute${a!==1?"s":""}`:c<24?g=`${c} hour${c!==1?"s":""}`:l<7?g=`${l} day${l!==1?"s":""}`:p<5?g=`${p} week${p!==1?"s":""}`:x<12?g=`${x} month${x!==1?"s":""}`:g=`${y} year${y!==1?"s":""}`,s<60?g:i?`${g} ago`:`in ${g}`}function Da(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}-${Ue(i+1)}-${Ue(s)}`;case"DD/MM/YYYY":return`${Ue(s)}/${Ue(i+1)}/${n}`;case"MM/DD/YYYY":return`${Ue(i+1)}/${Ue(s)}/${n}`;case"MMM DD, YYYY":return`${ji[i]} ${Ue(s)}, ${n}`;case"DD MMM YYYY":return`${Ue(s)} ${ji[i]} ${n}`;case"MMMM D, YYYY":return`${Ia[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ue(i+1)}-${Ue(s)} ${Ue(a)}:${Ue(c)}`;case"DD/MM/YYYY HH:mm":return`${Ue(s)}/${Ue(i+1)}/${n} ${Ue(a)}:${Ue(c)}`;case"MM/DD/YYYY HH:mm":return`${Ue(i+1)}/${Ue(s)}/${n} ${Ue(a)}:${Ue(c)}`;case"relative":return Ea(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function $a(e,r,n){if(!n||r==="unknown")return String(e);const i=Ba(e,r);return!i||isNaN(i.getTime())?String(e):Da(i,n)}function _a(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 js(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,js(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:js(r))}function go(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 p=0;r.forEach(v=>{typeof v=="object"&&v!==null&&c in v&&(p++,l.add(_a(v[c])))});const x=p===r.length,y=l.size>1&&!l.has("null");let g="mixed";if(l.size===1)g=Array.from(l)[0];else if(l.size===2&&l.has("null")){const v=Array.from(l).filter(S=>S!=="null");v.length===1&&(g=v[0])}i.push({name:c,type:g,required:x,hasConflict:y})});const a=r.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=Ta(c.name,a);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function wi(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function Oa(e){return e.some(r=>r.hasConflict)}function lt(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 ki(e){return e==null}function Ma(e){return(r,n,i)=>{const s=ki(r),a=ki(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),p=Number(n);c=l-p;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 Wa(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(y=>y.name===c.column);if(!l)continue;const x=Ma(l.type)(s[c.column],a[c.column],c.direction);if(x!==0)return x}return 0})}function Aa(e){return e===null?"asc":e==="asc"?"desc":null}function Ra(e){return e==="string"||e==="boolean"}function Pa(e){return e.filter(r=>Ra(r.type))}function Na(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 La(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=ii(e,n.levels,r);return ws(i,n.collapsedGroups||[])}function ii(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,c=new Map;e.forEach(x=>{const y=x[a],g=y==null?"(empty)":String(y);c.has(g)||c.set(g,[]),c.get(g).push(x)});const l=[];return Array.from(c.keys()).sort().forEach(x=>{const y=c.get(x),g=`${a}:${x}`,v=i?`${i}|${g}`:g,S=Na(y,n),k=s<r.length-1?ii(y,r,n,v,s+1):y,b={key:v,level:s,column:a,value:x,rowCount:y.length,aggregates:S,children:k};l.push(b)}),l}function ws(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&&ws(s.children,r,n,i+1)}else n.push({...s,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function zi(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=ii(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 Fa(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function ks(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Va(e,r,n){const i=r?lt(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function no(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ye(e){return"children"in e}function _t(){return{id:no(),operator:"and",children:[]}}function Le(e){return e?Array.isArray(e)?{id:no(),operator:"and",children:e.map(r=>({...r,id:r.id??no()}))}:e:_t()}function Ct(e){return e?Ye(e)?e.children.reduce((r,n)=>r+Ct(n),0):1:0}function qo(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(Ye(n)){const i=qo(n,r);if(i)return i}}}function io(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Ye(i)?io(i,r,n):i)}}function si(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!Ye(i)?{...i,...n}:Ye(i)?si(i,r,n):i)}}function ai(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>Ye(i)?ai(i,r,n):i)}}function li(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>Ye(i)?li(i,r):i).filter(i=>!Ye(i)||i.children.length>0);return{...e,children:n}}function Xn(e,r){return e?Ye(e)?e.children.some(n=>Xn(n,r)):e.column===r:!1}function zs(e,r){const n=e.children.filter(i=>Ye(i)||i.column!==r).map(i=>Ye(i)?zs(i,r):i).filter(i=>!Ye(i)||i.children.length>0);return{...e,children:n}}function Ts(e){return e?Ye(e)?e.children.flatMap(Ts):[e]:[]}function To(e){if(!e)return null;if(!Ye(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(To)}}function Co(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 ci(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 p=0;for(const x of n)c.has(x)?a.push(x):l.has(x)&&p<s.length?(a.push(s[p]),p++):l.has(x)||a.push(x);for(let x=p;x<s.length;x++)a.includes(s[x])||a.push(s[x]);return a}return[...e]}function Nn(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:_t(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Ha(e,r,n,i,s,a,c,l){const p={},x=[],y={};n.forEach(S=>{p[S.name]=!0,x.push(S.name),y[S.name]=170});const v=ci(s||x,c||null,l||x);return{filters:Le(e),sortStack:r||[],columnVisibility:i||p,columnOrder:v,columnWidths:a||y,grouping:c||null}}function Ua(e,r){const n=S=>{if(S==null)return S;if(Array.isArray(S))return S.map(k=>n(k));if(typeof S=="object"){const k={};return Object.keys(S).sort().forEach(b=>{k[b]=n(S[b])}),k}return S},i=S=>JSON.stringify(n(S));if(i(To(e.filters))!==i(To(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=ci(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),l=[...c].sort().join(","),p=[...r.columnOrder||[]].sort().join(",");if(l!==p)return!1;const x=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==x){if(c.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const S=[...c].sort().join(",");if(c.join(",")!==S)return!0}const g=e.columnWidths??{},v=r.columnWidths??{};return i(g)!==i(v)||i(e.grouping)!==i(r.grouping)}function Ga(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function Ya(e,r){var b,m,z;const n=[],i=JSON.stringify(To(e.filters)),s=JSON.stringify(To(r.filters));if(i!==s){const h=Ct(e.filters),B=Ct(r.filters);h>B?n.push({category:"filters",label:"Filters Added",description:`${h-B} new filter${h-B>1?"s":""} added`}):h<B?n.push({category:"filters",label:"Filters Removed",description:`${B-h} filter${B-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,B=r.sortStack.length;h>B?n.push({category:"sorting",label:"Sorting Added",description:`${h-B} new sort rule${h-B>1?"s":""} added`}):h<B?n.push({category:"sorting",label:"Sorting Removed",description:`${B-h} sort rule${B-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),p=JSON.stringify(r.columnVisibility);if(l!==p){const h=Object.values(e.columnVisibility).filter(T=>T).length,B=Object.values(r.columnVisibility).filter(T=>T).length;h>B?n.push({category:"visibility",label:"Columns Shown",description:`${h-B} column${h-B>1?"s":""} made visible`}):h<B?n.push({category:"visibility",label:"Columns Hidden",description:`${B-h} column${B-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),y=JSON.stringify(r.columnOrder);x!==y&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const g=JSON.stringify(e.columnWidths),v=JSON.stringify(r.columnWidths);if(g!==v){const h=Object.keys(e.columnWidths).filter(B=>e.columnWidths[B]!==r.columnWidths[B]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${h} column width${h>1?"s":""} modified`})}const S=JSON.stringify(e.grouping),k=JSON.stringify(r.grouping);if(S!==k){const h=(b=e.grouping)==null?void 0:b.enabled,B=(m=r.grouping)==null?void 0:m.enabled;if(h&&!B){const T=((z=e.grouping)==null?void 0:z.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${T} grouping level${T>1?"s":""} added`})}else!h&&B?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 Ti(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Bi(e){return`[${e}]`}const Lt={warn(e,r,...n){Ti()&&console.warn(Bi(e),r,...n)},error(e,r,...n){Ti()&&console.error(Bi(e),r,...n)}},Bs="urm_report_";function qa(e,r){try{const n=`${Bs}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Lt.error("urm:persistence","Failed to save report state",n)}}function Ja(e){try{const r=`${Bs}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Lt.error("urm:persistence","Failed to load report state",r),null}}function Io(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(Ka(c)){const l=s.children,p=Io(l,r,n+1);i.push(...p)}else{const l=s.children;for(const p of l)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:p})}}}return i}function Ka(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 an(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function ln(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 Qo(e,r,n,i,s,a,c){let l,p;a?(l={...a},p=c||r.map(y=>y.name)):s?(l={...s.snapshot.columnVisibility},p=c||[...s.snapshot.columnOrder]):(l={},p=[],r.forEach(y=>{l[y.name]=!0,p.push(y.name)}));const x=Object.entries(l).filter(([y,g])=>!g).map(([y,g])=>y);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:p,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 Zo(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(g=>e.columnVisibility[g]);let l;if(a&&a.enabled){const g=a.collapsedGroups??[],v=Io(i,g);l=an(v)}else l=i;const p=c.join(","),x=l.map(g=>c.map(v=>{const S=g[v];if(S==null)return"";const k=String(S);return k.includes(",")||k.includes('"')||k.includes(`
1
+ "use strict";var ha=Object.defineProperty;var fa=(e,r,n)=>r in e?ha(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var ji=(e,r,n)=>fa(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),f=require("react"),ma=require("xlsx"),$=require("@mui/icons-material"),o=require("@mui/material"),vs=require("react-dom"),xa=require("@emotion/react"),rr=require("react-dnd"),ni=require("react-dnd-html5-backend");function Ss(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 on=Ss(f),Ro=Ss(ma),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}},Cs="urm_dev_config";function ga(){try{const e=localStorage.getItem(Cs);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 ya(e){try{localStorage.setItem(Cs,JSON.stringify(e))}catch{}}function ba(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 js=f.createContext(ft);function _r(){return f.useContext(js)}const va=/^\d{4}-\d{2}-\d{2}$/,Sa=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Ca=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,ja=9783072e5,wa=41024448e5,ka=978307200,za=4102444800;function Ta(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=ja&&e<=wa?"timestamp_ms":Number.isInteger(e)&&e>=ka&&e<=za?"timestamp_s":"unknown":typeof e!="string"?"unknown":Sa.test(e)||va.test(e)?"iso":Ca.test(e.trim())?"locale_string":"unknown"}function Ba(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=Ta(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 Ia(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 wi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ea=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ve(e){return String(e).padStart(2,"0")}function Da(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),p=Math.floor(l/7),x=Math.floor(l/30),y=Math.floor(l/365);let g;return s<60?g="just now":a<60?g=`${a} minute${a!==1?"s":""}`:c<24?g=`${c} hour${c!==1?"s":""}`:l<7?g=`${l} day${l!==1?"s":""}`:p<5?g=`${p} week${p!==1?"s":""}`:x<12?g=`${x} month${x!==1?"s":""}`:g=`${y} year${y!==1?"s":""}`,s<60?g:i?`${g} ago`:`in ${g}`}function $a(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}-${Ve(i+1)}-${Ve(s)}`;case"DD/MM/YYYY":return`${Ve(s)}/${Ve(i+1)}/${n}`;case"MM/DD/YYYY":return`${Ve(i+1)}/${Ve(s)}/${n}`;case"MMM DD, YYYY":return`${wi[i]} ${Ve(s)}, ${n}`;case"DD MMM YYYY":return`${Ve(s)} ${wi[i]} ${n}`;case"MMMM D, YYYY":return`${Ea[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ve(i+1)}-${Ve(s)} ${Ve(a)}:${Ve(c)}`;case"DD/MM/YYYY HH:mm":return`${Ve(s)}/${Ve(i+1)}/${n} ${Ve(a)}:${Ve(c)}`;case"MM/DD/YYYY HH:mm":return`${Ve(i+1)}/${Ve(s)}/${n} ${Ve(a)}:${Ve(c)}`;case"relative":return Da(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function _a(e,r,n){if(!n||r==="unknown")return String(e);const i=Ia(e,r);return!i||isNaN(i.getTime())?String(e):$a(i,n)}function Oa(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 ws(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,ws(c,a,n+1)):i[a]=c}return i}function no(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:ws(r))}function yo(e){if(!Array.isArray(e)||e.length===0)return[];const r=no(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 p=0;r.forEach(v=>{typeof v=="object"&&v!==null&&c in v&&(p++,l.add(Oa(v[c])))});const x=p===r.length,y=l.size>1&&!l.has("null");let g="mixed";if(l.size===1)g=Array.from(l)[0];else if(l.size===2&&l.has("null")){const v=Array.from(l).filter(S=>S!=="null");v.length===1&&(g=v[0])}i.push({name:c,type:g,required:x,hasConflict:y})});const a=r.slice(0,50);for(const c of i){if(c.type!=="string"&&c.type!=="number")continue;const l=Ba(c.name,a);l!=="unknown"&&(c.type="date",c.dateFormat=l)}return i}function ki(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function Ma(e){return e.some(r=>r.hasConflict)}function ut(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 zi(e){return e==null}function Wa(e){return(r,n,i)=>{const s=zi(r),a=zi(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),p=Number(n);c=l-p;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 Aa(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(y=>y.name===c.column);if(!l)continue;const x=Wa(l.type)(s[c.column],a[c.column],c.direction);if(x!==0)return x}return 0})}function Ra(e){return e===null?"asc":e==="asc"?"desc":null}function Pa(e){return e==="string"||e==="boolean"}function Na(e){return e.filter(r=>Pa(r.type))}function La(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 Fa(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=ii(e,n.levels,r);return ks(i,n.collapsedGroups||[])}function ii(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,c=new Map;e.forEach(x=>{const y=x[a],g=y==null?"(empty)":String(y);c.has(g)||c.set(g,[]),c.get(g).push(x)});const l=[];return Array.from(c.keys()).sort().forEach(x=>{const y=c.get(x),g=`${a}:${x}`,v=i?`${i}|${g}`:g,S=La(y,n),k=s<r.length-1?ii(y,r,n,v,s+1):y,b={key:v,level:s,column:a,value:x,rowCount:y.length,aggregates:S,children:k};l.push(b)}),l}function ks(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&&ks(s.children,r,n,i+1)}else n.push({...s,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function Ti(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=ii(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 Va(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function zs(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Ha(e,r,n){const i=r?ut(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function so(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function qe(e){return"children"in e}function Wt(){return{id:so(),operator:"and",children:[]}}function Ne(e){return e?Array.isArray(e)?{id:so(),operator:"and",children:e.map(r=>({...r,id:r.id??so()}))}:e:Wt()}function Ct(e){return e?qe(e)?e.children.reduce((r,n)=>r+Ct(n),0):1:0}function Go(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(qe(n)){const i=Go(n,r);if(i)return i}}}function ao(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>qe(i)?ao(i,r,n):i)}}function si(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!qe(i)?{...i,...n}:qe(i)?si(i,r,n):i)}}function ai(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>qe(i)?ai(i,r,n):i)}}function li(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>qe(i)?li(i,r):i).filter(i=>!qe(i)||i.children.length>0);return{...e,children:n}}function Xn(e,r){return e?qe(e)?e.children.some(n=>Xn(n,r)):e.column===r:!1}function Ts(e,r){const n=e.children.filter(i=>qe(i)||i.column!==r).map(i=>qe(i)?Ts(i,r):i).filter(i=>!qe(i)||i.children.length>0);return{...e,children:n}}function Bs(e){return e?qe(e)?e.children.flatMap(Bs):[e]:[]}function To(e){if(!e)return null;if(!qe(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(To)}}function Co(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 ci(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 p=0;for(const x of n)c.has(x)?a.push(x):l.has(x)&&p<s.length?(a.push(s[p]),p++):l.has(x)||a.push(x);for(let x=p;x<s.length;x++)a.includes(s[x])||a.push(s[x]);return a}return[...e]}function Nn(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:Wt(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Ua(e,r,n,i,s,a,c,l){const p={},x=[],y={};n.forEach(S=>{p[S.name]=!0,x.push(S.name),y[S.name]=170});const v=ci(s||x,c||null,l||x);return{filters:Ne(e),sortStack:r||[],columnVisibility:i||p,columnOrder:v,columnWidths:a||y,grouping:c||null}}function Ga(e,r){const n=S=>{if(S==null)return S;if(Array.isArray(S))return S.map(k=>n(k));if(typeof S=="object"){const k={};return Object.keys(S).sort().forEach(b=>{k[b]=n(S[b])}),k}return S},i=S=>JSON.stringify(n(S));if(i(To(e.filters))!==i(To(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=ci(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),l=[...c].sort().join(","),p=[...r.columnOrder||[]].sort().join(",");if(l!==p)return!1;const x=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==x){if(c.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const S=[...c].sort().join(",");if(c.join(",")!==S)return!0}const g=e.columnWidths??{},v=r.columnWidths??{};return i(g)!==i(v)||i(e.grouping)!==i(r.grouping)}function Ya(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function qa(e,r){var b,m,z;const n=[],i=JSON.stringify(To(e.filters)),s=JSON.stringify(To(r.filters));if(i!==s){const h=Ct(e.filters),B=Ct(r.filters);h>B?n.push({category:"filters",label:"Filters Added",description:`${h-B} new filter${h-B>1?"s":""} added`}):h<B?n.push({category:"filters",label:"Filters Removed",description:`${B-h} filter${B-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,B=r.sortStack.length;h>B?n.push({category:"sorting",label:"Sorting Added",description:`${h-B} new sort rule${h-B>1?"s":""} added`}):h<B?n.push({category:"sorting",label:"Sorting Removed",description:`${B-h} sort rule${B-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),p=JSON.stringify(r.columnVisibility);if(l!==p){const h=Object.values(e.columnVisibility).filter(T=>T).length,B=Object.values(r.columnVisibility).filter(T=>T).length;h>B?n.push({category:"visibility",label:"Columns Shown",description:`${h-B} column${h-B>1?"s":""} made visible`}):h<B?n.push({category:"visibility",label:"Columns Hidden",description:`${B-h} column${B-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),y=JSON.stringify(r.columnOrder);x!==y&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const g=JSON.stringify(e.columnWidths),v=JSON.stringify(r.columnWidths);if(g!==v){const h=Object.keys(e.columnWidths).filter(B=>e.columnWidths[B]!==r.columnWidths[B]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${h} column width${h>1?"s":""} modified`})}const S=JSON.stringify(e.grouping),k=JSON.stringify(r.grouping);if(S!==k){const h=(b=e.grouping)==null?void 0:b.enabled,B=(m=r.grouping)==null?void 0:m.enabled;if(h&&!B){const T=((z=e.grouping)==null?void 0:z.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${T} grouping level${T>1?"s":""} added`})}else!h&&B?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 Bi(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Ii(e){return`[${e}]`}const Gt={warn(e,r,...n){Bi()&&console.warn(Ii(e),r,...n)},error(e,r,...n){Bi()&&console.error(Ii(e),r,...n)}},Is="urm_report_";function Ja(e,r){try{const n=`${Is}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Gt.error("urm:persistence","Failed to save report state",n)}}function Ka(e){try{const r=`${Is}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Gt.error("urm:persistence","Failed to load report state",r),null}}function Io(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(Xa(c)){const l=s.children,p=Io(l,r,n+1);i.push(...p)}else{const l=s.children;for(const p of l)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:p})}}}return i}function Xa(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 nn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function sn(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 Ko(e,r,n,i,s,a,c){let l,p;a?(l={...a},p=c||r.map(y=>y.name)):s?(l={...s.snapshot.columnVisibility},p=c||[...s.snapshot.columnOrder]):(l={},p=[],r.forEach(y=>{l[y.name]=!0,p.push(y.name)}));const x=Object.entries(l).filter(([y,g])=>!g).map(([y,g])=>y);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:l,columnOrder:p,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 Xo(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(g=>e.columnVisibility[g]);let l;if(a&&a.enabled){const g=a.collapsedGroups??[],v=Io(i,g);l=nn(v)}else l=i;const p=c.join(","),x=l.map(g=>c.map(v=>{const S=g[v];if(S==null)return"";const k=String(S);return k.includes(",")||k.includes('"')||k.includes(`
2
2
  `)?`"${k.replace(/"/g,'""')}"`:k}).join(",")),y=[p,...x].join(`
3
- `);di(y,ln(r,"csv"),"text/csv;charset=utf-8;")}function en(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(g=>e.columnVisibility[g]);let l;if(a&&a.enabled){const g=a.collapsedGroups??[],v=Io(i,g);l=an(v)}else l=i;const p=[c,...l.map(g=>c.map(v=>g[v]??""))],x=No.utils.aoa_to_sheet(p),y=No.utils.book_new();No.utils.book_append_sheet(y,x,"Data"),No.writeFile(y,ln(r,"xlsx"))}function tn(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:c,hiddenColumns:l,columnOrder:p,grouping:x}=e,y=p.filter(k=>e.columnVisibility[k]);let g;if(x&&x.enabled){const k=x.collapsedGroups??[],b=Io(i,k);g=an(b)}else g=i;g=g.map(k=>{const b={};return y.forEach(m=>{b[m]=k[m]}),b});const v={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(c==null?void 0:c.name)||"Default View",filters:Ts(s).map(k=>({field:k.column,operator:k.operator,value:k.value})),sortStack:a.map(k=>({field:k.column,direction:k.direction,priority:k.priority})),grouping:x||{},hiddenColumns:l,columnOrder:p,exportConfig:n||{scope:"visible"}},data:g},S=JSON.stringify(v,null,2);di(S,ln(r,"json"),"application/json;charset=utf-8;")}function di(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 ui(e,r="export",n){var b;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??[],z=Io(i,m);l=an(z)}else l=i;const p=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),x=c.map(m=>`<th>${Lo(m)}</th>`).join(""),y=l.map((m,z)=>{const h=c.map(B=>{const T=m[B],j=T==null?"":String(T);return`<td>${Lo(j)}</td>`}).join("");return`<tr class="${z%2===0?"even":"odd"}">${h}</tr>`}).join(""),g=`<!DOCTYPE html>
3
+ `);di(y,sn(r,"csv"),"text/csv;charset=utf-8;")}function Qo(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(g=>e.columnVisibility[g]);let l;if(a&&a.enabled){const g=a.collapsedGroups??[],v=Io(i,g);l=nn(v)}else l=i;const p=[c,...l.map(g=>c.map(v=>g[v]??""))],x=Ro.utils.aoa_to_sheet(p),y=Ro.utils.book_new();Ro.utils.book_append_sheet(y,x,"Data"),Ro.writeFile(y,sn(r,"xlsx"))}function Zo(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:c,hiddenColumns:l,columnOrder:p,grouping:x}=e,y=p.filter(k=>e.columnVisibility[k]);let g;if(x&&x.enabled){const k=x.collapsedGroups??[],b=Io(i,k);g=nn(b)}else g=i;g=g.map(k=>{const b={};return y.forEach(m=>{b[m]=k[m]}),b});const v={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(c==null?void 0:c.name)||"Default View",filters:Bs(s).map(k=>({field:k.column,operator:k.operator,value:k.value})),sortStack:a.map(k=>({field:k.column,direction:k.direction,priority:k.priority})),grouping:x||{},hiddenColumns:l,columnOrder:p,exportConfig:n||{scope:"visible"}},data:g},S=JSON.stringify(v,null,2);di(S,sn(r,"json"),"application/json;charset=utf-8;")}function di(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 ui(e,r="export",n){var b;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??[],z=Io(i,m);l=nn(z)}else l=i;const p=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),x=c.map(m=>`<th>${Po(m)}</th>`).join(""),y=l.map((m,z)=>{const h=c.map(B=>{const T=m[B],w=T==null?"":String(T);return`<td>${Po(w)}</td>`}).join("");return`<tr class="${z%2===0?"even":"odd"}">${h}</tr>`}).join(""),g=`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8" />
7
- <title>${Lo(r)}</title>
7
+ <title>${Po(r)}</title>
8
8
  <style>
9
9
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
10
10
  body {
@@ -82,7 +82,7 @@
82
82
  </head>
83
83
  <body>
84
84
  <div class="report-header">
85
- <div class="report-title">${Lo(r)}</div>
85
+ <div class="report-title">${Po(r)}</div>
86
86
  <div class="report-meta">
87
87
  ${l.length.toLocaleString()} row${l.length!==1?"s":""}<br/>
88
88
  Generated ${p}
@@ -102,26 +102,26 @@
102
102
  };
103
103
  <\/script>
104
104
  </body>
105
- </html>`;try{const m=document.createElement("iframe");m.style.position="fixed",m.style.right="0",m.style.bottom="0",m.style.width="0",m.style.height="0",m.style.border="0",document.body.appendChild(m);const z=((b=m.contentWindow)==null?void 0:b.document)||m.contentDocument;if(z){z.open(),z.write(g),z.close(),setTimeout(()=>{var h,B;try{(h=m.contentWindow)==null||h.focus(),(B=m.contentWindow)==null||B.print()}catch{}setTimeout(()=>{document.body.removeChild(m)},3e3)},300);return}}catch{}const v=new Blob([g],{type:"text/html;charset=utf-8;"}),S=URL.createObjectURL(v);window.open(S,"_blank")||di(g,ln(r,"html"),"text/html;charset=utf-8;")}function Lo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Ii=10;function Xa(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>Ii&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Ii)),s}function Qa(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function Za(e,r){return e.filter(n=>n.query!==r)}function el(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 tl={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 rl(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function bt(e,r){return tl[r].includes(e)}function vt(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 ol(e){return e==="viewer"}const Ei=1e3;function Qn(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Nt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return Qn(n)}const nl={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 il(e){if(!e||!e.column)return"a filter";const r=Nt(e.column),n=nl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function Ln(e){return e?typeof e=="string"?e:"children"in e?"a condition group":il(e):"a filter"}function Di(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${Nt(n.column)}"`).join(", ")}`}function sl(e){var s,a,c;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Ln(i)}`};case"filter_removed":return{summary:`Filter removed: ${Ln(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const l=n,p=i;return l!=null&&l.column&&(p!=null&&p.column)&&l.column!==p.column?{summary:`Filter changed on "${Nt(p.column)}"`,detail:`Previously filtered "${Nt(l.column)}"`}:{summary:`Filter updated: ${Ln(p)}`}}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?Nt(i.column):"",p=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:l?`Sort added: "${l}" ${p}`:"Sort level added"}}case"sort_level_removed":{const l=n!=null&&n.column?Nt(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: ${Di(i)}`};case"group_level_removed":{const l=n,p=(a=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&a.column?Nt(l.levels[0].column):"";return{summary:p?`Group level removed: "${p}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Di(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: "${Nt(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${Nt(l)}"`:"Column made visible"}}case"column_reordered":{const l=Array.isArray(n)?n:[],p=Array.isArray(i)?i:[];return l.length>0&&p.length>0?{summary:"Column order changed",detail:`${p.length} column${p.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const l=(i==null?void 0:i.column)??"",p=(i==null?void 0:i.width)??"";return{summary:l?`Column resized: "${Nt(l)}"`:"Column resized",detail:p?`New width: ${p}px`:void 0}}case"view_created":{const l=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:l?`View created: "${l}"`:"New view created"}}case"view_updated":{const l=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:l?`View updated: "${l}"`:"View updated"}}case"view_deleted":{const l=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:l?`View deleted: "${l}"`:"View deleted"}}case"view_set_default":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Default view set to "${l}"`:"Default view changed"}}case"view_switched":{const l=(n==null?void 0:n.name)??"",p=(i==null?void 0:i.name)??"";return l&&p?{summary:`Switched to view "${p}"`,detail:`From "${l}"`}:p?{summary:`Switched to view "${p}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":case"export_pdf":{const l=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",p=i==null?void 0:i.rowCount,x=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",y=(i==null?void 0:i.viewName)??"",g=typeof p=="number"?` (${p.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${g}`,detail:y?`${Qn(x)} · View: "${y}"`:Qn(x)}}case"export_triggered":{const l=((c=i==null?void 0:i.format)==null?void 0:c.toUpperCase())??"";return{summary:l?`Export triggered: ${l}`:"Export triggered"}}case"preset_created":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset created: "${l}"`:"New preset created"}}case"preset_applied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset applied: "${l}"`:"Preset applied"}}case"preset_deleted":{const l=(n==null?void 0:n.name)??"";return{summary:l?`Preset deleted: "${l}"`:"Preset deleted"}}case"preset_link_copied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset link copied: "${l}"`:"Preset link copied to clipboard"}}case"theme_changed":{const l=typeof n=="string"?n:(n==null?void 0:n.theme)??"",p=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return l&&p?{summary:`Theme changed from "${l}" to "${p}"`}:p?{summary:`Theme changed to "${p}"`}:{summary:"Theme changed"}}case"error_occurred":{const l=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:l?`Details: ${String(l).slice(0,120)}`:void 0}}default:return{summary:ll(r)}}}function al(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Is(e,r,n,i,s,a){return{id:al(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function Es(e,r){const n=[r,...e];return n.length>Ei?n.slice(0,Ei):n}function ll(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",error_occurred:"Error Occurred"}[e]||e}function cl(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[e]||e}function dl(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 $i=100;function ul(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function pl(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=ci(i,e.grouping||null,n);return{filters:Le(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 hl(e,r,n,i){return{id:ul(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function fl(e,r){const n=e||[];if(n.length>=$i)throw new Error(`Maximum of ${$i} presets reached. Please delete old presets first.`);return[...n,r]}function ml(e,r){return(e||[]).filter(i=>i.id!==r)}function _i(e,r){if(e)return e.find(n=>n.id===r)}function xl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function gl(e){const r=e.columnOrder,n=Co(r,e.grouping);return{filters:Le(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 yl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Lt.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){Lt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Lt.error("urm:presets","Fallback copy method failed",r),!1}}function bl(e,r){return{totalRows:e.length,totalColumns:r.length}}function ur(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:vl(e,r)};return process.env.NODE_ENV==="development"&&Lt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function vl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Sl(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 Cl(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 jl(e,r,n){n(e.id,{filters:Le(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function wl(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 Ds(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 $s(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 kl(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(p=>{if(Ye(p))return!0;const x=i.has(p.column);return x||n.push(`Filter for column "${p.column}" ignored (column not found)`),x}).map(p=>Ye(p)?a(p):p).filter(p=>!Ye(p)||p.children.length>0);return{...c,children:l}};s.filters=a(Le(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:c}=Ds(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}=$s(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 zl(e,r){return ur("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Oi(e,r,n,i){const s=Is(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Es(i||[],s)}function Tl(e){return e==null}function Bl(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(Tl(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)===String(s);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 Zn(e,r,n){var s;if(Ye(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>Zn(e,a,n)):r.children.some(a=>Zn(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return Bl(e[r.column],r,i)}function Il(e,r,n){return!r||r.children.length===0?e:e.filter(i=>Zn(i,r,n))}function rn(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 El(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Dl({data:e,filters:r,schema:n}){return{filteredData:f.useMemo(()=>!r||r.children.length===0?e:Il(e,r,n),[e,r,n])}}function $l(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 p=c[l.name];return p==null?!1:String(p).toLowerCase().includes(s)}))}function _l({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:f.useMemo(()=>s==="server"||!r||r.trim()===""?e:$l(e,n,r,i),[e,r,n,i,s])}}function Ol({data:e,sortStack:r,schema:n}){return{sortedData:f.useMemo(()=>!r||r.length===0?e:Wa(e,n,r),[e,r,n])}}function Ml({data:e,grouping:r,schema:n}){const i=f.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:La(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 Wl({schema:e,columnVisibility:r,columnOrder:n}){const i=f.useMemo(()=>n.filter(l=>r[l]!==!1),[n,r]),s=f.useMemo(()=>Object.entries(r).filter(([l,p])=>!p).map(([l,p])=>l),[r]),a=f.useMemo(()=>n.map(l=>e.find(x=>x.name===l)||{name:l,type:"string"}),[n,e]),c=f.useMemo(()=>i.map(l=>e.find(x=>x.name===l)||{name:l,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:c,hiddenCount:s.length}}function Al({views:e,activeViewId:r,currentState:n}){const i=f.useMemo(()=>e.find(x=>x.id===r),[e,r]),s=f.useMemo(()=>i?Ua(n,i.snapshot):!1,[i,n]),a=f.useMemo(()=>e.find(x=>x.isDefault),[e]),c=f.useMemo(()=>e.filter(x=>!x.isDefault&&!x.isDeleted),[e]),l=f.useMemo(()=>e.filter(x=>x.isFavorite&&!x.isDeleted),[e]),p=f.useMemo(()=>e.filter(x=>x.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:c,favoriteViews:l,deletedViews:p,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Rl(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 p={};let x=l+1;for(let g=r-1;g>=0;g--){const v=e[g];if(v.__isGroupHeader||v.isGroupHeader){const S=v.groupLevel??0;if(S<=l&&p[S]===void 0&&(p[S]=v,x--,x<=0))break}}const y=[];for(let g=0;g<=l;g++)p[g]&&y.push({...p[g],__urm_is_continuation_header__:!0});return[...y,...i]}function Pl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=f.useState(i),c=e.length,l=Math.max(1,Math.ceil(c/n));f.useEffect(()=>{s>l&&a(l)},[s,l]);const p=f.useMemo(()=>{if(!r)return e;const S=(s-1)*n,k=S+n;return Rl(e,S,k)},[e,r,s,n]),x=f.useCallback(S=>{const k=Math.max(1,Math.min(S,l));a(k)},[l]),y=f.useCallback(()=>{s<l&&a(S=>Math.min(S+1,l))},[l]),g=f.useCallback(()=>{s>1&&a(S=>Math.max(S-1,1))},[]),v=f.useCallback(()=>{a(1)},[]);return{paginatedData:p,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:x,nextPage:y,prevPage:g,resetPage:v,hasNextPage:s<l,hasPrevPage:s>1}}function Nl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:c,searchMode:l,columnVisibility:p,columnOrder:x,columnWidths:y,views:g,activeViewId:v,pagination:S}=e,k=f.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:p,columnOrder:x,columnWidths:y}),[i,s,a,p,x,y]),b=Al({views:g,activeViewId:v,currentState:k}),m=Wl({schema:n,columnVisibility:p,columnOrder:x}),{filteredData:z}=Dl({data:r,filters:i,schema:n}),{sortedData:h}=Ol({data:z,sortStack:s,schema:n}),{groupedData:B,isGrouped:T}=Ml({data:h,grouping:a,schema:n}),{searchedData:j}=_l({data:B,searchQuery:c,schema:n,visibleColumns:m.visibleColumns,mode:l}),P=Pl({data:j,enabled:(S==null?void 0:S.enabled)||!1,pageSize:(S==null?void 0:S.pageSize)||100,initialPage:(S==null?void 0:S.currentPage)||1}),_=S!=null&&S.enabled?P.paginatedData:j,M=f.useMemo(()=>({totalRows:r.length,filteredRows:z.length,sortedRows:h.length,groupedRows:T?B.length:h.length,searchedRows:j.length,visibleRows:_.length,hiddenColumns:m.hiddenCount,activeFilters:Ct(i),activeSorts:s.length,isGrouped:T}),[r.length,z.length,h.length,B.length,j.length,_.length,m.hiddenCount,i,s.length,T]);return{data:_,filteredData:z,sortedData:h,groupedData:B,searchedData:j,viewEngine:b,columnEngine:m,paginationEngine:P,metrics:M,isGrouped:T,isPaginated:(S==null?void 0:S.enabled)||!1}}let Ll=0;function Fl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):Ll++,writable:!1,enumerable:!1,configurable:!1})}const $t="user-demo-001";function Vl(e={}){var Po,yi,bi,vi,Si;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:c,scheduler:l,reportName:p,reportId:x,sharedReportId:y,sharedViewId:g,viewPersistence:v,config:S={}}=e,k=(v==null?void 0:v.mode)??"local",b=(a==null?void 0:a.mode)??"client",m=(c==null?void 0:c.mode)??"client",[z,h]=f.useState([]),B=Dr(),[T,j]=f.useState(""),[P,_]=f.useState(!1),[M,G]=f.useState(!1),[q,R]=f.useState({message:"",severity:"info",open:!1}),u=(w,D="info")=>{R({message:w,severity:D,open:!0})},A=()=>R(w=>({...w,open:!1})),F=S.notifDurationMs??2e3,d=z.find(w=>w.id===T),[ne,U]=f.useState("idle"),[re,xe]=f.useState(!1),[V,X]=f.useState(!1),[ae,le]=f.useState(!1),[ie,Q]=f.useState(!1),[de,I]=f.useState(!1),[te,he]=f.useState(void 0),[se,ze]=f.useState(null),[Y,We]=f.useState(null),[kt,dt]=f.useState(!1),[Or,Ot]=f.useState(!1),[ot,Ft]=f.useState(null),[qe,zt]=f.useState(!1),[fr,xt]=f.useState(!1),[tr,so]=f.useState({enabled:!1,levels:[],collapsedGroups:[]}),[rr,ao]=f.useState(""),[Tt,mr]=f.useState(""),[Je,Mt]=f.useState(new Set),[Vt,tt]=f.useState(1),[Qe,Wt]=f.useState(15),[lo,Mr]=f.useState(!1),[xr,Ve]=f.useState(!1),[ke,or]=f.useState(!1),[At,gr]=f.useState(null),[yr,Ht]=f.useState(!1),[nr,Ze]=f.useState(null),[ir,gt]=f.useState(null),Wr=f.useRef(null),ee=f.useMemo(()=>d?rl(d.permissions,$t):"owner",[d]),br=ol(ee),Ar=f.useMemo(()=>!(d!=null&&d.uploadedData)||!(d!=null&&d.schema)?{totalRows:0,totalColumns:0}:bl(d.uploadedData,d.schema),[d==null?void 0:d.uploadedData,d==null?void 0:d.schema]),Bt=f.useCallback(()=>{d&&(Wr.current=Cl(d))},[d]),H=f.useCallback((w,D)=>{h(W=>W.map(O=>O.id===w?{...O,...D}:O))},[]),ut=f.useCallback(w=>{if(!d)return;gt(w);const D=Oi(d.id,$t,w,d.auditHistory||[]);H(d.id,{auditHistory:D}),u(w.message,"error"),w.recoverable&&Wr.current&&setTimeout(()=>{jl(d,Wr.current,H),u("Previous state restored","success")},100)},[d,H]),we=f.useCallback((w,D,W,O)=>{if(!d)return;const J=Is(d.id,$t,w,D,W,O),K=d.auditHistory||[],ue=Es(K,J);setTimeout(()=>{H(d.id,{auditHistory:ue})},0)},[d,H]);f.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const w=Nn(d.schema);(()=>{try{const D=localStorage.getItem("urm_dev_config");return D?JSON.parse(D):null}catch{return null}})(),H(d.id,{views:[w],activeViewId:w.id,filters:w.snapshot.filters,sortStack:w.snapshot.sortStack,columnVisibility:w.snapshot.columnVisibility,columnOrder:w.snapshot.columnOrder,columnWidths:w.snapshot.columnWidths,grouping:w.snapshot.grouping})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,H]),f.useEffect(()=>{if(i&&n&&!M&&z.length===0){const w=So(i),D={id:x||`auto-report-${Date.now()}`,name:p||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:w,schema:wi(go(w),S.hiddenColumns),permissions:{owner:$t,editors:[],viewers:[]}};h([D]),j(D.id),G(!0),U("confirmed")}},[i,n,M,z.length,r,p,x]),f.useEffect(()=>{b!=="server"||!M||!T||H(T,{uploadedData:So(i||[])})},[i,b,M,T]),f.useEffect(()=>{b==="server"&&((a==null?void 0:a.page)!==void 0&&tt(a.page),(a==null?void 0:a.pageSize)!==void 0&&Wt(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,b]),f.useEffect(()=>{if(!s||M)return;let w=!1,D=null;const W=async()=>{try{U("uploading");let O;if(s.type==="api"){const K=await fetch(s.url,{headers:s.headers||{}});if(!K.ok)throw new Error(`HTTP ${K.status}: ${K.statusText}`);O=await K.json()}else O=await s.fetch();if(w)return;if(!Array.isArray(O))throw new Error("Data source must return an array of objects");const J=go(O);if(M)h(K=>K.map(ue=>ue.id===T?{...ue,uploadedData:O}:ue)),U("confirmed");else{const K={id:x||`auto-report-${Date.now()}`,name:p||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:So(O),schema:wi(go(So(O)),S.hiddenColumns),permissions:{owner:$t,editors:[],viewers:[]}};h([K]),j(K.id),G(!0),U("confirmed")}}catch(O){w||(U("error"),d&&H(d.id,{uploadError:(O==null?void 0:O.message)||"Failed to load data from source"}))}};return W(),s.refreshInterval&&s.refreshInterval>0&&(D=setInterval(W,s.refreshInterval)),()=>{w=!0,D&&clearInterval(D)}},[s,p,r,x]);const Ke=(Po=d==null?void 0:d.views)==null?void 0:Po.find(w=>w.id===d.activeViewId),sr=f.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(w=>Fl(w,S.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);f.useEffect(()=>{Mt(w=>{if(w.size===0)return w;const D=new Set(sr.map(O=>O==null?void 0:O.__urm_row_id__)),W=new Set(Array.from(w).filter(O=>D.has(O==null?void 0:O.__urm_row_id__)));return W.size===w.size?w:W})},[sr]);const vr=Nl({rawData:sr,schema:(d==null?void 0:d.schema)||[],filters:Le(d==null?void 0:d.filters),sortStack:(d==null?void 0:d.sortStack)||[],grouping:(d==null?void 0:d.grouping)||null,searchQuery:Tt||"",searchMode:m,columnVisibility:(d==null?void 0:d.columnVisibility)||(Ke==null?void 0:Ke.snapshot.columnVisibility)||{},columnOrder:(d==null?void 0:d.columnOrder)||(Ke==null?void 0:Ke.snapshot.columnOrder)||[],columnWidths:(d==null?void 0:d.columnWidths)||(Ke==null?void 0:Ke.snapshot.columnWidths)||{},views:(d==null?void 0:d.views)||[],activeViewId:(d==null?void 0:d.activeViewId)||"",pagination:{enabled:b==="client",pageSize:Qe,currentPage:Vt}}),{data:co=[],searchedData:Ut=[],groupedData:Sr=[],sortedData:Gt=[],metrics:ar={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Yt=!1,paginationEngine:be}=vr||{},yt=b==="server"?(a==null?void 0:a.totalRows)??0:ar.searchedRows,Z=((yi=vr.viewEngine)==null?void 0:yi.activeView)||Ke,pe=((bi=vr.viewEngine)==null?void 0:bi.isDirty)||!1;f.useEffect(()=>{if(!(!Z||!d)&&!d.columnOrder){const w=Z.snapshot.columnOrder,D=Co(w,Z.snapshot.grouping);H(d.id,{columnOrder:D})}},[d==null?void 0:d.activeViewId]);const ye=f.useMemo(()=>!(d!=null&&d.schema)||!Z?null:Ha(d.filters,d.sortStack||[],d.schema,d.columnVisibility,d.columnOrder,d.columnWidths,d.grouping,Z.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,Z]),Cr=f.useMemo(()=>!Z||!ye||!pe?[]:Ya(ye,Z.snapshot),[Z,ye,pe]),jr=f.useCallback((w,D,W)=>{const O={id:`report-${Date.now()}`,name:w,description:D,schemaLocked:!1,permissions:{owner:$t,editors:[],viewers:[]}};if(W&&Array.isArray(W)&&W.length>0){const J=go(W),K=Nn(J);O.uploadedData=W,O.schema=J,O.schemaLocked=!0,O.views=[K],O.activeViewId=K.id,O.sortStack=K.snapshot.sortStack,O.filters=K.snapshot.filters,O.columnVisibility=K.snapshot.columnVisibility,O.columnOrder=K.snapshot.columnOrder,O.columnWidths=K.snapshot.columnWidths,O.grouping=K.snapshot.grouping}h(J=>[...J,O]),j(O.id),_(!1),U("confirmed")},[]),uo=f.useCallback(w=>{d&&(U("uploading"),setTimeout(()=>{const D=go(w);H(d.id,{uploadedData:w,schema:D,uploadError:void 0}),U("preview")},500))},[d,H]),Rr=f.useCallback(w=>{d&&(H(d.id,{uploadError:w}),U("idle"))},[d,H]),po=f.useCallback(()=>{d&&(H(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),U("idle"))},[d,H]),qt=f.useCallback(()=>{d&&(H(d.id,{schemaLocked:!0}),U("confirmed"))},[d,H]),Pr=f.useCallback(w=>{if(!d)return;if(!bt("edit_sorting",ee)){u(vt("edit_sorting"),"error");return}const D=d.sortStack??[],W=D.find(O=>O.column===w);if(W){const O=Aa(W.direction);if(O===null){const J=D.filter(K=>K.column!==w).map((K,ue)=>({...K,priority:ue+1}));H(d.id,{sortStack:J.length>0?J:void 0})}else{const J=O,K=D.map(ue=>ue.column===w?{...ue,direction:J}:ue);H(d.id,{sortStack:K})}}else{if(D.length>=B.sort.maxLevels){u(`Sort limit reached — maximum ${B.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:w,direction:"asc",priority:D.length+1};H(d.id,{sortStack:[...D,O]})}},[d,ee,H]),Nr=f.useCallback(w=>{if(d)if(d.schema){const{validRules:D,invalidColumns:W}=Ds(w,d.schema);W.length>0&&u(`Removed invalid sort columns: ${W.join(", ")}`),Bt();try{H(d.id,{sortStack:D.length>0?D:void 0})}catch(O){const J=ur("processing","sorting",O);ut(J)}}else H(d.id,{sortStack:w.length>0?w:void 0})},[d,H,Bt,ut]),ve=f.useCallback(w=>{if(!d)return;const D=d.sortStack??[],W=D.find(O=>O.column===w);if(!(W&&W.direction==="asc"))if(W){const O=D.map(J=>J.column===w?{...J,direction:"asc"}:J);H(d.id,{sortStack:O})}else{if(D.length>=B.sort.maxLevels){u(`Sort limit reached — maximum ${B.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:w,direction:"asc",priority:D.length+1};H(d.id,{sortStack:[...D,O]})}},[d,H]),Ge=f.useCallback(w=>{if(!d)return;const D=d.sortStack??[],W=D.find(O=>O.column===w);if(!(W&&W.direction==="desc"))if(W){const O=D.map(J=>J.column===w?{...J,direction:"desc"}:J);H(d.id,{sortStack:O})}else{if(D.length>=B.sort.maxLevels){u(`Sort limit reached — maximum ${B.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:w,direction:"desc",priority:D.length+1};H(d.id,{sortStack:[...D,O]})}},[d,H]),wr=f.useCallback((w,D)=>{var O;if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const W=(O=d.schema)==null?void 0:O.find(J=>J.name===D.column);if(W&&D.value!==void 0){const J=wl(W.type,D.operator,D.value);if(!J.isValid){u(J.errorMessage||"Invalid filter value","error");return}}Bt();try{const J=Le(d.filters),K={...D,id:no()},ue=io(J,w,K);we("filters","filter_added",null,K),H(d.id,{filters:ue})}catch(J){const K=ur("processing","filters",J);ut(K)}},[d,ee,H,Bt,ut,we]),st=f.useCallback(w=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const D=Le(d.filters),W=io(D,w,_t());we("filters","filter_added",null,"a condition group"),H(d.id,{filters:W})},[d,ee,H,we]),Jt=f.useCallback((w,D)=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const W=Le(d.filters),O=qo(W,w),J=si(W,w,D),K=qo(J,w);we("filters","filter_updated",O,K),H(d.id,{filters:J})},[d,ee,H,we]),It=f.useCallback((w,D)=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const W=Le(d.filters),O=ai(W,w,D);we("filters","filter_updated",null,`group operator changed to ${D.toUpperCase()}`),H(d.id,{filters:O})},[d,ee,H,we]),kr=f.useCallback(w=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const D=Le(d.filters),W=qo(D,w),O=li(D,w);we("filters","filter_removed",W,null),H(d.id,{filters:O})},[d,ee,H,we]),me=f.useCallback(()=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const w=Le(d.filters);we("filters","filter_cleared",{count:Ct(w)},null),H(d.id,{filters:_t()})},[d,ee,H,we]),Se=f.useCallback(w=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const D=Le(d.filters);we("filters","filter_cleared",{count:Ct(D)},{count:Ct(w)}),H(d.id,{filters:w})},[d,ee,H,we]),Ne=f.useCallback(w=>{var J;if(!d)return;const D=(J=d.views)==null?void 0:J.find(K=>K.id===w);if(!D)return;const W=D.snapshot.columnOrder,O=Co(W,D.snapshot.grouping);H(d.id,{filters:D.snapshot.filters,sortStack:D.snapshot.sortStack.length>0?[...D.snapshot.sortStack]:void 0,columnVisibility:{...D.snapshot.columnVisibility},columnOrder:O,columnWidths:{...D.snapshot.columnWidths},grouping:D.snapshot.grouping,activeViewId:w}),Mt(new Set)},[d,H]),nt=f.useCallback((w,D,W)=>{var He;if(!(d!=null&&d.schema)||!ye)return;const O=d.views??[],J=O.filter(Pn=>!Pn.isDeleted).length,K=((He=B.views)==null?void 0:He.maxViews)??10;if(J>=K){u(`View limit reached — you can have at most ${K} saved views. Delete an existing view to create a new one.`,"error");return}const ue={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:w,description:D||void 0,isDefault:W,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:$t,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...ye}},je=W?O.map(Pn=>({...Pn,isDefault:!1})):O;H(d.id,{views:[...je,ue],activeViewId:ue.id}),u(`"${w}" view created`,"success")},[d,ye,H]),Et=f.useCallback(w=>{var ue;if(!(d!=null&&d.views))return;const D=d.views.find(je=>je.id===w);if(!D)return;const W=d.views,O=W.filter(je=>!je.isDeleted).length,J=((ue=B.views)==null?void 0:ue.maxViews)??10;if(O>=J){u(`View limit reached — you can have at most ${J} saved views. Delete an existing view to create a new one.`,"error");return}const K={...D,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${D.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:$t,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...D.snapshot}};H(d.id,{views:[...W,K]}),u(`"${K.name}" created`,"success")},[d,B,H]),zr=f.useCallback(()=>{var D;if(!Z||!ye||!d)return;const w=(D=d.views)==null?void 0:D.map(W=>W.id===Z.id?{...W,snapshot:{...ye}}:W);H(d.id,{views:w}),u(`"${Z.name}" view updated`,"success")},[Z,ye,d,H]),Lr=f.useCallback(w=>{var O;if(!Z||!ye||!d)return;const D=w??ye.columnWidths,W=(O=d.views)==null?void 0:O.map(J=>J.id===Z.id?{...J,snapshot:{...J.snapshot,columnVisibility:ye.columnVisibility,columnOrder:ye.columnOrder,columnWidths:D},updatedAt:Date.now()}:J);H(d.id,{views:W,columnWidths:D}),u(`Column configuration saved to "${Z.name}"`,"success")},[Z,ye,d,H]),Fr=f.useCallback(w=>{var K,ue;if(!ye||!d||!Z)return;const D=w??ye.columnWidths,W={...Z,snapshot:{...Z.snapshot,columnVisibility:ye.columnVisibility,columnOrder:ye.columnOrder,columnWidths:D},updatedAt:Date.now()},O=(K=d.views)==null?void 0:K.map(je=>je.id===Z.id?W:{...je,snapshot:{...je.snapshot,columnVisibility:ye.columnVisibility,columnOrder:ye.columnOrder,columnWidths:D},updatedAt:Date.now()});H(d.id,{views:O,columnWidths:D});const J=(((ue=d.views)==null?void 0:ue.length)||0)-1;u(`Column configuration saved to current view and ${J} other view${J===1?"":"s"}`,"success")},[ye,d,Z,H]),kn=f.useCallback(()=>{le(!0)},[]),Vr=f.useCallback(()=>{if(!Z||!d)return;const w=Z.snapshot.columnOrder,D=Co(w,Z.snapshot.grouping);H(d.id,{filters:Z.snapshot.filters,sortStack:Z.snapshot.sortStack.length>0?[...Z.snapshot.sortStack]:void 0,columnVisibility:{...Z.snapshot.columnVisibility},columnOrder:D,columnWidths:{...Z.snapshot.columnWidths},grouping:Z.snapshot.grouping}),u("Changes reverted to last saved state","success")},[Z,d,H]),ho=f.useCallback(w=>{if(!(d!=null&&d.views))return;const D=d.views.map(O=>({...O,isDefault:O.id===w}));H(d.id,{views:D});const W=d.views.find(O=>O.id===w);W&&u(`"${W.name}" set as default view`,"success")},[d,H]),zn=f.useCallback(w=>{if(!(d!=null&&d.views))return;const D=d.views.map(O=>O.id===w?{...O,isFavorite:!O.isFavorite,updatedAt:Date.now()}:O);H(d.id,{views:D});const W=d.views.find(O=>O.id===w);W&&!W.isFavorite?u(`"${W.name}" added to favorites`,"success"):W&&u(`"${W.name}" removed from favorites`,"info")},[d,H]),_o=f.useCallback(w=>{if(!(d!=null&&d.views))return;const D=d.views.find(He=>He.id===w),W=d.views.filter(He=>!He.isDeleted||He.id===w);if((D==null?void 0:D.isDefault)&&W.filter(He=>He.isDefault).length===1){u("Cannot delete the last default view","error");return}const J=d.views.map(He=>He.id===w?{...He,isDeleted:!0,updatedAt:Date.now()}:He),K=d.activeViewId===w,ue=J.find(He=>He.isDefault&&!He.isDeleted);H(d.id,{views:J,activeViewId:K&&ue?ue.id:d.activeViewId,filters:K&&ue?ue.snapshot.filters:d.filters,sortStack:K&&ue?ue.snapshot.sortStack.length>0?ue.snapshot.sortStack:void 0:d.sortStack});const je=d.views.find(He=>He.id===w);je&&u(`"${je.name}" moved to Recently Deleted`,"info")},[d,H]),Hr=f.useCallback(w=>{if(!(d!=null&&d.views))return;const D=d.views.map(O=>O.id===w?{...O,isDeleted:!1,updatedAt:Date.now()}:O);H(d.id,{views:D});const W=d.views.find(O=>O.id===w);W&&u(`"${W.name}" restored`,"success")},[d,H]),Oo=f.useCallback(w=>{if(!(d!=null&&d.views))return;const D=d.views.find(je=>je.id===w),W=d.views.filter(je=>!je.isDeleted||je.id===w);if((D==null?void 0:D.isDefault)&&W.filter(je=>je.isDefault).length===1){u("Cannot delete the last default view","error");return}const J=d.views.filter(je=>je.id!==w),K=d.activeViewId===w,ue=J.find(je=>je.isDefault&&!je.isDeleted);H(d.id,{views:J,activeViewId:K&&ue?ue.id:d.activeViewId,filters:K&&ue?ue.snapshot.filters:d.filters,sortStack:K&&ue?ue.snapshot.sortStack.length>0?ue.snapshot.sortStack:void 0:d.sortStack}),D&&u(`"${D.name}" permanently deleted`,"success")},[d,H]),Ur=f.useCallback(w=>{ze(w),Q(!0)},[]),Gr=f.useCallback(async w=>{if(!d)return;const D=new URLSearchParams(window.location.search);D.set("reportId",d.id),D.set("view",w);const W=`${window.location.origin}${window.location.pathname}?${D.toString()}`,O=await yl(W);u(O?"Link copied to clipboard":"Failed to copy link",O?"success":"error")},[d]),fo=f.useCallback((w,D)=>{if(!se||!(d!=null&&d.views))return;const W=d.views.map(O=>O.id===se?{...O,name:w,description:D||void 0}:O);H(d.id,{views:W}),ze(null)},[se,d,H]),Yr=f.useCallback(w=>{We(w),I(!0)},[]),qr=f.useCallback(()=>{if(!Y||!(d!=null&&d.views))return;const w=d.views.filter(O=>O.id!==Y),D=d.activeViewId===Y,W=w.find(O=>O.isDefault);H(d.id,{views:w,activeViewId:D&&W?W.id:d.activeViewId,filters:D&&W?W.snapshot.filters:d.filters,sortStack:D&&W?W.snapshot.sortStack.length>0?W.snapshot.sortStack:void 0:d.sortStack}),We(null),I(!1)},[Y,d,H]),lr=f.useCallback(w=>{var J;if(!(d!=null&&d.views))return;if(!(((J=B.views)==null?void 0:J.isAdmin)??!1)){u("Only administrators can promote views to Global.","error");return}const W=d.views.find(K=>K.id===w);if(!W)return;if(W.scope==="global"){u(`"${W.name}" is already a Global View.`,"info");return}const O=d.views.map(K=>K.id===w?{...K,scope:"global",isDefault:!0,updatedAt:Date.now()}:K.scope==="global"&&K.isDefault?{...K,isDefault:!1}:K);H(d.id,{views:O}),u(`"${W.name}" promoted to Global View and set as default.`,"success")},[d,B,H]),mo=f.useRef(!0);f.useEffect(()=>{var w;if(mo.current){mo.current=!1;return}if(b==="server"){tt(1),(w=a==null?void 0:a.onPaginationChange)==null||w.call(a,1,Qe);return}be!=null&&be.resetPage?be.resetPage():tt(1)},[d==null?void 0:d.filters,Tt,d==null?void 0:d.activeViewId,d==null?void 0:d.grouping]);const Jr=f.useCallback(w=>{var D;if(b==="server"){tt(w),(D=a==null?void 0:a.onPaginationChange)==null||D.call(a,w,Qe);return}be!=null&&be.goToPage&&be.goToPage(w),tt(w)},[b,a,Qe,be]),Tn=f.useCallback(w=>{var O;const D=(Vt-1)*Qe,W=Math.floor(D/w)+1;if(b==="server"){Wt(w),tt(W),(O=a==null?void 0:a.onPaginationChange)==null||O.call(a,W,w);return}Wt(w),tt(W),be==null||be.goToPage(W)},[Vt,Qe,b,a,be]),Bn=f.useCallback((w,D)=>{if(!d)return;if(!bt("edit_columns",ee)){u(vt("edit_columns"),"error");return}const O={...d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{},[w]:D};H(d.id,{columnVisibility:O})},[d,Z,ee,H]),In=f.useCallback(w=>{if(d){if(!bt("edit_columns",ee)){u(vt("edit_columns"),"error");return}H(d.id,{columnOrder:w})}},[d,ee,H]),En=f.useCallback((w,D)=>{if(!d)return;if(!bt("edit_columns",ee)){u(vt("edit_columns"),"error");return}const O={...d.columnWidths||(Z==null?void 0:Z.snapshot.columnWidths)||{},[w]:D};H(d.id,{columnWidths:O})},[d,Z,ee,H]),Dn=f.useCallback(w=>{if(!d)return;const D=Le(d.filters),W=zs(D,w);H(d.id,{filters:W})},[d,H]),$n=f.useCallback(()=>{if(!Z||!(d!=null&&d.schema))return;const w={},D=[],W={};d.schema.forEach(O=>{w[O.name]=!0,D.push(O.name),W[O.name]=170}),H(d.id,{columnVisibility:w,columnOrder:D,columnWidths:W,filters:void 0,sortStack:void 0}),u("Reset to default layout - all filters and sorts cleared","success")},[Z,d,H]);f.useEffect(()=>{const w=setTimeout(()=>mr(rr),300);return()=>clearTimeout(w)},[rr]),f.useEffect(()=>{var w;m==="server"&&((w=c==null?void 0:c.onSearchChange)==null||w.call(c,Tt))},[Tt,m,c]);const _n=f.useCallback(w=>{ao(w)},[]),On=f.useCallback(w=>{if(!w.trim()||!d)return;const D=d.searchHistory||[],W=Xa(D,w);H(d.id,{searchHistory:W})},[d,H]),Mn=f.useCallback(w=>{if(!d)return;const D=d.searchHistory||[],W=Qa(D,w);H(d.id,{searchHistory:W})},[d,H]),Kr=f.useCallback(w=>{if(!d)return;const D=d.searchHistory||[],W=Za(D,w);H(d.id,{searchHistory:W})},[d,H]);f.useEffect(()=>{if(!S.onSelectionChange)return;const w=Array.from(Je);S.onSelectionChange(w,w.map(D=>D==null?void 0:D.__urm_row_id__))},[Je,S.onSelectionChange]);const Kt=f.useCallback(w=>{const D=w==null?void 0:w.__urm_row_id__;Mt(W=>{const O=new Set(W);if(D!==void 0){const J=Array.from(O).find(K=>(K==null?void 0:K.__urm_row_id__)===D);J!==void 0?O.delete(J):O.add(w)}else{const J=JSON.stringify(w),K=Array.from(O).find(ue=>JSON.stringify(ue)===J);K!==void 0?O.delete(K):O.add(w)}return O})},[]),Wn=f.useCallback((w,D)=>{Mt(W=>{const O=new Set(W);for(const J of D)w?O.add(J):O.delete(J);return O})},[]),An=f.useCallback((w,D,W)=>{Mt(O=>{const J=new Set(O),K=Math.min(w,D),ue=Math.max(w,D);for(let je=K;je<=ue;je++)W[je]!==void 0&&J.add(W[je]);return J})},[]),Me=f.useCallback(()=>{Mt(new Set)},[]),at=f.useCallback(w=>{const D=w==null?void 0:w.__urm_row_id__;Mt(W=>{const O=new Set(W);if(D!==void 0){const J=Array.from(O).find(K=>(K==null?void 0:K.__urm_row_id__)===D);J!==void 0&&O.delete(J)}else O.delete(w);return O})},[]),xo=f.useCallback(w=>{var D,W;if(d){if(!bt("edit_columns",ee)){u(vt("edit_columns"),"error");return}if(w&&d.schema){const{validGrouping:O,invalidColumns:J}=$s(w,d.schema);J.length>0&&u(`Removed invalid grouping columns: ${J.join(", ")}`,"warning"),Bt();try{const K=d.grouping;O===null?we("grouping","group_cleared",K,null):K?we("grouping","group_reordered",K,O):we("grouping","group_level_added",null,O);const ue=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[],je=Co(ue,O),He=O.levels.length>0?{...O,collapsedGroups:zi(Gt,d.schema,O)}:O;H(d.id,{grouping:He,columnOrder:je}),tt(1),be==null||be.resetPage(),b==="server"&&((D=a==null?void 0:a.onPaginationChange)==null||D.call(a,1,Qe)),JSON.stringify(je)!==JSON.stringify(d.columnOrder)&&we("columns","column_reordered",d.columnOrder,je),xt(!1)}catch(K){const ue=ur("processing","grouping",K);ut(ue)}}else{const O=d.grouping;we("grouping","group_cleared",O,null);const J=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[];H(d.id,{grouping:w,columnOrder:J}),tt(1),be==null||be.resetPage(),b==="server"&&((W=a==null?void 0:a.onPaginationChange)==null||W.call(a,1,Qe)),JSON.stringify(J)!==JSON.stringify(d.columnOrder)&&we("columns","column_reordered",d.columnOrder,J),xt(!1)}}},[d,Z,ee,H,Bt,ut,we,Gt]),Mo=f.useCallback(w=>{if(!d)return;const D=d.grouping;if(!D)return;const W=Fa(D,w);H(d.id,{grouping:W})},[d,H]),Rn=f.useCallback(()=>{d!=null&&d.grouping&&H(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,H]),Dt=f.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema)return;const w=zi(Gt,d.schema,d.grouping);H(d.id,{grouping:{...d.grouping,collapsedGroups:w}})},[d,Gt,H]),Tr=f.useCallback(()=>{Ht(!0)},[]),pt=f.useCallback(w=>{d!=null&&d.schema&&(dt(!0),setTimeout(()=>{try{let D;w.scope==="visible"?D=Ut:D=d.uploadedData||[];let W;w.columnScope==="all"?(W={},(d.schema??[]).forEach(je=>{W[je.name]=!0})):W=d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{};const O=d.columnOrder||(Z==null?void 0:Z.snapshot.columnOrder),J=Qo(D,d.schema,Le(d.filters),d.sortStack??[],Z,W,O),K=d.name;let ue;switch(w.format){case"csv":Zo(J,K,w),ue="export_csv";break;case"excel":en(J,K,w),ue="export_excel";break;case"json":tn(J,K,w),ue="export_json";break;case"pdf":ui(J,K,w),ue="export_pdf";break}we("export",ue,null,{format:w.format,scope:w.scope,columnScope:w.columnScope,rowCount:D.length,viewName:(Z==null?void 0:Z.name)||"Default View"}),u(`Export completed successfully (${w.format.toUpperCase()})`,"success")}catch(D){const W=zl(D,{onRetry:()=>pt(w)});u(`Export failed: ${W.message}. Click Export to retry.`,"error");const O=Oi(d.id,$t,W,d.auditHistory||[]);H(d.id,{auditHistory:O}),Lt.error("urm:report-engine","Export failed",D)}finally{dt(!1)}},500))},[d,Z,Ut,H,we]),Wo=f.useCallback(w=>{if(d!=null&&d.schema){if(pe&&Z&&!Z.isDefault){Ft(w.format),Ot(!0),Ht(!1);return}pt(w),Ht(!1)}},[d,Z,pe,pt]),Xr=f.useCallback(w=>{pt({format:w,scope:"visible",columnScope:"visible"})},[pt]),Ao=f.useCallback(()=>{ot&&Xr(ot),Ot(!1),Ft(null)},[ot,Xr]),Ro=f.useCallback(()=>{zr(),ot&&Xr(ot),Ot(!1),Ft(null)},[zr,ot,Xr]),C=f.useCallback(()=>{Ot(!1),Ft(null)},[]),N=f.useCallback(w=>{!(d!=null&&d.schema)||Je.size===0||(dt(!0),setTimeout(()=>{try{const D=Array.from(Je),W=Qo(D,d.schema,Le(d.filters),d.sortStack??[],Z),O=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(w){case"csv":Zo(W,O);break;case"excel":en(W,O);break;case"json":tn(W,O);break}u(`Exported ${D.length} selected rows`,"info")}catch(D){u("Export failed. Please try again.","error"),Lt.error("urm:report-engine","Bulk export failed",D)}finally{dt(!1)}},500))},[d,Z,Je,Sr]),oe=f.useCallback((w,D)=>{if(d)try{const W=pl(d),O=hl(w,D,$t,W),J=fl(d.presets,O);H(d.id,{presets:J}),we("presets","preset_created",null,{presetId:O.id,name:O.name}),Ve(!1),u(`Preset "${w}" saved successfully`,"success")}catch(W){u(W instanceof Error?W.message:"Failed to create preset","error")}},[d,H,we]),Ce=f.useCallback(()=>{gr(null),u("Exited preset view","info")},[]),Ae=f.useCallback(()=>{or(!0)},[]),rt=f.useCallback((w,D)=>{if(!d)return;const W=ml(d.presets,w);H(d.id,{presets:W}),we("presets","preset_deleted",{presetId:w,name:D},null),At===w&&gr(null),u(`Preset "${D}" deleted`,"success")},[d,At,H,we]);f.useEffect(()=>{if(!y||z.length===0)return;const w=z.find(D=>D.id===y);w&&w.id!==T&&j(w.id)},[y,z,T]);const Xe=f.useRef(!1);f.useEffect(()=>{var D;if(!g||Xe.current||!d||d.id!==y)return;const w=(D=d.views)==null?void 0:D.find(W=>W.id===g&&!W.isDeleted);w&&Ne(w.id),Xe.current=!0},[g,y,d,Ne]),f.useEffect(()=>{if(!d)return;const w=xl();if(w&&d.presets&&d.schemaLocked&&d.schema){const D=_i(d.presets,w);if(D){const{sanitizedConfig:W,warnings:O}=kl(D.config,d.schema);O.length>0&&O.forEach(K=>u(K,"warning"));const J=gl(W);H(d.id,J),gr(w),we("presets","preset_applied",null,{presetId:D.id,name:D.name}),u(`Loaded preset: ${D.name}`,"info")}else u("Preset not found","info")}},[d==null?void 0:d.schemaLocked]);const fe=At?_i(d==null?void 0:d.presets,At):void 0;f.useEffect(()=>{var w;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&(k==="api"?(w=v==null?void 0:v.onViewsChange)==null||w.call(v,d.views,d.activeViewId):qa(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,k]),f.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const w=k==="api"?v!=null&&v.views&&v.views.length>0?{views:v.views,activeViewId:v.activeViewId??v.views[0].id}:null:Ja(d.id);if(w&&w.views.length>0){const D=w.views.find(W=>W.id===w.activeViewId);if(D)H(d.id,{views:w.views,activeViewId:w.activeViewId,filters:Le(D.snapshot.filters),sortStack:D.snapshot.sortStack.length>0?D.snapshot.sortStack:void 0});else{const W=w.views.find(O=>O.isDefault)||Nn(d.schema);H(d.id,{views:w.views,activeViewId:W.id,filters:Le(W.snapshot.filters),sortStack:W.snapshot.sortStack.length>0?W.snapshot.sortStack:void 0})}}}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,k,v]);const Rt=f.useCallback(w=>{var O;const D=Le(d==null?void 0:d.filters),W=((O=B.filter)==null?void 0:O.maxConditions)??3;if(Ct(D)>=W){u(`Filter limit reached — maximum ${W} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}he(w),xe(!0)},[d,B,u]),Xt=f.useCallback(()=>{xe(!1),he(void 0)},[]),_e=(vi=d==null?void 0:d.views)==null?void 0:vi.find(w=>w.id===se),cr=(Si=d==null?void 0:d.views)==null?void 0:Si.find(w=>w.id===Y);return{reports:z,activeReport:d,activeReportId:T,setActiveReportId:j,isModalOpen:P,setIsModalOpen:_,createReport:jr,updateReport:H,uploadState:ne,handleFileUpload:uo,handleUploadError:Rr,handleRetry:po,handleConfirm:qt,paginatedData:co,processedData:Ut,displayData:Sr,tableMetrics:ar,isGrouped:Yt,tableEngine:vr,activeView:Z,isDirty:pe,currentTableState:ye,viewChanges:Cr,filters:d==null?void 0:d.filters,showFilterPanel:re,setShowFilterPanel:xe,filterFocusColumn:te,handleAddCondition:wr,handleAddGroup:st,handleUpdateCondition:Jt,handleSetGroupOperator:It,handleRemoveFilterNode:kr,handleClearAllFilters:me,handleReplaceFilters:Se,handleOpenFilterForColumn:Rt,handleCloseFilterPanel:Xt,handleClearFiltersForColumn:Dn,sortStack:d==null?void 0:d.sortStack,showSortPanel:V,setShowSortPanel:X,handleSort:Pr,handleUpdateSortStack:Nr,handleSortAscending:ve,handleSortDescending:Ge,views:d==null?void 0:d.views,showCreateViewModal:ae,setShowCreateViewModal:le,showEditViewModal:ie,setShowEditViewModal:Q,showDeleteConfirmation:de,setShowDeleteConfirmation:I,editingView:_e,deletingView:cr,editingViewId:se,deletingViewId:Y,handleSelectView:Ne,handleCreateView:nt,handleCloneView:Et,handleUpdateCurrentView:zr,handleSaveColumnConfigToCurrentView:Lr,handleSaveColumnConfigToAllViews:Fr,handleSaveAsNewView:kn,handleRevertChanges:Vr,handleToggleDefault:ho,handleToggleFavorite:zn,handleSoftDelete:_o,handleRestoreView:Hr,handlePermanentDelete:Oo,handleEditView:Ur,handleCopyViewLink:Gr,handleSaveEditView:fo,handleDeleteView:Yr,handleConfirmDelete:qr,handlePromoteToGlobal:lr,showManageColumns:qe,setShowManageColumns:zt,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:Bn,handleUpdateColumnOrder:In,handleUpdateColumnWidth:En,handleResetColumnLayout:$n,showGroupPanel:fr,setShowGroupPanel:xt,grouping:d==null?void 0:d.grouping,groupingState:tr,handleGroup:xo,handleToggleGroupCollapse:Mo,handleExpandAllGroups:Rn,handleCollapseAllGroups:Dt,searchQuery:rr,debouncedSearchQuery:Tt,searchHistory:el((d==null?void 0:d.searchHistory)||[]),handleSearchChange:_n,handleAddToSearchHistory:On,handleToggleSearchFavourite:Mn,handleDeleteSearchHistory:Kr,selectedRowIds:Je,handleToggleRowSelection:Kt,handleToggleAllRows:Wn,handleRangeSelection:An,handleClearSelection:Me,handleUpdateSelectionAfterDelete:at,currentPage:Vt,pageSize:Qe,paginationEngine:be,paginationMode:b,paginationTotalRows:yt,handlePageChange:Jr,handlePageSizeChange:Tn,isExporting:kt,showExportModal:yr,setShowExportModal:Ht,showDirtyExportWarning:Or,handleExport:Tr,handleExportWithConfig:Wo,handleExportSelected:N,handleExportAnyway:Ao,handleSaveAndExport:Ro,handleCancelExport:C,showAuditHistory:lo,setShowAuditHistory:Mr,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:xr,setShowCreatePreset:Ve,showManagePresets:ke,setShowManagePresets:or,activePreset:fe,activePresetId:At,handleOpenManagePresets:Ae,handleCreatePreset:oe,handleClearActivePreset:Ce,handleDeletePresetById:rt,userRole:ee,isViewerRole:br,currentUserId:$t,featureLimitWarning:nr,setFeatureLimitWarning:Ze,datasetMeta:Ar,reportError:ir,setReportError:gt,handleError:ut,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?Oa(d.schema):!1,snack:q,handleSnackClose:A,showSnack:u,snackDurationMs:F,config:S,scheduler:l}}const _s=f.createContext(void 0);function pi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:c,pagination:l,search:p,scheduler:x,mode:y="builder",autoLoad:g=!0,config:v,devConfig:S,showDevPanel:k=!1,sharedReportId:b,sharedViewId:m,viewPersistence:z}=e,B=Vl({mode:y,autoLoad:g,initialData:i||n,dataSource:c,pagination:l,search:p,scheduler:x,reportName:s,reportId:a,sharedReportId:b,sharedViewId:m,viewPersistence:z,config:v}),[T,j]=f.useState(()=>xa()),P=(()=>{const q=ya(T,S,!!S);return{...q,display:{...q.display,showDevPanel:k||q.display.showDevPanel}}})(),_=f.useCallback(G=>{j(G),ga(G)},[]),M={...B,activeDevConfig:P,handleDevConfigChange:_};return t.jsx(Cs.Provider,{value:P,children:t.jsx(_s.Provider,{value:M,children:r})})}function cn(){const e=f.useContext(_s);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Hl({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 y,g,v;const c=((v=(g=(y=a.components)==null?void 0:y.MuiCardHeader)==null?void 0:g.styleOverrides)==null?void 0:v.root)||{},l=c.backgroundColor&&c.backgroundColor!=="transparent"?c.backgroundColor:a.palette.background.paper,p=c.borderBottom&&c.borderBottom!=="none"?c.borderBottom:"1px solid",x=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:p,borderColor:p!=="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($.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($.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($.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function Er(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 Ul="$$material";function Gl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fo={exports:{}},Vo={exports:{}},Te={};/** @license React v16.13.1
105
+ </html>`;try{const m=document.createElement("iframe");m.style.position="fixed",m.style.right="0",m.style.bottom="0",m.style.width="0",m.style.height="0",m.style.border="0",document.body.appendChild(m);const z=((b=m.contentWindow)==null?void 0:b.document)||m.contentDocument;if(z){z.open(),z.write(g),z.close(),setTimeout(()=>{var h,B;try{(h=m.contentWindow)==null||h.focus(),(B=m.contentWindow)==null||B.print()}catch{}setTimeout(()=>{document.body.removeChild(m)},3e3)},300);return}}catch{}const v=new Blob([g],{type:"text/html;charset=utf-8;"}),S=URL.createObjectURL(v);window.open(S,"_blank")||di(g,sn(r,"html"),"text/html;charset=utf-8;")}function Po(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Ei=10;function Qa(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>Ei&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Ei)),s}function Za(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function el(e,r){return e.filter(n=>n.query!==r)}function tl(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 rl={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 ol(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function bt(e,r){return rl[r].includes(e)}function vt(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 nl(e){return e==="viewer"}const Di=1e3;function Qn(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Ut(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return Qn(n)}const il={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 sl(e){if(!e||!e.column)return"a filter";const r=Ut(e.column),n=il[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function Ln(e){return e?typeof e=="string"?e:"children"in e?"a condition group":sl(e):"a filter"}function $i(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${Ut(n.column)}"`).join(", ")}`}function al(e){var s,a,c;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Ln(i)}`};case"filter_removed":return{summary:`Filter removed: ${Ln(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const l=n,p=i;return l!=null&&l.column&&(p!=null&&p.column)&&l.column!==p.column?{summary:`Filter changed on "${Ut(p.column)}"`,detail:`Previously filtered "${Ut(l.column)}"`}:{summary:`Filter updated: ${Ln(p)}`}}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?Ut(i.column):"",p=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:l?`Sort added: "${l}" ${p}`:"Sort level added"}}case"sort_level_removed":{const l=n!=null&&n.column?Ut(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: ${$i(i)}`};case"group_level_removed":{const l=n,p=(a=(s=l==null?void 0:l.levels)==null?void 0:s[0])!=null&&a.column?Ut(l.levels[0].column):"";return{summary:p?`Group level removed: "${p}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${$i(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: "${Ut(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${Ut(l)}"`:"Column made visible"}}case"column_reordered":{const l=Array.isArray(n)?n:[],p=Array.isArray(i)?i:[];return l.length>0&&p.length>0?{summary:"Column order changed",detail:`${p.length} column${p.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const l=(i==null?void 0:i.column)??"",p=(i==null?void 0:i.width)??"";return{summary:l?`Column resized: "${Ut(l)}"`:"Column resized",detail:p?`New width: ${p}px`:void 0}}case"view_created":{const l=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:l?`View created: "${l}"`:"New view created"}}case"view_updated":{const l=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:l?`View updated: "${l}"`:"View updated"}}case"view_deleted":{const l=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:l?`View deleted: "${l}"`:"View deleted"}}case"view_set_default":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Default view set to "${l}"`:"Default view changed"}}case"view_switched":{const l=(n==null?void 0:n.name)??"",p=(i==null?void 0:i.name)??"";return l&&p?{summary:`Switched to view "${p}"`,detail:`From "${l}"`}:p?{summary:`Switched to view "${p}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":case"export_pdf":{const l=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",p=i==null?void 0:i.rowCount,x=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",y=(i==null?void 0:i.viewName)??"",g=typeof p=="number"?` (${p.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${g}`,detail:y?`${Qn(x)} · View: "${y}"`:Qn(x)}}case"export_triggered":{const l=((c=i==null?void 0:i.format)==null?void 0:c.toUpperCase())??"";return{summary:l?`Export triggered: ${l}`:"Export triggered"}}case"preset_created":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset created: "${l}"`:"New preset created"}}case"preset_applied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset applied: "${l}"`:"Preset applied"}}case"preset_deleted":{const l=(n==null?void 0:n.name)??"";return{summary:l?`Preset deleted: "${l}"`:"Preset deleted"}}case"preset_link_copied":{const l=(i==null?void 0:i.name)??"";return{summary:l?`Preset link copied: "${l}"`:"Preset link copied to clipboard"}}case"theme_changed":{const l=typeof n=="string"?n:(n==null?void 0:n.theme)??"",p=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return l&&p?{summary:`Theme changed from "${l}" to "${p}"`}:p?{summary:`Theme changed to "${p}"`}:{summary:"Theme changed"}}case"error_occurred":{const l=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:l?`Details: ${String(l).slice(0,120)}`:void 0}}default:return{summary:cl(r)}}}function ll(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Es(e,r,n,i,s,a){return{id:ll(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function Ds(e,r){const n=[r,...e];return n.length>Di?n.slice(0,Di):n}function cl(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",error_occurred:"Error Occurred"}[e]||e}function dl(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[e]||e}function ul(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 _i=100;function pl(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function hl(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=ci(i,e.grouping||null,n);return{filters:Ne(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 fl(e,r,n,i){return{id:pl(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function ml(e,r){const n=e||[];if(n.length>=_i)throw new Error(`Maximum of ${_i} presets reached. Please delete old presets first.`);return[...n,r]}function xl(e,r){return(e||[]).filter(i=>i.id!==r)}function Oi(e,r){if(e)return e.find(n=>n.id===r)}function gl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function yl(e){const r=e.columnOrder,n=Co(r,e.grouping);return{filters:Ne(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 bl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Gt.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){Gt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Gt.error("urm:presets","Fallback copy method failed",r),!1}}function vl(e,r){return{totalRows:e.length,totalColumns:r.length}}function hr(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:Sl(e,r)};return process.env.NODE_ENV==="development"&&Gt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function Sl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Cl(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 jl(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 wl(e,r,n){n(e.id,{filters:Ne(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function kl(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 $s(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 _s(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 zl(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(p=>{if(qe(p))return!0;const x=i.has(p.column);return x||n.push(`Filter for column "${p.column}" ignored (column not found)`),x}).map(p=>qe(p)?a(p):p).filter(p=>!qe(p)||p.children.length>0);return{...c,children:l}};s.filters=a(Ne(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:c}=$s(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}=_s(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 Tl(e,r){return hr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Mi(e,r,n,i){const s=Es(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Ds(i||[],s)}function Bl(e){return e==null}function Il(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(Bl(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 Zn(e,r,n){var s;if(qe(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>Zn(e,a,n)):r.children.some(a=>Zn(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return Il(e[r.column],r,i)}function El(e,r,n){return!r||r.children.length===0?e:e.filter(i=>Zn(i,r,n))}function en(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 Dl(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function $l({data:e,filters:r,schema:n}){return{filteredData:f.useMemo(()=>!r||r.children.length===0?e:El(e,r,n),[e,r,n])}}function _l(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 p=c[l.name];return p==null?!1:String(p).toLowerCase().includes(s)}))}function Ol({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:f.useMemo(()=>s==="server"||!r||r.trim()===""?e:_l(e,n,r,i),[e,r,n,i,s])}}function Ml({data:e,sortStack:r,schema:n}){return{sortedData:f.useMemo(()=>!r||r.length===0?e:Aa(e,n,r),[e,r,n])}}function Wl({data:e,grouping:r,schema:n}){const i=f.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:Fa(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 Al({schema:e,columnVisibility:r,columnOrder:n}){const i=f.useMemo(()=>n.filter(l=>r[l]!==!1),[n,r]),s=f.useMemo(()=>Object.entries(r).filter(([l,p])=>!p).map(([l,p])=>l),[r]),a=f.useMemo(()=>n.map(l=>e.find(x=>x.name===l)||{name:l,type:"string"}),[n,e]),c=f.useMemo(()=>i.map(l=>e.find(x=>x.name===l)||{name:l,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:c,hiddenCount:s.length}}function Rl({views:e,activeViewId:r,currentState:n}){const i=f.useMemo(()=>e.find(x=>x.id===r),[e,r]),s=f.useMemo(()=>i?Ga(n,i.snapshot):!1,[i,n]),a=f.useMemo(()=>e.find(x=>x.isDefault),[e]),c=f.useMemo(()=>e.filter(x=>!x.isDefault&&!x.isDeleted),[e]),l=f.useMemo(()=>e.filter(x=>x.isFavorite&&!x.isDeleted),[e]),p=f.useMemo(()=>e.filter(x=>x.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:c,favoriteViews:l,deletedViews:p,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Pl(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 p={};let x=l+1;for(let g=r-1;g>=0;g--){const v=e[g];if(v.__isGroupHeader||v.isGroupHeader){const S=v.groupLevel??0;if(S<=l&&p[S]===void 0&&(p[S]=v,x--,x<=0))break}}const y=[];for(let g=0;g<=l;g++)p[g]&&y.push({...p[g],__urm_is_continuation_header__:!0});return[...y,...i]}function Nl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=f.useState(i),c=e.length,l=Math.max(1,Math.ceil(c/n));f.useEffect(()=>{s>l&&a(l)},[s,l]);const p=f.useMemo(()=>{if(!r)return e;const S=(s-1)*n,k=S+n;return Pl(e,S,k)},[e,r,s,n]),x=f.useCallback(S=>{const k=Math.max(1,Math.min(S,l));a(k)},[l]),y=f.useCallback(()=>{s<l&&a(S=>Math.min(S+1,l))},[l]),g=f.useCallback(()=>{s>1&&a(S=>Math.max(S-1,1))},[]),v=f.useCallback(()=>{a(1)},[]);return{paginatedData:p,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:x,nextPage:y,prevPage:g,resetPage:v,hasNextPage:s<l,hasPrevPage:s>1}}function Ll(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:c,searchMode:l,columnVisibility:p,columnOrder:x,columnWidths:y,views:g,activeViewId:v,pagination:S}=e,k=f.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:p,columnOrder:x,columnWidths:y}),[i,s,a,p,x,y]),b=Rl({views:g,activeViewId:v,currentState:k}),m=Al({schema:n,columnVisibility:p,columnOrder:x}),{filteredData:z}=$l({data:r,filters:i,schema:n}),{sortedData:h}=Ml({data:z,sortStack:s,schema:n}),{groupedData:B,isGrouped:T}=Wl({data:h,grouping:a,schema:n}),{searchedData:w}=Ol({data:B,searchQuery:c,schema:n,visibleColumns:m.visibleColumns,mode:l}),P=Nl({data:w,enabled:(S==null?void 0:S.enabled)||!1,pageSize:(S==null?void 0:S.pageSize)||100,initialPage:(S==null?void 0:S.currentPage)||1}),O=S!=null&&S.enabled?P.paginatedData:w,M=f.useMemo(()=>({totalRows:r.length,filteredRows:z.length,sortedRows:h.length,groupedRows:T?B.length:h.length,searchedRows:w.length,visibleRows:O.length,hiddenColumns:m.hiddenCount,activeFilters:Ct(i),activeSorts:s.length,isGrouped:T}),[r.length,z.length,h.length,B.length,w.length,O.length,m.hiddenCount,i,s.length,T]);return{data:O,filteredData:z,sortedData:h,groupedData:B,searchedData:w,viewEngine:b,columnEngine:m,paginationEngine:P,metrics:M,isGrouped:T,isPaginated:(S==null?void 0:S.enabled)||!1}}let Fl=0;function Vl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):Fl++,writable:!1,enumerable:!1,configurable:!1})}const Mt="user-demo-001";function Hl(e={}){var yi,bi,vi,Si,Ci;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:c,scheduler:l,reportName:p,reportId:x,sharedReportId:y,sharedViewId:g,viewPersistence:v,config:S={}}=e,k=(v==null?void 0:v.mode)??"local",b=(a==null?void 0:a.mode)??"client",m=(c==null?void 0:c.mode)??"client",[z,h]=f.useState([]),B=_r(),[T,w]=f.useState(""),[P,O]=f.useState(!1),[M,q]=f.useState(!1),[K,R]=f.useState({message:"",severity:"info",open:!1}),u=(j,E="info")=>{R({message:j,severity:E,open:!0})},A=()=>R(j=>({...j,open:!1})),F=S.notifDurationMs??2e3,d=z.find(j=>j.id===T),[oe,G]=f.useState("idle"),[te,xe]=f.useState(!1),[H,Q]=f.useState(!1),[le,ce]=f.useState(!1),[ie,Z]=f.useState(!1),[ue,I]=f.useState(!1),[ee,fe]=f.useState(void 0),[se,ke]=f.useState(null),[J,We]=f.useState(null),[kt,ht]=f.useState(!1),[Wr,At]=f.useState(!1),[it,Yt]=f.useState(null),[Je,zt]=f.useState(!1),[xr,gt]=f.useState(!1),[nr,lo]=f.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Rt,co]=f.useState(""),[yt,gr]=f.useState(""),[Ke,Pt]=f.useState(new Set),[Tt,Xe]=f.useState(1),Bt=f.useRef(null),[rt,yr]=f.useState(15),[Ar,br]=f.useState(!1),[He,Ce]=f.useState(!1),[vr,Sr]=f.useState(!1),[qt,Jt]=f.useState(null),[Rr,It]=f.useState(!1),[Qe,ir]=f.useState(null),[Et,uo]=f.useState(null),pe=f.useRef(null),je=f.useMemo(()=>d?ol(d.permissions,Mt):"owner",[d]),Pr=nl(je),Nr=f.useMemo(()=>!(d!=null&&d.uploadedData)||!(d!=null&&d.schema)?{totalRows:0,totalColumns:0}:vl(d.uploadedData,d.schema),[d==null?void 0:d.uploadedData,d==null?void 0:d.schema]),Nt=f.useCallback(()=>{d&&(pe.current=jl(d))},[d]),V=f.useCallback((j,E)=>{h(W=>W.map(_=>_.id===j?{..._,...E}:_))},[]),Dt=f.useCallback(j=>{if(!d)return;uo(j);const E=Mi(d.id,Mt,j,d.auditHistory||[]);V(d.id,{auditHistory:E}),u(j.message,"error"),j.recoverable&&pe.current&&setTimeout(()=>{wl(d,pe.current,V),u("Previous state restored","success")},100)},[d,V]),ne=f.useCallback((j,E,W,_)=>{if(!d)return;const Y=Es(d.id,Mt,j,E,W,_),X=d.auditHistory||[],ae=Ds(X,Y);setTimeout(()=>{V(d.id,{auditHistory:ae})},0)},[d,V]);f.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const j=Nn(d.schema);(()=>{try{const E=localStorage.getItem("urm_dev_config");return E?JSON.parse(E):null}catch{return null}})(),V(d.id,{views:[j],activeViewId:j.id,filters:j.snapshot.filters,sortStack:j.snapshot.sortStack,columnVisibility:j.snapshot.columnVisibility,columnOrder:j.snapshot.columnOrder,columnWidths:j.snapshot.columnWidths,grouping:j.snapshot.grouping})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,V]),f.useEffect(()=>{if(i&&n&&!M&&z.length===0){const j=no(i),E={id:x||`auto-report-${Date.now()}`,name:p||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:j,schema:ki(yo(j),S.hiddenColumns),permissions:{owner:Mt,editors:[],viewers:[]}};h([E]),w(E.id),q(!0),G("confirmed")}},[i,n,M,z.length,r,p,x]),f.useEffect(()=>{b!=="server"||!M||!T||V(T,{uploadedData:no(i||[])})},[i,b,M,T]),f.useEffect(()=>{b==="server"&&((a==null?void 0:a.page)!==void 0&&Xe(a.page),(a==null?void 0:a.pageSize)!==void 0&&yr(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,b]),f.useEffect(()=>{if(!s||M)return;let j=!1,E=null;const W=async()=>{try{G("uploading");let _;if(s.type==="api"){const X=await fetch(s.url,{headers:s.headers||{}});if(!X.ok)throw new Error(`HTTP ${X.status}: ${X.statusText}`);_=await X.json()}else _=await s.fetch();if(j)return;if(!Array.isArray(_))throw new Error("Data source must return an array of objects");const Y=yo(_);if(M)h(X=>X.map(ae=>ae.id===T?{...ae,uploadedData:no(_)}:ae)),G("confirmed");else{const X={id:x||`auto-report-${Date.now()}`,name:p||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:no(_),schema:ki(yo(no(_)),S.hiddenColumns),permissions:{owner:Mt,editors:[],viewers:[]}};h([X]),w(X.id),q(!0),G("confirmed")}}catch(_){j||(G("error"),d&&V(d.id,{uploadError:(_==null?void 0:_.message)||"Failed to load data from source"}))}};return W(),s.refreshInterval&&s.refreshInterval>0&&(E=setInterval(W,s.refreshInterval)),()=>{j=!0,E&&clearInterval(E)}},[s,p,r,x]);const st=(yi=d==null?void 0:d.views)==null?void 0:yi.find(j=>j.id===d.activeViewId),Lr=f.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(j=>Vl(j,S.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);f.useEffect(()=>{Pt(j=>{if(j.size===0)return j;const E=new Set(Lr.map(_=>_==null?void 0:_.__urm_row_id__)),W=new Set(Array.from(j).filter(_=>E.has(_==null?void 0:_.__urm_row_id__)));return W.size===j.size?j:W})},[Lr]);const sr=Ll({rawData:Lr,schema:(d==null?void 0:d.schema)||[],filters:Ne(d==null?void 0:d.filters),sortStack:(d==null?void 0:d.sortStack)||[],grouping:(d==null?void 0:d.grouping)||null,searchQuery:yt||"",searchMode:m,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:b==="client",pageSize:rt,currentPage:Tt}}),{data:Cr=[],searchedData:ar=[],groupedData:jr=[],sortedData:Lt=[],metrics:Ft={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:ot=!1,paginationEngine:we}=sr||{},lt=b==="server"?(a==null?void 0:a.totalRows)??0:Ft.searchedRows,U=((bi=sr.viewEngine)==null?void 0:bi.activeView)||st,Ue=((vi=sr.viewEngine)==null?void 0:vi.isDirty)||!1;f.useEffect(()=>{if(!(!U||!d)&&!d.columnOrder){const j=U.snapshot.columnOrder,E=Co(j,U.snapshot.grouping);V(d.id,{columnOrder:E})}},[d==null?void 0:d.activeViewId]);const Ee=f.useMemo(()=>!(d!=null&&d.schema)||!U?null:Ua(d.filters,d.sortStack||[],d.schema,d.columnVisibility,d.columnOrder,d.columnWidths,d.grouping,U.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,U]),wr=f.useMemo(()=>!U||!Ee||!Ue?[]:qa(Ee,U.snapshot),[U,Ee,Ue]),po=f.useCallback((j,E,W)=>{const _={id:`report-${Date.now()}`,name:j,description:E,schemaLocked:!1,permissions:{owner:Mt,editors:[],viewers:[]}};if(W&&Array.isArray(W)&&W.length>0){const Y=yo(W),X=Nn(Y);_.uploadedData=W,_.schema=Y,_.schemaLocked=!0,_.views=[X],_.activeViewId=X.id,_.sortStack=X.snapshot.sortStack,_.filters=X.snapshot.filters,_.columnVisibility=X.snapshot.columnVisibility,_.columnOrder=X.snapshot.columnOrder,_.columnWidths=X.snapshot.columnWidths,_.grouping=X.snapshot.grouping}h(Y=>[...Y,_]),w(_.id),O(!1),G("confirmed")},[]),Fr=f.useCallback(j=>{d&&(G("uploading"),setTimeout(()=>{const E=yo(j);V(d.id,{uploadedData:j,schema:E,uploadError:void 0}),G("preview")},500))},[d,V]),ho=f.useCallback(j=>{d&&(V(d.id,{uploadError:j}),G("idle"))},[d,V]),Kt=f.useCallback(()=>{d&&(V(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),G("idle"))},[d,V]),Vr=f.useCallback(()=>{d&&(V(d.id,{schemaLocked:!0}),G("confirmed"))},[d,V]),Hr=f.useCallback(j=>{if(!d)return;if(!bt("edit_sorting",je)){u(vt("edit_sorting"),"error");return}const E=d.sortStack??[],W=E.find(_=>_.column===j);if(W){const _=Ra(W.direction);if(_===null){const Y=E.filter(X=>X.column!==j).map((X,ae)=>({...X,priority:ae+1}));ne("sorting","sort_level_removed",W,null),V(d.id,{sortStack:Y.length>0?Y:void 0})}else{const Y=_,X=E.map(ae=>ae.column===j?{...ae,direction:Y}:ae);ne("sorting","sort_reordered",{column:j,direction:W.direction},{column:j,direction:Y}),V(d.id,{sortStack:X})}}else{if(E.length>=B.sort.maxLevels){u(`Sort limit reached — maximum ${B.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const _={column:j,direction:"asc",priority:E.length+1};ne("sorting","sort_level_added",null,_),V(d.id,{sortStack:[...E,_]})}},[d,je,V,ne]),ye=f.useCallback(j=>{if(!d)return;const E=d.sortStack??[],W=j.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:_,invalidColumns:Y}=$s(j,d.schema);Y.length>0&&u(`Removed invalid sort columns: ${Y.join(", ")}`),Nt();try{ne("sorting",W,E,_.length>0?_:null),V(d.id,{sortStack:_.length>0?_:void 0})}catch(X){const ae=hr("processing","sorting",X);Dt(ae)}}else ne("sorting",W,E,j.length>0?j:null),V(d.id,{sortStack:j.length>0?j:void 0})},[d,V,Nt,Dt,ne]),Ge=f.useCallback(j=>{if(!d)return;const E=d.sortStack??[],W=E.find(_=>_.column===j);if(!(W&&W.direction==="asc"))if(W){const _=E.map(Y=>Y.column===j?{...Y,direction:"asc"}:Y);ne("sorting","sort_reordered",{column:j,direction:W.direction},{column:j,direction:"asc"}),V(d.id,{sortStack:_})}else{if(E.length>=B.sort.maxLevels){u(`Sort limit reached — maximum ${B.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const _={column:j,direction:"asc",priority:E.length+1};ne("sorting","sort_level_added",null,_),V(d.id,{sortStack:[...E,_]})}},[d,V,ne]),kr=f.useCallback(j=>{if(!d)return;const E=d.sortStack??[],W=E.find(_=>_.column===j);if(!(W&&W.direction==="desc"))if(W){const _=E.map(Y=>Y.column===j?{...Y,direction:"desc"}:Y);ne("sorting","sort_reordered",{column:j,direction:W.direction},{column:j,direction:"desc"}),V(d.id,{sortStack:_})}else{if(E.length>=B.sort.maxLevels){u(`Sort limit reached — maximum ${B.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const _={column:j,direction:"desc",priority:E.length+1};ne("sorting","sort_level_added",null,_),V(d.id,{sortStack:[...E,_]})}},[d,V,ne]),ct=f.useCallback((j,E)=>{var _;if(!d)return;if(!bt("edit_filters",je)){u(vt("edit_filters"),"error");return}const W=(_=d.schema)==null?void 0:_.find(Y=>Y.name===E.column);if(W&&E.value!==void 0){const Y=kl(W.type,E.operator,E.value);if(!Y.isValid){u(Y.errorMessage||"Invalid filter value","error");return}}Nt();try{const Y=Ne(d.filters),X={...E,id:so()},ae=ao(Y,j,X);ne("filters","filter_added",null,X),V(d.id,{filters:ae})}catch(Y){const X=hr("processing","filters",Y);Dt(X)}},[d,je,V,Nt,Dt,ne]),Xt=f.useCallback(j=>{if(!d)return;if(!bt("edit_filters",je)){u(vt("edit_filters"),"error");return}const E=Ne(d.filters),W=ao(E,j,Wt());ne("filters","filter_added",null,"a condition group"),V(d.id,{filters:W})},[d,je,V,ne]),$t=f.useCallback((j,E)=>{if(!d)return;if(!bt("edit_filters",je)){u(vt("edit_filters"),"error");return}const W=Ne(d.filters),_=Go(W,j),Y=si(W,j,E),X=Go(Y,j);ne("filters","filter_updated",_,X),V(d.id,{filters:Y})},[d,je,V,ne]),zr=f.useCallback((j,E)=>{if(!d)return;if(!bt("edit_filters",je)){u(vt("edit_filters"),"error");return}const W=Ne(d.filters),_=ai(W,j,E);ne("filters","filter_updated",null,`group operator changed to ${E.toUpperCase()}`),V(d.id,{filters:_})},[d,je,V,ne]),me=f.useCallback(j=>{if(!d)return;if(!bt("edit_filters",je)){u(vt("edit_filters"),"error");return}const E=Ne(d.filters),W=Go(E,j),_=li(E,j);ne("filters","filter_removed",W,null),V(d.id,{filters:_})},[d,je,V,ne]),be=f.useCallback(()=>{if(!d)return;if(!bt("edit_filters",je)){u(vt("edit_filters"),"error");return}const j=Ne(d.filters);ne("filters","filter_cleared",{count:Ct(j)},null),V(d.id,{filters:Wt()})},[d,je,V,ne]),Ye=f.useCallback(j=>{if(!d)return;if(!bt("edit_filters",je)){u(vt("edit_filters"),"error");return}const E=Ne(d.filters);ne("filters","filter_cleared",{count:Ct(E)},{count:Ct(j)}),V(d.id,{filters:j})},[d,je,V,ne]),Ze=f.useCallback(j=>{var Y;if(!d)return;const E=(Y=d.views)==null?void 0:Y.find(X=>X.id===j);if(!E)return;const W=E.snapshot.columnOrder,_=Co(W,E.snapshot.grouping);ne("views","view_switched",{previousViewId:d.activeViewId},{viewId:j,name:E.name}),V(d.id,{filters:E.snapshot.filters,sortStack:E.snapshot.sortStack.length>0?[...E.snapshot.sortStack]:void 0,columnVisibility:{...E.snapshot.columnVisibility},columnOrder:_,columnWidths:{...E.snapshot.columnWidths},grouping:E.snapshot.grouping,activeViewId:j}),Pt(new Set)},[d,V,ne]),_t=f.useCallback((j,E,W)=>{var Fe;if(!(d!=null&&d.schema)||!Ee)return;const _=d.views??[],Y=_.filter(Pn=>!Pn.isDeleted).length,X=((Fe=B.views)==null?void 0:Fe.maxViews)??10;if(Y>=X){u(`View limit reached — you can have at most ${X} 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:j,description:E||void 0,isDefault:W,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Ee}},Se=W?_.map(Pn=>({...Pn,isDefault:!1})):_;ne("views","view_created",null,{viewId:ae.id,name:j,isDefault:W}),V(d.id,{views:[...Se,ae],activeViewId:ae.id}),u(`"${j}" view created`,"success")},[d,Ee,V,ne]),fo=f.useCallback(j=>{var ae;if(!(d!=null&&d.views))return;const E=d.views.find(Se=>Se.id===j);if(!E)return;const W=d.views,_=W.filter(Se=>!Se.isDeleted).length,Y=((ae=B.views)==null?void 0:ae.maxViews)??10;if(_>=Y){u(`View limit reached — you can have at most ${Y} saved views. Delete an existing view to create a new one.`,"error");return}const X={...E,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${E.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...E.snapshot}};V(d.id,{views:[...W,X]}),u(`"${X.name}" created`,"success")},[d,B,V]),lr=f.useCallback(()=>{var E;if(!U||!Ee||!d)return;const j=(E=d.views)==null?void 0:E.map(W=>W.id===U.id?{...W,snapshot:{...Ee}}:W);V(d.id,{views:j}),u(`"${U.name}" view updated`,"success")},[U,Ee,d,V]),Ur=f.useCallback(j=>{var _;if(!U||!Ee||!d)return;const E=j??Ee.columnWidths,W=(_=d.views)==null?void 0:_.map(Y=>Y.id===U.id?{...Y,snapshot:{...Y.snapshot,columnVisibility:Ee.columnVisibility,columnOrder:Ee.columnOrder,columnWidths:E},updatedAt:Date.now()}:Y);V(d.id,{views:W,columnWidths:E}),u(`Column configuration saved to "${U.name}"`,"success")},[U,Ee,d,V]),jn=f.useCallback(j=>{var X,ae;if(!Ee||!d||!U)return;const E=j??Ee.columnWidths,W={...U,snapshot:{...U.snapshot,columnVisibility:Ee.columnVisibility,columnOrder:Ee.columnOrder,columnWidths:E},updatedAt:Date.now()},_=(X=d.views)==null?void 0:X.map(Se=>Se.id===U.id?W:{...Se,snapshot:{...Se.snapshot,columnVisibility:Ee.columnVisibility,columnOrder:Ee.columnOrder,columnWidths:E},updatedAt:Date.now()});V(d.id,{views:_,columnWidths:E});const Y=(((ae=d.views)==null?void 0:ae.length)||0)-1;u(`Column configuration saved to current view and ${Y} other view${Y===1?"":"s"}`,"success")},[Ee,d,U,V]),Gr=f.useCallback(()=>{ce(!0)},[]),mo=f.useCallback(()=>{if(!U||!d)return;const j=U.snapshot.columnOrder,E=Co(j,U.snapshot.grouping);V(d.id,{filters:U.snapshot.filters,sortStack:U.snapshot.sortStack.length>0?[...U.snapshot.sortStack]:void 0,columnVisibility:{...U.snapshot.columnVisibility},columnOrder:E,columnWidths:{...U.snapshot.columnWidths},grouping:U.snapshot.grouping}),u("Changes reverted to last saved state","success")},[U,d,V]),wn=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.map(_=>({..._,isDefault:_.id===j}));V(d.id,{views:E});const W=d.views.find(_=>_.id===j);W&&u(`"${W.name}" set as default view`,"success")},[d,V]),_o=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.map(_=>_.id===j?{..._,isFavorite:!_.isFavorite,updatedAt:Date.now()}:_);V(d.id,{views:E});const W=d.views.find(_=>_.id===j);W&&!W.isFavorite?u(`"${W.name}" added to favorites`,"success"):W&&u(`"${W.name}" removed from favorites`,"info")},[d,V]),Yr=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.find(Fe=>Fe.id===j),W=d.views.filter(Fe=>!Fe.isDeleted||Fe.id===j);if((E==null?void 0:E.isDefault)&&W.filter(Fe=>Fe.isDefault).length===1){u("Cannot delete the last default view","error");return}const Y=d.views.map(Fe=>Fe.id===j?{...Fe,isDeleted:!0,updatedAt:Date.now()}:Fe),X=d.activeViewId===j,ae=Y.find(Fe=>Fe.isDefault&&!Fe.isDeleted);V(d.id,{views:Y,activeViewId:X&&ae?ae.id:d.activeViewId,filters:X&&ae?ae.snapshot.filters:d.filters,sortStack:X&&ae?ae.snapshot.sortStack.length>0?ae.snapshot.sortStack:void 0:d.sortStack});const Se=d.views.find(Fe=>Fe.id===j);Se&&u(`"${Se.name}" moved to Recently Deleted`,"info")},[d,V]),Oo=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.map(_=>_.id===j?{..._,isDeleted:!1,updatedAt:Date.now()}:_);V(d.id,{views:E});const W=d.views.find(_=>_.id===j);W&&u(`"${W.name}" restored`,"success")},[d,V]),qr=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.find(Se=>Se.id===j),W=d.views.filter(Se=>!Se.isDeleted||Se.id===j);if((E==null?void 0:E.isDefault)&&W.filter(Se=>Se.isDefault).length===1){u("Cannot delete the last default view","error");return}const Y=d.views.filter(Se=>Se.id!==j),X=d.activeViewId===j,ae=Y.find(Se=>Se.isDefault&&!Se.isDeleted);V(d.id,{views:Y,activeViewId:X&&ae?ae.id:d.activeViewId,filters:X&&ae?ae.snapshot.filters:d.filters,sortStack:X&&ae?ae.snapshot.sortStack.length>0?ae.snapshot.sortStack:void 0:d.sortStack}),E&&u(`"${E.name}" permanently deleted`,"success")},[d,V]),Jr=f.useCallback(j=>{ke(j),Z(!0)},[]),xo=f.useCallback(async j=>{if(!d)return;const E=new URLSearchParams(window.location.search);E.set("reportId",d.id),E.set("view",j);const W=`${window.location.origin}${window.location.pathname}?${E.toString()}`,_=await bl(W);u(_?"Link copied to clipboard":"Failed to copy link",_?"success":"error")},[d]),Kr=f.useCallback((j,E)=>{if(!se||!(d!=null&&d.views))return;const W=d.views.map(_=>_.id===se?{..._,name:j,description:E||void 0}:_);V(d.id,{views:W}),ke(null)},[se,d,V]),Xr=f.useCallback(j=>{We(j),I(!0)},[]),cr=f.useCallback(()=>{if(!J||!(d!=null&&d.views))return;const j=d.views.find(Y=>Y.id===J),E=d.views.filter(Y=>Y.id!==J),W=d.activeViewId===J,_=E.find(Y=>Y.isDefault);ne("views","view_deleted",{viewId:J,name:j==null?void 0:j.name},null),V(d.id,{views:E,activeViewId:W&&_?_.id:d.activeViewId,filters:W&&_?_.snapshot.filters:d.filters,sortStack:W&&_?_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0:d.sortStack}),We(null),I(!1)},[J,d,V,ne]),Mo=f.useCallback(j=>{var Y;if(!(d!=null&&d.views))return;if(!(((Y=B.views)==null?void 0:Y.isAdmin)??!1)){u("Only administrators can promote views to Global.","error");return}const W=d.views.find(X=>X.id===j);if(!W)return;if(W.scope==="global"){u(`"${W.name}" is already a Global View.`,"info");return}const _=d.views.map(X=>X.id===j?{...X,scope:"global",isDefault:!0,updatedAt:Date.now()}:X.scope==="global"&&X.isDefault?{...X,isDefault:!1}:X);V(d.id,{views:_}),u(`"${W.name}" promoted to Global View and set as default.`,"success")},[d,B,V]),Tr=f.useRef(!0);f.useEffect(()=>{var j;if(Tr.current){Tr.current=!1;return}if(b==="server"){Xe(1),(j=a==null?void 0:a.onPaginationChange)==null||j.call(a,1,rt);return}we!=null&&we.resetPage?we.resetPage():Xe(1)},[d==null?void 0:d.filters,yt,d==null?void 0:d.activeViewId,d==null?void 0:d.grouping]);const kn=f.useCallback(j=>{var E;if(b==="server"){Xe(j),(E=a==null?void 0:a.onPaginationChange)==null||E.call(a,j,rt);return}we!=null&&we.goToPage&&we.goToPage(j),Xe(j)},[b,a,rt,we]),zn=f.useCallback(j=>{var _;const E=(Tt-1)*rt,W=Math.floor(E/j)+1;if(b==="server"){yr(j),Xe(W),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,W,j);return}yr(j),Xe(W),we==null||we.goToPage(W)},[Tt,rt,b,a,we]),Tn=f.useCallback((j,E)=>{if(!d)return;if(!bt("edit_columns",je)){u(vt("edit_columns"),"error");return}const _={...d.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{},[j]:E};ne("columns",E?"column_shown":"column_hidden",{columnName:j,visible:!E},{columnName:j,visible:E}),V(d.id,{columnVisibility:_})},[d,U,je,V,ne]),Bn=f.useCallback(j=>{if(d){if(!bt("edit_columns",je)){u(vt("edit_columns"),"error");return}ne("columns","column_reordered",d.columnOrder,j),V(d.id,{columnOrder:j})}},[d,je,V,ne]),In=f.useCallback((j,E)=>{if(!d)return;if(!bt("edit_columns",je)){u(vt("edit_columns"),"error");return}const W=d.columnWidths||(U==null?void 0:U.snapshot.columnWidths)||{},_={...W,[j]:E};ne("columns","column_resized",{columnName:j,width:W[j]},{columnName:j,width:E}),V(d.id,{columnWidths:_})},[d,U,je,V,ne]),En=f.useCallback(j=>{if(!d)return;const E=Ne(d.filters),W=Ts(E,j);V(d.id,{filters:W})},[d,V]),Dn=f.useCallback(()=>{if(!U||!(d!=null&&d.schema))return;const j={},E=[],W={};yt&&!Rt&&(Bt.current=Tt),d.schema.forEach(_=>{j[_.name]=!0,E.push(_.name),W[_.name]=170}),V(d.id,{columnVisibility:j,columnOrder:E,columnWidths:W,filters:void 0,sortStack:void 0}),u("Reset to default layout - all filters and sorts cleared","success")},[U,d,V]);f.useEffect(()=>{const j=setTimeout(()=>gr(Rt),300);return()=>clearTimeout(j)},[Rt]),f.useEffect(()=>{var j;m==="server"&&((j=c==null?void 0:c.onSearchChange)==null||j.call(c,yt))},[yt,m,c]);const $n=f.useCallback(j=>{co(j),j?Xe(1):(Xe(Bt.current??1),Bt.current=null)},[Rt,Tt]),_n=f.useCallback(j=>{if(!j.trim()||!d)return;const E=d.searchHistory||[],W=Qa(E,j);V(d.id,{searchHistory:W})},[d,V]),Qr=f.useCallback(j=>{if(!d)return;const E=d.searchHistory||[],W=Za(E,j);V(d.id,{searchHistory:W})},[d,V]),Qt=f.useCallback(j=>{if(!d)return;const E=d.searchHistory||[],W=el(E,j);V(d.id,{searchHistory:W})},[d,V]);f.useEffect(()=>{if(!S.onSelectionChange)return;const j=Array.from(Ke);S.onSelectionChange(j,j.map(E=>E==null?void 0:E.__urm_row_id__))},[Ke,S.onSelectionChange]);const On=f.useCallback(j=>{const E=j==null?void 0:j.__urm_row_id__;Pt(W=>{const _=new Set(W);if(E!==void 0){const Y=Array.from(_).find(X=>(X==null?void 0:X.__urm_row_id__)===E);Y!==void 0?_.delete(Y):_.add(j)}else{const Y=JSON.stringify(j),X=Array.from(_).find(ae=>JSON.stringify(ae)===Y);X!==void 0?_.delete(X):_.add(j)}return _})},[]),Mn=f.useCallback((j,E)=>{Pt(W=>{const _=new Set(W);for(const Y of E)j?_.add(Y):_.delete(Y);return _})},[]),Me=f.useCallback((j,E,W)=>{Pt(_=>{const Y=new Set(_),X=Math.min(j,E),ae=Math.max(j,E);for(let Se=X;Se<=ae;Se++)W[Se]!==void 0&&Y.add(W[Se]);return Y})},[]),dt=f.useCallback(()=>{Pt(new Set)},[]),go=f.useCallback(j=>{const E=j==null?void 0:j.__urm_row_id__;Pt(W=>{const _=new Set(W);if(E!==void 0){const Y=Array.from(_).find(X=>(X==null?void 0:X.__urm_row_id__)===E);Y!==void 0&&_.delete(Y)}else _.delete(j);return _})},[]),Wo=f.useCallback(j=>{var E,W;if(d){if(!bt("edit_columns",je)){u(vt("edit_columns"),"error");return}if(j&&d.schema){const{validGrouping:_,invalidColumns:Y}=_s(j,d.schema);Y.length>0&&u(`Removed invalid grouping columns: ${Y.join(", ")}`,"warning"),Nt();try{const X=d.grouping;_===null?ne("grouping","group_cleared",X,null):X?ne("grouping","group_reordered",X,_):ne("grouping","group_level_added",null,_);const ae=(U==null?void 0:U.snapshot.columnOrder)||d.columnOrder||[],Se=Co(ae,_),Fe=_.levels.length>0?{..._,collapsedGroups:Ti(Lt,d.schema,_)}:_;V(d.id,{grouping:Fe,columnOrder:Se}),Xe(1),we==null||we.resetPage(),b==="server"&&((E=a==null?void 0:a.onPaginationChange)==null||E.call(a,1,rt)),JSON.stringify(Se)!==JSON.stringify(d.columnOrder)&&ne("columns","column_reordered",d.columnOrder,Se),gt(!1)}catch(X){const ae=hr("processing","grouping",X);Dt(ae)}}else{const _=d.grouping;ne("grouping","group_cleared",_,null);const Y=(U==null?void 0:U.snapshot.columnOrder)||d.columnOrder||[];V(d.id,{grouping:j,columnOrder:Y}),Xe(1),we==null||we.resetPage(),b==="server"&&((W=a==null?void 0:a.onPaginationChange)==null||W.call(a,1,rt)),JSON.stringify(Y)!==JSON.stringify(d.columnOrder)&&ne("columns","column_reordered",d.columnOrder,Y),gt(!1)}}},[d,U,je,V,Nt,Dt,ne,Lt]),Wn=f.useCallback(j=>{if(!d)return;const E=d.grouping;if(!E)return;const W=Va(E,j);V(d.id,{grouping:W})},[d,V]),Ot=f.useCallback(()=>{d!=null&&d.grouping&&V(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,V]),Br=f.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema)return;const j=Ti(Lt,d.schema,d.grouping);V(d.id,{grouping:{...d.grouping,collapsedGroups:j}})},[d,Lt,V]),Zt=f.useCallback(()=>{It(!0)},[]),dr=f.useCallback(j=>{d!=null&&d.schema&&(ht(!0),setTimeout(()=>{try{let E;j.scope==="visible"?E=ar:E=d.uploadedData||[];let W;j.columnScope==="all"?(W={},(d.schema??[]).forEach(Se=>{W[Se.name]=!0})):W=d.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{};const _=d.columnOrder||(U==null?void 0:U.snapshot.columnOrder),Y=Ko(E,d.schema,Ne(d.filters),d.sortStack??[],U,W,_),X=d.name;let ae;switch(j.format){case"csv":Xo(Y,X,j),ae="export_csv";break;case"excel":Qo(Y,X,j),ae="export_excel";break;case"json":Zo(Y,X,j),ae="export_json";break;case"pdf":ui(Y,X,j),ae="export_pdf";break}ne("export",ae,null,{format:j.format,scope:j.scope,columnScope:j.columnScope,rowCount:E.length,viewName:(U==null?void 0:U.name)||"Default View"}),u(`Export completed successfully (${j.format.toUpperCase()})`,"success")}catch(E){const W=Tl(E,{onRetry:()=>dr(j)});u(`Export failed: ${W.message}. Click Export to retry.`,"error");const _=Mi(d.id,Mt,W,d.auditHistory||[]);V(d.id,{auditHistory:_}),Gt.error("urm:report-engine","Export failed",E)}finally{ht(!1)}},500))},[d,U,ar,V,ne]),An=f.useCallback(j=>{if(d!=null&&d.schema){if(Ue&&U&&!U.isDefault){Yt(j.format),At(!0),It(!1);return}dr(j),It(!1)}},[d,U,Ue,dr]),Ir=f.useCallback(j=>{dr({format:j,scope:"visible",columnScope:"visible"})},[dr]),Ao=f.useCallback(()=>{it&&Ir(it),At(!1),Yt(null)},[it,Ir]),C=f.useCallback(()=>{lr(),it&&Ir(it),At(!1),Yt(null)},[lr,it,Ir]),N=f.useCallback(()=>{At(!1),Yt(null)},[]),re=f.useCallback(j=>{!(d!=null&&d.schema)||Ke.size===0||(ht(!0),setTimeout(()=>{try{const E=Array.from(Ke),W=Ko(E,d.schema,Ne(d.filters),d.sortStack??[],U),_=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(j){case"csv":Xo(W,_);break;case"excel":Qo(W,_);break;case"json":Zo(W,_);break}u(`Exported ${E.length} selected rows`,"info")}catch(E){u("Export failed. Please try again.","error"),Gt.error("urm:report-engine","Bulk export failed",E)}finally{ht(!1)}},500))},[d,U,Ke,jr]),ve=f.useCallback((j,E)=>{if(d)try{const W=hl(d),_=fl(j,E,Mt,W),Y=ml(d.presets,_);V(d.id,{presets:Y}),ne("presets","preset_created",null,{presetId:_.id,name:_.name}),Ce(!1),u(`Preset "${j}" saved successfully`,"success")}catch(W){u(W instanceof Error?W.message:"Failed to create preset","error")}},[d,V,ne]),Ae=f.useCallback(()=>{Jt(null),u("Exited preset view","info")},[]),nt=f.useCallback(()=>{Sr(!0)},[]),et=f.useCallback((j,E)=>{if(!d)return;const W=xl(d.presets,j);V(d.id,{presets:W}),ne("presets","preset_deleted",{presetId:j,name:E},null),qt===j&&Jt(null),u(`Preset "${E}" deleted`,"success")},[d,qt,V,ne]);f.useEffect(()=>{if(!y||z.length===0)return;const j=z.find(E=>E.id===y);j&&j.id!==T&&w(j.id)},[y,z,T]);const he=f.useRef(!1);f.useEffect(()=>{var E;if(!g||he.current||!d||d.id!==y)return;const j=(E=d.views)==null?void 0:E.find(W=>W.id===g&&!W.isDeleted);j&&Ze(j.id),he.current=!0},[g,y,d,Ze]),f.useEffect(()=>{if(!d)return;const j=gl();if(j&&d.presets&&d.schemaLocked&&d.schema){const E=Oi(d.presets,j);if(E){const{sanitizedConfig:W,warnings:_}=zl(E.config,d.schema);_.length>0&&_.forEach(X=>u(X,"warning"));const Y=yl(W);V(d.id,Y),Jt(j),ne("presets","preset_applied",null,{presetId:E.id,name:E.name}),u(`Loaded preset: ${E.name}`,"info")}else u("Preset not found","info")}},[d==null?void 0:d.schemaLocked]);const Vt=qt?Oi(d==null?void 0:d.presets,qt):void 0;f.useEffect(()=>{var j;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&(k==="api"?(j=v==null?void 0:v.onViewsChange)==null||j.call(v,d.views,d.activeViewId):Ja(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,k]),f.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const j=k==="api"?v!=null&&v.views&&v.views.length>0?{views:v.views,activeViewId:v.activeViewId??v.views[0].id}:null:Ka(d.id);if(j&&j.views.length>0){const E=j.views.find(W=>W.id===j.activeViewId);if(E)V(d.id,{views:j.views,activeViewId:j.activeViewId,filters:Ne(E.snapshot.filters),sortStack:E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0});else{const W=j.views.find(_=>_.isDefault)||Nn(d.schema);V(d.id,{views:j.views,activeViewId:W.id,filters:Ne(W.snapshot.filters),sortStack:W.snapshot.sortStack.length>0?W.snapshot.sortStack:void 0})}}}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,k,v]);const er=f.useCallback(j=>{var _;const E=Ne(d==null?void 0:d.filters),W=((_=B.filter)==null?void 0:_.maxConditions)??3;if(Ct(E)>=W){u(`Filter limit reached — maximum ${W} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}fe(j),xe(!0)},[d,B,u]),_e=f.useCallback(()=>{xe(!1),fe(void 0)},[]),ur=(Si=d==null?void 0:d.views)==null?void 0:Si.find(j=>j.id===se),Rn=(Ci=d==null?void 0:d.views)==null?void 0:Ci.find(j=>j.id===J);return{reports:z,activeReport:d,activeReportId:T,setActiveReportId:w,isModalOpen:P,setIsModalOpen:O,createReport:po,updateReport:V,uploadState:oe,handleFileUpload:Fr,handleUploadError:ho,handleRetry:Kt,handleConfirm:Vr,paginatedData:Cr,processedData:ar,displayData:jr,tableMetrics:Ft,isGrouped:ot,tableEngine:sr,activeView:U,isDirty:Ue,currentTableState:Ee,viewChanges:wr,filters:d==null?void 0:d.filters,showFilterPanel:te,setShowFilterPanel:xe,filterFocusColumn:ee,handleAddCondition:ct,handleAddGroup:Xt,handleUpdateCondition:$t,handleSetGroupOperator:zr,handleRemoveFilterNode:me,handleClearAllFilters:be,handleReplaceFilters:Ye,handleOpenFilterForColumn:er,handleCloseFilterPanel:_e,handleClearFiltersForColumn:En,sortStack:d==null?void 0:d.sortStack,showSortPanel:H,setShowSortPanel:Q,handleSort:Hr,handleUpdateSortStack:ye,handleSortAscending:Ge,handleSortDescending:kr,views:d==null?void 0:d.views,showCreateViewModal:le,setShowCreateViewModal:ce,showEditViewModal:ie,setShowEditViewModal:Z,showDeleteConfirmation:ue,setShowDeleteConfirmation:I,editingView:ur,deletingView:Rn,editingViewId:se,deletingViewId:J,handleSelectView:Ze,handleCreateView:_t,handleCloneView:fo,handleUpdateCurrentView:lr,handleSaveColumnConfigToCurrentView:Ur,handleSaveColumnConfigToAllViews:jn,handleSaveAsNewView:Gr,handleRevertChanges:mo,handleToggleDefault:wn,handleToggleFavorite:_o,handleSoftDelete:Yr,handleRestoreView:Oo,handlePermanentDelete:qr,handleEditView:Jr,handleCopyViewLink:xo,handleSaveEditView:Kr,handleDeleteView:Xr,handleConfirmDelete:cr,handlePromoteToGlobal:Mo,showManageColumns:Je,setShowManageColumns:zt,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:Tn,handleUpdateColumnOrder:Bn,handleUpdateColumnWidth:In,handleResetColumnLayout:Dn,showGroupPanel:xr,setShowGroupPanel:gt,grouping:d==null?void 0:d.grouping,groupingState:nr,handleGroup:Wo,handleToggleGroupCollapse:Wn,handleExpandAllGroups:Ot,handleCollapseAllGroups:Br,searchQuery:Rt,debouncedSearchQuery:yt,searchHistory:tl((d==null?void 0:d.searchHistory)||[]),handleSearchChange:$n,handleAddToSearchHistory:_n,handleToggleSearchFavourite:Qr,handleDeleteSearchHistory:Qt,selectedRowIds:Ke,handleToggleRowSelection:On,handleToggleAllRows:Mn,handleRangeSelection:Me,handleClearSelection:dt,handleUpdateSelectionAfterDelete:go,currentPage:Tt,pageSize:rt,paginationEngine:we,paginationMode:b,paginationTotalRows:lt,handlePageChange:kn,handlePageSizeChange:zn,isExporting:kt,showExportModal:Rr,setShowExportModal:It,showDirtyExportWarning:Wr,handleExport:Zt,handleExportWithConfig:An,handleExportSelected:re,handleExportAnyway:Ao,handleSaveAndExport:C,handleCancelExport:N,showAuditHistory:Ar,setShowAuditHistory:br,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:He,setShowCreatePreset:Ce,showManagePresets:vr,setShowManagePresets:Sr,activePreset:Vt,activePresetId:qt,handleOpenManagePresets:nt,handleCreatePreset:ve,handleClearActivePreset:Ae,handleDeletePresetById:et,userRole:je,isViewerRole:Pr,currentUserId:Mt,featureLimitWarning:Qe,setFeatureLimitWarning:ir,datasetMeta:Nr,reportError:Et,setReportError:uo,handleError:Dt,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?Ma(d.schema):!1,snack:K,handleSnackClose:A,showSnack:u,snackDurationMs:F,config:S,scheduler:l}}const Os=f.createContext(void 0);function pi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:c,pagination:l,search:p,scheduler:x,mode:y="builder",autoLoad:g=!0,config:v,devConfig:S,showDevPanel:k=!1,sharedReportId:b,sharedViewId:m,viewPersistence:z}=e,B=Hl({mode:y,autoLoad:g,initialData:i||n,dataSource:c,pagination:l,search:p,scheduler:x,reportName:s,reportId:a,sharedReportId:b,sharedViewId:m,viewPersistence:z,config:v}),[T,w]=f.useState(()=>ga()),P=(()=>{const K=ba(T,S,!!S);return{...K,display:{...K.display,showDevPanel:k||K.display.showDevPanel}}})(),O=f.useCallback(q=>{w(q),ya(q)},[]),M={...B,activeDevConfig:P,handleDevConfigChange:O};return t.jsx(js.Provider,{value:P,children:t.jsx(Os.Provider,{value:M,children:r})})}function an(){const e=f.useContext(Os);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Ul({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 y,g,v;const c=((v=(g=(y=a.components)==null?void 0:y.MuiCardHeader)==null?void 0:g.styleOverrides)==null?void 0:v.root)||{},l=c.backgroundColor&&c.backgroundColor!=="transparent"?c.backgroundColor:a.palette.background.paper,p=c.borderBottom&&c.borderBottom!=="none"?c.borderBottom:"1px solid",x=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:p,borderColor:p!=="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($.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($.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($.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function $r(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 Gl="$$material";function Yl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var No={exports:{}},Lo={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 Mi;function Yl(){if(Mi)return Te;Mi=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,p=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,y=e?Symbol.for("react.forward_ref"):60112,g=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,k=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,z=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function B(j){if(typeof j=="object"&&j!==null){var P=j.$$typeof;switch(P){case r:switch(j=j.type,j){case p:case x:case i:case a:case s:case g:return j;default:switch(j=j&&j.$$typeof,j){case l:case y:case k:case S:case c:return j;default:return P}}case n:return P}}}function T(j){return B(j)===x}return Te.AsyncMode=p,Te.ConcurrentMode=x,Te.ContextConsumer=l,Te.ContextProvider=c,Te.Element=r,Te.ForwardRef=y,Te.Fragment=i,Te.Lazy=k,Te.Memo=S,Te.Portal=n,Te.Profiler=a,Te.StrictMode=s,Te.Suspense=g,Te.isAsyncMode=function(j){return T(j)||B(j)===p},Te.isConcurrentMode=T,Te.isContextConsumer=function(j){return B(j)===l},Te.isContextProvider=function(j){return B(j)===c},Te.isElement=function(j){return typeof j=="object"&&j!==null&&j.$$typeof===r},Te.isForwardRef=function(j){return B(j)===y},Te.isFragment=function(j){return B(j)===i},Te.isLazy=function(j){return B(j)===k},Te.isMemo=function(j){return B(j)===S},Te.isPortal=function(j){return B(j)===n},Te.isProfiler=function(j){return B(j)===a},Te.isStrictMode=function(j){return B(j)===s},Te.isSuspense=function(j){return B(j)===g},Te.isValidElementType=function(j){return typeof j=="string"||typeof j=="function"||j===i||j===x||j===a||j===s||j===g||j===v||typeof j=="object"&&j!==null&&(j.$$typeof===k||j.$$typeof===S||j.$$typeof===c||j.$$typeof===l||j.$$typeof===y||j.$$typeof===m||j.$$typeof===z||j.$$typeof===h||j.$$typeof===b)},Te.typeOf=B,Te}var Be={};/** @license React v16.13.1
112
+ */var Wi;function ql(){if(Wi)return ze;Wi=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,p=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,y=e?Symbol.for("react.forward_ref"):60112,g=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,k=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,z=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function B(w){if(typeof w=="object"&&w!==null){var P=w.$$typeof;switch(P){case r:switch(w=w.type,w){case p:case x:case i:case a:case s:case g:return w;default:switch(w=w&&w.$$typeof,w){case l:case y:case k:case S:case c:return w;default:return P}}case n:return P}}}function T(w){return B(w)===x}return ze.AsyncMode=p,ze.ConcurrentMode=x,ze.ContextConsumer=l,ze.ContextProvider=c,ze.Element=r,ze.ForwardRef=y,ze.Fragment=i,ze.Lazy=k,ze.Memo=S,ze.Portal=n,ze.Profiler=a,ze.StrictMode=s,ze.Suspense=g,ze.isAsyncMode=function(w){return T(w)||B(w)===p},ze.isConcurrentMode=T,ze.isContextConsumer=function(w){return B(w)===l},ze.isContextProvider=function(w){return B(w)===c},ze.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===r},ze.isForwardRef=function(w){return B(w)===y},ze.isFragment=function(w){return B(w)===i},ze.isLazy=function(w){return B(w)===k},ze.isMemo=function(w){return B(w)===S},ze.isPortal=function(w){return B(w)===n},ze.isProfiler=function(w){return B(w)===a},ze.isStrictMode=function(w){return B(w)===s},ze.isSuspense=function(w){return B(w)===g},ze.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===i||w===x||w===a||w===s||w===g||w===v||typeof w=="object"&&w!==null&&(w.$$typeof===k||w.$$typeof===S||w.$$typeof===c||w.$$typeof===l||w.$$typeof===y||w.$$typeof===m||w.$$typeof===z||w.$$typeof===h||w.$$typeof===b)},ze.typeOf=B,ze}var Te={};/** @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 Wi;function ql(){return Wi||(Wi=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,p=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,y=e?Symbol.for("react.forward_ref"):60112,g=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,k=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,z=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function B(Y){return typeof Y=="string"||typeof Y=="function"||Y===i||Y===x||Y===a||Y===s||Y===g||Y===v||typeof Y=="object"&&Y!==null&&(Y.$$typeof===k||Y.$$typeof===S||Y.$$typeof===c||Y.$$typeof===l||Y.$$typeof===y||Y.$$typeof===m||Y.$$typeof===z||Y.$$typeof===h||Y.$$typeof===b)}function T(Y){if(typeof Y=="object"&&Y!==null){var We=Y.$$typeof;switch(We){case r:var kt=Y.type;switch(kt){case p:case x:case i:case a:case s:case g:return kt;default:var dt=kt&&kt.$$typeof;switch(dt){case l:case y:case k:case S:case c:return dt;default:return We}}case n:return We}}}var j=p,P=x,_=l,M=c,G=r,q=y,R=i,u=k,A=S,F=n,d=a,ne=s,U=g,re=!1;function xe(Y){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.")),V(Y)||T(Y)===p}function V(Y){return T(Y)===x}function X(Y){return T(Y)===l}function ae(Y){return T(Y)===c}function le(Y){return typeof Y=="object"&&Y!==null&&Y.$$typeof===r}function ie(Y){return T(Y)===y}function Q(Y){return T(Y)===i}function de(Y){return T(Y)===k}function I(Y){return T(Y)===S}function te(Y){return T(Y)===n}function he(Y){return T(Y)===a}function se(Y){return T(Y)===s}function ze(Y){return T(Y)===g}Be.AsyncMode=j,Be.ConcurrentMode=P,Be.ContextConsumer=_,Be.ContextProvider=M,Be.Element=G,Be.ForwardRef=q,Be.Fragment=R,Be.Lazy=u,Be.Memo=A,Be.Portal=F,Be.Profiler=d,Be.StrictMode=ne,Be.Suspense=U,Be.isAsyncMode=xe,Be.isConcurrentMode=V,Be.isContextConsumer=X,Be.isContextProvider=ae,Be.isElement=le,Be.isForwardRef=ie,Be.isFragment=Q,Be.isLazy=de,Be.isMemo=I,Be.isPortal=te,Be.isProfiler=he,Be.isStrictMode=se,Be.isSuspense=ze,Be.isValidElementType=B,Be.typeOf=T})()),Be}var Ai;function Os(){return Ai||(Ai=1,process.env.NODE_ENV==="production"?Vo.exports=Yl():Vo.exports=ql()),Vo.exports}/*
119
+ */var Ai;function Jl(){return Ai||(Ai=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,p=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,y=e?Symbol.for("react.forward_ref"):60112,g=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,k=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,z=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function B(J){return typeof J=="string"||typeof J=="function"||J===i||J===x||J===a||J===s||J===g||J===v||typeof J=="object"&&J!==null&&(J.$$typeof===k||J.$$typeof===S||J.$$typeof===c||J.$$typeof===l||J.$$typeof===y||J.$$typeof===m||J.$$typeof===z||J.$$typeof===h||J.$$typeof===b)}function T(J){if(typeof J=="object"&&J!==null){var We=J.$$typeof;switch(We){case r:var kt=J.type;switch(kt){case p:case x:case i:case a:case s:case g:return kt;default:var ht=kt&&kt.$$typeof;switch(ht){case l:case y:case k:case S:case c:return ht;default:return We}}case n:return We}}}var w=p,P=x,O=l,M=c,q=r,K=y,R=i,u=k,A=S,F=n,d=a,oe=s,G=g,te=!1;function xe(J){return te||(te=!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.")),H(J)||T(J)===p}function H(J){return T(J)===x}function Q(J){return T(J)===l}function le(J){return T(J)===c}function ce(J){return typeof J=="object"&&J!==null&&J.$$typeof===r}function ie(J){return T(J)===y}function Z(J){return T(J)===i}function ue(J){return T(J)===k}function I(J){return T(J)===S}function ee(J){return T(J)===n}function fe(J){return T(J)===a}function se(J){return T(J)===s}function ke(J){return T(J)===g}Te.AsyncMode=w,Te.ConcurrentMode=P,Te.ContextConsumer=O,Te.ContextProvider=M,Te.Element=q,Te.ForwardRef=K,Te.Fragment=R,Te.Lazy=u,Te.Memo=A,Te.Portal=F,Te.Profiler=d,Te.StrictMode=oe,Te.Suspense=G,Te.isAsyncMode=xe,Te.isConcurrentMode=H,Te.isContextConsumer=Q,Te.isContextProvider=le,Te.isElement=ce,Te.isForwardRef=ie,Te.isFragment=Z,Te.isLazy=ue,Te.isMemo=I,Te.isPortal=ee,Te.isProfiler=fe,Te.isStrictMode=se,Te.isSuspense=ke,Te.isValidElementType=B,Te.typeOf=T})()),Te}var Ri;function Ms(){return Ri||(Ri=1,process.env.NODE_ENV==="production"?Lo.exports=ql():Lo.exports=Jl()),Lo.exports}/*
120
120
  object-assign
121
121
  (c) Sindre Sorhus
122
122
  @license MIT
123
- */var Fn,Ri;function Jl(){if(Ri)return Fn;Ri=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 p=Object.getOwnPropertyNames(c).map(function(y){return c[y]});if(p.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(y){x[y]=y}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Fn=s()?Object.assign:function(a,c){for(var l,p=i(a),x,y=1;y<arguments.length;y++){l=Object(arguments[y]);for(var g in l)r.call(l,g)&&(p[g]=l[g]);if(e){x=e(l);for(var v=0;v<x.length;v++)n.call(l,x[v])&&(p[x[v]]=l[x[v]])}}return p},Fn}var Vn,Pi;function hi(){if(Pi)return Vn;Pi=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Vn=e,Vn}var Hn,Ni;function Ms(){return Ni||(Ni=1,Hn=Function.call.bind(Object.prototype.hasOwnProperty)),Hn}var Un,Li;function Kl(){if(Li)return Un;Li=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=hi(),n={},i=Ms();e=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(a,c,l,p,x){if(process.env.NODE_ENV!=="production"){for(var y in a)if(i(a,y)){var g;try{if(typeof a[y]!="function"){var v=Error((p||"React class")+": "+l+" type `"+y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[y]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}g=a[y](c,y,p,l,null,r)}catch(k){g=k}if(g&&!(g instanceof Error)&&e((p||"React class")+": type specification of "+l+" `"+y+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof g+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),g instanceof Error&&!(g.message in n)){n[g.message]=!0;var S=x?x():"";e("Failed "+l+" type: "+g.message+(S??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Un=s,Un}var Gn,Fi;function Xl(){if(Fi)return Gn;Fi=1;var e=Os(),r=Jl(),n=hi(),i=Ms(),s=Kl(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(l){var p="Warning: "+l;typeof console<"u"&&console.error(p);try{throw new Error(p)}catch{}});function c(){return null}return Gn=function(l,p){var x=typeof Symbol=="function"&&Symbol.iterator,y="@@iterator";function g(V){var X=V&&(x&&V[x]||V[y]);if(typeof X=="function")return X}var v="<<anonymous>>",S={array:z("array"),bigint:z("bigint"),bool:z("boolean"),func:z("function"),number:z("number"),object:z("object"),string:z("string"),symbol:z("symbol"),any:h(),arrayOf:B,element:T(),elementType:j(),instanceOf:P,node:q(),objectOf:M,oneOf:_,oneOfType:G,shape:u,exact:A};function k(V,X){return V===X?V!==0||1/V===1/X:V!==V&&X!==X}function b(V,X){this.message=V,this.data=X&&typeof X=="object"?X:{},this.stack=""}b.prototype=Error.prototype;function m(V){if(process.env.NODE_ENV!=="production")var X={},ae=0;function le(Q,de,I,te,he,se,ze){if(te=te||v,se=se||I,ze!==n){if(p){var Y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw Y.name="Invariant Violation",Y}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var We=te+":"+I;!X[We]&&ae<3&&(a("You are manually calling a React.PropTypes validation function for the `"+se+"` prop on `"+te+"`. 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[We]=!0,ae++)}}return de[I]==null?Q?de[I]===null?new b("The "+he+" `"+se+"` is marked as required "+("in `"+te+"`, but its value is `null`.")):new b("The "+he+" `"+se+"` is marked as required in "+("`"+te+"`, but its value is `undefined`.")):null:V(de,I,te,he,se)}var ie=le.bind(null,!1);return ie.isRequired=le.bind(null,!0),ie}function z(V){function X(ae,le,ie,Q,de,I){var te=ae[le],he=ne(te);if(he!==V){var se=U(te);return new b("Invalid "+Q+" `"+de+"` of type "+("`"+se+"` supplied to `"+ie+"`, expected ")+("`"+V+"`."),{expectedType:V})}return null}return m(X)}function h(){return m(c)}function B(V){function X(ae,le,ie,Q,de){if(typeof V!="function")return new b("Property `"+de+"` of component `"+ie+"` has invalid PropType notation inside arrayOf.");var I=ae[le];if(!Array.isArray(I)){var te=ne(I);return new b("Invalid "+Q+" `"+de+"` of type "+("`"+te+"` supplied to `"+ie+"`, expected an array."))}for(var he=0;he<I.length;he++){var se=V(I,he,ie,Q,de+"["+he+"]",n);if(se instanceof Error)return se}return null}return m(X)}function T(){function V(X,ae,le,ie,Q){var de=X[ae];if(!l(de)){var I=ne(de);return new b("Invalid "+ie+" `"+Q+"` of type "+("`"+I+"` supplied to `"+le+"`, expected a single ReactElement."))}return null}return m(V)}function j(){function V(X,ae,le,ie,Q){var de=X[ae];if(!e.isValidElementType(de)){var I=ne(de);return new b("Invalid "+ie+" `"+Q+"` of type "+("`"+I+"` supplied to `"+le+"`, expected a single ReactElement type."))}return null}return m(V)}function P(V){function X(ae,le,ie,Q,de){if(!(ae[le]instanceof V)){var I=V.name||v,te=xe(ae[le]);return new b("Invalid "+Q+" `"+de+"` of type "+("`"+te+"` supplied to `"+ie+"`, expected ")+("instance of `"+I+"`."))}return null}return m(X)}function _(V){if(!Array.isArray(V))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(ae,le,ie,Q,de){for(var I=ae[le],te=0;te<V.length;te++)if(k(I,V[te]))return null;var he=JSON.stringify(V,function(ze,Y){var We=U(Y);return We==="symbol"?String(Y):Y});return new b("Invalid "+Q+" `"+de+"` of value `"+String(I)+"` "+("supplied to `"+ie+"`, expected one of "+he+"."))}return m(X)}function M(V){function X(ae,le,ie,Q,de){if(typeof V!="function")return new b("Property `"+de+"` of component `"+ie+"` has invalid PropType notation inside objectOf.");var I=ae[le],te=ne(I);if(te!=="object")return new b("Invalid "+Q+" `"+de+"` of type "+("`"+te+"` supplied to `"+ie+"`, expected an object."));for(var he in I)if(i(I,he)){var se=V(I,he,ie,Q,de+"."+he,n);if(se instanceof Error)return se}return null}return m(X)}function G(V){if(!Array.isArray(V))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var X=0;X<V.length;X++){var ae=V[X];if(typeof ae!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+re(ae)+" at index "+X+"."),c}function le(ie,Q,de,I,te){for(var he=[],se=0;se<V.length;se++){var ze=V[se],Y=ze(ie,Q,de,I,te,n);if(Y==null)return null;Y.data&&i(Y.data,"expectedType")&&he.push(Y.data.expectedType)}var We=he.length>0?", expected one of type ["+he.join(", ")+"]":"";return new b("Invalid "+I+" `"+te+"` supplied to "+("`"+de+"`"+We+"."))}return m(le)}function q(){function V(X,ae,le,ie,Q){return F(X[ae])?null:new b("Invalid "+ie+" `"+Q+"` supplied to "+("`"+le+"`, expected a ReactNode."))}return m(V)}function R(V,X,ae,le,ie){return new b((V||"React class")+": "+X+" type `"+ae+"."+le+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+ie+"`.")}function u(V){function X(ae,le,ie,Q,de){var I=ae[le],te=ne(I);if(te!=="object")return new b("Invalid "+Q+" `"+de+"` of type `"+te+"` "+("supplied to `"+ie+"`, expected `object`."));for(var he in V){var se=V[he];if(typeof se!="function")return R(ie,Q,de,he,U(se));var ze=se(I,he,ie,Q,de+"."+he,n);if(ze)return ze}return null}return m(X)}function A(V){function X(ae,le,ie,Q,de){var I=ae[le],te=ne(I);if(te!=="object")return new b("Invalid "+Q+" `"+de+"` of type `"+te+"` "+("supplied to `"+ie+"`, expected `object`."));var he=r({},ae[le],V);for(var se in he){var ze=V[se];if(i(V,se)&&typeof ze!="function")return R(ie,Q,de,se,U(ze));if(!ze)return new b("Invalid "+Q+" `"+de+"` key `"+se+"` supplied to `"+ie+"`.\nBad object: "+JSON.stringify(ae[le],null," ")+`
124
- Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Y=ze(I,se,ie,Q,de+"."+se,n);if(Y)return Y}return null}return m(X)}function F(V){switch(typeof V){case"number":case"string":case"undefined":return!0;case"boolean":return!V;case"object":if(Array.isArray(V))return V.every(F);if(V===null||l(V))return!0;var X=g(V);if(X){var ae=X.call(V),le;if(X!==V.entries){for(;!(le=ae.next()).done;)if(!F(le.value))return!1}else for(;!(le=ae.next()).done;){var ie=le.value;if(ie&&!F(ie[1]))return!1}}else return!1;return!0;default:return!1}}function d(V,X){return V==="symbol"?!0:X?X["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&X instanceof Symbol:!1}function ne(V){var X=typeof V;return Array.isArray(V)?"array":V instanceof RegExp?"object":d(X,V)?"symbol":X}function U(V){if(typeof V>"u"||V===null)return""+V;var X=ne(V);if(X==="object"){if(V instanceof Date)return"date";if(V instanceof RegExp)return"regexp"}return X}function re(V){var X=U(V);switch(X){case"array":case"object":return"an "+X;case"boolean":case"date":case"regexp":return"a "+X;default:return X}}function xe(V){return!V.constructor||!V.constructor.name?v:V.constructor.name}return S.checkPropTypes=s,S.resetWarningCache=s.resetWarningCache,S.PropTypes=S,S},Gn}var Yn,Vi;function Ql(){if(Vi)return Yn;Vi=1;var e=hi();function r(){}function n(){}return n.resetWarningCache=r,Yn=function(){function i(c,l,p,x,y,g){if(g!==e){var v=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 v.name="Invariant Violation",v}}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},Yn}var Hi;function Zl(){if(Hi)return Fo.exports;if(Hi=1,process.env.NODE_ENV!=="production"){var e=Os(),r=!0;Fo.exports=Xl()(e.isElement,r)}else Fo.exports=Ql()();return Fo.exports}var ec=Zl();const yo=Gl(ec);var Ho={exports:{}},De={};/**
123
+ */var Fn,Pi;function Kl(){if(Pi)return Fn;Pi=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 p=Object.getOwnPropertyNames(c).map(function(y){return c[y]});if(p.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(y){x[y]=y}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Fn=s()?Object.assign:function(a,c){for(var l,p=i(a),x,y=1;y<arguments.length;y++){l=Object(arguments[y]);for(var g in l)r.call(l,g)&&(p[g]=l[g]);if(e){x=e(l);for(var v=0;v<x.length;v++)n.call(l,x[v])&&(p[x[v]]=l[x[v]])}}return p},Fn}var Vn,Ni;function hi(){if(Ni)return Vn;Ni=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Vn=e,Vn}var Hn,Li;function Ws(){return Li||(Li=1,Hn=Function.call.bind(Object.prototype.hasOwnProperty)),Hn}var Un,Fi;function Xl(){if(Fi)return Un;Fi=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=hi(),n={},i=Ws();e=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(a,c,l,p,x){if(process.env.NODE_ENV!=="production"){for(var y in a)if(i(a,y)){var g;try{if(typeof a[y]!="function"){var v=Error((p||"React class")+": "+l+" type `"+y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[y]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}g=a[y](c,y,p,l,null,r)}catch(k){g=k}if(g&&!(g instanceof Error)&&e((p||"React class")+": type specification of "+l+" `"+y+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof g+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),g instanceof Error&&!(g.message in n)){n[g.message]=!0;var S=x?x():"";e("Failed "+l+" type: "+g.message+(S??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Un=s,Un}var Gn,Vi;function Ql(){if(Vi)return Gn;Vi=1;var e=Ms(),r=Kl(),n=hi(),i=Ws(),s=Xl(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(l){var p="Warning: "+l;typeof console<"u"&&console.error(p);try{throw new Error(p)}catch{}});function c(){return null}return Gn=function(l,p){var x=typeof Symbol=="function"&&Symbol.iterator,y="@@iterator";function g(H){var Q=H&&(x&&H[x]||H[y]);if(typeof Q=="function")return Q}var v="<<anonymous>>",S={array:z("array"),bigint:z("bigint"),bool:z("boolean"),func:z("function"),number:z("number"),object:z("object"),string:z("string"),symbol:z("symbol"),any:h(),arrayOf:B,element:T(),elementType:w(),instanceOf:P,node:K(),objectOf:M,oneOf:O,oneOfType:q,shape:u,exact:A};function k(H,Q){return H===Q?H!==0||1/H===1/Q:H!==H&&Q!==Q}function b(H,Q){this.message=H,this.data=Q&&typeof Q=="object"?Q:{},this.stack=""}b.prototype=Error.prototype;function m(H){if(process.env.NODE_ENV!=="production")var Q={},le=0;function ce(Z,ue,I,ee,fe,se,ke){if(ee=ee||v,se=se||I,ke!==n){if(p){var J=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw J.name="Invariant Violation",J}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var We=ee+":"+I;!Q[We]&&le<3&&(a("You are manually calling a React.PropTypes validation function for the `"+se+"` prop on `"+ee+"`. 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."),Q[We]=!0,le++)}}return ue[I]==null?Z?ue[I]===null?new b("The "+fe+" `"+se+"` is marked as required "+("in `"+ee+"`, but its value is `null`.")):new b("The "+fe+" `"+se+"` is marked as required in "+("`"+ee+"`, but its value is `undefined`.")):null:H(ue,I,ee,fe,se)}var ie=ce.bind(null,!1);return ie.isRequired=ce.bind(null,!0),ie}function z(H){function Q(le,ce,ie,Z,ue,I){var ee=le[ce],fe=oe(ee);if(fe!==H){var se=G(ee);return new b("Invalid "+Z+" `"+ue+"` of type "+("`"+se+"` supplied to `"+ie+"`, expected ")+("`"+H+"`."),{expectedType:H})}return null}return m(Q)}function h(){return m(c)}function B(H){function Q(le,ce,ie,Z,ue){if(typeof H!="function")return new b("Property `"+ue+"` of component `"+ie+"` has invalid PropType notation inside arrayOf.");var I=le[ce];if(!Array.isArray(I)){var ee=oe(I);return new b("Invalid "+Z+" `"+ue+"` of type "+("`"+ee+"` supplied to `"+ie+"`, expected an array."))}for(var fe=0;fe<I.length;fe++){var se=H(I,fe,ie,Z,ue+"["+fe+"]",n);if(se instanceof Error)return se}return null}return m(Q)}function T(){function H(Q,le,ce,ie,Z){var ue=Q[le];if(!l(ue)){var I=oe(ue);return new b("Invalid "+ie+" `"+Z+"` of type "+("`"+I+"` supplied to `"+ce+"`, expected a single ReactElement."))}return null}return m(H)}function w(){function H(Q,le,ce,ie,Z){var ue=Q[le];if(!e.isValidElementType(ue)){var I=oe(ue);return new b("Invalid "+ie+" `"+Z+"` of type "+("`"+I+"` supplied to `"+ce+"`, expected a single ReactElement type."))}return null}return m(H)}function P(H){function Q(le,ce,ie,Z,ue){if(!(le[ce]instanceof H)){var I=H.name||v,ee=xe(le[ce]);return new b("Invalid "+Z+" `"+ue+"` of type "+("`"+ee+"` supplied to `"+ie+"`, expected ")+("instance of `"+I+"`."))}return null}return m(Q)}function O(H){if(!Array.isArray(H))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 Q(le,ce,ie,Z,ue){for(var I=le[ce],ee=0;ee<H.length;ee++)if(k(I,H[ee]))return null;var fe=JSON.stringify(H,function(ke,J){var We=G(J);return We==="symbol"?String(J):J});return new b("Invalid "+Z+" `"+ue+"` of value `"+String(I)+"` "+("supplied to `"+ie+"`, expected one of "+fe+"."))}return m(Q)}function M(H){function Q(le,ce,ie,Z,ue){if(typeof H!="function")return new b("Property `"+ue+"` of component `"+ie+"` has invalid PropType notation inside objectOf.");var I=le[ce],ee=oe(I);if(ee!=="object")return new b("Invalid "+Z+" `"+ue+"` of type "+("`"+ee+"` supplied to `"+ie+"`, expected an object."));for(var fe in I)if(i(I,fe)){var se=H(I,fe,ie,Z,ue+"."+fe,n);if(se instanceof Error)return se}return null}return m(Q)}function q(H){if(!Array.isArray(H))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var Q=0;Q<H.length;Q++){var le=H[Q];if(typeof le!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+te(le)+" at index "+Q+"."),c}function ce(ie,Z,ue,I,ee){for(var fe=[],se=0;se<H.length;se++){var ke=H[se],J=ke(ie,Z,ue,I,ee,n);if(J==null)return null;J.data&&i(J.data,"expectedType")&&fe.push(J.data.expectedType)}var We=fe.length>0?", expected one of type ["+fe.join(", ")+"]":"";return new b("Invalid "+I+" `"+ee+"` supplied to "+("`"+ue+"`"+We+"."))}return m(ce)}function K(){function H(Q,le,ce,ie,Z){return F(Q[le])?null:new b("Invalid "+ie+" `"+Z+"` supplied to "+("`"+ce+"`, expected a ReactNode."))}return m(H)}function R(H,Q,le,ce,ie){return new b((H||"React class")+": "+Q+" type `"+le+"."+ce+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+ie+"`.")}function u(H){function Q(le,ce,ie,Z,ue){var I=le[ce],ee=oe(I);if(ee!=="object")return new b("Invalid "+Z+" `"+ue+"` of type `"+ee+"` "+("supplied to `"+ie+"`, expected `object`."));for(var fe in H){var se=H[fe];if(typeof se!="function")return R(ie,Z,ue,fe,G(se));var ke=se(I,fe,ie,Z,ue+"."+fe,n);if(ke)return ke}return null}return m(Q)}function A(H){function Q(le,ce,ie,Z,ue){var I=le[ce],ee=oe(I);if(ee!=="object")return new b("Invalid "+Z+" `"+ue+"` of type `"+ee+"` "+("supplied to `"+ie+"`, expected `object`."));var fe=r({},le[ce],H);for(var se in fe){var ke=H[se];if(i(H,se)&&typeof ke!="function")return R(ie,Z,ue,se,G(ke));if(!ke)return new b("Invalid "+Z+" `"+ue+"` key `"+se+"` supplied to `"+ie+"`.\nBad object: "+JSON.stringify(le[ce],null," ")+`
124
+ Valid keys: `+JSON.stringify(Object.keys(H),null," "));var J=ke(I,se,ie,Z,ue+"."+se,n);if(J)return J}return null}return m(Q)}function F(H){switch(typeof H){case"number":case"string":case"undefined":return!0;case"boolean":return!H;case"object":if(Array.isArray(H))return H.every(F);if(H===null||l(H))return!0;var Q=g(H);if(Q){var le=Q.call(H),ce;if(Q!==H.entries){for(;!(ce=le.next()).done;)if(!F(ce.value))return!1}else for(;!(ce=le.next()).done;){var ie=ce.value;if(ie&&!F(ie[1]))return!1}}else return!1;return!0;default:return!1}}function d(H,Q){return H==="symbol"?!0:Q?Q["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&Q instanceof Symbol:!1}function oe(H){var Q=typeof H;return Array.isArray(H)?"array":H instanceof RegExp?"object":d(Q,H)?"symbol":Q}function G(H){if(typeof H>"u"||H===null)return""+H;var Q=oe(H);if(Q==="object"){if(H instanceof Date)return"date";if(H instanceof RegExp)return"regexp"}return Q}function te(H){var Q=G(H);switch(Q){case"array":case"object":return"an "+Q;case"boolean":case"date":case"regexp":return"a "+Q;default:return Q}}function xe(H){return!H.constructor||!H.constructor.name?v:H.constructor.name}return S.checkPropTypes=s,S.resetWarningCache=s.resetWarningCache,S.PropTypes=S,S},Gn}var Yn,Hi;function Zl(){if(Hi)return Yn;Hi=1;var e=hi();function r(){}function n(){}return n.resetWarningCache=r,Yn=function(){function i(c,l,p,x,y,g){if(g!==e){var v=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 v.name="Invariant Violation",v}}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},Yn}var Ui;function ec(){if(Ui)return No.exports;if(Ui=1,process.env.NODE_ENV!=="production"){var e=Ms(),r=!0;No.exports=Ql()(e.isElement,r)}else No.exports=Zl()();return No.exports}var tc=ec();const bo=Yl(tc);var Fo={exports:{}},De={};/**
125
125
  * @license React
126
126
  * react-is.production.js
127
127
  *
@@ -129,7 +129,7 @@ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Y=ze(I,se,ie,Q,de+".
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 Ui;function tc(){if(Ui)return De;Ui=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"),p=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),S=Symbol.for("react.client.reference");function k(b){if(typeof b=="object"&&b!==null){var m=b.$$typeof;switch(m){case e:switch(b=b.type,b){case n:case s:case i:case p:case x:case v:return b;default:switch(b=b&&b.$$typeof,b){case c:case l:case g:case y:return b;case a:return b;default:return m}}case r:return m}}}return De.ContextConsumer=a,De.ContextProvider=c,De.Element=e,De.ForwardRef=l,De.Fragment=n,De.Lazy=g,De.Memo=y,De.Portal=r,De.Profiler=s,De.StrictMode=i,De.Suspense=p,De.SuspenseList=x,De.isContextConsumer=function(b){return k(b)===a},De.isContextProvider=function(b){return k(b)===c},De.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===e},De.isForwardRef=function(b){return k(b)===l},De.isFragment=function(b){return k(b)===n},De.isLazy=function(b){return k(b)===g},De.isMemo=function(b){return k(b)===y},De.isPortal=function(b){return k(b)===r},De.isProfiler=function(b){return k(b)===s},De.isStrictMode=function(b){return k(b)===i},De.isSuspense=function(b){return k(b)===p},De.isSuspenseList=function(b){return k(b)===x},De.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===n||b===s||b===i||b===p||b===x||typeof b=="object"&&b!==null&&(b.$$typeof===g||b.$$typeof===y||b.$$typeof===c||b.$$typeof===a||b.$$typeof===l||b.$$typeof===S||b.getModuleId!==void 0)},De.typeOf=k,De}var $e={};/**
132
+ */var Gi;function rc(){if(Gi)return De;Gi=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"),p=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),S=Symbol.for("react.client.reference");function k(b){if(typeof b=="object"&&b!==null){var m=b.$$typeof;switch(m){case e:switch(b=b.type,b){case n:case s:case i:case p:case x:case v:return b;default:switch(b=b&&b.$$typeof,b){case c:case l:case g:case y:return b;case a:return b;default:return m}}case r:return m}}}return De.ContextConsumer=a,De.ContextProvider=c,De.Element=e,De.ForwardRef=l,De.Fragment=n,De.Lazy=g,De.Memo=y,De.Portal=r,De.Profiler=s,De.StrictMode=i,De.Suspense=p,De.SuspenseList=x,De.isContextConsumer=function(b){return k(b)===a},De.isContextProvider=function(b){return k(b)===c},De.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===e},De.isForwardRef=function(b){return k(b)===l},De.isFragment=function(b){return k(b)===n},De.isLazy=function(b){return k(b)===g},De.isMemo=function(b){return k(b)===y},De.isPortal=function(b){return k(b)===r},De.isProfiler=function(b){return k(b)===s},De.isStrictMode=function(b){return k(b)===i},De.isSuspense=function(b){return k(b)===p},De.isSuspenseList=function(b){return k(b)===x},De.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===n||b===s||b===i||b===p||b===x||typeof b=="object"&&b!==null&&(b.$$typeof===g||b.$$typeof===y||b.$$typeof===c||b.$$typeof===a||b.$$typeof===l||b.$$typeof===S||b.getModuleId!==void 0)},De.typeOf=k,De}var $e={};/**
133
133
  * @license React
134
134
  * react-is.development.js
135
135
  *
@@ -137,15 +137,15 @@ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Y=ze(I,se,ie,Q,de+".
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 Gi;function rc(){return Gi||(Gi=1,process.env.NODE_ENV!=="production"&&(function(){function e(b){if(typeof b=="object"&&b!==null){var m=b.$$typeof;switch(m){case r:switch(b=b.type,b){case i:case a:case s:case x:case y:case S:return b;default:switch(b=b&&b.$$typeof,b){case l:case p:case v:case g:return b;case c:return b;default:return m}}case n:return m}}}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"),p=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),k=Symbol.for("react.client.reference");$e.ContextConsumer=c,$e.ContextProvider=l,$e.Element=r,$e.ForwardRef=p,$e.Fragment=i,$e.Lazy=v,$e.Memo=g,$e.Portal=n,$e.Profiler=a,$e.StrictMode=s,$e.Suspense=x,$e.SuspenseList=y,$e.isContextConsumer=function(b){return e(b)===c},$e.isContextProvider=function(b){return e(b)===l},$e.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===r},$e.isForwardRef=function(b){return e(b)===p},$e.isFragment=function(b){return e(b)===i},$e.isLazy=function(b){return e(b)===v},$e.isMemo=function(b){return e(b)===g},$e.isPortal=function(b){return e(b)===n},$e.isProfiler=function(b){return e(b)===a},$e.isStrictMode=function(b){return e(b)===s},$e.isSuspense=function(b){return e(b)===x},$e.isSuspenseList=function(b){return e(b)===y},$e.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===i||b===a||b===s||b===x||b===y||typeof b=="object"&&b!==null&&(b.$$typeof===v||b.$$typeof===g||b.$$typeof===l||b.$$typeof===c||b.$$typeof===p||b.$$typeof===k||b.getModuleId!==void 0)},$e.typeOf=e})()),$e}var Yi;function oc(){return Yi||(Yi=1,process.env.NODE_ENV==="production"?Ho.exports=tc():Ho.exports=rc()),Ho.exports}var Ws=oc();function dr(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 As(e){if(sn.isValidElement(e)||Ws.isValidElementType(e)||!dr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=As(e[n])}),r}function mt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return dr(e)&&dr(r)&&Object.keys(r).forEach(s=>{sn.isValidElement(r[s])||Ws.isValidElementType(r[s])?i[s]=r[s]:dr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&dr(e[s])?i[s]=mt(e[s],r[s],n):n.clone?i[s]=dr(r[s])?As(r[s]):r[s]:i[s]=r[s]}),i}const nc=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 ic(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,a=nc(r),c=Object.keys(a);function l(v){return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n})`}function p(v){return`@media (max-width:${(typeof r[v]=="number"?r[v]:v)-i/100}${n})`}function x(v,S){const k=c.indexOf(S);return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n}) and (max-width:${(k!==-1&&typeof r[c[k]]=="number"?r[c[k]]:S)-i/100}${n})`}function y(v){return c.indexOf(v)+1<c.length?x(v,c[c.indexOf(v)+1]):l(v)}function g(v){const S=c.indexOf(v);return S===0?l(c[1]):S===c.length-1?p(c[S]):x(v,c[c.indexOf(v)+1]).replace("@media","@media not all and")}return{keys:c,values:a,up:l,down:p,between:x,only:y,not:g,unit:n,...s}}function qi(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 sc(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function ac(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 lc(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 p=r(e.breakpoints.not(...l),c);return p.includes("not all and")?p.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):p}}const i={},s=a=>(n(i,a),i);return n(s),{...e,containerQueries:s}}const cc={borderRadius:4},hr=process.env.NODE_ENV!=="production"?yo.oneOfType([yo.number,yo.string,yo.object,yo.array]):{};function zo(e,r){return r?mt(e,r,{clone:!1}):e}const dn={xs:0,sm:600,md:900,lg:1200,xl:1536},Ji={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${dn[e]}px)`},dc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:dn[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function er(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||Ji;return r.reduce((c,l,p)=>(c[a.up(a.keys[p])]=n(r[p]),c),{})}if(typeof r=="object"){const a=i.breakpoints||Ji;return Object.keys(r).reduce((c,l)=>{if(sc(a.keys,l)){const p=ac(i.containerQueries?i:dc,l);p&&(c[p]=n(r[l],l))}else if(Object.keys(a.values||dn).includes(l)){const p=a.up(l);c[p]=n(r[l],l)}else{const p=l;c[p]=r[p]}return c},{})}return n(r)}function uc(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function Ki(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function Rs(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Er(7));return e.charAt(0).toUpperCase()+e.slice(1)}function un(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 on(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=un(e,n)||i,r&&(s=r(s,i,e)),s}function Fe(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],p=c.theme,x=un(p,i)||{};return er(c,l,g=>{let v=on(x,s,g);return g===v&&typeof g=="string"&&(v=on(x,s,`${r}${g==="default"?"":Rs(g)}`,g)),n===!1?v:{[n]:v}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:hr}:{},a.filterProps=[r],a}function pc(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const hc={m:"margin",p:"padding"},fc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Xi={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},mc=pc(e=>{if(e.length>2)if(Xi[e])e=Xi[e];else return[e];const[r,n]=e.split(""),i=hc[r],s=fc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),pn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],hn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],xc=[...pn,...hn];function Eo(e,r,n,i){const s=un(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 Yi;function oc(){return Yi||(Yi=1,process.env.NODE_ENV!=="production"&&(function(){function e(b){if(typeof b=="object"&&b!==null){var m=b.$$typeof;switch(m){case r:switch(b=b.type,b){case i:case a:case s:case x:case y:case S:return b;default:switch(b=b&&b.$$typeof,b){case l:case p:case v:case g:return b;case c:return b;default:return m}}case n:return m}}}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"),p=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),k=Symbol.for("react.client.reference");$e.ContextConsumer=c,$e.ContextProvider=l,$e.Element=r,$e.ForwardRef=p,$e.Fragment=i,$e.Lazy=v,$e.Memo=g,$e.Portal=n,$e.Profiler=a,$e.StrictMode=s,$e.Suspense=x,$e.SuspenseList=y,$e.isContextConsumer=function(b){return e(b)===c},$e.isContextProvider=function(b){return e(b)===l},$e.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===r},$e.isForwardRef=function(b){return e(b)===p},$e.isFragment=function(b){return e(b)===i},$e.isLazy=function(b){return e(b)===v},$e.isMemo=function(b){return e(b)===g},$e.isPortal=function(b){return e(b)===n},$e.isProfiler=function(b){return e(b)===a},$e.isStrictMode=function(b){return e(b)===s},$e.isSuspense=function(b){return e(b)===x},$e.isSuspenseList=function(b){return e(b)===y},$e.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===i||b===a||b===s||b===x||b===y||typeof b=="object"&&b!==null&&(b.$$typeof===v||b.$$typeof===g||b.$$typeof===l||b.$$typeof===c||b.$$typeof===p||b.$$typeof===k||b.getModuleId!==void 0)},$e.typeOf=e})()),$e}var qi;function nc(){return qi||(qi=1,process.env.NODE_ENV==="production"?Fo.exports=rc():Fo.exports=oc()),Fo.exports}var As=nc();function pr(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 Rs(e){if(on.isValidElement(e)||As.isValidElementType(e)||!pr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Rs(e[n])}),r}function xt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return pr(e)&&pr(r)&&Object.keys(r).forEach(s=>{on.isValidElement(r[s])||As.isValidElementType(r[s])?i[s]=r[s]:pr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&pr(e[s])?i[s]=xt(e[s],r[s],n):n.clone?i[s]=pr(r[s])?Rs(r[s]):r[s]:i[s]=r[s]}),i}const ic=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 sc(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,a=ic(r),c=Object.keys(a);function l(v){return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n})`}function p(v){return`@media (max-width:${(typeof r[v]=="number"?r[v]:v)-i/100}${n})`}function x(v,S){const k=c.indexOf(S);return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n}) and (max-width:${(k!==-1&&typeof r[c[k]]=="number"?r[c[k]]:S)-i/100}${n})`}function y(v){return c.indexOf(v)+1<c.length?x(v,c[c.indexOf(v)+1]):l(v)}function g(v){const S=c.indexOf(v);return S===0?l(c[1]):S===c.length-1?p(c[S]):x(v,c[c.indexOf(v)+1]).replace("@media","@media not all and")}return{keys:c,values:a,up:l,down:p,between:x,only:y,not:g,unit:n,...s}}function Ji(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 ac(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function lc(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 cc(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 p=r(e.breakpoints.not(...l),c);return p.includes("not all and")?p.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):p}}const i={},s=a=>(n(i,a),i);return n(s),{...e,containerQueries:s}}const dc={borderRadius:4},mr=process.env.NODE_ENV!=="production"?bo.oneOfType([bo.number,bo.string,bo.object,bo.array]):{};function zo(e,r){return r?xt(e,r,{clone:!1}):e}const ln={xs:0,sm:600,md:900,lg:1200,xl:1536},Ki={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${ln[e]}px)`},uc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:ln[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function or(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||Ki;return r.reduce((c,l,p)=>(c[a.up(a.keys[p])]=n(r[p]),c),{})}if(typeof r=="object"){const a=i.breakpoints||Ki;return Object.keys(r).reduce((c,l)=>{if(ac(a.keys,l)){const p=lc(i.containerQueries?i:uc,l);p&&(c[p]=n(r[l],l))}else if(Object.keys(a.values||ln).includes(l)){const p=a.up(l);c[p]=n(r[l],l)}else{const p=l;c[p]=r[p]}return c},{})}return n(r)}function pc(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function Xi(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function Ps(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":$r(7));return e.charAt(0).toUpperCase()+e.slice(1)}function cn(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 tn(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=cn(e,n)||i,r&&(s=r(s,i,e)),s}function Le(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],p=c.theme,x=cn(p,i)||{};return or(c,l,g=>{let v=tn(x,s,g);return g===v&&typeof g=="string"&&(v=tn(x,s,`${r}${g==="default"?"":Ps(g)}`,g)),n===!1?v:{[n]:v}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:mr}:{},a.filterProps=[r],a}function hc(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const fc={m:"margin",p:"padding"},mc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Qi={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},xc=hc(e=>{if(e.length>2)if(Qi[e])e=Qi[e];else return[e];const[r,n]=e.split(""),i=fc[r],s=mc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),dn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],un=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],gc=[...dn,...un];function Eo(e,r,n,i){const s=cn(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(`
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
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 fi(e){return Eo(e,"spacing",8,"spacing")}function Do(e,r){return typeof r=="string"||r==null?r:e(r)}function gc(e,r){return n=>e.reduce((i,s)=>(i[s]=Do(r,n),i),{})}function yc(e,r,n,i){if(!r.includes(n))return null;const s=mc(n),a=gc(s,i),c=e[n];return er(e,c,a)}function Ps(e,r){const n=fi(e.theme);return Object.keys(e).map(i=>yc(e,r,i,n)).reduce(zo,{})}function Re(e){return Ps(e,pn)}Re.propTypes=process.env.NODE_ENV!=="production"?pn.reduce((e,r)=>(e[r]=hr,e),{}):{};Re.filterProps=pn;function Pe(e){return Ps(e,hn)}Pe.propTypes=process.env.NODE_ENV!=="production"?hn.reduce((e,r)=>(e[r]=hr,e),{}):{};Pe.filterProps=hn;process.env.NODE_ENV!=="production"&&xc.reduce((e,r)=>(e[r]=hr,e),{});function Ns(e=8,r=fi({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 fn(...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]?zo(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 St(e){return typeof e!="number"?e:`${e}px solid`}function wt(e,r){return Fe({prop:e,themeKey:"borders",transform:r})}const bc=wt("border",St),vc=wt("borderTop",St),Sc=wt("borderRight",St),Cc=wt("borderBottom",St),jc=wt("borderLeft",St),wc=wt("borderColor"),kc=wt("borderTopColor"),zc=wt("borderRightColor"),Tc=wt("borderBottomColor"),Bc=wt("borderLeftColor"),Ic=wt("outline",St),Ec=wt("outlineColor"),mn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Eo(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Do(r,i)});return er(e,e.borderRadius,n)}return null};mn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:hr}:{};mn.filterProps=["borderRadius"];fn(bc,vc,Sc,Cc,jc,wc,kc,zc,Tc,Bc,mn,Ic,Ec);const xn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Eo(e.theme,"spacing",8,"gap"),n=i=>({gap:Do(r,i)});return er(e,e.gap,n)}return null};xn.propTypes=process.env.NODE_ENV!=="production"?{gap:hr}:{};xn.filterProps=["gap"];const gn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Eo(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Do(r,i)});return er(e,e.columnGap,n)}return null};gn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:hr}:{};gn.filterProps=["columnGap"];const yn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Eo(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Do(r,i)});return er(e,e.rowGap,n)}return null};yn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:hr}:{};yn.filterProps=["rowGap"];const Dc=Fe({prop:"gridColumn"}),$c=Fe({prop:"gridRow"}),_c=Fe({prop:"gridAutoFlow"}),Oc=Fe({prop:"gridAutoColumns"}),Mc=Fe({prop:"gridAutoRows"}),Wc=Fe({prop:"gridTemplateColumns"}),Ac=Fe({prop:"gridTemplateRows"}),Rc=Fe({prop:"gridTemplateAreas"}),Pc=Fe({prop:"gridArea"});fn(xn,gn,yn,Dc,$c,_c,Oc,Mc,Wc,Ac,Rc,Pc);function oo(e,r){return r==="grey"?r:e}const Nc=Fe({prop:"color",themeKey:"palette",transform:oo}),Lc=Fe({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:oo}),Fc=Fe({prop:"backgroundColor",themeKey:"palette",transform:oo});fn(Nc,Lc,Fc);function ft(e){return e<=1&&e!==0?`${e*100}%`:e}const Vc=Fe({prop:"width",transform:ft}),mi=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,c,l,p;const i=((c=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:c[n])||dn[n];return i?((p=(l=e.theme)==null?void 0:l.breakpoints)==null?void 0:p.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:ft(n)}};return er(e,e.maxWidth,r)}return null};mi.filterProps=["maxWidth"];const Hc=Fe({prop:"minWidth",transform:ft}),Uc=Fe({prop:"height",transform:ft}),Gc=Fe({prop:"maxHeight",transform:ft}),Yc=Fe({prop:"minHeight",transform:ft});Fe({prop:"size",cssProperty:"width",transform:ft});Fe({prop:"size",cssProperty:"height",transform:ft});const qc=Fe({prop:"boxSizing"});fn(Vc,mi,Hc,Uc,Gc,Yc,qc);const bn={border:{themeKey:"borders",transform:St},borderTop:{themeKey:"borders",transform:St},borderRight:{themeKey:"borders",transform:St},borderBottom:{themeKey:"borders",transform:St},borderLeft:{themeKey:"borders",transform:St},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:St},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:mn},color:{themeKey:"palette",transform:oo},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:oo},backgroundColor:{themeKey:"palette",transform:oo},p:{style:Pe},pt:{style:Pe},pr:{style:Pe},pb:{style:Pe},pl:{style:Pe},px:{style:Pe},py:{style:Pe},padding:{style:Pe},paddingTop:{style:Pe},paddingRight:{style:Pe},paddingBottom:{style:Pe},paddingLeft:{style:Pe},paddingX:{style:Pe},paddingY:{style:Pe},paddingInline:{style:Pe},paddingInlineStart:{style:Pe},paddingInlineEnd:{style:Pe},paddingBlock:{style:Pe},paddingBlockStart:{style:Pe},paddingBlockEnd:{style:Pe},m:{style:Re},mt:{style:Re},mr:{style:Re},mb:{style:Re},ml:{style:Re},mx:{style:Re},my:{style:Re},margin:{style:Re},marginTop:{style:Re},marginRight:{style:Re},marginBottom:{style:Re},marginLeft:{style:Re},marginX:{style:Re},marginY:{style:Re},marginInline:{style:Re},marginInlineStart:{style:Re},marginInlineEnd:{style:Re},marginBlock:{style:Re},marginBlockStart:{style:Re},marginBlockEnd:{style:Re},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:xn},rowGap:{style:yn},columnGap:{style:gn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:ft},maxWidth:{style:mi},minWidth:{transform:ft},height:{transform:ft},maxHeight:{transform:ft},minHeight:{transform:ft},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 Jc(...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 Kc(e,r){return typeof e=="function"?e(r):e}function Xc(){function e(n,i,s,a){const c={[n]:i,theme:s},l=a[n];if(!l)return{[n]:i};const{cssProperty:p=n,themeKey:x,transform:y,style:g}=l;if(i==null)return null;if(x==="typography"&&i==="inherit")return{[n]:i};const v=un(s,x)||{};return g?g(c):er(c,i,k=>{let b=on(v,y,k);return k===b&&typeof k=="string"&&(b=on(v,y,`${n}${k==="default"?"":Rs(k)}`,k)),p===!1?b:{[p]:b}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const c=s.unstable_sxConfig??bn;function l(p){let x=p;if(typeof p=="function")x=p(s);else if(typeof p!="object")return p;if(!x)return null;const y=uc(s.breakpoints),g=Object.keys(y);let v=y;return Object.keys(x).forEach(S=>{const k=Kc(x[S],s);if(k!=null)if(typeof k=="object")if(c[S])v=zo(v,e(S,k,s,c));else{const b=er({theme:s},k,m=>({[S]:m}));Jc(b,k)?v[S]=r({sx:k,theme:s,nested:!0}):v=zo(v,b)}else v=zo(v,e(S,k,s,c))}),!a&&s.modularCssLayers?{"@layer sx":qi(s,Ki(g,v))}:qi(s,Ki(g,v))}return Array.isArray(i)?i.map(l):l(i)}return r}const vn=Xc();vn.filterProps=["sx"];function Qc(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 Ls(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...c}=e,l=ic(n),p=Ns(s);let x=mt({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:p,shape:{...cc,...a}},c);return x=lc(x),x.applyStyles=Qc,x=r.reduce((y,g)=>mt(y,g),x),x.unstable_sxConfig={...bn,...c==null?void 0:c.unstable_sxConfig},x.unstable_sx=function(g){return vn({sx:g,theme:this})},x}function Zc(e){return Object.keys(e).length===0}function ed(e=null){const r=sn.useContext(ma.ThemeContext);return!r||Zc(r)?e:r}const td=Ls();function rd(e=td){return ed(e)}const Qi=e=>e,od=()=>{let e=Qi;return{configure(r){e=r},generate(r){return e(r)},reset(){e=Qi}}},nd=od(),id={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 sd(e,r,n="Mui"){const i=id[r];return i?`${n}-${i}`:`${nd.generate(e)}-${r}`}function ad(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function xi(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}].`),ad(e,r,n)}function ld(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 pr(e){if(e.type)return e;if(e.charAt(0)==="#")return pr(ld(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().`:Er(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.`:Er(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:n,values:i,colorSpace:s}}const cd=e=>{const r=pr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},jo=(e,r)=>{try{return cd(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function Sn(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 Fs(e){e=pr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),c=(x,y=(x+n/30)%12)=>s-a*Math.max(Math.min(y-3,9-y,1),-1);let l="rgb";const p=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return e.type==="hsla"&&(l+="a",p.push(r[3])),Sn({type:l,values:p})}function ei(e){e=pr(e);let r=e.type==="hsl"||e.type==="hsla"?pr(Fs(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 Zi(e,r){const n=ei(e),i=ei(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function E(e,r){return e=pr(e),r=xi(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,Sn(e)}function Br(e,r,n){try{return E(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function Cn(e,r){if(e=pr(e),r=xi(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 Sn(e)}function Ie(e,r,n){try{return Cn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function jn(e,r){if(e=pr(e),r=xi(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 Sn(e)}function Ee(e,r,n){try{return jn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function dd(e,r=.15){return ei(e)>.5?Cn(e,r):jn(e,r)}function Uo(e,r,n){try{return dd(e,r)}catch{return e}}function ud(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 es=(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])})},pd=(e,r,n)=>{function i(s,a=[],c=[]){Object.entries(s).forEach(([l,p])=>{(!n||n&&!n([...a,l]))&&p!=null&&(typeof p=="object"&&Object.keys(p).length>0?i(p,[...a,l],Array.isArray(p)?[...c,l]:c):r([...a,l],p,c))})}i(e)},hd=(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 qn(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},a={},c={};return pd(e,(l,p,x)=>{if((typeof p=="string"||typeof p=="number")&&(!i||!i(l,p))){const y=`--${n?`${n}-`:""}${l.join("-")}`,g=hd(l,p);Object.assign(s,{[y]:g}),es(a,l,`var(${y})`,x),es(c,l,`var(${y}, ${g})`,x)}},l=>l[0]==="vars"),{css:s,vars:a,varsWithDefaults:c}}function fd(e,r={}){const{getSelector:n=z,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:c={},components:l,defaultColorScheme:p="light",...x}=e,{vars:y,css:g,varsWithDefaults:v}=qn(x,r);let S=v;const k={},{[p]:b,...m}=c;if(Object.entries(m||{}).forEach(([T,j])=>{const{vars:P,css:_,varsWithDefaults:M}=qn(j,r);S=mt(S,M),k[T]={css:_,vars:P}}),b){const{css:T,vars:j,varsWithDefaults:P}=qn(b,r);S=mt(S,P),k[p]={css:T,vars:j}}function z(T,j){var _,M;let P=s;if(s==="class"&&(P=".%s"),s==="data"&&(P="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(P=`[${s}="%s"]`),T){if(P==="media")return e.defaultColorScheme===T?":root":{[`@media (prefers-color-scheme: ${((M=(_=c[T])==null?void 0:_.palette)==null?void 0:M.mode)||T})`]:{":root":j}};if(P)return e.defaultColorScheme===T?`:root, ${P.replace("%s",String(T))}`:P.replace("%s",String(T))}return":root"}return{vars:S,generateThemeVars:()=>{let T={...y};return Object.entries(k).forEach(([,{vars:j}])=>{T=mt(T,j)}),T},generateStyleSheets:()=>{var G,q;const T=[],j=e.defaultColorScheme||"light";function P(R,u){Object.keys(u).length&&T.push(typeof R=="string"?{[R]:{...u}}:R)}P(n(void 0,{...g}),g);const{[j]:_,...M}=k;if(_){const{css:R}=_,u=(q=(G=c[j])==null?void 0:G.palette)==null?void 0:q.mode,A=!i&&u?{colorScheme:u,...R}:{...R};P(n(j,{...A}),A)}return Object.entries(M).forEach(([R,{css:u}])=>{var d,ne;const A=(ne=(d=c[R])==null?void 0:d.palette)==null?void 0:ne.mode,F=!i&&A?{colorScheme:A,...u}:{...u};P(n(R,{...F}),F)}),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 md(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 Bo={black:"#000",white:"#fff"},xd={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"},Qr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},Zr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},bo={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},eo={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},to={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},ro={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Vs(){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:Bo.white,default:Bo.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 Hs=Vs();function Us(){return{text:{primary:Bo.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:Bo.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 ti=Us();function ts(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=jn(e.main,s):r==="dark"&&(e.dark=Cn(e.main,a)))}function rs(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 gd(e="light"){return e==="dark"?{main:eo[200],light:eo[50],dark:eo[400]}:{main:eo[700],light:eo[400],dark:eo[800]}}function yd(e="light"){return e==="dark"?{main:Qr[200],light:Qr[50],dark:Qr[400]}:{main:Qr[500],light:Qr[300],dark:Qr[700]}}function bd(e="light"){return e==="dark"?{main:Zr[500],light:Zr[300],dark:Zr[700]}:{main:Zr[700],light:Zr[400],dark:Zr[800]}}function vd(e="light"){return e==="dark"?{main:to[400],light:to[300],dark:to[700]}:{main:to[700],light:to[500],dark:to[900]}}function Sd(e="light"){return e==="dark"?{main:ro[400],light:ro[300],dark:ro[700]}:{main:ro[800],light:ro[500],dark:ro[900]}}function Cd(e="light"){return e==="dark"?{main:bo[400],light:bo[300],dark:bo[700]}:{main:"#ed6c02",light:bo[500],dark:bo[900]}}function jd(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function gi(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...a}=e,c=e.primary||gd(r),l=e.secondary||yd(r),p=e.error||bd(r),x=e.info||vd(r),y=e.success||Sd(r),g=e.warning||Cd(r);function v(m){if(s)return jd(m);const z=Zi(m,ti.text.primary)>=n?ti.text.primary:Hs.text.primary;if(process.env.NODE_ENV!=="production"){const h=Zi(m,z);h<3&&console.error([`MUI: The contrast ratio of ${h}:1 for ${z} on ${m}`,"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(`
144
+ `)),()=>{})}function fi(e){return Eo(e,"spacing",8,"spacing")}function Do(e,r){return typeof r=="string"||r==null?r:e(r)}function yc(e,r){return n=>e.reduce((i,s)=>(i[s]=Do(r,n),i),{})}function bc(e,r,n,i){if(!r.includes(n))return null;const s=xc(n),a=yc(s,i),c=e[n];return or(e,c,a)}function Ns(e,r){const n=fi(e.theme);return Object.keys(e).map(i=>bc(e,r,i,n)).reduce(zo,{})}function Re(e){return Ns(e,dn)}Re.propTypes=process.env.NODE_ENV!=="production"?dn.reduce((e,r)=>(e[r]=mr,e),{}):{};Re.filterProps=dn;function Pe(e){return Ns(e,un)}Pe.propTypes=process.env.NODE_ENV!=="production"?un.reduce((e,r)=>(e[r]=mr,e),{}):{};Pe.filterProps=un;process.env.NODE_ENV!=="production"&&gc.reduce((e,r)=>(e[r]=mr,e),{});function Ls(e=8,r=fi({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 pn(...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]?zo(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 St(e){return typeof e!="number"?e:`${e}px solid`}function wt(e,r){return Le({prop:e,themeKey:"borders",transform:r})}const vc=wt("border",St),Sc=wt("borderTop",St),Cc=wt("borderRight",St),jc=wt("borderBottom",St),wc=wt("borderLeft",St),kc=wt("borderColor"),zc=wt("borderTopColor"),Tc=wt("borderRightColor"),Bc=wt("borderBottomColor"),Ic=wt("borderLeftColor"),Ec=wt("outline",St),Dc=wt("outlineColor"),hn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Eo(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Do(r,i)});return or(e,e.borderRadius,n)}return null};hn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:mr}:{};hn.filterProps=["borderRadius"];pn(vc,Sc,Cc,jc,wc,kc,zc,Tc,Bc,Ic,hn,Ec,Dc);const fn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Eo(e.theme,"spacing",8,"gap"),n=i=>({gap:Do(r,i)});return or(e,e.gap,n)}return null};fn.propTypes=process.env.NODE_ENV!=="production"?{gap:mr}:{};fn.filterProps=["gap"];const mn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Eo(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Do(r,i)});return or(e,e.columnGap,n)}return null};mn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:mr}:{};mn.filterProps=["columnGap"];const xn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Eo(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Do(r,i)});return or(e,e.rowGap,n)}return null};xn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:mr}:{};xn.filterProps=["rowGap"];const $c=Le({prop:"gridColumn"}),_c=Le({prop:"gridRow"}),Oc=Le({prop:"gridAutoFlow"}),Mc=Le({prop:"gridAutoColumns"}),Wc=Le({prop:"gridAutoRows"}),Ac=Le({prop:"gridTemplateColumns"}),Rc=Le({prop:"gridTemplateRows"}),Pc=Le({prop:"gridTemplateAreas"}),Nc=Le({prop:"gridArea"});pn(fn,mn,xn,$c,_c,Oc,Mc,Wc,Ac,Rc,Pc,Nc);function io(e,r){return r==="grey"?r:e}const Lc=Le({prop:"color",themeKey:"palette",transform:io}),Fc=Le({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:io}),Vc=Le({prop:"backgroundColor",themeKey:"palette",transform:io});pn(Lc,Fc,Vc);function mt(e){return e<=1&&e!==0?`${e*100}%`:e}const Hc=Le({prop:"width",transform:mt}),mi=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,c,l,p;const i=((c=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:c[n])||ln[n];return i?((p=(l=e.theme)==null?void 0:l.breakpoints)==null?void 0:p.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:mt(n)}};return or(e,e.maxWidth,r)}return null};mi.filterProps=["maxWidth"];const Uc=Le({prop:"minWidth",transform:mt}),Gc=Le({prop:"height",transform:mt}),Yc=Le({prop:"maxHeight",transform:mt}),qc=Le({prop:"minHeight",transform:mt});Le({prop:"size",cssProperty:"width",transform:mt});Le({prop:"size",cssProperty:"height",transform:mt});const Jc=Le({prop:"boxSizing"});pn(Hc,mi,Uc,Gc,Yc,qc,Jc);const gn={border:{themeKey:"borders",transform:St},borderTop:{themeKey:"borders",transform:St},borderRight:{themeKey:"borders",transform:St},borderBottom:{themeKey:"borders",transform:St},borderLeft:{themeKey:"borders",transform:St},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:St},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:hn},color:{themeKey:"palette",transform:io},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:io},backgroundColor:{themeKey:"palette",transform:io},p:{style:Pe},pt:{style:Pe},pr:{style:Pe},pb:{style:Pe},pl:{style:Pe},px:{style:Pe},py:{style:Pe},padding:{style:Pe},paddingTop:{style:Pe},paddingRight:{style:Pe},paddingBottom:{style:Pe},paddingLeft:{style:Pe},paddingX:{style:Pe},paddingY:{style:Pe},paddingInline:{style:Pe},paddingInlineStart:{style:Pe},paddingInlineEnd:{style:Pe},paddingBlock:{style:Pe},paddingBlockStart:{style:Pe},paddingBlockEnd:{style:Pe},m:{style:Re},mt:{style:Re},mr:{style:Re},mb:{style:Re},ml:{style:Re},mx:{style:Re},my:{style:Re},margin:{style:Re},marginTop:{style:Re},marginRight:{style:Re},marginBottom:{style:Re},marginLeft:{style:Re},marginX:{style:Re},marginY:{style:Re},marginInline:{style:Re},marginInlineStart:{style:Re},marginInlineEnd:{style:Re},marginBlock:{style:Re},marginBlockStart:{style:Re},marginBlockEnd:{style:Re},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:fn},rowGap:{style:xn},columnGap:{style:mn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:mt},maxWidth:{style:mi},minWidth:{transform:mt},height:{transform:mt},maxHeight:{transform:mt},minHeight:{transform:mt},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 Kc(...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 Xc(e,r){return typeof e=="function"?e(r):e}function Qc(){function e(n,i,s,a){const c={[n]:i,theme:s},l=a[n];if(!l)return{[n]:i};const{cssProperty:p=n,themeKey:x,transform:y,style:g}=l;if(i==null)return null;if(x==="typography"&&i==="inherit")return{[n]:i};const v=cn(s,x)||{};return g?g(c):or(c,i,k=>{let b=tn(v,y,k);return k===b&&typeof k=="string"&&(b=tn(v,y,`${n}${k==="default"?"":Ps(k)}`,k)),p===!1?b:{[p]:b}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const c=s.unstable_sxConfig??gn;function l(p){let x=p;if(typeof p=="function")x=p(s);else if(typeof p!="object")return p;if(!x)return null;const y=pc(s.breakpoints),g=Object.keys(y);let v=y;return Object.keys(x).forEach(S=>{const k=Xc(x[S],s);if(k!=null)if(typeof k=="object")if(c[S])v=zo(v,e(S,k,s,c));else{const b=or({theme:s},k,m=>({[S]:m}));Kc(b,k)?v[S]=r({sx:k,theme:s,nested:!0}):v=zo(v,b)}else v=zo(v,e(S,k,s,c))}),!a&&s.modularCssLayers?{"@layer sx":Ji(s,Xi(g,v))}:Ji(s,Xi(g,v))}return Array.isArray(i)?i.map(l):l(i)}return r}const yn=Qc();yn.filterProps=["sx"];function Zc(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 Fs(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...c}=e,l=sc(n),p=Ls(s);let x=xt({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:p,shape:{...dc,...a}},c);return x=cc(x),x.applyStyles=Zc,x=r.reduce((y,g)=>xt(y,g),x),x.unstable_sxConfig={...gn,...c==null?void 0:c.unstable_sxConfig},x.unstable_sx=function(g){return yn({sx:g,theme:this})},x}function ed(e){return Object.keys(e).length===0}function td(e=null){const r=on.useContext(xa.ThemeContext);return!r||ed(r)?e:r}const rd=Fs();function od(e=rd){return td(e)}const Zi=e=>e,nd=()=>{let e=Zi;return{configure(r){e=r},generate(r){return e(r)},reset(){e=Zi}}},id=nd(),sd={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 ad(e,r,n="Mui"){const i=sd[r];return i?`${n}-${i}`:`${id.generate(e)}-${r}`}function ld(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function xi(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}].`),ld(e,r,n)}function cd(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 fr(e){if(e.type)return e;if(e.charAt(0)==="#")return fr(cd(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().`:$r(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.`:$r(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:n,values:i,colorSpace:s}}const dd=e=>{const r=fr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},jo=(e,r)=>{try{return dd(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 Vs(e){e=fr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),c=(x,y=(x+n/30)%12)=>s-a*Math.max(Math.min(y-3,9-y,1),-1);let l="rgb";const p=[Math.round(c(0)*255),Math.round(c(8)*255),Math.round(c(4)*255)];return e.type==="hsla"&&(l+="a",p.push(r[3])),bn({type:l,values:p})}function ei(e){e=fr(e);let r=e.type==="hsl"||e.type==="hsla"?fr(Vs(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 es(e,r){const n=ei(e),i=ei(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function D(e,r){return e=fr(e),r=xi(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,bn(e)}function Er(e,r,n){try{return D(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function vn(e,r){if(e=fr(e),r=xi(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 Be(e,r,n){try{return vn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function Sn(e,r){if(e=fr(e),r=xi(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 Ie(e,r,n){try{return Sn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function ud(e,r=.15){return ei(e)>.5?vn(e,r):Sn(e,r)}function Vo(e,r,n){try{return ud(e,r)}catch{return e}}function pd(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 ts=(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])})},hd=(e,r,n)=>{function i(s,a=[],c=[]){Object.entries(s).forEach(([l,p])=>{(!n||n&&!n([...a,l]))&&p!=null&&(typeof p=="object"&&Object.keys(p).length>0?i(p,[...a,l],Array.isArray(p)?[...c,l]:c):r([...a,l],p,c))})}i(e)},fd=(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 qn(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},a={},c={};return hd(e,(l,p,x)=>{if((typeof p=="string"||typeof p=="number")&&(!i||!i(l,p))){const y=`--${n?`${n}-`:""}${l.join("-")}`,g=fd(l,p);Object.assign(s,{[y]:g}),ts(a,l,`var(${y})`,x),ts(c,l,`var(${y}, ${g})`,x)}},l=>l[0]==="vars"),{css:s,vars:a,varsWithDefaults:c}}function md(e,r={}){const{getSelector:n=z,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:c={},components:l,defaultColorScheme:p="light",...x}=e,{vars:y,css:g,varsWithDefaults:v}=qn(x,r);let S=v;const k={},{[p]:b,...m}=c;if(Object.entries(m||{}).forEach(([T,w])=>{const{vars:P,css:O,varsWithDefaults:M}=qn(w,r);S=xt(S,M),k[T]={css:O,vars:P}}),b){const{css:T,vars:w,varsWithDefaults:P}=qn(b,r);S=xt(S,P),k[p]={css:T,vars:w}}function z(T,w){var O,M;let P=s;if(s==="class"&&(P=".%s"),s==="data"&&(P="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(P=`[${s}="%s"]`),T){if(P==="media")return e.defaultColorScheme===T?":root":{[`@media (prefers-color-scheme: ${((M=(O=c[T])==null?void 0:O.palette)==null?void 0:M.mode)||T})`]:{":root":w}};if(P)return e.defaultColorScheme===T?`:root, ${P.replace("%s",String(T))}`:P.replace("%s",String(T))}return":root"}return{vars:S,generateThemeVars:()=>{let T={...y};return Object.entries(k).forEach(([,{vars:w}])=>{T=xt(T,w)}),T},generateStyleSheets:()=>{var q,K;const T=[],w=e.defaultColorScheme||"light";function P(R,u){Object.keys(u).length&&T.push(typeof R=="string"?{[R]:{...u}}:R)}P(n(void 0,{...g}),g);const{[w]:O,...M}=k;if(O){const{css:R}=O,u=(K=(q=c[w])==null?void 0:q.palette)==null?void 0:K.mode,A=!i&&u?{colorScheme:u,...R}:{...R};P(n(w,{...A}),A)}return Object.entries(M).forEach(([R,{css:u}])=>{var d,oe;const A=(oe=(d=c[R])==null?void 0:d.palette)==null?void 0:oe.mode,F=!i&&A?{colorScheme:A,...u}:{...u};P(n(R,{...F}),F)}),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 xd(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 Bo={black:"#000",white:"#fff"},gd={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"},Zr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},eo={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},vo={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},to={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},ro={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},oo={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Hs(){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:Bo.white,default:Bo.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 Us=Hs();function Gs(){return{text:{primary:Bo.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:Bo.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 ti=Gs();function rs(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=Sn(e.main,s):r==="dark"&&(e.dark=vn(e.main,a)))}function os(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 yd(e="light"){return e==="dark"?{main:to[200],light:to[50],dark:to[400]}:{main:to[700],light:to[400],dark:to[800]}}function bd(e="light"){return e==="dark"?{main:Zr[200],light:Zr[50],dark:Zr[400]}:{main:Zr[500],light:Zr[300],dark:Zr[700]}}function vd(e="light"){return e==="dark"?{main:eo[500],light:eo[300],dark:eo[700]}:{main:eo[700],light:eo[400],dark:eo[800]}}function Sd(e="light"){return e==="dark"?{main:ro[400],light:ro[300],dark:ro[700]}:{main:ro[700],light:ro[500],dark:ro[900]}}function Cd(e="light"){return e==="dark"?{main:oo[400],light:oo[300],dark:oo[700]}:{main:oo[800],light:oo[500],dark:oo[900]}}function jd(e="light"){return e==="dark"?{main:vo[400],light:vo[300],dark:vo[700]}:{main:"#ed6c02",light:vo[500],dark:vo[900]}}function wd(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function gi(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...a}=e,c=e.primary||yd(r),l=e.secondary||bd(r),p=e.error||vd(r),x=e.info||Sd(r),y=e.success||Cd(r),g=e.warning||jd(r);function v(m){if(s)return wd(m);const z=es(m,ti.text.primary)>=n?ti.text.primary:Us.text.primary;if(process.env.NODE_ENV!=="production"){const h=es(m,z);h<3&&console.error([`MUI: The contrast ratio of ${h}:1 for ${z} on ${m}`,"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
147
  `))}return z}const S=({color:m,name:z,mainShade:h=500,lightShade:B=300,darkShade:T=700})=>{if(m={...m},!m.main&&m[h]&&(m.main=m[h]),!m.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${z?` (${z})`:""} provided to augmentColor(color) is invalid.
148
- The color object needs to have a \`main\` property or a \`${h}\` property.`:Er(11,z?` (${z})`:"",h));if(typeof m.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${z?` (${z})`:""} provided to augmentColor(color) is invalid.
148
+ The color object needs to have a \`main\` property or a \`${h}\` property.`:$r(11,z?` (${z})`:"",h));if(typeof m.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${z?` (${z})`:""} provided to augmentColor(color) is invalid.
149
149
  \`color.main\` should be a string, but \`${JSON.stringify(m.main)}\` was provided instead.
150
150
 
151
151
  Did you intend to use one of the following approaches?
@@ -158,17 +158,17 @@ const theme1 = createTheme({ palette: {
158
158
 
159
159
  const theme2 = createTheme({ palette: {
160
160
  primary: { main: green[500] },
161
- } });`:Er(12,z?` (${z})`:"",JSON.stringify(m.main)));return s?(rs(s,m,"light",B,i),rs(s,m,"dark",T,i)):(ts(m,"light",B,i),ts(m,"dark",T,i)),m.contrastText||(m.contrastText=v(m.main)),m};let k;return r==="light"?k=Vs():r==="dark"&&(k=Us()),process.env.NODE_ENV!=="production"&&(k||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),mt({common:{...Bo},mode:r,primary:S({color:c,name:"primary"}),secondary:S({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:S({color:p,name:"error"}),warning:S({color:g,name:"warning"}),info:S({color:x,name:"info"}),success:S({color:y,name:"success"}),grey:xd,contrastThreshold:n,getContrastText:v,augmentColor:S,tonalOffset:i,...k},a)}function wd(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 kd(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function zd(e){return Math.round(e*1e5)/1e5}const os={textTransform:"uppercase"},ns='"Roboto", "Helvetica", "Arial", sans-serif';function Td(e,r){const{fontFamily:n=ns,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:p=16,allVariants:x,pxToRem:y,...g}=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 p!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const v=i/14,S=y||(m=>`${m/p*v}rem`),k=(m,z,h,B,T)=>({fontFamily:n,fontWeight:m,fontSize:S(z),lineHeight:h,...n===ns?{letterSpacing:`${zd(B/z)}em`}:{},...T,...x}),b={h1:k(s,96,1.167,-1.5),h2:k(s,60,1.2,-.5),h3:k(a,48,1.167,0),h4:k(a,34,1.235,.25),h5:k(a,24,1.334,0),h6:k(c,20,1.6,.15),subtitle1:k(a,16,1.75,.15),subtitle2:k(c,14,1.57,.1),body1:k(a,16,1.5,.15),body2:k(a,14,1.43,.15),button:k(c,14,1.75,.4,os),caption:k(a,12,1.66,.4),overline:k(a,12,2.66,1,os),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return mt({htmlFontSize:p,pxToRem:S,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:c,fontWeightBold:l,...b},g,{clone:!1})}const Bd=.2,Id=.14,Ed=.12;function Oe(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${Bd})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Id})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Ed})`].join(",")}const Dd=["none",Oe(0,2,1,-1,0,1,1,0,0,1,3,0),Oe(0,3,1,-2,0,2,2,0,0,1,5,0),Oe(0,3,3,-2,0,3,4,0,0,1,8,0),Oe(0,2,4,-1,0,4,5,0,0,1,10,0),Oe(0,3,5,-1,0,5,8,0,0,1,14,0),Oe(0,3,5,-1,0,6,10,0,0,1,18,0),Oe(0,4,5,-2,0,7,10,1,0,2,16,1),Oe(0,5,5,-3,0,8,10,1,0,3,14,2),Oe(0,5,6,-3,0,9,12,1,0,3,16,2),Oe(0,6,6,-3,0,10,14,1,0,4,18,3),Oe(0,6,7,-4,0,11,15,1,0,4,20,3),Oe(0,7,8,-4,0,12,17,2,0,5,22,4),Oe(0,7,8,-4,0,13,19,2,0,5,24,4),Oe(0,7,9,-4,0,14,21,2,0,5,26,4),Oe(0,8,9,-5,0,15,22,2,0,6,28,5),Oe(0,8,10,-5,0,16,24,2,0,6,30,5),Oe(0,8,11,-5,0,17,26,2,0,6,32,5),Oe(0,9,11,-5,0,18,28,2,0,7,34,6),Oe(0,9,12,-6,0,19,29,2,0,7,36,6),Oe(0,10,13,-6,0,20,31,3,0,8,38,7),Oe(0,10,13,-6,0,21,33,3,0,8,40,7),Oe(0,10,14,-6,0,22,35,3,0,8,42,7),Oe(0,11,14,-7,0,23,36,3,0,9,44,8),Oe(0,11,15,-7,0,24,38,3,0,9,46,8)],$d={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)"},_d={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function is(e){return`${Math.round(e)}ms`}function Od(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function Md(e){const r={...$d,...e.easing},n={..._d,...e.duration};return{getAutoHeightDuration:Od,create:(s=["all"],a={})=>{const{duration:c=n.standard,easing:l=r.easeInOut,delay:p=0,...x}=a;if(process.env.NODE_ENV!=="production"){const y=v=>typeof v=="string",g=v=>!Number.isNaN(parseFloat(v));!y(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!g(c)&&!y(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),y(l)||console.error('MUI: Argument "easing" must be a string.'),!g(p)&&!y(p)&&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(y=>`${y} ${typeof c=="string"?c:is(c)} ${l} ${typeof p=="string"?p:is(p)}`).join(",")},...e,easing:r,duration:n}}const Wd={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Ad(e){return dr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function Gs(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];!Ad(l)||c.startsWith("unstable_")?delete i[c]:dr(l)&&(i[c]={...l},n(i[c]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
161
+ } });`:$r(12,z?` (${z})`:"",JSON.stringify(m.main)));return s?(os(s,m,"light",B,i),os(s,m,"dark",T,i)):(rs(m,"light",B,i),rs(m,"dark",T,i)),m.contrastText||(m.contrastText=v(m.main)),m};let k;return r==="light"?k=Hs():r==="dark"&&(k=Gs()),process.env.NODE_ENV!=="production"&&(k||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),xt({common:{...Bo},mode:r,primary:S({color:c,name:"primary"}),secondary:S({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:S({color:p,name:"error"}),warning:S({color:g,name:"warning"}),info:S({color:x,name:"info"}),success:S({color:y,name:"success"}),grey:gd,contrastThreshold:n,getContrastText:v,augmentColor:S,tonalOffset:i,...k},a)}function kd(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 zd(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function Td(e){return Math.round(e*1e5)/1e5}const ns={textTransform:"uppercase"},is='"Roboto", "Helvetica", "Arial", sans-serif';function Bd(e,r){const{fontFamily:n=is,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:p=16,allVariants:x,pxToRem:y,...g}=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 p!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const v=i/14,S=y||(m=>`${m/p*v}rem`),k=(m,z,h,B,T)=>({fontFamily:n,fontWeight:m,fontSize:S(z),lineHeight:h,...n===is?{letterSpacing:`${Td(B/z)}em`}:{},...T,...x}),b={h1:k(s,96,1.167,-1.5),h2:k(s,60,1.2,-.5),h3:k(a,48,1.167,0),h4:k(a,34,1.235,.25),h5:k(a,24,1.334,0),h6:k(c,20,1.6,.15),subtitle1:k(a,16,1.75,.15),subtitle2:k(c,14,1.57,.1),body1:k(a,16,1.5,.15),body2:k(a,14,1.43,.15),button:k(c,14,1.75,.4,ns),caption:k(a,12,1.66,.4),overline:k(a,12,2.66,1,ns),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return xt({htmlFontSize:p,pxToRem:S,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:c,fontWeightBold:l,...b},g,{clone:!1})}const Id=.2,Ed=.14,Dd=.12;function Oe(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${Id})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Ed})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Dd})`].join(",")}const $d=["none",Oe(0,2,1,-1,0,1,1,0,0,1,3,0),Oe(0,3,1,-2,0,2,2,0,0,1,5,0),Oe(0,3,3,-2,0,3,4,0,0,1,8,0),Oe(0,2,4,-1,0,4,5,0,0,1,10,0),Oe(0,3,5,-1,0,5,8,0,0,1,14,0),Oe(0,3,5,-1,0,6,10,0,0,1,18,0),Oe(0,4,5,-2,0,7,10,1,0,2,16,1),Oe(0,5,5,-3,0,8,10,1,0,3,14,2),Oe(0,5,6,-3,0,9,12,1,0,3,16,2),Oe(0,6,6,-3,0,10,14,1,0,4,18,3),Oe(0,6,7,-4,0,11,15,1,0,4,20,3),Oe(0,7,8,-4,0,12,17,2,0,5,22,4),Oe(0,7,8,-4,0,13,19,2,0,5,24,4),Oe(0,7,9,-4,0,14,21,2,0,5,26,4),Oe(0,8,9,-5,0,15,22,2,0,6,28,5),Oe(0,8,10,-5,0,16,24,2,0,6,30,5),Oe(0,8,11,-5,0,17,26,2,0,6,32,5),Oe(0,9,11,-5,0,18,28,2,0,7,34,6),Oe(0,9,12,-6,0,19,29,2,0,7,36,6),Oe(0,10,13,-6,0,20,31,3,0,8,38,7),Oe(0,10,13,-6,0,21,33,3,0,8,40,7),Oe(0,10,14,-6,0,22,35,3,0,8,42,7),Oe(0,11,14,-7,0,23,36,3,0,9,44,8),Oe(0,11,15,-7,0,24,38,3,0,9,46,8)],_d={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)"},Od={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function ss(e){return`${Math.round(e)}ms`}function Md(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function Wd(e){const r={..._d,...e.easing},n={...Od,...e.duration};return{getAutoHeightDuration:Md,create:(s=["all"],a={})=>{const{duration:c=n.standard,easing:l=r.easeInOut,delay:p=0,...x}=a;if(process.env.NODE_ENV!=="production"){const y=v=>typeof v=="string",g=v=>!Number.isNaN(parseFloat(v));!y(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!g(c)&&!y(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),y(l)||console.error('MUI: Argument "easing" must be a string.'),!g(p)&&!y(p)&&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(y=>`${y} ${typeof c=="string"?c:ss(c)} ${l} ${typeof p=="string"?p:ss(p)}`).join(",")},...e,easing:r,duration:n}}const Ad={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Rd(e){return pr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function Ys(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];!Rd(l)||c.startsWith("unstable_")?delete i[c]:pr(l)&&(i[c]={...l},n(i[c]))}}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 ss(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Rd=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 Pd(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})`:E(r,Rd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${ss(n)})`:jn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${ss(n)})`:Cn(r,n)}})}function ri(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:c={},typography:l={},shape:p,colorSpace:x,...y}=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.":Er(20));const g=gi({...a,colorSpace:x}),v=Ls(e);let S=mt(v,{mixins:kd(v.breakpoints,i),palette:g,shadows:Dd.slice(),typography:Td(g,l),transitions:Md(c),zIndex:{...Wd}});if(S=mt(S,y),S=r.reduce((k,b)=>mt(k,b),S),process.env.NODE_ENV!=="production"){const k=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],b=(m,z)=>{let h;for(h in m){const B=m[h];if(k.includes(h)&&Object.keys(B).length>0){if(process.env.NODE_ENV!=="production"){const T=sd("",h);console.error([`MUI: The \`${z}\` component increases the CSS specificity of the \`${h}\` internal state.`,"You can not override it like this: ",JSON.stringify(m,null,2),"",`Instead, you need to use the '&.${T}' syntax:`,JSON.stringify({root:{[`&.${T}`]:B}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
- `))}m[h]={}}}};Object.keys(S.components).forEach(m=>{const z=S.components[m].styleOverrides;z&&m.startsWith("Mui")&&b(z,m)})}return S.unstable_sxConfig={...bn,...y==null?void 0:y.unstable_sxConfig},S.unstable_sx=function(b){return vn({sx:b,theme:this})},S.toRuntimeSource=Gs,Pd(S),S}function Nd(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 Ld=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Nd(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Ys(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function qs(e){return e==="dark"?Ld:[]}function Fd(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...a}=e,c=gi({...r,colorSpace:s});return{palette:c,opacity:{...Ys(c.mode),...n},overlays:i||qs(c.mode),...a}}function Vd(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 Hd=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Ud=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 Hd(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 Gd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function L(e,r,n){!e[r]&&n&&(e[r]=n)}function wo(e){return typeof e!="string"||!e.startsWith("hsl")?e:Fs(e)}function Qt(e,r){`${r}Channel`in e||(e[`${r}Channel`]=jo(wo(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 Yd(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Pt=e=>{try{return e()}catch{}},qd=(e="mui")=>ud(e);function Jn(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Fd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:c,...l}=ri({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:c,opacity:{...Ys(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||qs(a)},l}function Jd(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=Vd,colorSchemeSelector:p=n.light&&n.dark?"media":void 0,rootSelector:x=":root",...y}=e,g=Object.keys(n)[0],v=i||(n.light&&g!=="light"?"light":g),S=qd(a),{[v]:k,light:b,dark:m,...z}=n,h={...z};let B=k;if((v==="dark"&&!("dark"in n)||v==="light"&&!("light"in n))&&(B=!0),!B)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${v}\` option is either missing or invalid.`:Er(21,v));let T;c&&(T="oklch");const j=Jn(T,h,B,y,v);b&&!h.light&&Jn(T,h,b,void 0,"light"),m&&!h.dark&&Jn(T,h,m,void 0,"dark");let P={defaultColorScheme:v,...j,cssVarPrefix:a,colorSchemeSelector:p,rootSelector:x,getCssVar:S,colorSchemes:h,font:{...wd(j.typography),...j.font},spacing:Yd(y.spacing)};Object.keys(P.colorSchemes).forEach(R=>{const u=P.colorSchemes[R].palette,A=d=>{const ne=d.split("-"),U=ne[1],re=ne[2];return S(d,u[U][re])};u.mode==="light"&&(L(u.common,"background","#fff"),L(u.common,"onBackground","#000")),u.mode==="dark"&&(L(u.common,"background","#000"),L(u.common,"onBackground","#fff"));function F(d,ne,U){if(T){let re;return d===Br&&(re=`transparent ${((1-U)*100).toFixed(0)}%`),d===Ie&&(re=`#000 ${(U*100).toFixed(0)}%`),d===Ee&&(re=`#fff ${(U*100).toFixed(0)}%`),`color-mix(in ${T}, ${ne}, ${re})`}return d(ne,U)}if(Gd(u,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),u.mode==="light"){L(u.Alert,"errorColor",F(Ie,u.error.light,.6)),L(u.Alert,"infoColor",F(Ie,u.info.light,.6)),L(u.Alert,"successColor",F(Ie,u.success.light,.6)),L(u.Alert,"warningColor",F(Ie,u.warning.light,.6)),L(u.Alert,"errorFilledBg",A("palette-error-main")),L(u.Alert,"infoFilledBg",A("palette-info-main")),L(u.Alert,"successFilledBg",A("palette-success-main")),L(u.Alert,"warningFilledBg",A("palette-warning-main")),L(u.Alert,"errorFilledColor",Pt(()=>u.getContrastText(u.error.main))),L(u.Alert,"infoFilledColor",Pt(()=>u.getContrastText(u.info.main))),L(u.Alert,"successFilledColor",Pt(()=>u.getContrastText(u.success.main))),L(u.Alert,"warningFilledColor",Pt(()=>u.getContrastText(u.warning.main))),L(u.Alert,"errorStandardBg",F(Ee,u.error.light,.9)),L(u.Alert,"infoStandardBg",F(Ee,u.info.light,.9)),L(u.Alert,"successStandardBg",F(Ee,u.success.light,.9)),L(u.Alert,"warningStandardBg",F(Ee,u.warning.light,.9)),L(u.Alert,"errorIconColor",A("palette-error-main")),L(u.Alert,"infoIconColor",A("palette-info-main")),L(u.Alert,"successIconColor",A("palette-success-main")),L(u.Alert,"warningIconColor",A("palette-warning-main")),L(u.AppBar,"defaultBg",A("palette-grey-100")),L(u.Avatar,"defaultBg",A("palette-grey-400")),L(u.Button,"inheritContainedBg",A("palette-grey-300")),L(u.Button,"inheritContainedHoverBg",A("palette-grey-A100")),L(u.Chip,"defaultBorder",A("palette-grey-400")),L(u.Chip,"defaultAvatarColor",A("palette-grey-700")),L(u.Chip,"defaultIconColor",A("palette-grey-700")),L(u.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),L(u.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),L(u.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),L(u.LinearProgress,"primaryBg",F(Ee,u.primary.main,.62)),L(u.LinearProgress,"secondaryBg",F(Ee,u.secondary.main,.62)),L(u.LinearProgress,"errorBg",F(Ee,u.error.main,.62)),L(u.LinearProgress,"infoBg",F(Ee,u.info.main,.62)),L(u.LinearProgress,"successBg",F(Ee,u.success.main,.62)),L(u.LinearProgress,"warningBg",F(Ee,u.warning.main,.62)),L(u.Skeleton,"bg",T?F(Br,u.text.primary,.11):`rgba(${A("palette-text-primaryChannel")} / 0.11)`),L(u.Slider,"primaryTrack",F(Ee,u.primary.main,.62)),L(u.Slider,"secondaryTrack",F(Ee,u.secondary.main,.62)),L(u.Slider,"errorTrack",F(Ee,u.error.main,.62)),L(u.Slider,"infoTrack",F(Ee,u.info.main,.62)),L(u.Slider,"successTrack",F(Ee,u.success.main,.62)),L(u.Slider,"warningTrack",F(Ee,u.warning.main,.62));const d=T?F(Ie,u.background.default,.6825):Uo(u.background.default,.8);L(u.SnackbarContent,"bg",d),L(u.SnackbarContent,"color",Pt(()=>T?ti.text.primary:u.getContrastText(d))),L(u.SpeedDialAction,"fabHoverBg",Uo(u.background.paper,.15)),L(u.StepConnector,"border",A("palette-grey-400")),L(u.StepContent,"border",A("palette-grey-400")),L(u.Switch,"defaultColor",A("palette-common-white")),L(u.Switch,"defaultDisabledColor",A("palette-grey-100")),L(u.Switch,"primaryDisabledColor",F(Ee,u.primary.main,.62)),L(u.Switch,"secondaryDisabledColor",F(Ee,u.secondary.main,.62)),L(u.Switch,"errorDisabledColor",F(Ee,u.error.main,.62)),L(u.Switch,"infoDisabledColor",F(Ee,u.info.main,.62)),L(u.Switch,"successDisabledColor",F(Ee,u.success.main,.62)),L(u.Switch,"warningDisabledColor",F(Ee,u.warning.main,.62)),L(u.TableCell,"border",F(Ee,F(Br,u.divider,1),.88)),L(u.Tooltip,"bg",F(Br,u.grey[700],.92))}if(u.mode==="dark"){L(u.Alert,"errorColor",F(Ee,u.error.light,.6)),L(u.Alert,"infoColor",F(Ee,u.info.light,.6)),L(u.Alert,"successColor",F(Ee,u.success.light,.6)),L(u.Alert,"warningColor",F(Ee,u.warning.light,.6)),L(u.Alert,"errorFilledBg",A("palette-error-dark")),L(u.Alert,"infoFilledBg",A("palette-info-dark")),L(u.Alert,"successFilledBg",A("palette-success-dark")),L(u.Alert,"warningFilledBg",A("palette-warning-dark")),L(u.Alert,"errorFilledColor",Pt(()=>u.getContrastText(u.error.dark))),L(u.Alert,"infoFilledColor",Pt(()=>u.getContrastText(u.info.dark))),L(u.Alert,"successFilledColor",Pt(()=>u.getContrastText(u.success.dark))),L(u.Alert,"warningFilledColor",Pt(()=>u.getContrastText(u.warning.dark))),L(u.Alert,"errorStandardBg",F(Ie,u.error.light,.9)),L(u.Alert,"infoStandardBg",F(Ie,u.info.light,.9)),L(u.Alert,"successStandardBg",F(Ie,u.success.light,.9)),L(u.Alert,"warningStandardBg",F(Ie,u.warning.light,.9)),L(u.Alert,"errorIconColor",A("palette-error-main")),L(u.Alert,"infoIconColor",A("palette-info-main")),L(u.Alert,"successIconColor",A("palette-success-main")),L(u.Alert,"warningIconColor",A("palette-warning-main")),L(u.AppBar,"defaultBg",A("palette-grey-900")),L(u.AppBar,"darkBg",A("palette-background-paper")),L(u.AppBar,"darkColor",A("palette-text-primary")),L(u.Avatar,"defaultBg",A("palette-grey-600")),L(u.Button,"inheritContainedBg",A("palette-grey-800")),L(u.Button,"inheritContainedHoverBg",A("palette-grey-700")),L(u.Chip,"defaultBorder",A("palette-grey-700")),L(u.Chip,"defaultAvatarColor",A("palette-grey-300")),L(u.Chip,"defaultIconColor",A("palette-grey-300")),L(u.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),L(u.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),L(u.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),L(u.LinearProgress,"primaryBg",F(Ie,u.primary.main,.5)),L(u.LinearProgress,"secondaryBg",F(Ie,u.secondary.main,.5)),L(u.LinearProgress,"errorBg",F(Ie,u.error.main,.5)),L(u.LinearProgress,"infoBg",F(Ie,u.info.main,.5)),L(u.LinearProgress,"successBg",F(Ie,u.success.main,.5)),L(u.LinearProgress,"warningBg",F(Ie,u.warning.main,.5)),L(u.Skeleton,"bg",T?F(Br,u.text.primary,.13):`rgba(${A("palette-text-primaryChannel")} / 0.13)`),L(u.Slider,"primaryTrack",F(Ie,u.primary.main,.5)),L(u.Slider,"secondaryTrack",F(Ie,u.secondary.main,.5)),L(u.Slider,"errorTrack",F(Ie,u.error.main,.5)),L(u.Slider,"infoTrack",F(Ie,u.info.main,.5)),L(u.Slider,"successTrack",F(Ie,u.success.main,.5)),L(u.Slider,"warningTrack",F(Ie,u.warning.main,.5));const d=T?F(Ee,u.background.default,.985):Uo(u.background.default,.98);L(u.SnackbarContent,"bg",d),L(u.SnackbarContent,"color",Pt(()=>T?Hs.text.primary:u.getContrastText(d))),L(u.SpeedDialAction,"fabHoverBg",Uo(u.background.paper,.15)),L(u.StepConnector,"border",A("palette-grey-600")),L(u.StepContent,"border",A("palette-grey-600")),L(u.Switch,"defaultColor",A("palette-grey-300")),L(u.Switch,"defaultDisabledColor",A("palette-grey-600")),L(u.Switch,"primaryDisabledColor",F(Ie,u.primary.main,.55)),L(u.Switch,"secondaryDisabledColor",F(Ie,u.secondary.main,.55)),L(u.Switch,"errorDisabledColor",F(Ie,u.error.main,.55)),L(u.Switch,"infoDisabledColor",F(Ie,u.info.main,.55)),L(u.Switch,"successDisabledColor",F(Ie,u.success.main,.55)),L(u.Switch,"warningDisabledColor",F(Ie,u.warning.main,.55)),L(u.TableCell,"border",F(Ie,F(Br,u.divider,1),.68)),L(u.Tooltip,"bg",F(Br,u.grey[700],.92))}Qt(u.background,"default"),Qt(u.background,"paper"),Qt(u.common,"background"),Qt(u.common,"onBackground"),Qt(u,"divider"),Object.keys(u).forEach(d=>{const ne=u[d];d!=="tonalOffset"&&ne&&typeof ne=="object"&&(ne.main&&L(u[d],"mainChannel",jo(wo(ne.main))),ne.light&&L(u[d],"lightChannel",jo(wo(ne.light))),ne.dark&&L(u[d],"darkChannel",jo(wo(ne.dark))),ne.contrastText&&L(u[d],"contrastTextChannel",jo(wo(ne.contrastText))),d==="text"&&(Qt(u[d],"primary"),Qt(u[d],"secondary")),d==="action"&&(ne.active&&Qt(u[d],"active"),ne.selected&&Qt(u[d],"selected")))})}),P=r.reduce((R,u)=>mt(R,u),P);const _={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Ud(P),enableContrastVars:c},{vars:M,generateThemeVars:G,generateStyleSheets:q}=fd(P,_);return P.vars=M,Object.entries(P.colorSchemes[P.defaultColorScheme]).forEach(([R,u])=>{P[R]=u}),P.generateThemeVars=G,P.generateStyleSheets=q,P.generateSpacing=function(){return Ns(y.spacing,fi(this))},P.getColorSchemeSelector=md(p),P.spacing=P.generateSpacing(),P.shouldSkipGeneratingVar=l,P.unstable_sxConfig={...bn,...y==null?void 0:y.unstable_sxConfig},P.unstable_sx=function(u){return vn({sx:u,theme:this})},P.toRuntimeSource=Gs,P}function as(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:gi({...n===!0?{}:n.palette,mode:r})})}function Kd(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",p=s==null?void 0:s[l],x={...s,...n?{[l]:{...typeof p!="boolean"&&p,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return ri(e,...r);let y=n;"palette"in e||x[l]&&(x[l]!==!0?y=x[l].palette:l==="dark"&&(y={mode:"dark"}));const g=ri({...e,palette:y},...r);return g.defaultColorScheme=l,g.colorSchemes=x,g.palette.mode==="light"&&(g.colorSchemes.light={...x.light!==!0&&x.light,palette:g.palette},as(g,"dark",x.dark)),g.palette.mode==="dark"&&(g.colorSchemes.dark={...x.dark!==!0&&x.dark,palette:g.palette},as(g,"light",x.light)),g}return!n&&!("light"in x)&&l==="light"&&(x.light=!0),Jd({...c,colorSchemes:x,defaultColorScheme:l,...typeof i!="boolean"&&i},...r)}const Xd=Kd();function ct(){const e=rd(Xd);return process.env.NODE_ENV!=="production"&&sn.useDebugValue(e),e[Ul]||e}async function Qd(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(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(c.status===401)throw new Error("Authentication failed (401) — check your API key");if(!c.ok)throw new Error(`API error ${c.status}: ${c.statusText}`);let l;try{l=await c.json()}catch{throw new Error("Response is not valid JSON")}let p;if(Array.isArray(l))p=l;else if(n&&l[n]&&Array.isArray(l[n]))p=l[n];else{const y=["data","results","items","records"].find(g=>l[g]&&Array.isArray(l[g]));if(y)p=l[y];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:p,source:e,fetchedAt:new Date().toISOString()}}function Zd(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${E(e.palette.common.black,n.opacity)}`).join(", ")}const eu={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 ge(e,r){return Zd(e,eu[r])}function et(e){return`${Number(e.shape.borderRadius)*1.5}px`}function $o(e){return`${Number(e.shape.borderRadius)}px`}function ls(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 it(e){const r=e.tokens,n=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:n,bg:`var(--highlight-bg, ${E(n,.08)})`,hoverBg:`var(--highlight-hover, ${E(n,.12)})`}}function ce(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||ge(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 tu({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,c]=f.useState(""),[l,p]=f.useState(!1),[x,y]=f.useState(""),[g,v]=f.useState(null),[S,k]=f.useState(null),[b,m]=f.useState(!1),[z,h]=f.useState(""),B=f.useRef(null),[T,j]=f.useState("json"),[P,_]=f.useState(""),[M,G]=f.useState(""),[q,R]=f.useState(""),[u,A]=f.useState("idle"),[F,d]=f.useState(""),[ne,U]=f.useState(null),[re,xe]=f.useState(0),V=async I=>{if(h(""),!I.name.endsWith(".json")){h("Only .json files are allowed");return}const te=10*1024*1024;if(I.size>te){h("File size exceeds 10MB limit");return}try{const he=await I.text();let se;try{se=JSON.parse(he)}catch{h("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(se)){h("JSON must be an array of objects");return}if(se.length===0){h("No data rows found in JSON file");return}v(I),k(se)}catch{h("Network error — please try again")}},X=I=>{I.preventDefault();const te=I.dataTransfer.files[0];te&&V(te)},ae=async()=>{if(P.trim()){A("loading"),d("");try{const I=await Qd(P.trim(),M.trim()||void 0,q.trim()||void 0);U(I.data),xe(I.data.length),A("ready")}catch(I){d((I==null?void 0:I.message)||"Connection failed"),A("error")}}},le=()=>{if(!a.trim()){p(!0);return}const I=T==="api"?ne:i||S;I&&(n(a.trim(),x.trim(),I),ie())},ie=()=>{c(""),p(!1),y(""),v(null),k(null),h(""),j("json"),_(""),G(""),R(""),A("idle"),d(""),U(null),xe(0),r()},Q=i||S,de=l&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:ie,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:I=>({borderRadius:et(I),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...ce(I).paper})},children:[t.jsxs(o.DialogTitle,{sx:I=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:te=>te.typography.h6.fontWeight||500,fontSize:te=>te.typography.h6.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...ce(I).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:ie,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:I=>{c(I.target.value),l&&I.target.value.trim()&&p(!1)},placeholder:"Enter report name",autoFocus:!0,error:de,helperText:de?"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:I=>y(I.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:(I,te)=>{j(te===0?"json":"api"),A("idle"),d("")},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($.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:I=>`var(--highlight-hover, ${E(I.palette.primary.main,.15)})`},"&:hover":{bgcolor:I=>`var(--highlight-hover, ${E(I.palette.primary.main,.08)})`}}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx($.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:I=>`var(--highlight-hover, ${E(I.palette.primary.main,.15)})`},"&:hover":{bgcolor:I=>`var(--highlight-hover, ${E(I.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:I=>E(I.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:I=>E(I.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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:()=>m(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx($.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:X,onDragOver:I=>I.preventDefault(),onPaste:I=>I.preventDefault(),onClick:()=>{var I;return(I=B.current)==null?void 0:I.click()},sx:{position:"relative",border:"1.5px",borderStyle:S?"solid":"dashed",borderColor:S?"success.main":z?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:S?I=>E(I.palette.success.main,.04):z?I=>E(I.palette.error.main,.04):I=>E(I.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:S?I=>E(I.palette.success.main,.08):z?I=>E(I.palette.error.main,.08):I=>E(I.palette.primary.main,.08),borderColor:S?"success.dark":z?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:B,type:"file",accept:".json",sx:{display:"none"},onChange:I=>{var te;return((te=I.target.files)==null?void 0:te[0])&&V(I.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:I=>E(I.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx($.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:g==null?void 0:g.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:I=>E(I.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx($.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"}),z&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:I=>E(I.palette.error.main,.08),border:1,borderColor:I=>E(I.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:z})})]})]})]})}),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:P,onChange:I=>{_(I.target.value),A("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:M,onChange:I=>G(I.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx($.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:q,onChange:I=>R(I.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:!P.trim()||u==="loading",onClick:ae,startIcon:u==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx($.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:I=>E(I.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:u==="loading"?"Connecting...":"Test Connection & Load Data"}),u==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:I=>E(I.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.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:P})]})]}),u==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:I=>E(I.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.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:F})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:ie,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:I=>`${I.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:I=>E(I.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:le,disabled:T==="json"&&!Q||T==="api"&&u!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:I=>`${I.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:b,onClose:()=>m(!1),maxWidth:"sm",PaperProps:{sx:I=>({borderRadius:3,width:560,maxHeight:"80vh",...ce(I).paper})},children:[t.jsxs(o.DialogTitle,{sx:I=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...ce(I).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>m(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx($.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 as(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Pd=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 Nd(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})`:D(r,Pd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${as(n)})`:Sn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${as(n)})`:vn(r,n)}})}function ri(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:c={},typography:l={},shape:p,colorSpace:x,...y}=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.":$r(20));const g=gi({...a,colorSpace:x}),v=Fs(e);let S=xt(v,{mixins:zd(v.breakpoints,i),palette:g,shadows:$d.slice(),typography:Bd(g,l),transitions:Wd(c),zIndex:{...Ad}});if(S=xt(S,y),S=r.reduce((k,b)=>xt(k,b),S),process.env.NODE_ENV!=="production"){const k=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],b=(m,z)=>{let h;for(h in m){const B=m[h];if(k.includes(h)&&Object.keys(B).length>0){if(process.env.NODE_ENV!=="production"){const T=ad("",h);console.error([`MUI: The \`${z}\` component increases the CSS specificity of the \`${h}\` internal state.`,"You can not override it like this: ",JSON.stringify(m,null,2),"",`Instead, you need to use the '&.${T}' syntax:`,JSON.stringify({root:{[`&.${T}`]:B}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
+ `))}m[h]={}}}};Object.keys(S.components).forEach(m=>{const z=S.components[m].styleOverrides;z&&m.startsWith("Mui")&&b(z,m)})}return S.unstable_sxConfig={...gn,...y==null?void 0:y.unstable_sxConfig},S.unstable_sx=function(b){return yn({sx:b,theme:this})},S.toRuntimeSource=Ys,Nd(S),S}function Ld(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 Fd=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Ld(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function qs(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function Js(e){return e==="dark"?Fd:[]}function Vd(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...a}=e,c=gi({...r,colorSpace:s});return{palette:c,opacity:{...qs(c.mode),...n},overlays:i||Js(c.mode),...a}}function Hd(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 Ud=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Gd=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 Ud(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 Yd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function L(e,r,n){!e[r]&&n&&(e[r]=n)}function wo(e){return typeof e!="string"||!e.startsWith("hsl")?e:Vs(e)}function tr(e,r){`${r}Channel`in e||(e[`${r}Channel`]=jo(wo(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 Ht=e=>{try{return e()}catch{}},Jd=(e="mui")=>pd(e);function Jn(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Vd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:c,...l}=ri({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:c,opacity:{...qs(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||Js(a)},l}function Kd(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:c=!1,shouldSkipGeneratingVar:l=Hd,colorSchemeSelector:p=n.light&&n.dark?"media":void 0,rootSelector:x=":root",...y}=e,g=Object.keys(n)[0],v=i||(n.light&&g!=="light"?"light":g),S=Jd(a),{[v]:k,light:b,dark:m,...z}=n,h={...z};let B=k;if((v==="dark"&&!("dark"in n)||v==="light"&&!("light"in n))&&(B=!0),!B)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${v}\` option is either missing or invalid.`:$r(21,v));let T;c&&(T="oklch");const w=Jn(T,h,B,y,v);b&&!h.light&&Jn(T,h,b,void 0,"light"),m&&!h.dark&&Jn(T,h,m,void 0,"dark");let P={defaultColorScheme:v,...w,cssVarPrefix:a,colorSchemeSelector:p,rootSelector:x,getCssVar:S,colorSchemes:h,font:{...kd(w.typography),...w.font},spacing:qd(y.spacing)};Object.keys(P.colorSchemes).forEach(R=>{const u=P.colorSchemes[R].palette,A=d=>{const oe=d.split("-"),G=oe[1],te=oe[2];return S(d,u[G][te])};u.mode==="light"&&(L(u.common,"background","#fff"),L(u.common,"onBackground","#000")),u.mode==="dark"&&(L(u.common,"background","#000"),L(u.common,"onBackground","#fff"));function F(d,oe,G){if(T){let te;return d===Er&&(te=`transparent ${((1-G)*100).toFixed(0)}%`),d===Be&&(te=`#000 ${(G*100).toFixed(0)}%`),d===Ie&&(te=`#fff ${(G*100).toFixed(0)}%`),`color-mix(in ${T}, ${oe}, ${te})`}return d(oe,G)}if(Yd(u,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),u.mode==="light"){L(u.Alert,"errorColor",F(Be,u.error.light,.6)),L(u.Alert,"infoColor",F(Be,u.info.light,.6)),L(u.Alert,"successColor",F(Be,u.success.light,.6)),L(u.Alert,"warningColor",F(Be,u.warning.light,.6)),L(u.Alert,"errorFilledBg",A("palette-error-main")),L(u.Alert,"infoFilledBg",A("palette-info-main")),L(u.Alert,"successFilledBg",A("palette-success-main")),L(u.Alert,"warningFilledBg",A("palette-warning-main")),L(u.Alert,"errorFilledColor",Ht(()=>u.getContrastText(u.error.main))),L(u.Alert,"infoFilledColor",Ht(()=>u.getContrastText(u.info.main))),L(u.Alert,"successFilledColor",Ht(()=>u.getContrastText(u.success.main))),L(u.Alert,"warningFilledColor",Ht(()=>u.getContrastText(u.warning.main))),L(u.Alert,"errorStandardBg",F(Ie,u.error.light,.9)),L(u.Alert,"infoStandardBg",F(Ie,u.info.light,.9)),L(u.Alert,"successStandardBg",F(Ie,u.success.light,.9)),L(u.Alert,"warningStandardBg",F(Ie,u.warning.light,.9)),L(u.Alert,"errorIconColor",A("palette-error-main")),L(u.Alert,"infoIconColor",A("palette-info-main")),L(u.Alert,"successIconColor",A("palette-success-main")),L(u.Alert,"warningIconColor",A("palette-warning-main")),L(u.AppBar,"defaultBg",A("palette-grey-100")),L(u.Avatar,"defaultBg",A("palette-grey-400")),L(u.Button,"inheritContainedBg",A("palette-grey-300")),L(u.Button,"inheritContainedHoverBg",A("palette-grey-A100")),L(u.Chip,"defaultBorder",A("palette-grey-400")),L(u.Chip,"defaultAvatarColor",A("palette-grey-700")),L(u.Chip,"defaultIconColor",A("palette-grey-700")),L(u.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),L(u.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),L(u.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),L(u.LinearProgress,"primaryBg",F(Ie,u.primary.main,.62)),L(u.LinearProgress,"secondaryBg",F(Ie,u.secondary.main,.62)),L(u.LinearProgress,"errorBg",F(Ie,u.error.main,.62)),L(u.LinearProgress,"infoBg",F(Ie,u.info.main,.62)),L(u.LinearProgress,"successBg",F(Ie,u.success.main,.62)),L(u.LinearProgress,"warningBg",F(Ie,u.warning.main,.62)),L(u.Skeleton,"bg",T?F(Er,u.text.primary,.11):`rgba(${A("palette-text-primaryChannel")} / 0.11)`),L(u.Slider,"primaryTrack",F(Ie,u.primary.main,.62)),L(u.Slider,"secondaryTrack",F(Ie,u.secondary.main,.62)),L(u.Slider,"errorTrack",F(Ie,u.error.main,.62)),L(u.Slider,"infoTrack",F(Ie,u.info.main,.62)),L(u.Slider,"successTrack",F(Ie,u.success.main,.62)),L(u.Slider,"warningTrack",F(Ie,u.warning.main,.62));const d=T?F(Be,u.background.default,.6825):Vo(u.background.default,.8);L(u.SnackbarContent,"bg",d),L(u.SnackbarContent,"color",Ht(()=>T?ti.text.primary:u.getContrastText(d))),L(u.SpeedDialAction,"fabHoverBg",Vo(u.background.paper,.15)),L(u.StepConnector,"border",A("palette-grey-400")),L(u.StepContent,"border",A("palette-grey-400")),L(u.Switch,"defaultColor",A("palette-common-white")),L(u.Switch,"defaultDisabledColor",A("palette-grey-100")),L(u.Switch,"primaryDisabledColor",F(Ie,u.primary.main,.62)),L(u.Switch,"secondaryDisabledColor",F(Ie,u.secondary.main,.62)),L(u.Switch,"errorDisabledColor",F(Ie,u.error.main,.62)),L(u.Switch,"infoDisabledColor",F(Ie,u.info.main,.62)),L(u.Switch,"successDisabledColor",F(Ie,u.success.main,.62)),L(u.Switch,"warningDisabledColor",F(Ie,u.warning.main,.62)),L(u.TableCell,"border",F(Ie,F(Er,u.divider,1),.88)),L(u.Tooltip,"bg",F(Er,u.grey[700],.92))}if(u.mode==="dark"){L(u.Alert,"errorColor",F(Ie,u.error.light,.6)),L(u.Alert,"infoColor",F(Ie,u.info.light,.6)),L(u.Alert,"successColor",F(Ie,u.success.light,.6)),L(u.Alert,"warningColor",F(Ie,u.warning.light,.6)),L(u.Alert,"errorFilledBg",A("palette-error-dark")),L(u.Alert,"infoFilledBg",A("palette-info-dark")),L(u.Alert,"successFilledBg",A("palette-success-dark")),L(u.Alert,"warningFilledBg",A("palette-warning-dark")),L(u.Alert,"errorFilledColor",Ht(()=>u.getContrastText(u.error.dark))),L(u.Alert,"infoFilledColor",Ht(()=>u.getContrastText(u.info.dark))),L(u.Alert,"successFilledColor",Ht(()=>u.getContrastText(u.success.dark))),L(u.Alert,"warningFilledColor",Ht(()=>u.getContrastText(u.warning.dark))),L(u.Alert,"errorStandardBg",F(Be,u.error.light,.9)),L(u.Alert,"infoStandardBg",F(Be,u.info.light,.9)),L(u.Alert,"successStandardBg",F(Be,u.success.light,.9)),L(u.Alert,"warningStandardBg",F(Be,u.warning.light,.9)),L(u.Alert,"errorIconColor",A("palette-error-main")),L(u.Alert,"infoIconColor",A("palette-info-main")),L(u.Alert,"successIconColor",A("palette-success-main")),L(u.Alert,"warningIconColor",A("palette-warning-main")),L(u.AppBar,"defaultBg",A("palette-grey-900")),L(u.AppBar,"darkBg",A("palette-background-paper")),L(u.AppBar,"darkColor",A("palette-text-primary")),L(u.Avatar,"defaultBg",A("palette-grey-600")),L(u.Button,"inheritContainedBg",A("palette-grey-800")),L(u.Button,"inheritContainedHoverBg",A("palette-grey-700")),L(u.Chip,"defaultBorder",A("palette-grey-700")),L(u.Chip,"defaultAvatarColor",A("palette-grey-300")),L(u.Chip,"defaultIconColor",A("palette-grey-300")),L(u.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),L(u.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),L(u.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),L(u.LinearProgress,"primaryBg",F(Be,u.primary.main,.5)),L(u.LinearProgress,"secondaryBg",F(Be,u.secondary.main,.5)),L(u.LinearProgress,"errorBg",F(Be,u.error.main,.5)),L(u.LinearProgress,"infoBg",F(Be,u.info.main,.5)),L(u.LinearProgress,"successBg",F(Be,u.success.main,.5)),L(u.LinearProgress,"warningBg",F(Be,u.warning.main,.5)),L(u.Skeleton,"bg",T?F(Er,u.text.primary,.13):`rgba(${A("palette-text-primaryChannel")} / 0.13)`),L(u.Slider,"primaryTrack",F(Be,u.primary.main,.5)),L(u.Slider,"secondaryTrack",F(Be,u.secondary.main,.5)),L(u.Slider,"errorTrack",F(Be,u.error.main,.5)),L(u.Slider,"infoTrack",F(Be,u.info.main,.5)),L(u.Slider,"successTrack",F(Be,u.success.main,.5)),L(u.Slider,"warningTrack",F(Be,u.warning.main,.5));const d=T?F(Ie,u.background.default,.985):Vo(u.background.default,.98);L(u.SnackbarContent,"bg",d),L(u.SnackbarContent,"color",Ht(()=>T?Us.text.primary:u.getContrastText(d))),L(u.SpeedDialAction,"fabHoverBg",Vo(u.background.paper,.15)),L(u.StepConnector,"border",A("palette-grey-600")),L(u.StepContent,"border",A("palette-grey-600")),L(u.Switch,"defaultColor",A("palette-grey-300")),L(u.Switch,"defaultDisabledColor",A("palette-grey-600")),L(u.Switch,"primaryDisabledColor",F(Be,u.primary.main,.55)),L(u.Switch,"secondaryDisabledColor",F(Be,u.secondary.main,.55)),L(u.Switch,"errorDisabledColor",F(Be,u.error.main,.55)),L(u.Switch,"infoDisabledColor",F(Be,u.info.main,.55)),L(u.Switch,"successDisabledColor",F(Be,u.success.main,.55)),L(u.Switch,"warningDisabledColor",F(Be,u.warning.main,.55)),L(u.TableCell,"border",F(Be,F(Er,u.divider,1),.68)),L(u.Tooltip,"bg",F(Er,u.grey[700],.92))}tr(u.background,"default"),tr(u.background,"paper"),tr(u.common,"background"),tr(u.common,"onBackground"),tr(u,"divider"),Object.keys(u).forEach(d=>{const oe=u[d];d!=="tonalOffset"&&oe&&typeof oe=="object"&&(oe.main&&L(u[d],"mainChannel",jo(wo(oe.main))),oe.light&&L(u[d],"lightChannel",jo(wo(oe.light))),oe.dark&&L(u[d],"darkChannel",jo(wo(oe.dark))),oe.contrastText&&L(u[d],"contrastTextChannel",jo(wo(oe.contrastText))),d==="text"&&(tr(u[d],"primary"),tr(u[d],"secondary")),d==="action"&&(oe.active&&tr(u[d],"active"),oe.selected&&tr(u[d],"selected")))})}),P=r.reduce((R,u)=>xt(R,u),P);const O={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Gd(P),enableContrastVars:c},{vars:M,generateThemeVars:q,generateStyleSheets:K}=md(P,O);return P.vars=M,Object.entries(P.colorSchemes[P.defaultColorScheme]).forEach(([R,u])=>{P[R]=u}),P.generateThemeVars=q,P.generateStyleSheets=K,P.generateSpacing=function(){return Ls(y.spacing,fi(this))},P.getColorSchemeSelector=xd(p),P.spacing=P.generateSpacing(),P.shouldSkipGeneratingVar=l,P.unstable_sxConfig={...gn,...y==null?void 0:y.unstable_sxConfig},P.unstable_sx=function(u){return yn({sx:u,theme:this})},P.toRuntimeSource=Ys,P}function ls(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:gi({...n===!0?{}:n.palette,mode:r})})}function Xd(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",p=s==null?void 0:s[l],x={...s,...n?{[l]:{...typeof p!="boolean"&&p,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return ri(e,...r);let y=n;"palette"in e||x[l]&&(x[l]!==!0?y=x[l].palette:l==="dark"&&(y={mode:"dark"}));const g=ri({...e,palette:y},...r);return g.defaultColorScheme=l,g.colorSchemes=x,g.palette.mode==="light"&&(g.colorSchemes.light={...x.light!==!0&&x.light,palette:g.palette},ls(g,"dark",x.dark)),g.palette.mode==="dark"&&(g.colorSchemes.dark={...x.dark!==!0&&x.dark,palette:g.palette},ls(g,"light",x.light)),g}return!n&&!("light"in x)&&l==="light"&&(x.light=!0),Kd({...c,colorSchemes:x,defaultColorScheme:l,...typeof i!="boolean"&&i},...r)}const Qd=Xd();function pt(){const e=od(Qd);return process.env.NODE_ENV!=="production"&&on.useDebugValue(e),e[Gl]||e}async function Zd(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(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(c.status===401)throw new Error("Authentication failed (401) — check your API key");if(!c.ok)throw new Error(`API error ${c.status}: ${c.statusText}`);let l;try{l=await c.json()}catch{throw new Error("Response is not valid JSON")}let p;if(Array.isArray(l))p=l;else if(n&&l[n]&&Array.isArray(l[n]))p=l[n];else{const y=["data","results","items","records"].find(g=>l[g]&&Array.isArray(l[g]));if(y)p=l[y];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:p,source:e,fetchedAt:new Date().toISOString()}}function eu(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${D(e.palette.common.black,n.opacity)}`).join(", ")}const tu={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 ge(e,r){return eu(e,tu[r])}function tt(e){return`${Number(e.shape.borderRadius)*1.5}px`}function $o(e){return`${Number(e.shape.borderRadius)}px`}function cs(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 at(e){const r=e.tokens,n=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:n,bg:`var(--highlight-bg, ${D(n,.08)})`,hoverBg:`var(--highlight-hover, ${D(n,.12)})`}}function de(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||ge(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 ru({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,c]=f.useState(""),[l,p]=f.useState(!1),[x,y]=f.useState(""),[g,v]=f.useState(null),[S,k]=f.useState(null),[b,m]=f.useState(!1),[z,h]=f.useState(""),B=f.useRef(null),[T,w]=f.useState("json"),[P,O]=f.useState(""),[M,q]=f.useState(""),[K,R]=f.useState(""),[u,A]=f.useState("idle"),[F,d]=f.useState(""),[oe,G]=f.useState(null),[te,xe]=f.useState(0),H=async I=>{if(h(""),!I.name.endsWith(".json")){h("Only .json files are allowed");return}const ee=10*1024*1024;if(I.size>ee){h("File size exceeds 10MB limit");return}try{const fe=await I.text();let se;try{se=JSON.parse(fe)}catch{h("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(se)){h("JSON must be an array of objects");return}if(se.length===0){h("No data rows found in JSON file");return}v(I),k(se)}catch{h("Network error — please try again")}},Q=I=>{I.preventDefault();const ee=I.dataTransfer.files[0];ee&&H(ee)},le=async()=>{if(P.trim()){A("loading"),d("");try{const I=await Zd(P.trim(),M.trim()||void 0,K.trim()||void 0);G(I.data),xe(I.data.length),A("ready")}catch(I){d((I==null?void 0:I.message)||"Connection failed"),A("error")}}},ce=()=>{if(!a.trim()){p(!0);return}const I=T==="api"?oe:i||S;I&&(n(a.trim(),x.trim(),I),ie())},ie=()=>{c(""),p(!1),y(""),v(null),k(null),h(""),w("json"),O(""),q(""),R(""),A("idle"),d(""),G(null),xe(0),r()},Z=i||S,ue=l&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:ie,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:I=>({borderRadius:tt(I),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...de(I).paper})},children:[t.jsxs(o.DialogTitle,{sx:I=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:ee=>ee.typography.h6.fontWeight||500,fontSize:ee=>ee.typography.h6.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...de(I).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:ie,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:I=>{c(I.target.value),l&&I.target.value.trim()&&p(!1)},placeholder:"Enter report name",autoFocus:!0,error:ue,helperText:ue?"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:I=>y(I.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:(I,ee)=>{w(ee===0?"json":"api"),A("idle"),d("")},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($.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:I=>`var(--highlight-hover, ${D(I.palette.primary.main,.15)})`},"&:hover":{bgcolor:I=>`var(--highlight-hover, ${D(I.palette.primary.main,.08)})`}}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx($.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:I=>`var(--highlight-hover, ${D(I.palette.primary.main,.15)})`},"&:hover":{bgcolor:I=>`var(--highlight-hover, ${D(I.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:I=>D(I.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:I=>D(I.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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:()=>m(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx($.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:Q,onDragOver:I=>I.preventDefault(),onPaste:I=>I.preventDefault(),onClick:()=>{var I;return(I=B.current)==null?void 0:I.click()},sx:{position:"relative",border:"1.5px",borderStyle:S?"solid":"dashed",borderColor:S?"success.main":z?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:S?I=>D(I.palette.success.main,.04):z?I=>D(I.palette.error.main,.04):I=>D(I.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:S?I=>D(I.palette.success.main,.08):z?I=>D(I.palette.error.main,.08):I=>D(I.palette.primary.main,.08),borderColor:S?"success.dark":z?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:B,type:"file",accept:".json",sx:{display:"none"},onChange:I=>{var ee;return((ee=I.target.files)==null?void 0:ee[0])&&H(I.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:I=>D(I.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx($.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:g==null?void 0:g.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:I=>D(I.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx($.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"}),z&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:I=>D(I.palette.error.main,.08),border:1,borderColor:I=>D(I.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:z})})]})]})]})}),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:P,onChange:I=>{O(I.target.value),A("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:M,onChange:I=>q(I.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx($.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:K,onChange:I=>R(I.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:!P.trim()||u==="loading",onClick:le,startIcon:u==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx($.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:I=>D(I.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:u==="loading"?"Connecting...":"Test Connection & Load Data"}),u==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:I=>D(I.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.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:[te.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:P})]})]}),u==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:I=>D(I.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.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:F})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:ie,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:I=>`${I.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:I=>D(I.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:ce,disabled:T==="json"&&!Z||T==="api"&&u!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:I=>`${I.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:b,onClose:()=>m(!1),maxWidth:"sm",PaperProps:{sx:I=>({borderRadius:3,width:560,maxHeight:"80vh",...de(I).paper})},children:[t.jsxs(o.DialogTitle,{sx:I=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...de(I).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>m(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx($.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:()=>m(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:I=>`${I.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Js({isOpen:e,onClose:r}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:n=>({borderRadius:et(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ce(n).paper})},children:[t.jsxs(o.DialogTitle,{sx:n=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ce(n).header}),children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children: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:()=>m(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:I=>`${I.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Ks({isOpen:e,onClose:r}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:n=>({borderRadius:tt(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...de(n).paper})},children:[t.jsxs(o.DialogTitle,{sx:n=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...de(n).header}),children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children: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:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.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:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.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:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.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:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.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:n=>`${n.shape.borderRadius}px`,boxShadow:n=>ge(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>ge(n,"hoverButton")},"&:active":{boxShadow:n=>ge(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function ru({onFileUpload:e,onError:r,isUploading:n}){const[i,s]=f.useState(!1),[a,c]=f.useState(""),[l,p]=f.useState(!1),x=f.useRef(null),y=async z=>{if(!z.name.endsWith(".json")){r("Only .json files are allowed");return}const h=10*1024*1024;if(z.size>h){r("File size exceeds 10MB limit");return}c(z.name);try{const B=await z.text();let T;try{T=JSON.parse(B)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(T)){r("JSON must be an array of objects");return}if(T.length===0){r("No data rows found in JSON file");return}e(T)}catch{r("Network error — please try again")}finally{c("")}},g=z=>{z.preventDefault(),s(!0)},v=z=>{z.preventDefault(),s(!1)},S=z=>{z.preventDefault(),s(!1);const h=z.dataTransfer.files[0];h&&y(h)},k=()=>{var z;(z=x.current)==null||z.click()},b=z=>{var B;const h=(B=z.target.files)==null?void 0:B[0];h&&y(h)},m=z=>{z.stopPropagation(),p(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:g,onDragLeave:v,onDrop:S,onPaste:z=>z.preventDefault(),onClick:k,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?z=>E(z.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:x,type:"file",accept:".json",onChange:b,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:z=>z.typography.body2.fontWeight||500,fontSize:z=>z.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),a&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:a})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:z=>E(z.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.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:m,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx($.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(Js,{isOpen:l,onClose:()=>p(!1)})]})}function ou({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=>E(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($.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 nu({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=>E(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=>E(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.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($.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function Ks({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=>E(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx($.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 iu({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:c}){const[l,p]=f.useState(!1),[x,y]=f.useState(!1),[g,v]=f.useState(-1),S=f.useRef(null),k=f.useRef(null);f.useEffect(()=>{function M(G){S.current&&!S.current.contains(G.target)&&(p(!1),y(!1))}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);const b=f.useCallback(()=>{y(!0),v(-1),n.length>0&&p(!0)},[n.length]),m=f.useCallback(M=>{r(M),v(-1)},[r]),z=f.useCallback(M=>{var G;r(M),i(M),p(!1),(G=k.current)==null||G.blur()},[r,i]),h=f.useCallback(M=>{v(-1),z(M)},[z]),B=f.useCallback(M=>{var G;M.key==="Enter"?g>=0&&g<n.length?(M.preventDefault(),h(n[g].query)):e.trim()&&z(e.trim()):M.key==="Escape"?(p(!1),v(-1),(G=k.current)==null||G.blur()):M.key==="ArrowDown"?(M.preventDefault(),n.length>0&&(l||p(!0),v(q=>q<n.length-1?q+1:q))):M.key==="ArrowUp"&&(M.preventDefault(),v(q=>q>0?q-1:-1))},[g,n,e,l,h,z]),T=f.useCallback(()=>{var M;r(""),(M=k.current)==null||M.focus()},[r]),j=f.useMemo(()=>n.filter(M=>M.isFavourite),[n]),P=f.useMemo(()=>n.filter(M=>!M.isFavourite),[n]),_=l&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:S,children:[t.jsx(o.TextField,{inputRef:k,size:"small",fullWidth:!0,value:e,onChange:M=>m(M.target.value),onFocus:b,onKeyDown:B,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:M=>E(M.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:M=>E(M.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($.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($.Close,{sx:{fontSize:16}})})}):null}}),_&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[j.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:M=>M.typography.caption.fontWeight||600,fontSize:M=>M.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),j.map((M,G)=>t.jsx(cs,{entry:M,isSelected:g===G,onClick:()=>h(M.query),onToggleFavourite:()=>s(M.query),onDelete:()=>a(M.query)},`fav-${M.query}`))]}),P.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[j.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:M=>M.typography.caption.fontWeight||600,fontSize:M=>M.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),P.map((M,G)=>{const q=j.length+G;return t.jsx(cs,{entry:M,isSelected:g===q,onClick:()=>h(M.query),onToggleFavourite:()=>s(M.query),onDelete:()=>a(M.query)},`recent-${M.query}`)})]})]})]})}const cs=f.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const c=f.useCallback(p=>{p.stopPropagation(),s()},[s]),l=f.useCallback(p=>{p.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?p=>E(p.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?p=>E(p.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($.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx($.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($.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function su({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:c,onRestoreView:l,onPermanentDelete:p,onEditView:x,onCloneView:y,onCopyLink:g,onDeleteView:v,onPromoteToGlobal:S,isReadOnly:k,isAdmin:b=!1}){const m=ct(),[z,h]=f.useState(!1),[B,T]=f.useState(!1),[j,P]=f.useState({top:0,left:0}),[_,M]=f.useState(null),[G,q]=f.useState(null),R=f.useRef(null),u=f.useRef(null),A=e.find(I=>I.id===r),F=A==null?void 0:A.isDefault,d=(I,te)=>I.name.localeCompare(te.name),ne=e.filter(I=>I.scope==="global"&&!I.isDeleted).sort(d),U=e.filter(I=>I.scope!=="global"&&!I.isDeleted).sort(d),re=e.filter(I=>I.isFavorite&&!I.isDeleted).sort(d),xe=e.filter(I=>I.isDeleted);f.useEffect(()=>{if(z&&u.current){const I=u.current.getBoundingClientRect();P({top:I.bottom+window.scrollY+8,left:I.right+window.scrollX-320})}},[z]),f.useEffect(()=>{const I=te=>{R.current&&!R.current.contains(te.target)&&u.current&&!u.current.contains(te.target)&&h(!1)};return z&&document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[z]);const V=I=>{if(n&&I!==r){M(I),h(!1);return}i(I),h(!1)},X=()=>{_&&(i(_),M(null))},ae=()=>{M(null)},le=(I,te=!1)=>{const he=I.scope==="global",se=!k&&(!he||b),ze=b&&!he;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===I.id?E(m.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===I.id?E(m.palette.primary.main,.12):m.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>V(I.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===I.id&&t.jsx($.Check,{sx:{fontSize:16,flexShrink:0}}),r!==I.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===I.id?m.palette.primary.dark:m.palette.text.primary,fontWeight:r===I.id?Y=>Y.typography.body2.fontWeight||500:400,fontSize:Y=>Y.typography.body2.fontSize||"0.875rem"},children:I.name}),te&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:m.palette.text.secondary,backgroundColor:m.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[se&&c&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),c(I.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:I.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx($.Star,{sx:{fontSize:16}})}),se&&a&&!I.isDefault&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),a(I.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Set as default",children:t.jsx($.RadioButtonUnchecked,{sx:{fontSize:16}})}),(se||ze)&&(x||y||g||v||ze&&S)&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),q({el:Y.currentTarget,view:I})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"More actions",children:t.jsx($.MoreVert,{sx:{fontSize:16}})})]})]},I.id)},ie=I=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:m.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:m.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:I.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[l&&t.jsx(o.IconButton,{onClick:te=>{te.stopPropagation(),l(I.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Restore view",children:t.jsx($.Undo,{sx:{fontSize:16,color:"success.main"}})}),p&&t.jsx(o.IconButton,{onClick:te=>{te.stopPropagation(),p(I.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Delete permanently",children:t.jsx($.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},I.id),Q=n||!F,de=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:u,onClick:()=>h(!z),variant:"outlined",size:"small",endIcon:t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:Q?"warning.main":"text.primary",borderColor:Q?"warning.main":"divider",bgcolor:Q?E(m.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:Q?"warning.dark":"primary.main",bgcolor:Q?E(m.palette.warning.main,.2):E(m.palette.text.primary,.06),color:Q?"warning.dark":"text.primary"}},title:`View: ${(A==null?void 0:A.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(A==null?void 0:A.name)||"Default View"}),de&&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"}})]}),z&&bs.createPortal(t.jsxs(o.Box,{ref:R,sx:{position:"fixed",width:"320px",backgroundColor:m.palette.background.paper,border:`1px solid ${m.palette.divider}`,borderRadius:1,boxShadow:m.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:j.top,left:j.left},children:[ne.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:I=>I.typography.caption.fontSize||"caption.fontSize",fontWeight:I=>I.typography.caption.fontWeight||600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),ne.map(I=>le(I,I.isDefault))]}),re.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.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:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx($.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),re.map(I=>le(I))]})]}),U.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:I=>I.typography.caption.fontSize||"caption.fontSize",fontWeight:I=>I.typography.caption.fontWeight||600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),U.map(I=>le(I))]})]}),xe.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>T(!B),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",xe.length,")"]}),t.jsx($.ChevronRight,{sx:{fontSize:16}})]}),B&&t.jsx(o.Box,{sx:{backgroundColor:m.palette.action.hover},children:xe.map(I=>ie(I))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),h(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:m.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},children:[t.jsx($.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!G,anchorEl:(G==null?void 0:G.el)||null,onClose:()=>q(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[x&&t.jsxs(o.MenuItem,{onClick:()=>{G&&x(G.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Edit,{sx:{fontSize:18}}),"Edit"]}),g&&t.jsxs(o.MenuItem,{onClick:()=>{G&&g(G.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Link,{sx:{fontSize:18}}),"Copy Link"]}),y&&t.jsxs(o.MenuItem,{onClick:()=>{G&&y(G.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),S&&b&&(G==null?void 0:G.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{G&&S(G.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Language,{sx:{fontSize:18}}),"Promote to Global"]}),v&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{G&&v(G.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx($.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:_!==null,onClose:ae,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:$o(m)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx($.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:ae,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:X,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function au({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:c=!1,position:l,onSortAscending:p,onSortDescending:x,onRemoveSort:y,onFilter:g,onClearFilter:v,onGroupByColumn:S,onHideColumn:k,onManageColumns:b,onResetLayout:m,onClose:z}){const h=ct(),B=h.palette,T=f.useRef(null);f.useEffect(()=>{if(!T.current)return;const q=T.current,R=q.getBoundingClientRect(),u=window.innerWidth,A=window.innerHeight;R.right>u-8&&(q.style.left=`${u-R.width-8}px`),R.bottom>A-8&&(q.style.top=`${A-R.height-8}px`)},[l]),f.useEffect(()=>{const q=u=>{T.current&&!T.current.contains(u.target)&&z()},R=u=>{u.key==="Escape"&&z()};return document.addEventListener("mousedown",q),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",q),document.removeEventListener("keydown",R)}},[z]);const j=f.useCallback(q=>()=>{q(),z()},[z]),P=(n==null?void 0:n.direction)==="asc",_=(n==null?void 0:n.direction)==="desc",M=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",G=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:$o(h),overflow:"hidden",boxShadow:`0 4px 20px ${E(B.common.black,.12)}, 0 1px 4px ${E(B.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:q=>q.typography.body2.fontSize||"0.8125rem",fontWeight:q=>q.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 (${M})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:j(()=>p(e)),sx:{p:.625,borderRadius:"6px",color:P?"primary.main":"text.secondary",bgcolor:P?E(B.primary.main,.1):"transparent","&:hover":{bgcolor:E(B.primary.main,.08),color:"primary.main"}},children:t.jsx($.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${G})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:j(()=>x(e)),sx:{p:.625,borderRadius:"6px",color:_?"primary.main":"text.secondary",bgcolor:_?E(B.primary.main,.1):"transparent","&:hover":{bgcolor:E(B.primary.main,.08),color:"primary.main"}},children:t.jsx($.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:j(()=>y(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:E(B.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx($.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:j(()=>g(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.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:j(()=>v(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:E(B.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($.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:j(()=>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($.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:j(()=>k(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($.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:j(b),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:E(B.primary.main,.08),color:"primary.main"}},children:t.jsx($.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:j(b),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&c&&m&&t.jsxs(o.MenuItem,{onClick:j(m),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:E(B.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($.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const lu=176,ds="COLUMN_HEADER",cu=f.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:c=!1,isGrouped:l=!1,hasModifications:p=!1,width:x,onColumnClick:y,onMoveColumn:g,onColumnDragEnd:v,onResizeStart:S,onSortAscending:k,onSortDescending:b,onRemoveSort:m,onOpenFilterForColumn:z,onClearFiltersForColumn:h,onGroupByColumn:B,onHideColumn:T,onManageColumns:j,onResetLayout:P}){const M=ct().urmTable,G=f.useRef(null),[q,R]=f.useState(!1),[u,A]=f.useState({x:0,y:0}),[{handlerId:F,isOver:d},ne]=Zt.useDrop({accept:ds,collect(Q){return{handlerId:Q.getHandlerId(),isOver:Q.isOver()}},hover(Q,de){var We;if(!G.current)return;const I=Q.index,te=n;if(I===te)return;const he=(We=G.current)==null?void 0:We.getBoundingClientRect(),se=(he.right-he.left)/2,ze=de.getClientOffset(),Y=((ze==null?void 0:ze.x)??0)-he.left;I<te&&Y<se||I>te&&Y>se||(g(I,te),Q.index=te)}}),[{isDragging:U},re]=Zt.useDrag({type:ds,item:()=>({index:n,columnName:r.name}),collect:Q=>({isDragging:Q.isDragging()}),end:()=>{v==null||v()}});re(ne(G));const xe=f.useCallback(Q=>{Q.preventDefault(),Q.stopPropagation(),A({x:Q.clientX,y:Q.clientY}),R(!0)},[]),V=f.useCallback(()=>R(!1),[]),X=f.useCallback(()=>{l||y(r.name)},[y,r.name,l]),ae=f.useCallback(Q=>{Q.stopPropagation(),z(r.name)},[z,r.name]),le=f.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx($.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx($.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]),ie=f.useCallback(()=>s?t.jsx($.FilterList,{onClick:ae,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,ae]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:G,"data-handler-id":F,"data-column-index":n,onClick:X,onContextMenu:xe,sx:{position:"sticky",top:0,zIndex:5,textAlign:(M==null?void 0:M.cellAlignH)??"left",verticalAlign:(M==null?void 0:M.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(M==null?void 0:M.headerColor)??"text.secondary",opacity:U?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:d?Q=>E(Q.palette.primary.main,.08):(M==null?void 0:M.headerBg)??"action.hover",boxShadow:Q=>`0 1px 0 ${E(Q.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(M==null?void 0:M.rowDivider)??"1px solid",borderRight:M==null?void 0:M.colDivider,borderColor:"divider",py:0,px:l?0:(M==null?void 0:M.cellPaddingX)??2,"&:hover":{bgcolor:Q=>E(Q.palette.primary.main,.1),color:"text.primary"},width:l?"32px":x?`${x}px`:`${lu}px`,minWidth:l?"32px":void 0,maxWidth:l?"32px":void 0},children:[!l&&t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[lt(r.name),le(),ie()]}),!l&&t.jsx(o.Box,{draggable:!1,onDragStart:Q=>Q.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:Q=>{Q.preventDefault(),Q.stopPropagation(),S(Q,r.name)},onClick:Q=>Q.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"}})]}),q&&t.jsx(au,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:c,hasModifications:p,position:u,onSortAscending:k,onSortDescending:b,onRemoveSort:m,onFilter:z,onClearFilter:h,onGroupByColumn:B,onHideColumn:T,onManageColumns:j,onResetLayout:P,onClose:V})]})}),du={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 nn(e,r){const n=du[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:E(i.main,e.palette.mode==="dark"?.24:.12),color:e.palette.mode==="dark"?i.light:i.dark}}function uu(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 pu={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"}};function hu(e,r){const n=pu[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function jt(e){return E(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function fu(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=>nn(n,r).bg,color:n=>nn(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function mu(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 fu(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=uu(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 xu(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 gu({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:c,onOpenRowMenu:l,onToggleSelection:p,hideCheckbox:x}){const[y,g]=f.useState(!1),{primaryCol:v,idCol:S,bodyColumns:k}=f.useMemo(()=>xu(n),[n]),b=v?e[v.name]:null,m=S?e[S.name]:null,z=y||i;return t.jsxs(o.Box,{onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!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,j,P,_;const B=(_=(P=(j=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:j.styleOverrides)==null?void 0:P.root)==null?void 0:_.border;return i?"2px solid":B&&B!=="none"?B:"1px solid"},borderColor:i?h=>it(h).main:h=>{var T,j,P,_;const B=(_=(P=(j=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:j.styleOverrides)==null?void 0:P.root)==null?void 0:_.border;return B&&B!=="none"?"inherit":E(h.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:h=>{var T,j,P,_;const B=(_=(P=(j=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:j.styleOverrides)==null?void 0:P.root)==null?void 0:_.borderRadius;return B!==void 0?typeof B=="number"?`${B}px`:B:`${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 ${E(it(h).main,.15)}, 0 2px 8px ${E(h.palette.common.black,.08)}`:y?h=>{var T,j,P,_;const B=(_=(P=(j=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:j.styleOverrides)==null?void 0:P.root)==null?void 0:_.boxShadow;return B&&B!=="none"?B:ge(h,"cardHover")}:h=>{var T,j,P,_;const B=(_=(P=(j=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:j.styleOverrides)==null?void 0:P.root)==null?void 0:_.boxShadow;return B&&B!=="none"?B:ge(h,"cardRest")},transform:y&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:h=>E(it(h).main,.03)}},children:[t.jsxs(o.Box,{sx:h=>{var _,M,G,q;const B=((G=(M=(_=h.components)==null?void 0:_.MuiCardHeader)==null?void 0:M.styleOverrides)==null?void 0:G.root)||{},T=(B.backgroundColor&&B.backgroundColor!=="transparent"?B.backgroundColor:void 0)??((q=h.tokens)==null?void 0:q.cardHdrHex)??"transparent",j=B.borderBottom&&B.borderBottom!=="none"?B.borderBottom:void 0,P=B.boxShadow&&B.boxShadow!=="none"?B.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:T,borderBottom:j,boxShadow:P,display:"flex",alignItems:"center",gap:.5}},children:[!x&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:h=>h.stopPropagation(),onChange:()=>p(e),sx:{p:.25,opacity:z?1:0,transition:"opacity 0.15s ease"}}),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:b!=null&&b!==""?String(b):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:h=>{var j,P,_;const B=((_=(P=(j=h.components)==null?void 0:j.MuiCardHeader)==null?void 0:P.styleOverrides)==null?void 0:_.root)||{};return B.borderBottom&&B.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:[k.map(h=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:B=>B.typography.body2.fontWeight||500,fontSize:B=>B.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:lt(h.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[h.name]??""),children:mu(h,e[h.name])})]},h.name)),k.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=>E(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:m?.85:0,userSelect:"none"},children:m?String(m):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:z?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=>E(h.palette.text.primary,.08)}},children:t.jsx($.MoreVert,{sx:{fontSize:17}})})})})]})]})}function yu({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=>ge(s,"flatHover"),"&:hover":{bgcolor:s=>E(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx($.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx($.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:Va(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=>E(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])=>ks(a)).filter(Boolean).join(" • ")})]})}function bu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:c,onCardDoubleClick:l,onCardContextMenu:p,onOpenRowMenu:x,onToggleSelection:y,hideSelectionCheckboxes:g}){const v=f.useMemo(()=>{const S=new Set;return i.forEach(k=>{const b=k==null?void 0:k.__urm_row_id__;b!==void 0&&S.add(b)}),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=>ls(S).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:S=>ls(S).cardGap,alignContent:"start"},children:e.map((S,k)=>s&&S.isGroupHeader?t.jsx(yu,{row:S,grouping:n,onToggleCollapse:a||(()=>{})},`group-${S.groupKey}`):t.jsx(gu,{row:S,rowIndex:k,visibleColumns:r,isSelected:v.has(S==null?void 0:S.__urm_row_id__),onCardClick:c,onCardDoubleClick:l,onCardContextMenu:p,onOpenRowMenu:x,onToggleSelection:y,hideCheckbox:g},`card-${k}`))})})}const us=[10,15,25,50,100];function vu(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 Su({currentPage:e,pageSize:r,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:a}){const l=ct().palette,p=Math.ceil(n/r),[x,y]=f.useState(String(e)),[g,v]=f.useState(null),[S,k]=f.useState(!1),b=f.useRef(null);f.useEffect(()=>{S||(y(String(e)),v(null))},[e,S]);const m=f.useCallback(()=>{const A=vu(x,p);if(A){v(A);return}const F=parseInt(x.trim(),10);v(null),k(!1),F!==e&&s(F)},[x,p,e,s]),z=f.useCallback(A=>{var F;A.key==="Enter"?(A.preventDefault(),m()):A.key==="Escape"&&(y(String(e)),v(null),k(!1),(F=b.current)==null||F.blur())},[m,e]),h=f.useCallback(()=>{y(String(e)),v(null),k(!1)},[e]),B=f.useCallback(()=>{k(!0),v(null),setTimeout(()=>{var A;return(A=b.current)==null?void 0:A.select()},0)},[]);if(n<=Math.min(...us))return null;const T=()=>{y(String(e)),v(null),k(!1)},j=()=>{T(),s(1)},P=()=>{T(),e>1&&s(e-1)},_=()=>{T(),e<p&&s(e+1)},M=()=>{T(),s(p)},G=(e-1)*r+1,q=Math.min(e*r,n),R=`${Math.max(2,String(p).length+.5)}ch`,u={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:A=>A.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:A=>A.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:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:A=>a(Number(A.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:us.map(A=>t.jsx(o.MenuItem,{value:A,sx:{fontSize:"0.8125rem"},children:A},A))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[G,"–",q," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[g&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:E(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${E(l.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:E(l.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:A=>A.typography.caption.fontSize||"0.6875rem",fontWeight:A=>A.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:g})}),t.jsx(o.InputBase,{inputRef:b,value:x,onChange:A=>{y(A.target.value),g&&v(null)},onKeyDown:z,onFocus:B,onBlur:h,inputProps:{"aria-label":`Page number, 1 to ${p}`,style:{textAlign:"center",padding:"2px 0",width:R,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:g?"error.main":"text.primary",border:"1px solid",borderColor:g?"error.main":S?"primary.main":"divider",borderRadius:"4px",bgcolor:g?E(l.error.main,.04):S?E(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:g?"error.main":"text.secondary"},"&:focus-within":{boxShadow:g?`0 0 0 2px ${E(l.error.main,.2)}`:`0 0 0 2px ${E(l.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",p]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:j,disabled:e===1,size:"small",title:"First page",sx:u,children:t.jsx($.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:P,disabled:e===1,size:"small",title:"Previous page",sx:u,children:t.jsx($.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:_,disabled:e===p,size:"small",title:"Next page",sx:u,children:t.jsx($.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:M,disabled:e===p,size:"small",title:"Last page",sx:u,children:t.jsx($.LastPage,{sx:{fontSize:20}})})]})]})]})}function Cu(){return t.jsx(o.Chip,{icon:t.jsx($.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 Xs="urm_hint_seen_";function ju(e){try{return localStorage.getItem(Xs+e)==="true"}catch{return!1}}function wu(e){try{localStorage.setItem(Xs+e,"true")}catch{}}const Qs={"& .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 oi(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 Zs({row:e,schema:r}){const i=ct().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:lt(l.name),value:oi(e[l.name],l.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:Qs},l.name)),c.map(l=>{const p=oi(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:lt(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:E(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:p?"text.primary":"text.disabled",fontStyle:p?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:p||"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 ku({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=ct(),c=a.palette;if(!n)return null;const l=i.filter(x=>x.name in n).length,p=ce(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:et(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...p.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,...p.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:E(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:E(c.text.primary,.015)},children:t.jsx(Zs,{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 zu({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=ct(),c=ce(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:et(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=>E(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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($.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(Zs,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>E(l.palette.error.main,.1),border:l=>`1px solid ${E(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($.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=>ge(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>ge(l,"hoverButton")},"&:active":{boxShadow:l=>ge(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Tu({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var z;const c=ct(),l=c.palette,[p,x]=f.useState({});if(f.useEffect(()=>{e&&i&&x({...i})},[e,i]),!i)return null;const y=s.filter(h=>h.name in i),g=y.filter(h=>h.type!=="object"&&h.type!=="array"),v=y.filter(h=>h.type==="object"||h.type==="array"),S=(h,B)=>{x(T=>({...T,[h]:B}))},k=()=>{const h={...p};y.forEach(B=>{const T=p[B.name];if(B.type==="number"){const j=Number(T);h[B.name]=isNaN(j)?i[B.name]:j}else B.type==="boolean"&&(h[B.name]=!!T)}),n(h),r()},b=y.length,m=ce(c);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:et(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...m.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,...m.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:E(((z=l.warning)==null?void 0:z.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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," · ",b," ",b===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($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:E(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[g.map(h=>{const B=p[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:lt(h.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!B,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:B?"Enabled":"Disabled"})]})]},h.name):t.jsx(o.TextField,{label:lt(h.name),value:B??"",onChange:T=>S(h.name,T.target.value),type:h.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:Qs},h.name)}),v.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:v.map(h=>{const B=oi(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:lt(h.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:E(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($.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:E(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:B?"text.primary":"text.disabled",fontStyle:B?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:B||"No value"})]},h.name)})}),y.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx($.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:k,variant:"contained",startIcon:t.jsx($.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:h=>`${h.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Bu=176,Iu=170,Eu=40,Du=32;function ea(e){return e.type==="date"?180:Bu}function $u(e,r){return r!=null&&r!==Iu&&r!==ea(e)}function _u(e,r,n,i){return f.useMemo(()=>{const s=e.map(v=>i!=null&&i.has(v.name)?{name:v.name,width:Du,explicit:!0}:{name:v.name,width:r[v.name]??ea(v),explicit:$u(v,r[v.name])}),a={};s.forEach(v=>{a[v.name]=v.width});const c=s.reduce((v,S)=>v+S.width,0),p=Math.max(0,n-Eu)-c;if(p<=0)return{widths:a,fillerWidth:0};const x=s.filter(v=>!v.explicit);if(x.length===0)return{widths:a,fillerWidth:p};const y=x.reduce((v,S)=>v+S.width,0)||1;let g=0;return x.forEach((v,S)=>{const b=S===x.length-1?v.width+p-g:Math.round(v.width+p*v.width/y);a[v.name]=b,g+=b-v.width}),{widths:a,fillerWidth:0}},[e,r,n,i])}const ps=176,Ou=_t(),Mu={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Wu(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=>nn(n,r).bg,color:n=>nn(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Au(e){const r=e.toLowerCase().trim(),n=Mu[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Ru(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 Pu(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 Wu(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Au(s);if(e.type==="date"){const l=e.dateFormat??"iso",p=$a(r,l,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:p})}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(p=>typeof p=="object"?JSON.stringify(p):String(p)).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 Ru(s,i)}function Nu({schema:e,data:r,sortStack:n=[],filters:i=Ou,views:s=[],activeViewId:a="",isDirty:c=!1,isExporting:l=!1,columnVisibility:p={},columnOrder:x=[],columnWidths:y={},grouping:g=null,classTokens:v={},onSort:S,onSortAscending:k,onSortDescending:b,onOpenFilters:m,onOpenSort:z,onOpenFilterForColumn:h,onSelectView:B,onCreateView:T,onUpdateCurrentView:j,onSaveAsNewView:P,onDiscardChanges:_,onToggleDefault:M,onToggleFavorite:G,onRestoreView:q,onPermanentDelete:R,onEditView:u,onCloneView:A,onCopyLink:F,onDeleteView:d,onPromoteToGlobal:ne,isAdmin:U=!1,onExport:re,onOpenColumns:xe,onUpdateColumnWidth:V,onUpdateColumnOrder:X,onUpdateColumnVisibility:ae,onClearFiltersForColumn:le,onResetLayout:ie,onOpenGroup:Q,onGroupByColumn:de,onToggleGroupCollapse:I,onExpandAllGroups:te,onCollapseAllGroups:he,onOpenAuditHistory:se,onOpenScheduledReports:ze,searchQuery:Y,highlightQuery:We="",searchHistory:kt=[],onAddToSearchHistory:dt,onToggleSearchFavourite:Or,onDeleteSearchHistory:Ot,selectedRowIds:ot=new Set,onSearchChange:Ft,onToggleRowSelection:qe,onToggleAllRows:zt,onRangeSelection:fr,onClearSelection:xt,onExportSelected:tr,currentPage:so=1,pageSize:rr=15,totalRowsBeforePagination:ao=r.length,onPageChange:Tt,onPageSizeChange:mr,isReadOnly:Je=!1,userRole:Mt,reportName:Vt,onEditRow:tt,onDuplicateRow:Qe,onDeleteRow:Wt,showDevPanel:lo=!1,onOpenDevConfig:Mr,rowActions:xr,hideDefaultRowActions:Ve,hideToolbarActions:ke,customSettingsActions:or,viewOptions:At,defaultViewMode:gr,bulkActions:yr,hideSelectionCheckboxes:Ht,rowClickBehavior:nr="select",openModalOn:Ze,onRowClick:ir,onRowRightClick:gt}){var Ro;const ee=ct().urmTable,[br,Ar]=f.useState(null),[Bt,H]=f.useState(0),[ut,we]=f.useState(0),[Ke,sr]=f.useState(null),co=((Ro=Dr().dates)==null?void 0:Ro.displayFormat)??null,[Ut,Sr]=f.useState(null),[Gt,ar]=f.useState(null),[Yt,be]=f.useState(null),[yt,Z]=f.useState(!1),[pe,ye]=f.useState(!1),[Cr,jr]=f.useState(null),[uo,Rr]=f.useState(!1),[po,qt]=f.useState(null),[Pr,Nr]=f.useState(null),[ve,Ge]=f.useState(null),[wr,st]=f.useState(null),Jt=f.useRef(null),It=f.useCallback(()=>{Jt.current&&(clearTimeout(Jt.current),Jt.current=null)},[]),kr=f.useCallback(()=>{It(),Jt.current=setTimeout(()=>st(null),200)},[It]);f.useEffect(()=>It,[It]);const[me,Se]=f.useState(null),Ne=f.useMemo(()=>At??["list","grid"],[At]),[nt,Et]=f.useState(()=>gr??Ne[0]??"list"),[zr,Lr]=f.useState(!1),[Fr,kn]=f.useState(()=>!ju("toolbar_search")),Vr=f.useRef(null),ho=f.useRef(null),[zn,_o]=f.useState(0);f.useLayoutEffect(()=>{const C=Vr.current;if(!C)return;_o(C.clientWidth);const N=new ResizeObserver(oe=>{_o(oe[0].contentRect.width)});return N.observe(C),()=>N.disconnect()},[]);const Hr=f.useCallback(()=>{wu("toolbar_search"),kn(!1)},[]);f.useEffect(()=>{if(!Fr)return;const C=setTimeout(Hr,2e3);return()=>clearTimeout(C)},[Fr,Hr]);const Oo=f.useMemo(()=>{const C=Ke??x;return C.length>0?C.map(N=>e.find(oe=>oe.name===N)).filter(N=>N!==void 0):e},[Ke,x,e]),Ur=f.useMemo(()=>Oo.filter(C=>p[C.name]!==!1),[Oo,p]),Gr=f.useMemo(()=>new Set(((g==null?void 0:g.levels)??[]).map(C=>C.column)),[g]),fo=!!(g!=null&&g.enabled&&(g!=null&&g.levels)&&g.levels.length>0),Yr=f.useMemo(()=>{if(!fo)return Ur;const C=((g==null?void 0:g.levels)??[]).map(oe=>e.find(Ce=>Ce.name===oe.column)).filter(oe=>oe!==void 0),N=Ur.filter(oe=>!Gr.has(oe.name));return[...C,...N]},[Ur,fo,Gr,g,e]),{widths:qr}=_u(Yr,y,zn,fo?Gr:void 0),lr=f.useMemo(()=>e.filter(C=>p[C.name]===!1).length,[e,p]),mo=f.useMemo(()=>e.map(C=>C.name),[e]),Jr=f.useMemo(()=>x.length===0?!1:JSON.stringify(x)!==JSON.stringify(mo),[x,mo]),Tn=f.useCallback((C,N)=>{C.preventDefault(),C.stopPropagation(),Ar(N),H(C.clientX),we(y[N]||150)},[y]);f.useEffect(()=>{if(!br)return;const C=oe=>{const Ce=oe.clientX-Bt,Ae=Math.max(100,Math.min(600,ut+Ce));V==null||V(br,Ae)},N=()=>{Ar(null)};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",N),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",N)}},[br,Bt,ut,V]);const Bn=f.useCallback(C=>C==null?"-":typeof C=="object"?JSON.stringify(C):typeof C=="boolean"?C?"true":"false":String(C),[]);f.useCallback(C=>{const N=n.find(oe=>oe.column===C);return N?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[N.direction==="asc"?t.jsx($.ArrowUpward,{sx:{fontSize:14}}):t.jsx($.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]),f.useCallback(C=>Xn(i,C)?t.jsx(o.IconButton,{size:"small",onClick:oe=>{oe.stopPropagation(),h==null||h(C)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx($.FilterList,{sx:{fontSize:14}})}):null,[i,h]);const In=f.useCallback(C=>{S&&S(C)},[S]),En=f.useCallback((C,N)=>{sr(oe=>{const Ae=[...oe??(x.length>0?x:e.map(Xe=>Xe.name))],[rt]=Ae.splice(C,1);return Ae.splice(N,0,rt),Ae})},[x,e]),Dn=f.useCallback(()=>{Ke&&X&&X(Ke),sr(null)},[Ke,X]),$n=f.useCallback(C=>{if(!S)return;const N=n.find(oe=>oe.column===C);(!N||N.direction!=="asc")&&S(C)},[S,n]),_n=f.useCallback(C=>{if(!S)return;const N=n.find(oe=>oe.column===C);N?N.direction==="asc"&&S(C):(S(C),setTimeout(()=>S(C),0))},[S,n]),On=f.useCallback(C=>{if(!S)return;const N=n.find(oe=>oe.column===C);N&&(N.direction==="asc"?(S(C),setTimeout(()=>S(C),0)):N.direction==="desc"&&S(C))},[S,n]),Mn=f.useCallback(C=>{ae&&ae(C,!1)},[ae]),Kr=!!(g!=null&&g.enabled&&(g!=null&&g.levels)&&g.levels.length>0),Kt=f.useMemo(()=>Ct(i),[i]),Wn=n.length>0||Kt>0||((g==null?void 0:g.enabled)??!1)||Object.values(p).some(C=>C===!1),An=(so-1)*rr,Me=r,at=f.useMemo(()=>{const C=new Set;return ot.forEach(N=>{const oe=N==null?void 0:N.__urm_row_id__;oe!==void 0&&C.add(oe)}),C},[ot]);f.useEffect(()=>{const C=N=>{!zt||!xt||N.target instanceof HTMLInputElement||N.target instanceof HTMLTextAreaElement||((N.ctrlKey||N.metaKey)&&N.key==="a"&&(N.preventDefault(),zt(!0,Me)),N.key==="Escape"&&(N.preventDefault(),xt()))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[zt,xt,Me]);const xo=f.useCallback((C,N)=>{ir==null||ir(Me[C],C,N),(nr==="activate"||nr==="both")&&(be(Me[C]),Z(!0)),nr!=="activate"&&qe&&(N.shiftKey&&Ut!==null?(N.preventDefault(),fr&&fr(Ut,C,Me)):(qe(Me[C]),Sr(C)))},[qe,Ut,fr,Me,ir,nr,be,Z]),Mo=f.useMemo(()=>Me.length>0&&at.size>0&&Me.every(C=>at.has(C==null?void 0:C.__urm_row_id__)),[Me,at]),Rn=!Mo&&Me.some(C=>at.has(C==null?void 0:C.__urm_row_id__)),Dt=!!(qe&&zt&&!Ht),Tr=f.useMemo(()=>!(g!=null&&g.enabled)||!(g!=null&&g.levels)?new Set:new Set(g.levels.map(C=>C.column)),[g]),pt=f.useMemo(()=>Yr,[Yr]),Wo=f.useMemo(()=>{const C=new Map;if(!(g!=null&&g.enabled)||!Me)return C;let N=[];for(const oe of Me)if(oe.__isGroupHeader||oe.isGroupHeader){const Ce=oe.groupLevel??0;N[Ce]=oe.groupKey,N=N.slice(0,Ce+1),C.has(oe.groupKey)||C.set(oe.groupKey,[])}else if(oe.__urm_is_grouped_data_row__)for(const Ce of N)Ce&&C.has(Ce)&&C.get(Ce).push(oe);return C},[g,Me]),Xr=f.useCallback(C=>{const N=C.groupLevel,oe=N===0?v.groupRowLevel0||"urm-group-level-0":N===1?v.groupRowLevel1||"urm-group-level-1":v.groupRowLevel2||"urm-group-level-2",Ce=N===0?_e=>_e.palette.mode==="dark"?E(_e.palette.action.hover,.12):"#f1f5f9":_e=>_e.palette.mode==="dark"?E(_e.palette.action.hover,.06):"#f8fafc",Ae=String(C.groupValue??"(empty)"),rt=`${C.rowCount} ${C.rowCount===1?"item":"items"}`,Xe=Wo.get(C.groupKey)||[],fe=Xe.filter(_e=>at.has(_e==null?void 0:_e.__urm_row_id__)).length,Rt=Xe.length>0&&fe===Xe.length,Xt=fe>0&&fe<Xe.length;return t.jsxs(o.TableRow,{onClick:()=>I==null?void 0:I(C.groupKey),className:`urm-group-header-row urm-group-level-${N} ${oe} ${v.groupRow||""}`,sx:{bgcolor:Ce,"&:hover":{bgcolor:_e=>E(_e.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[Dt&&t.jsx(o.TableCell,{padding:"checkbox",onClick:_e=>_e.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Rt,indeterminate:Xt,onChange:()=>{if(!qe)return;const _e=!Rt;Xe.forEach(cr=>{const Po=at.has(cr==null?void 0:cr.__urm_row_id__);_e!==Po&&qe(cr)})}})}),t.jsxs(o.TableCell,{colSpan:pt.length-Tr.size+(!Dt&&Tr.size===0?1:0),className:`urm-group-cell ${v.groupCellFirst||""} ${v.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 ${v.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${v.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:C.isCollapsed?t.jsx($.ChevronRight,{sx:{fontSize:18}}):t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",className:`urm-group-title ${v.groupTitle||""}`,sx:{fontWeight:N===0?600:500,fontSize:N===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Ae}),!!C.__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:_e=>E(_e.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 ${v.groupBadge||""} ${v.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:_e=>E(_e.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:rt}),Object.keys(C.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${v.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(C.aggregates).map(([_e,cr])=>ks(cr)).filter(Boolean).join(" • "),")"]})]})]})]},C.groupKey)},[Tr,pt,Dt,g,e,I,v,ee,Wo,at,qe]),Ao=f.useCallback((C,N)=>{const oe=at.has(C==null?void 0:C.__urm_row_id__),Ce=Gt===N,Ae=yt&&(C==null?void 0:C.__urm_row_id__)===(Yt==null?void 0:Yt.__urm_row_id__),rt=!!(C!=null&&C.__urm_is_grouped_data_row__),Xe=rt?C.__urm_group_level__??(g==null?void 0:g.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":N,className:rt?`urm-data-row-grouped ${v.dataRowGrouped||""}`:"",onMouseEnter:()=>ar(N),onMouseLeave:()=>ar(null),onClick:fe=>{fe.target.closest("[data-row-action-btn]")||xo(N,fe)},onDoubleClick:()=>{Ze!=null&&Ze.includes("doubleClick")&&(be(C),Z(!0))},onContextMenu:fe=>{fe.preventDefault(),fe.stopPropagation(),gt==null||gt(C,N,fe),st(null),Ge({mouseX:fe.clientX,mouseY:fe.clientY,row:C,rowIndex:N}),Ze!=null&&Ze.includes("rightClick")&&(be(C),Z(!0))},sx:{cursor:"pointer",bgcolor:oe?fe=>it(fe).bg:Ae?fe=>E(fe.palette.info.main,.12):ee!=null&&ee.striped&&N%2===1?ee.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:oe?fe=>it(fe).hoverBg:Ae?fe=>E(fe.palette.info.main,.2):fe=>`var(--highlight-hover-row, ${E(it(fe).main,.04)})`},borderBottom:(ee==null?void 0:ee.rowDivider)??"1px solid",borderColor:"divider"},children:[Dt&&t.jsx(o.TableCell,{padding:"checkbox",onClick:fe=>fe.stopPropagation(),sx:{borderBottom:(ee==null?void 0:ee.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(ee==null?void 0:ee.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:oe,onChange:()=>qe==null?void 0:qe(C)})}),pt.map((fe,Rt)=>{const Xt=Rt===0,_e=Tr.has(fe.name);return t.jsxs(o.TableCell,{className:rt&&Xt?`urm-data-cell-grouped ${v.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(ee==null?void 0:ee.rowPaddingY)??"6px",px:_e?0:(ee==null?void 0:ee.cellPaddingX)??2,position:"relative",textAlign:(ee==null?void 0:ee.cellAlignH)??"left",verticalAlign:(ee==null?void 0:ee.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(ee==null?void 0:ee.rowDivider)??"1px solid",borderRight:ee==null?void 0:ee.colDivider,borderColor:"divider",width:void 0,minWidth:y[fe.name]?`${y[fe.name]}px`:`${fe.type==="date"?Math.max(ps,180):ps}px`},children:[rt&&Xt&&Xe>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),!_e&&t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${v.itemTitle||""}`,children:Pu(fe,C[fe.name],co,We)})})]},fe.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:Ce?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:fe=>{fe.stopPropagation(),fe.preventDefault(),st(null),Ge({anchorEl:fe.currentTarget,row:C,rowIndex:N})},sx:{color:"text.secondary",opacity:Ce?1:0,transition:"opacity 0.12s ease",pointerEvents:Ce?"auto":"none","&:hover":{bgcolor:fe=>E(fe.palette.text.primary,.08),color:"text.primary"}},children:t.jsx($.MoreVert,{sx:{fontSize:18}})})})})]},N)},[ot,An,Gt,xo,Yr,y,We,Bn,tt,Qe,Wt,qe,Dt,be,Z,Yt,yt,Ge,Kr,Gr,gt,Ze]);return t.jsxs(Zt.DndProvider,{backend:ni.HTML5Backend,children:[t.jsxs(o.Box,{sx:C=>{var rt,Xe,fe;const N=((fe=(Xe=(rt=C.components)==null?void 0:rt.MuiCard)==null?void 0:Xe.styleOverrides)==null?void 0:fe.root)||{},oe=N.border&&N.border!=="none"?N.border:"1px solid",Ce=N.borderRadius!==void 0?typeof N.borderRadius=="number"?`${N.borderRadius}px`:N.borderRadius:`${C.shape.borderRadius}px`,Ae=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:ge(C,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:oe,borderColor:oe!=="none"?"divider":void 0,borderRadius:Ce,boxShadow:Ae,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:C=>{var rt,Xe,fe,Rt,Xt;const N=((fe=(Xe=(rt=C.components)==null?void 0:rt.MuiCardHeader)==null?void 0:Xe.styleOverrides)==null?void 0:fe.root)||{},oe=(N.backgroundColor&&N.backgroundColor!=="transparent"?N.backgroundColor:void 0)??((Rt=C.tokens)==null?void 0:Rt.cardHdrHex)??((Xt=C.urmTable)==null?void 0:Xt.headerBg)??C.palette.background.paper,Ce=N.borderBottom&&N.borderBottom!=="none"?N.borderBottom:"1px solid",Ae=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:oe,borderBottom:Ce,borderColor:Ce!=="none"?"divider":void 0,boxShadow:Ae,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Je&&t.jsx(Cu,{}),Ft&&dt&&Or&&Ot&&!(ke!=null&&ke.includes("search"))&&t.jsx(o.Tooltip,{open:Fr,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",fontWeight:C=>C.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:Hr},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(iu,{value:Y||"",onChange:C=>{Fr&&Hr(),Ft(C)},searchHistory:kt,onAddToHistory:dt,onToggleFavourite:Or,onDeleteHistory:Ot,disabled:Je})})}),t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>Lr(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:C=>E(C.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.InfoOutlined,{sx:{fontSize:20}})})}),B&&T&&j&&s.length>0&&t.jsx(su,{views:s||[],activeViewId:a||"",isDirty:c,onSelectView:B,onCreateView:T,onToggleDefault:M,onToggleFavorite:G,onRestoreView:q,onPermanentDelete:R,onEditView:u,onCloneView:A,onCopyLink:F,onDeleteView:d,onPromoteToGlobal:ne,isAdmin:U,isReadOnly:Je}),c&&!Je&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[j&&t.jsx(o.Button,{onClick:j,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:C=>`var(--urm-btn-save-current-bg, ${C.palette.primary.main})`,color:C=>`var(--urm-btn-save-current-color, ${C.palette.primary.contrastText})`,textTransform:"none",boxShadow:C=>ge(C,"restButton"),"&:hover":{bgcolor:C=>`var(--urm-btn-save-current-hover-bg, ${C.palette.primary.dark})`,boxShadow:C=>ge(C,"hoverButton")}},children:"Save current view"}),P&&t.jsx(o.Button,{onClick:P,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:C=>`var(--urm-btn-save-new-border, ${C.palette.primary.main})`,color:C=>`var(--urm-btn-save-new-color, ${C.palette.primary.main})`,bgcolor:C=>`var(--urm-btn-save-new-bg, ${C.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:C=>`var(--urm-btn-save-new-hover-border, ${C.palette.primary.dark})`,bgcolor:C=>`var(--urm-btn-save-new-hover-bg, ${E(C.palette.primary.main,.08)})`}},children:"Save new view"}),_&&t.jsx(o.Button,{onClick:_,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:C=>`var(--urm-btn-discard-bg, ${E(C.palette.text.primary,.12)})`,color:C=>`var(--urm-btn-discard-color, ${C.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:C=>`var(--urm-btn-discard-hover-bg, ${E(C.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),lo&&Mr&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:Mr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:C=>E(C.palette.text.secondary,.3),"&:hover":{bgcolor:C=>E(C.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx($.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!Je&&z&&!(ke!=null&&ke.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:z,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?C=>jt(C):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?C=>E(C.palette.primary.main,.2):C=>E(C.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx($.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&&m&&!(ke!=null&&ke.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:m,size:"small",sx:{position:"relative",color:Kt>0?"primary.main":"text.secondary",bgcolor:Kt>0?C=>jt(C):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Kt>0?C=>E(C.palette.primary.main,.2):C=>E(C.palette.text.primary,.06),color:Kt>0?"primary.main":"text.primary"}},children:[t.jsx($.FilterList,{sx:{fontSize:20}}),Kt>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:Kt})]})}),!Je&&xe&&!(ke!=null&&ke.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:xe,size:"small",sx:{position:"relative",color:lr>0||Jr?"primary.main":"text.secondary",bgcolor:lr>0||Jr?C=>jt(C):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:lr>0||Jr?C=>E(C.palette.primary.main,.2):C=>E(C.palette.text.primary,.06),color:lr>0||Jr?"primary.main":"text.primary"}},children:[t.jsx($.ViewColumn,{sx:{fontSize:20}}),lr>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:lr})]})}),Kr&&(te||he)&&(()=>{var oe;const C=(((oe=g==null?void 0:g.collapsedGroups)==null?void 0:oe.length)??0)>0,N=C?te:he;return N?t.jsx(o.Tooltip,{title:C?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:N,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:Ce=>E(Ce.palette.text.primary,.06),color:"text.primary"}},children:C?t.jsx($.UnfoldMore,{sx:{fontSize:20}}):t.jsx($.UnfoldLess,{sx:{fontSize:20}})})}):null})(),Ne.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),Ne.map(C=>{const N=nt===C,oe=C==="list"?t.jsx($.TableRows,{sx:{fontSize:20}}):t.jsx($.GridView,{sx:{fontSize:20}}),Ce=C==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:Ce,children:t.jsx(o.IconButton,{size:"small",onClick:()=>Et(C),sx:{borderRadius:1,color:N?"primary.main":"text.secondary",bgcolor:N?Ae=>jt(Ae):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:N?Ae=>E(Ae.palette.primary.main,.2):Ae=>E(Ae.palette.text.primary,.06),color:N?"primary.main":"text.primary"}},children:oe})},C)})]}),!(ke!=null&&ke.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:C=>Se(C.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:C=>E(C.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!me,anchorEl:me,onClose:()=>Se(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:[re&&!(ke!=null&&ke.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{re(),Se(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Je&&Q&&!(ke!=null&&ke.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Q(),Se(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),se&&!(ke!=null&&ke.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{se(),Se(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),ze&&!(ke!=null&&ke.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ze(),Se(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]}),or==null?void 0:or.map(C=>t.jsxs(o.MenuItem,{dense:!0,disabled:C.disabled,onClick:()=>{C.onClick(),Se(null)},sx:{py:1,px:2,gap:1.5},children:[C.icon,t.jsx(o.Typography,{variant:"body2",children:C.label})]},C.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[yr&&yr.length>0&&at.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:C=>it(C).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:C=>C.typography.body2.fontWeight||600,mr:1},children:[at.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>xt==null?void 0:xt(),children:"Clear"}),yr.map(C=>{var oe,Ce;const N=Array.from(ot);return(oe=C.hidden)!=null&&oe.call(C,N)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:C.icon,disabled:(Ce=C.disabled)==null?void 0:Ce.call(C,N),onClick:()=>C.onClick(N),children:C.label},C.key)})]}),nt!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(bu,{data:Me,visibleColumns:Ur,grouping:g,selectedRowIds:ot,isGrouped:!!Kr,onToggleGroupCollapse:I,onCardClick:(C,N)=>xo(C,N),onCardDoubleClick:C=>{Ze!=null&&Ze.includes("doubleClick")&&(be(C),Z(!0))},onCardContextMenu:(C,N,oe)=>{gt==null||gt(C,N,oe),st(null),Ge({mouseX:oe.clientX,mouseY:oe.clientY,row:C,rowIndex:N}),Ze!=null&&Ze.includes("rightClick")&&(be(C),Z(!0))},onOpenRowMenu:(C,N,oe)=>Ge({anchorEl:oe,row:C,rowIndex:N}),onToggleSelection:C=>qe==null?void 0:qe(C),hideSelectionCheckboxes:Ht})}),nt==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Vr,onScroll:C=>{ho.current&&(ho.current.scrollLeft=C.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(qr).reduce((C,N)=>C+N,0)}px`},children:[t.jsxs("colgroup",{children:[Dt&&t.jsx("col",{style:{width:"40px"}}),pt.map(C=>t.jsx("col",{style:{width:`${qr[C.name]}px`}},C.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(ee==null?void 0:ee.headerBg)??"action.hover",borderBottom:(ee==null?void 0:ee.rowDivider)??"1px solid",borderColor:"divider"},children:[Dt&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(ee==null?void 0:ee.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(ee==null?void 0:ee.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Mo,indeterminate:Rn,onChange:C=>zt==null?void 0:zt(C.target.checked,Me)})}),pt.map((C,N)=>{const oe=Tr.has(C.name);return t.jsx(cu,{column:C,index:N,isGrouped:oe,sortRule:n.find(Ce=>Ce.column===C.name),hasFilters:Xn(i,C.name),isInSortStack:n.some(Ce=>Ce.column===C.name),isReadOnly:Je,hasModifications:Wn,width:oe?32:y[C.name],onColumnClick:In,onMoveColumn:En,onColumnDragEnd:Dn,onResizeStart:Tn,onSortAscending:k||$n,onSortDescending:b||_n,onRemoveSort:On,onOpenFilterForColumn:h||(()=>{}),onClearFiltersForColumn:le||(()=>{}),onGroupByColumn:de,onHideColumn:Mn,onManageColumns:xe||(()=>{}),onResetLayout:ie},C.name)})]})})]})}),t.jsx(o.Box,{ref:ho,onScroll:C=>{Vr.current&&(Vr.current.scrollLeft=C.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:C=>E(C.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:C=>E(C.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(qr).reduce((C,N)=>C+N,0)}px`},children:[t.jsxs("colgroup",{children:[Dt&&t.jsx("col",{style:{width:"40px"}}),pt.map(C=>t.jsx("col",{style:{width:`${qr[C.name]}px`}},C.name))]}),t.jsx(o.TableBody,{children:Me.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:pt.length+(Dt?1:0),align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Kr?Me.map((C,N)=>C.isGroupHeader?Xr(C):Ao(C,N)):Me.map((C,N)=>Ao(C,N))})]})})]}),Tt&&mr&&t.jsx(Su,{currentPage:so,pageSize:rr,totalRows:ao,totalFields:e.length,onPageChange:Tt,onPageSizeChange:mr}),!(Tt&&mr)&&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 ",Me.length," ",Me.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!ve,onClose:()=>{Ge(null),st(null)},anchorEl:(ve==null?void 0:ve.anchorEl)||null,anchorReference:ve!=null&&ve.anchorEl?"anchorEl":"anchorPosition",anchorPosition:ve&&!ve.anchorEl?{top:ve.mouseY,left:ve.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:ve!=null&&ve.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(Ve!=null&&Ve.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ve&&(be(ve.row),Z(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(Ve!=null&&Ve.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ve&&(qt(ve.row),Nr(ve.rowIndex),Rr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(Ve!=null&&Ve.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ve&&(Qe==null||Qe(ve.rowIndex,ve.row)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),ve&&(xr==null?void 0:xr.map(C=>{var N,oe;return(N=C.hidden)!=null&&N.call(C,ve.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(oe=C.disabled)==null?void 0:oe.call(C,ve.row),onClick:()=>{C.onClick(ve.row,ve.rowIndex),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[C.icon,t.jsx(o.Typography,{variant:"body2",children:C.label})]},C.key)})),at.size>0&&tr&&!(Ve!=null&&Ve.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:C=>{It(),st(C.currentTarget)},onMouseLeave:kr,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($.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",at.size,")"]})]}),t.jsx($.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!wr,anchorEl:wr,placement:"right-start",transition:!0,sx:{zIndex:C=>C.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:C})=>t.jsx(o.Grow,{...C,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:It,onMouseLeave:kr,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:()=>{tr("csv"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{tr("excel"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{tr("json"),st(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]})]})})})})]}),!(Ve!=null&&Ve.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ve&&(jr(ve.row),ye(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx($.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(ku,{open:yt,onClose:()=>{Z(!1),be(null)},row:Yt,schema:e,reportName:Vt}),t.jsx(Tu,{open:uo,onClose:()=>{Rr(!1),qt(null),Nr(null)},onSave:C=>{Pr!==null&&(tt==null||tt(Pr,C))},row:po,schema:e,reportName:Vt}),t.jsx(zu,{open:pe,onClose:()=>{ye(!1),jr(null)},onConfirm:()=>{Cr!==null&&(Wt==null||Wt(Cr))},row:Cr,schema:e}),t.jsx(Js,{isOpen:zr,onClose:()=>Lr(!1)})]})}function $r({content:e,isDev:r=!1}){const[n,i]=f.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=>E(s.palette.primary.main,.08)}},children:t.jsx($.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=>E(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=>E(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>E(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 _r={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},Kn=40;function Lu({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 Fu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(p=>p.name===e.column),c=f.useMemo(()=>{const p=a?rn(a.type):[],x=i.filter.allowedOperators;return x.length>0?p.filter(y=>x.includes(y.value)):p},[a,i]),l=El(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:p=>{var g;const x=r.find(v=>v.name===p.target.value),y=x?rn(x.type):[];s({column:p.target.value,operator:((g=y[0])==null?void 0:g.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(p=>t.jsx(o.MenuItem,{value:p.name,sx:{fontSize:"0.875rem"},children:lt(p.name)},p.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:p=>s({operator:p.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:c.map(p=>t.jsx(o.MenuItem,{value:p.value,sx:{fontSize:"0.875rem"},children:p.label},p.value))})}),l&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:p=>s({value:p.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:p=>s({value:(a==null?void 0:a.type)==="number"?Number(p.target.value):p.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function ta({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}){const p=c>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((x,y)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:Kn,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[y<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),y>0&&t.jsx(Lu,{operator:e.operator,onSelect:g=>l(v=>ai(v,e.id,g))}),y>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:Kn/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:y>0?1:0},children:Ye(x)?t.jsx(Vu,{group:x,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}):t.jsx(Fu,{condition:x,schema:n,availableColumns:i,devConfig:s,onUpdate:g=>l(v=>si(v,x.id,g))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>l(g=>li(g,x.id)),sx:{mt:y>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx($.Close,{sx:{fontSize:16}})})]},x.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${Kn}px`},children:[t.jsx(o.Button,{size:"small",disabled:p||i.length===0,onClick:()=>l(x=>{var y,g,v;return io(x,e.id,{id:no(),column:((y=i[0])==null?void 0:y.name)??"",operator:((v=rn(((g=i[0])==null?void 0:g.type)??"string")[0])==null?void 0:v.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:p,onClick:()=>l(x=>io(x,e.id,_t())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Vu(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>E(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>E(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(ta,{...e})})}function Hu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s}){const[a,c]=f.useState(r??_t()),l=Dr(),p=f.useMemo(()=>e.filter(m=>m.type!=="mixed"&&m.type!=="null"&&m.type!=="array"&&m.type!=="object"),[e]);f.useEffect(()=>{var z;const m=r??_t();if(s&&m.children.length===0){const h=e.find(B=>B.name===s);if(h){c(io(m,m.id,{id:no(),column:s,operator:((z=rn(h.type)[0])==null?void 0:z.value)??"equals"}));return}}c(m)},[r,s,e]);const x=Ct(a),y=l.filter.maxConditions,g=f.useCallback(m=>{c(z=>m(z))},[]),v=f.useMemo(()=>JSON.stringify(a)!==JSON.stringify(r??_t()),[a,r]),S=f.useCallback(()=>{n(a),i()},[a,n,i]),k=f.useCallback(()=>{c(r??_t()),i()},[r,i]),b=f.useCallback(()=>{n(_t()),i()},[n,i]);return t.jsx(o.Box,{onClick:k,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:m=>E(m.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:m=>m.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:m=>m.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:m=>et(m),bgcolor:"background.paper",outline:"none",boxShadow:m=>ce(m).paper.boxShadow,border:m=>ce(m).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:m=>ce(m).header.backgroundColor,borderBottom:m=>ce(m).header.borderBottom,boxShadow:m=>ce(m).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:m=>m.typography.h6.fontSize||"1.125rem",fontWeight:m=>m.typography.h6.fontWeight||500,color:m=>m.typography.h6.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx($r,{content:_r.filter,isDev:process.env.NODE_ENV==="development"})]}),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($.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:m=>E(m.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:m=>E(m.palette.text.primary,.3)}}},children:[x===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:m=>m.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${lt(s)}"`:"","."]}),t.jsx(ta,{group:a,depth:0,schema:e,availableColumns:p,devConfig:l,maxConditions:y,totalConditions:x,onChange:g}),x>=y&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:m=>m.typography.caption.fontSize||"0.75rem",fontWeight:m=>m.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",y," 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:b,disabled:x===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:k,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:m=>`${m.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:S,disabled:!v,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:m=>`${m.shape.borderRadius}px`,boxShadow:m=>ge(m,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const hs="SORT_RULE";function Uu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=f.useRef(null),[{handlerId:c},l]=Zt.useDrop({accept:hs,collect(y){return{handlerId:y.getHandlerId()}},hover(y,g){var h;if(!a.current)return;const v=y.index,S=r;if(v===S)return;const k=(h=a.current)==null?void 0:h.getBoundingClientRect(),b=(k.bottom-k.top)/2,m=g.getClientOffset(),z=((m==null?void 0:m.y)??0)-k.top;v<S&&z<b||v>S&&z>b||(s(v,S),y.index=S)}}),[{isDragging:p},x]=Zt.useDrag({type:hs,item:()=>({index:r}),collect:y=>({isDragging:y.isDragging()})});return x(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:p?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:y=>ge(y,"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:y=>`0 1px 2px 0 ${E(y.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:y=>y.typography.body2.fontSize||"0.875rem",fontWeight:y=>y.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:y=>n(r,y.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:y=>jt(y),"&:hover":{bgcolor:y=>E(y.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:y=>jt(y),"&:hover":{bgcolor:y=>E(y.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:y=>E(y.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]})}function Gu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i}){const[s,a]=f.useState(""),[c,l]=f.useState([]);f.useEffect(()=>{l([...r])},[r]);const p=f.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r),[c,r]),x=Dr(),y=f.useCallback(h=>{if(!h||c.length>=x.sort.maxLevels)return;const B={column:h,direction:"asc",priority:c.length+1};l([...c,B]),a(""),setTimeout(()=>{var T;return(T=document.activeElement)==null?void 0:T.blur()},0)},[c,x.sort.maxLevels]),g=f.useCallback(h=>{const T=c.filter((j,P)=>P!==h).map((j,P)=>({...j,priority:P+1}));l(T)},[c]),v=f.useCallback((h,B)=>{const T=[...c];T[h]={...T[h],direction:B},l(T)},[c]),S=f.useCallback((h,B)=>{const T=[...c],[j]=T.splice(h,1);T.splice(B,0,j);const P=T.map((_,M)=>({..._,priority:M+1}));l(P)},[c]),k=f.useCallback(()=>{n([]),i()},[n,i]),b=f.useCallback(()=>{n(c),i()},[c,n,i]),m=f.useCallback(()=>{l([...r]),a(""),i()},[r,i]),z=e.filter(h=>!c.some(B=>B.column===h.name));return t.jsx(Zt.DndProvider,{backend:ni.HTML5Backend,children:t.jsx(o.Box,{onClick:m,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:h=>E(h.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:h=>h.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:h=>h.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:h=>et(h),bgcolor:"background.paper",outline:"none",boxShadow:h=>ce(h).paper.boxShadow,border:h=>ce(h).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:h=>ce(h).header.backgroundColor,borderBottom:h=>ce(h).header.borderBottom,boxShadow:h=>ce(h).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:h=>h.typography.h6.fontSize||"1.125rem",fontWeight:h=>h.typography.h6.fontWeight||500,color:h=>h.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx($r,{content:_r.sort,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:m,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:h=>E(h.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:h=>E(h.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:h=>h.typography.caption.fontSize||"0.6875rem",fontWeight:h=>h.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:c.length>=x.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:s,onChange:h=>y(h.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:z.map(h=>t.jsx(o.MenuItem,{value:h.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:B=>jt(B),"&:hover":{bgcolor:B=>E(B.palette.primary.main,.2)}}},children:lt(h.name)},h.name))})]}),c.length>=x.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:h=>h.typography.caption.fontSize||"0.75rem",fontWeight:h=>h.typography.caption.fontWeight||500},children:["Maximum ",x.sort.maxLevels," sort levels allowed"]})]}),c.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:h=>h.typography.caption.fontSize||"0.6875rem",fontWeight:h=>h.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",c.length,"/",x.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:k,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:c.map((h,B)=>t.jsx(Uu,{rule:h,index:B,onToggleDirection:v,onRemove:g,onMove:S},`${h.column}-${B}`))})]})]}),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:m,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:h=>`${h.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:!p||c.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:h=>`${h.shape.borderRadius}px`,boxShadow:h=>ge(h,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:h=>ge(h,"hoverButton")},"&:active":{boxShadow:h=>ge(h,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const Go=50;function fs({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:p=10}){const[x,y]=f.useState(s),[g,v]=f.useState(!1),[S,k]=f.useState(a),[b,m]=f.useState(c),z=()=>{if(!x.trim()){v(!0);return}if(x.trim().length>Go){v(!0);return}r(x.trim(),S.trim(),b),n()},h=T=>{T.key==="Enter"&&!T.shiftKey?z():T.key==="Escape"&&n()},B=()=>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:et(T),...ce(T).paper})},children:[t.jsxs(o.DialogTitle,{sx:T=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ce(T).header}),children:[B(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx($.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 ",p," 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<=Go&&y(T.target.value),g&&T.target.value.trim()&&v(!1)},onKeyDown:h,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:Go},error:g&&!x.trim(),helperText:g&&!x.trim()?"View name is required":`${x.length} / ${Go}`}),t.jsx(o.TextField,{label:"Description (optional)",value:S,onChange:T=>k(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:[Ct(e.filters)," filter",Ct(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",Ga(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:b,onChange:T=>m(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:z,variant:"contained",disabled:l&&!i,startIcon:t.jsx($.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=>ge(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>ge(T,"hoverButton")},"&:active":{boxShadow:T=>ge(T,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Yu({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:et(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($.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($.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=>ge(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ge(i,"hoverButton")},"&:active":{boxShadow:i=>ge(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const Jo=100,Ko=600,ms="COLUMN";function qu({column:e,index:r,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:a,moveColumn:c}){const l=f.useRef(null),[p,x]=f.useState(i.toString());f.useEffect(()=>{x(i.toString())},[i]);const[{handlerId:y},g]=Zt.useDrop({accept:ms,collect(h){return{handlerId:h.getHandlerId()}},hover(h,B){var q;if(!l.current)return;const T=h.index,j=r;if(T===j)return;const P=(q=l.current)==null?void 0:q.getBoundingClientRect(),_=(P.bottom-P.top)/2,M=B.getClientOffset(),G=((M==null?void 0:M.y)??0)-P.top;T<j&&G<_||T>j&&G>_||(c(T,j),h.index=j)}}),[{isDragging:v},S]=Zt.useDrag({type:ms,item:()=>({index:r}),collect:h=>({isDragging:h.isDragging()})});S(g(l));const k=()=>{const h=parseInt(p);if(isNaN(h)){x(i.toString()),a(e.name,i);return}const B=Math.max(Jo,Math.min(Ko,h));x(B.toString()),a(e.name,B)},b=h=>{if(h===""||/^\d+$/.test(h)){x(h);const B=parseInt(h);if(!isNaN(B)&&B>=Jo){const T=Math.min(Ko,B);a(e.name,T)}}},m=h=>{h.key==="Enter"&&(h.preventDefault(),k(),h.target.blur())},z=h=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[h]||"text.secondary";return t.jsxs(o.TableRow,{ref:l,"data-handler-id":y,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($.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||400,fontSize:h=>h.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:lt(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:`${z(e.type)}15`,color:z(e.type),border:`1px solid ${z(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:p,onChange:h=>b(h.target.value),onBlur:k,onKeyDown:m,placeholder:"150",size:"small",inputProps:{min:Jo,max:Ko,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:h=>h.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:()=>s(e.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"}},children:n?t.jsx($.Visibility,{sx:{fontSize:20}}):t.jsx($.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?h=>E(h.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Ju({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:p,onResetLayout:x,onClose:y}){const[g,v]=f.useState(!1),[S,k]=f.useState(n),[b,m]=f.useState(i),[z,h]=f.useState("all");f.useEffect(()=>{k(n)},[n]),f.useEffect(()=>{m(i)},[i]);const B=(u,A)=>{m(F=>({...F,[u]:A})),p==null||p(u,A)},T=(u,A)=>{const F=[...S],[d]=F.splice(u,1);F.splice(A,0,d),k(F),l(F)},j=()=>{x(),v(!1)},_=S.map(u=>e.find(A=>A.name===u)).filter(u=>u!==void 0).filter(u=>{const A=r[u.name]??!0;return z==="active"?A:z==="hidden"?!A:!0}),M=Object.values(r).filter(u=>u).length,G=e.length,q=s.find(u=>u.id===a),R=f.useMemo(()=>{if(!q)return!1;const u=q.snapshot,A=u.columnVisibility??{},F=JSON.stringify(r)!==JSON.stringify(A),d=u.columnOrder??[],ne=n??[],U=JSON.stringify(ne)!==JSON.stringify(d)&&!(ne.length===0&&d.length===0),re=u.columnWidths??{},xe=JSON.stringify(b)!==JSON.stringify(re);return F||U||xe},[q,r,n,b]);return t.jsx(Zt.DndProvider,{backend:ni.HTML5Backend,children:t.jsx(o.Box,{onClick:y,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:u=>E(u.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:u=>u.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:u=>u.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:u=>et(u),bgcolor:"background.paper",outline:"none",boxShadow:u=>ce(u).paper.boxShadow,border:u=>ce(u).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:u=>ce(u).header.backgroundColor,borderBottom:u=>ce(u).header.borderBottom,boxShadow:u=>ce(u).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:u=>u.typography.h6.fontSize||"1.125rem",fontWeight:u=>u.typography.h6.fontWeight||500,color:u=>u.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx($r,{content:_r.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:y,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:z,onChange:(u,A)=>h(A),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:u=>it(u).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:u=>it(u).hoverBg},"&:hover":{color:"text.primary",bgcolor:u=>it(u).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:u=>it(u).hoverBg},"&:hover":{color:"text.primary",bgcolor:u=>it(u).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:u=>it(u).hoverBg},"&:hover":{color:"text.primary",bgcolor:u=>it(u).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:u=>E(u.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:u=>E(u.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: ${Jo}px, max: ${Ko}px)`,arrow:!0,placement:"top",children:t.jsx($.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:_.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:u=>u.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):_.map((u,A)=>t.jsx(qu,{column:u,index:A,isVisible:r[u.name]??!0,width:b[u.name]||170,onToggleVisibility:c,onWidthChange:B,moveColumn:T},u.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:u=>u.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[M," of ",G," 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:()=>v(!0),disabled:!R,variant:"outlined",startIcon:t.jsx($.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:u=>`${u.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),g&&t.jsx(o.Box,{onClick:()=>v(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:u=>E(u.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:u=>u.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:u=>u.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:u=>$o(u),bgcolor:"background.paper",boxShadow:u=>ce(u).paper.boxShadow,border:u=>ce(u).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:()=>v(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:u=>`${u.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:j,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:u=>`${u.shape.borderRadius}px`,boxShadow:u=>ge(u,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:u=>ge(u,"hoverButton")},"&:active":{boxShadow:u=>ge(u,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function Ku({schema:e,grouping:r,onApply:n,onClose:i}){var P;const[s,a]=f.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[c,l]=f.useState(""),[p,x]=f.useState(null),y=f.useMemo(()=>Pa(e),[e]),g=f.useMemo(()=>y.filter(_=>!s.levels.some((M,G)=>M.column===_.name&&G!==p)),[y,s.levels,p]),v=Dr(),S=s.levels.length<v.grouping.maxLevels&&g.length>0,k=f.useCallback(_=>{!S||!_||(a({...s,levels:[...s.levels,{column:_}],enabled:!0}),l(""),setTimeout(()=>{var M;return(M=document.activeElement)==null?void 0:M.blur()},0))},[S,s]),b=f.useCallback(_=>{const M=s.levels.filter((G,q)=>q!==_);if(M.length===0){n(null),i();return}a({...s,levels:M,enabled:M.length>0})},[s,n,i]),m=f.useCallback(_=>{x(_),l(s.levels[_].column)},[s.levels]),z=f.useCallback(()=>{if(p===null||!c)return;const _=[...s.levels];_[p]={column:c},a({...s,levels:_}),x(null),l("")},[p,c,s]),h=f.useCallback(()=>{x(null),l("")},[]),B=f.useCallback((_,M)=>{const G=M==="up"?_-1:_+1;if(G<0||G>=s.levels.length)return;const q=[...s.levels],[R]=q.splice(_,1);q.splice(G,0,R),a({...s,levels:q})},[s]),T=f.useCallback(()=>{n(null),i()},[n,i]),j=f.useCallback(()=>{s.levels.length===0?n(null):n({...s,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[s,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:_=>E(_.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:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:_=>et(_),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:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:_=>ce(_).header.backgroundColor,borderBottom:_=>ce(_).header.borderBottom,boxShadow:_=>ce(_).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:_=>_.typography.h6.fontSize||"1.125rem",fontWeight:_=>_.typography.h6.fontWeight||500,color:_=>_.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx($r,{content:_r.grouping,isDev:process.env.NODE_ENV==="development"})]}),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($.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(_.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:_=>E(_.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[p===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:_=>_.typography.caption.fontSize||"0.6875rem",fontWeight:_=>_.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:c,onChange:_=>k(_.target.value),disabled:!S,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..."}),g.map(_=>t.jsxs(o.MenuItem,{value:_.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:M=>jt(M),"&:hover":{bgcolor:M=>E(M.palette.primary.main,.2)}}},children:[lt(_.name)," (",_.type.toUpperCase(),")"]},_.name))]})}),s.levels.length>=v.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:_=>_.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),y.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:_=>_.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),p!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:_=>`1px solid ${E(_.palette.warning.main,.5)}`,bgcolor:_=>E(_.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:_=>_.typography.body2.fontWeight||500,mb:1.5,fontSize:_=>_.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",p+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:c,onChange:_=>l(_.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:s.levels[p].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:_=>jt(_)}},children:[s.levels[p].column," (",(P=e.find(_=>_.name===s.levels[p].column))==null?void 0:P.type.toUpperCase(),")"]}),g.filter(_=>_.name!==s.levels[p].column).map(_=>t.jsxs(o.MenuItem,{value:_.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:M=>jt(M)}},children:[lt(_.name)," (",_.type.toUpperCase(),")"]},_.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:z,disabled:!c,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:_=>ge(_,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:h,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),s.levels.length>0&&p===null&&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:_=>_.typography.caption.fontSize||"0.6875rem",fontWeight:_=>_.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:T,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:s.levels.map((_,M)=>{const G=e.find(q=>q.name===_.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:q=>ge(q,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${M+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:q=>`0 1px 2px 0 ${E(q.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:q=>q.typography.body2.fontWeight||500,fontSize:q=>q.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:_.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:q=>q.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:G==null?void 0:G.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>B(M,"up"),disabled:M===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx($.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>B(M,"down"),disabled:M===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>m(M),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx($.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>b(M),sx:{color:"text.secondary","&:hover":{bgcolor:q=>E(q.palette.error.main,.08),color:"error.main"}},children:t.jsx($.Delete,{sx:{fontSize:18}})})]})]},M)})})]})]})}),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:_=>`${_.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:j,variant:"contained",disabled:s.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:_=>`${_.shape.borderRadius}px`,boxShadow:_=>ge(_,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:_=>ge(_,"hoverButton")},"&:active":{boxShadow:_=>ge(_,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function Xu({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($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx($.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($.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx($.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const xs=[{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 Qu(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 Zu(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function ep({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=ct(),s=i.palette,[a,c]=f.useState("1h"),[l,p]=f.useState(!1),x=[...e].sort((k,b)=>new Date(b.timestamp).getTime()-new Date(k.timestamp).getTime()),y=xs.find(k=>k.key===a),g=Qu(e,y.ms),v=()=>p(!0),S=()=>{n&&(n(Zu(e,y.ms)),p(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:E(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:k=>k.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:et(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:k=>k.typography.body1.fontSize||"0.9375rem",fontWeight:k=>k.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx($r,{content:_r.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:k=>k.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[x.length," event",x.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:k=>c(k.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:E(s.text.primary,.3)}},children:xs.map(k=>t.jsx(o.MenuItem,{value:k.key,sx:{fontSize:"0.8125rem"},children:k.label},k.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx($.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:v,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:E(s.error.main,.5),"&:hover":{bgcolor:E(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:17}})})]})]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:E(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:E(s.text.primary,.14),borderRadius:3}},children:x.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx($.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:k=>k.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:k=>k.typography.body2.fontWeight||500},children:"No audit events yet"}),t.jsx(o.Typography,{sx:{fontSize:k=>k.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:x.map(k=>{const b=hu(i,k.feature),{summary:m,detail:z}=sl(k);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:E(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:cl(k.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:E(b,.1),color:b,border:`1px solid ${E(b,.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:m}),z&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:z}),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($.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:dl(k.timestamp)})]}),k.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx($.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:k.user})]})]})]})]},k.id)})})})]})}),t.jsxs(o.Dialog,{open:l,onClose:()=>p(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:$o(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:E(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:k=>k.typography.body1.fontSize||"0.9375rem",fontWeight:k=>k.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:k=>k.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:[g," audit record",g!==1?"s":""]})," ",y.key==="all"?"from all time":`from the ${y.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:()=>p(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:S,variant:"contained",color:"error",startIcon:t.jsx($.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",g," Record",g!==1?"s":""]})]})]})]})}function tp({onSave:e,onClose:r}){const[n,i]=f.useState(""),[s,a]=f.useState(""),[c,l]=f.useState(""),[p,x]=f.useState([]),[y,g]=f.useState(""),[v,S]=f.useState(""),k=j=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j),b=()=>{const j=c.trim();if(j){if(!k(j)){S("Please enter a valid email address");return}if(p.includes(j)){S("This email is already added");return}x([...p,j]),l(""),S("")}},m=j=>{x(p.filter(P=>P!==j))},z=j=>{j.key==="Enter"&&(j.preventDefault(),b())},h=()=>{if(!n.trim()){g("Preset name is required");return}e(n.trim(),s.trim(),p.length>0?p:void 0)},B=j=>{i(j),y&&g("")},T=j=>{l(j),v&&S("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:j=>E(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:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:j=>et(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.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:"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($.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:j=>E(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>E(j.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($.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:j=>`1px solid ${E(j.palette.primary.main,.3)}`,bgcolor:j=>jt(j),"& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:j=>j.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:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.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:j=>B(j.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!y,helperText:y,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:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.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:j=>a(j.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.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:j=>T(j.target.value),onKeyPress:z,placeholder:"Enter email address",error:!!v,helperText:v,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx($.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:b,variant:"outlined",startIcon:t.jsx($.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:j=>`${j.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),p.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:p.map(j=>t.jsx(o.Chip,{label:j,onDelete:()=>m(j),deleteIcon:t.jsx($.Delete,{sx:{fontSize:16}}),sx:{bgcolor:P=>jt(P),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},j))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:p.length>0?`An email with the shareable link will be sent to ${p.length} recipient${p.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),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:j=>`${j.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($.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,boxShadow:j=>ge(j,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:j=>ge(j,"hoverButton")},"&:active":{boxShadow:j=>ge(j,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function rp({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx($.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($.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>E(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 op({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=>E(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=>et(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>ce(c).paper.boxShadow,border:c=>ce(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=>ce(c).header.backgroundColor,borderBottom:c=>ce(c).header.borderBottom,boxShadow:c=>ce(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($.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=>E(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($.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=>ge(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($.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=>E(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=>ge(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>ge(c,"hoverButton")},"&:active":{boxShadow:c=>ge(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const ra={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},np=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],ip=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function sp(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=ip.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(p=>np.some(x=>x.test(p))).length/c.length>.6),(s||a)&&n.push(i.name)}return n}function wn(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(x=>String(x[c]??"")).filter(x=>x.length>0);if(l.length===0)return 5;const p=l.reduce((x,y)=>x+y.length,0);return Math.ceil(p/l.length)+1}).reduce((c,l)=>c+l,0)+1;return r.reduce((c,l)=>c+l.length+1,0)+s*e.length}function ap(e,r){const n=wn(e,r);return Math.ceil(n*3.5)}function lp(e,r){const n=wn(e,r);return Math.ceil(n*.7)}function cp(e,r){const n=wn(e,r);return Math.ceil(n*2)}function dp(e,r,n){switch(e){case"csv":return wn(r,n);case"excel":return lp(r,n);case"json":return ap(r,n);case"pdf":return cp(r,n)}}function gs(e,r){return Math.ceil(e/r)}function up(e,r,n,i,s=ra){const a=[],c=dp(e,r,n),l=r.length;if(l>s.maxRowsHard){const y=gs(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 ${y} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:y,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const y=gs(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 ${y} smaller export${y>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:y,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${ko(c)} exceeds the ${ko(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 ${ko(c)}`,detail:`This exceeds the recommended ${ko(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),e!=="excel"){const y=sp(i.filter(g=>n.includes(g.name)),r);if(y.length>0){const g=y.length>s.maxImageColumns;a.push({type:"image_columns",severity:g?"error":"warning",message:`Image column${y.length>1?"s":""} detected: ${y.map(v=>`"${v.replace(/_/g," ")}"`).join(", ")}`,detail:g?`Exporting ${y.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:y.length,limit:s.maxImageColumns})}}const p=a.some(y=>y.severity==="error"),x=a.some(y=>y.severity==="warning");return{violations:a,hasBlockingViolation:p,hasWarning:x,estimatedBytes:c}}function ko(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function pp({violation:e}){const n=ct().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=E(i?n.error.main:n.warning.main,.06),c=i?E(n.error.main,.25):E(n.warning.main,.3),l=i?$.ErrorOutline:$.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:p=>p.typography.body2.fontSize||"0.8125rem",fontWeight:p=>p.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:p=>p.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($.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:p=>p.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:p=>p.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function hp({format:e}){const r=ct(),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:E(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 ys({checked:e}){const r=ct();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 fp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:c=[],allRows:l=[],processedRows:p=[],initialFormat:x,initialScope:y="visible",initialColumnScope:g="visible",classTokens:v={},onExport:S,onClose:k}){const b=ct(),m=b.palette,z=Dr(),h=f.useMemo(()=>{var ae,le,ie,Q,de;const U=((ie=(le=(ae=b.components)==null?void 0:ae.MuiCard)==null?void 0:le.styleOverrides)==null?void 0:ie.root)||{},re=U.border&&U.border!=="none"?U.border:(Q=b.tokens)!=null&&Q.cardBodyBorder&&b.tokens.cardBodyBorder!=="none"?b.tokens.cardBodyBorder:m.divider,xe=U.borderRadius!==void 0?typeof U.borderRadius=="number"?`${U.borderRadius}px`:U.borderRadius:`${b.shape.borderRadius}px`,V=U.boxShadow&&U.boxShadow!=="none"?U.boxShadow:((de=b.tokens)==null?void 0:de.cardBodyShadow)||ge(b,"menu"),X=it(b);return{sectionBorder:`var(--urm-export-section-border, ${re})`,sectionTitleColor:`var(--urm-export-section-title-color, ${m.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${m.background.paper})`,cardBg:`var(--urm-export-card-bg, ${m.background.paper})`,cardBorder:`var(--urm-export-card-border, ${re})`,cardRadius:xe,cardShadow:V,cardHoverBg:`var(--urm-export-card-hover-bg, ${m.mode==="dark"?E(m.common.white,.08):E(m.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${E(X.main,m.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${X.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${m.mode==="dark"?m.primary.light:m.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${m.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${m.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${m.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${b.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${b.spacing(1.5)})`}},[m,b]),B=x||z.export.allowedFormats[0]||"csv",[T,j]=f.useState(B),[P,_]=f.useState(y),[M,G]=f.useState(g),q=P==="visible"?r:e,R=M==="visible"?i:s,u=f.useMemo(()=>P==="visible"?p.length>0?p:new Array(r):l.length>0?l:new Array(e),[P,r,e,p,l]),A=f.useMemo(()=>M==="all"?a.map(U=>U.name):a.map(U=>U.name).slice(0,i),[M,a,i]),F=f.useMemo(()=>up(T,u,A,a,ra),[T,u,A,a]),d=()=>{F.hasBlockingViolation||(S({format:T,scope:P,columnScope:M}),k())},ne={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:k,className:`urm-export-backdrop ${v.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:E(m.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:b.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:U=>U.stopPropagation(),elevation:0,className:`urm-export-paper ${v.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:et(b),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 ${v.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:U=>ce(U).header.backgroundColor,borderBottom:U=>ce(U).header.borderBottom,boxShadow:U=>ce(U).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${v.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:m.text.primary},children:"Export Report"}),t.jsx($r,{content:_r.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:k,size:"small",className:`urm-export-close ${v.modalCloseButton||""}`,sx:{color:m.text.secondary,borderRadius:"50%","&:hover":{bgcolor:m.action.hover,color:m.text.primary}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${v.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:E(m.text.primary,.15),borderRadius:3}},children:[F.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:F.violations.map((U,re)=>t.jsx(pp,{violation:U},re))}),t.jsxs(o.Box,{className:`urm-export-section ${v.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 ${v.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:z.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:z.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:z.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:z.export.allowedFormats.includes("pdf")}].filter(U=>U.allowed).map(U=>{const re=T===U.id;return t.jsxs(o.Box,{onClick:()=>j(U.id),className:`urm-export-format-card ${re?v.formatCardSelected||"":v.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:E(m.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:m.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${E(m.primary.main,.3)}`},children:t.jsx($.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(hp,{format:U.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:m.text.primary},children:U.title}),t.jsx(o.Tooltip,{title:U.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:xe=>xe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:13}})})})]})]},U.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.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 ${v.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($.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx($.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(U=>{const re=P===U.value;return t.jsxs(o.Box,{onClick:()=>_(U.value),className:`urm-export-row-card ${re?v.rowCardSelected||"":v.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:E(m.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(ys,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:m.text.secondary,display:"flex"},children:U.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:m.text.primary},children:U.label})]}),t.jsx(o.Tooltip,{title:U.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:xe=>xe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:16}})})})]},U.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.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 ${v.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($.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx($.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(U=>{const re=M===U.value;return t.jsxs(o.Box,{onClick:()=>G(U.value),className:`urm-export-column-card ${re?v.columnCardSelected||"":v.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:E(m.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(ys,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:m.text.secondary,display:"flex"},children:U.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:m.text.primary},children:U.label})]}),t.jsx(o.Tooltip,{title:U.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:xe=>xe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:16}})})})]},U.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${v.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 ${v.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($.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Format",value:ne[T]},{icon:t.jsx($.FormatListNumberedOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Rows to Export",value:q.toLocaleString()},{icon:t.jsx($.SwapVertOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Columns to Export",value:String(R)},{icon:t.jsx($.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Estimated File Size",value:`~${ko(F.estimatedBytes)}`,highlight:F.hasBlockingViolation?"error.main":F.hasWarning?"warning.main":void 0}].map(({icon:U,label:re,value:xe,highlight:V})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${v.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[U,t.jsx(o.Typography,{className:`urm-export-summary-label ${v.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:m.text.secondary,fontWeight:500},children:re})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${v.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:V??m.text.primary},children:xe})]},re))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${v.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[F.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx($.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:U=>U.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:U=>U.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:k,variant:"outlined",className:`urm-export-cancel-btn ${v.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:m.text.primary,borderColor:h.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:h.cardHoverBg,borderColor:E(m.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:d,disabled:F.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${v.downloadButton||""}`,startIcon:t.jsx($.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 ${E(m.primary.main,.25)}`,"&:hover":{bgcolor:h.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:E(m.primary.main,.4),color:h.primaryBtnColor}},children:["Download ",ne[T]]})]})]})})}function mp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx($.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 xp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=5e3}){f.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($.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx($.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx($.InfoOutlined,{sx:{fontSize:20}})}}})(),c=Sl(e);return t.jsx(o.Box,{sx:{position:"fixed",top: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($.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 gp extends f.Component{constructor(n){super(n);Ci(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){Lt.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=>E(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($.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=>E(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($.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function yp({feature:e}){const[r,n]=f.useState(!0);return f.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($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx($.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Yo({children:e,feature:r,onError:n}){return t.jsx(gp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(yp,{feature:r}),children:e})}const bp=[{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"}],vp=[{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"}];function vo({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},children:e})}function Sp({open:e,onClose:r,config:n,onApply:i}){const[s,a]=f.useState(0),[c,l]=f.useState(n),p=()=>l(n),x=()=>l(ht),y=()=>{i(c),r()},g={sort:m=>l(z=>({...z,sort:{...z.sort,...m}})),filter:m=>l(z=>({...z,filter:{...z.filter,...m}})),columns:m=>l(z=>({...z,columns:{...z.columns,...m}})),grouping:m=>l(z=>({...z,grouping:{...z.grouping,...m}})),export:m=>l(z=>({...z,export:{...z.export,...m}}))},v=m=>{const z=c.filter.allowedOperators,h=z.includes(m)?z.filter(B=>B!==m):[...z,m];h.length!==0&&g.filter({allowedOperators:h})},S=m=>{const z=c.export.allowedFormats,h=z.includes(m)?z.filter(B=>B!==m):[...z,m];h.length!==0&&g.export({allowedFormats:h})},k=[{label:"Sort",icon:t.jsx($.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:t.jsx($.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:t.jsx($.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:t.jsx($.Layers,{sx:{fontSize:17}})},{label:"Export",icon:t.jsx($.Download,{sx:{fontSize:17}})}],b=m=>JSON.stringify(c[m])===JSON.stringify(ht[m]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:p},PaperProps:{sx:{borderRadius:m=>et(m),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:m=>`0 8px 32px ${E(m.palette.common.black,.2)}`}},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:"8px",bgcolor:m=>E(m.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem"},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($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:t.jsx(o.Tabs,{value:s,onChange:(m,z)=>a(z),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:k.map((m,z)=>t.jsx(o.Tab,{label:m.label,icon:m.icon,iconPosition:"start"},z))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[t.jsxs(vo,{active:s===0,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!b("sort")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),t.jsx(o.Slider,{value:c.sort.maxLevels,onChange:(m,z)=>g.sort({maxLevels:z}),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(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",t.jsx("strong",{children:"5"}),"."]})]}),t.jsxs(vo,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!b("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),t.jsx(o.Slider,{value:c.filter.maxConditions,onChange:(m,z)=>g.filter({maxConditions:z}),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.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter type dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(m=>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:"0.6875rem",display:"block",mb:.5},children:m}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:bp.filter(z=>z.group===m).map(z=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(z.value),onChange:()=>v(z.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:z.label}),sx:{mr:1.5}},z.value))})]},m))]})]}),t.jsxs(vo,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!b("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),t.jsx(o.Slider,{value:c.columns.maxVisible,onChange:(m,z)=>g.columns({maxVisible:z}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),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:(m,z)=>g.columns({minColumnWidth:z}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}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:(m,z)=>g.columns({maxColumnWidth:z}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]})]})]})]}),t.jsxs(vo,{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.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!b("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(m=>t.jsxs(o.Box,{onClick:()=>g.grouping({maxLevels:m}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===m?"primary.main":"divider",bgcolor:c.grouping.maxLevels===m?z=>E(z.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:z=>E(z.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===m?"primary.main":"text.secondary"},children:m}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][m-1]})]},m))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowNested,onChange:m=>g.grouping({allowNested:m.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:m=>g.grouping({allowCollapse:m.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),t.jsx(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),t.jsx(vo,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!b("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog and the bulk export action. At least one must remain checked."}),t.jsx(o.FormGroup,{sx:{gap:1},children:vp.map(m=>t.jsxs(o.Box,{onClick:()=>S(m.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:c.export.allowedFormats.includes(m.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(m.value)?z=>E(z.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(m.value),onChange:()=>S(m.value),onClick:z=>z.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:m.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:m.desc})]})]},m.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:m=>E(m.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx($.RestartAlt,{sx:{fontSize:18}}),onClick:x,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:m=>E(m.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:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),t.jsx(o.Button,{onClick:y,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const Cp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],jp={1:"1st",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",8:"8th",9:"9th",10:"10th",11:"11th",12:"12th",13:"13th",14:"14th",15:"15th",16:"16th",17:"17th",18:"18th",19:"19th",20:"20th",21:"21st",22:"22nd",23:"23rd",24:"24th",25:"25th",26:"26th",27:"27th",28:"28th"};function Xo(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 p=n??1,x=l.getDay();let y=p-x;return y<0&&(y+=7),y===0&&l<=s&&(y=7),l.setDate(l.getDate()+y),l.toISOString()}if(e==="monthly"){const p=Math.min(i??1,28);return l.setDate(p),l<=s&&(l.setMonth(l.getMonth()+1),l.setDate(p)),l.toISOString()}return l.toISOString()}function wp(e){const r=oa(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${Cp[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${jp[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function oa(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function kp(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 zp(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=oa(`${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 na(e){return`urm_schedules_${e}`}function ia(e){try{const r=localStorage.getItem(na(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 sa(e,r){try{localStorage.setItem(na(e),JSON.stringify(r))}catch{}}const Tp=[{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"}],Bp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,aa={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",email:""},Ir={"& .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 Ip({initial:e=aa,isEditing:r=!1,onSave:n,onBack:i}){const[s,a]=f.useState(e),[c,l]=f.useState(!1),[p,x]=f.useState(!1),y=(S,k)=>a(b=>({...b,[S]:k})),g=s.email.trim().length>0&&!Bp.test(s.email.trim()),v=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!g;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=>E(S.palette.text.primary,.06)}},children:t.jsx($.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=>{y("name",S.target.value),c&&S.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:Ir}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Ir,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:S=>y("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:Ir,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:S=>y("dayOfWeek",Number(S.target.value)),children:Tp.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=>y("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:Ir}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:S=>y("time",S.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:Ir}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Ir,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:S=>y("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=>y("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.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:S=>y("email",S.target.value),onBlur:()=>x(!0),placeholder:"user@company.com",error:p&&g,helperText:p&&g?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx($.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Ir}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[t.jsx($.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{lineHeight:1.5},children:"Opens your device's email app when the schedule fires. Requires a default mail app (e.g. Outlook, Mail) on this device."})]})]}),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=>E(S.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>v&&n(s),disabled:!v,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Ep({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:$o(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=>E(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.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 Dp({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=>E(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=>E(l.palette.success.main,.1):l=>E(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:wp(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=>E(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=>E(l.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx($.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>E(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: ",kp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",zp(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=>E(l.palette.primary.main,.08)}},children:t.jsx($.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=>E(l.palette.warning.main,.08):l=>E(l.palette.success.main,.08)}},children:c?t.jsx($.Pause,{sx:{fontSize:15}}):t.jsx($.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=>E(l.palette.primary.main,.08)}},children:t.jsx($.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=>E(l.palette.error.main,.08)}},children:t.jsx($.Delete,{sx:{fontSize:15}})})})]})]})]})}function $p({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,schedulerConfig:a}){const l=((a==null?void 0:a.mode)??"local")==="api",[p,x]=f.useState([]),y=l?(a==null?void 0:a.schedules)??[]:p,[g,v]=f.useState({type:"list"}),[S,k]=f.useState(0),[b,m]=f.useState(null);f.useEffect(()=>{e&&(l||x(ia(n)),v({type:"list"}))},[e,n,l]),f.useEffect(()=>{if(!e)return;const R=setInterval(()=>k(u=>u+1),3e4);return()=>clearInterval(R)},[e]);const z=f.useCallback(R=>{x(R),sa(n,R)},[n]),h=R=>{var F;const u=Xo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth),A={id:`sched-${Date.now()}`,reportId:n,name:R.name.trim(),frequency:R.frequency,dayOfWeek:R.frequency==="weekly"?R.dayOfWeek:void 0,dayOfMonth:R.frequency==="monthly"?R.dayOfMonth:void 0,time:R.time,format:R.format,scope:R.scope,email:R.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:u,runCount:0};l?(F=a==null?void 0:a.onScheduleCreate)==null||F.call(a,A):z([...y,A]),v({type:"list"})},B=R=>{var d;if(g.type!=="edit")return;const u=g.schedule,A=Xo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth),F={...u,name:R.name.trim(),frequency:R.frequency,dayOfWeek:R.frequency==="weekly"?R.dayOfWeek:void 0,dayOfMonth:R.frequency==="monthly"?R.dayOfMonth:void 0,time:R.time,format:R.format,scope:R.scope,email:R.email.trim()||void 0,nextRunAt:A};l?(d=a==null?void 0:a.onScheduleUpdate)==null||d.call(a,F):z(y.map(ne=>ne.id===u.id?F:ne)),v({type:"list"})},T=R=>{var ne;const u=y.find(U=>U.id===R);if(!u)return;const A=!u.isActive,F=A?Xo(u.frequency,u.time,u.dayOfWeek,u.dayOfMonth):u.nextRunAt,d={...u,isActive:A,nextRunAt:F};l?(ne=a==null?void 0:a.onScheduleToggle)==null||ne.call(a,R,A):z(y.map(U=>U.id===R?d:U))},j=R=>{if(s(R),!l){const u=new Date().toISOString();z(y.map(A=>A.id===R.id?{...A,lastRunAt:u,runCount:A.runCount+1}:A))}},P=R=>{const u=y.find(A=>A.id===R)??null;m(u)},_=()=>{var R;b&&(l?(R=a==null?void 0:a.onScheduleDelete)==null||R.call(a,b.id):z(y.filter(u=>u.id!==b.id)),m(null))},M=R=>({name:R.name,frequency:R.frequency,dayOfWeek:R.dayOfWeek??1,dayOfMonth:R.dayOfMonth??1,time:R.time,format:R.format,scope:R.scope,email:R.email??""}),G=g.type!=="list",q=y.filter(R=>R.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:G,PaperProps:{sx:R=>({borderRadius:et(R),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ce(R).paper})},children:[t.jsxs(o.DialogTitle,{sx:R=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...ce(R).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:R=>E(R.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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:R=>R.typography.h6.fontWeight||600,fontSize:R=>R.typography.subtitle2.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx($r,{content:_r.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:R=>E(R.palette.text.primary,.06)}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[G&&t.jsx(Ip,{initial:g.type==="edit"?M(g.schedule):aa,isEditing:g.type==="edit",onSave:g.type==="edit"?B:h,onBack:()=>v({type:"list"})}),g.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:y.length===0?"No schedules yet":`${q} of ${y.length} active`}),t.jsx(o.Button,{startIcon:t.jsx($.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>v({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),y.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx($.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:R=>R.typography.body2.fontWeight||500,fontSize:R=>R.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:y.map(R=>t.jsx(Dp,{schedule:R,tick:S,onToggle:T,onRunNow:j,onEdit:u=>v({type:"edit",schedule:u}),onDelete:P},R.id))})]})]}),g.type==="list"&&t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:R=>E(R.palette.warning.main,.06),border:"1px solid",borderColor:R=>E(R.palette.warning.main,.2)},children:[t.jsx($.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:R=>E(R.palette.text.primary,.06)}},children:"Close"})]})]}),b&&t.jsx(Ep,{scheduleName:b.name,onConfirm:_,onCancel:()=>m(null)})]})}const _p=6e4;function Op({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:p,sortStack:x,onFired:y,schedulerConfig:g}){const v=(g==null?void 0:g.mode)??"local",S=f.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:p,sortStack:x,onFired:y,schedulerConfig:g,schedulerMode:v});f.useEffect(()=>{S.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:p,sortStack:x,onFired:y,schedulerConfig:g,schedulerMode:v}});const k=f.useCallback(b=>{var R,u,A,F,d;const{reportName:m,uploadedData:z,processedData:h,schema:B,activeView:T,columnVisibility:j,columnOrder:P,filters:_,sortStack:M,schedulerConfig:G,schedulerMode:q}=S.current;try{const ne=b.scope==="all"?z:h;if(q==="api"){const xe=(P.length>0?P:B.map(X=>X.name)).filter(X=>j[X]!==!1),V={schedule:b,triggeredAt:new Date().toISOString(),rows:ne,columns:xe,format:b.format,reportName:m};(R=G==null?void 0:G.onScheduleFire)==null||R.call(G,V),(A=(u=S.current).onFired)==null||A.call(u,b);return}const U=Qo(ne,B,_,M,T,j,P),re=`${b.name}_scheduled`;switch(b.format){case"csv":Zo(U,re,{scope:b.scope});break;case"excel":en(U,re,{scope:b.scope});break;case"json":tn(U,re,{scope:b.scope});break;case"pdf":ui(U,re,{scope:b.scope});break}if(G!=null&&G.onScheduleFire){const xe=(P.length>0?P:B.map(V=>V.name)).filter(V=>j[V]!==!1);G.onScheduleFire({schedule:b,triggeredAt:new Date().toISOString(),rows:ne,columns:xe,format:b.format,reportName:m})}if(b.email){const xe=encodeURIComponent(`Scheduled Report: ${b.name}`),V=encodeURIComponent(`Your scheduled report "${b.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:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.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:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.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:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.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:n=>n.typography.body2.fontWeight||500,fontSize:n=>n.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:n=>`${n.shape.borderRadius}px`,boxShadow:n=>ge(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>ge(n,"hoverButton")},"&:active":{boxShadow:n=>ge(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function ou({onFileUpload:e,onError:r,isUploading:n}){const[i,s]=f.useState(!1),[a,c]=f.useState(""),[l,p]=f.useState(!1),x=f.useRef(null),y=async z=>{if(!z.name.endsWith(".json")){r("Only .json files are allowed");return}const h=10*1024*1024;if(z.size>h){r("File size exceeds 10MB limit");return}c(z.name);try{const B=await z.text();let T;try{T=JSON.parse(B)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(T)){r("JSON must be an array of objects");return}if(T.length===0){r("No data rows found in JSON file");return}e(T)}catch{r("Network error — please try again")}finally{c("")}},g=z=>{z.preventDefault(),s(!0)},v=z=>{z.preventDefault(),s(!1)},S=z=>{z.preventDefault(),s(!1);const h=z.dataTransfer.files[0];h&&y(h)},k=()=>{var z;(z=x.current)==null||z.click()},b=z=>{var B;const h=(B=z.target.files)==null?void 0:B[0];h&&y(h)},m=z=>{z.stopPropagation(),p(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:g,onDragLeave:v,onDrop:S,onPaste:z=>z.preventDefault(),onClick:k,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?z=>D(z.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:x,type:"file",accept:".json",onChange:b,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:z=>z.typography.body2.fontWeight||500,fontSize:z=>z.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),a&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:a})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:z=>D(z.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.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:m,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx($.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(Ks,{isOpen:l,onClose:()=>p(!1)})]})}function nu({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=>D(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($.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 iu({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=>D(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=>D(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.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($.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function Xs({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=>D(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx($.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 su({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:c}){const[l,p]=f.useState(!1),[x,y]=f.useState(!1),[g,v]=f.useState(-1),S=f.useRef(null),k=f.useRef(null);f.useEffect(()=>{function M(q){S.current&&!S.current.contains(q.target)&&(p(!1),y(!1))}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);const b=f.useCallback(()=>{y(!0),v(-1),n.length>0&&p(!0)},[n.length]),m=f.useCallback(M=>{r(M),v(-1)},[r]),z=f.useCallback(M=>{var q;r(M),i(M),p(!1),(q=k.current)==null||q.blur()},[r,i]),h=f.useCallback(M=>{v(-1),z(M)},[z]),B=f.useCallback(M=>{var q;M.key==="Enter"?g>=0&&g<n.length?(M.preventDefault(),h(n[g].query)):e.trim()&&z(e.trim()):M.key==="Escape"?(p(!1),v(-1),(q=k.current)==null||q.blur()):M.key==="ArrowDown"?(M.preventDefault(),n.length>0&&(l||p(!0),v(K=>K<n.length-1?K+1:K))):M.key==="ArrowUp"&&(M.preventDefault(),v(K=>K>0?K-1:-1))},[g,n,e,l,h,z]),T=f.useCallback(()=>{var M;r(""),(M=k.current)==null||M.focus()},[r]),w=f.useMemo(()=>n.filter(M=>M.isFavourite),[n]),P=f.useMemo(()=>n.filter(M=>!M.isFavourite),[n]),O=l&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:S,children:[t.jsx(o.TextField,{inputRef:k,size:"small",fullWidth:!0,value:e,onChange:M=>m(M.target.value),onFocus:b,onKeyDown:B,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:M=>D(M.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:M=>D(M.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($.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($.Close,{sx:{fontSize:16}})})}):null}}),O&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[w.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:M=>M.typography.caption.fontWeight||600,fontSize:M=>M.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),w.map((M,q)=>t.jsx(ds,{entry:M,isSelected:g===q,onClick:()=>h(M.query),onToggleFavourite:()=>s(M.query),onDelete:()=>a(M.query)},`fav-${M.query}`))]}),P.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[w.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:M=>M.typography.caption.fontWeight||600,fontSize:M=>M.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),P.map((M,q)=>{const K=w.length+q;return t.jsx(ds,{entry:M,isSelected:g===K,onClick:()=>h(M.query),onToggleFavourite:()=>s(M.query),onDelete:()=>a(M.query)},`recent-${M.query}`)})]})]})]})}const ds=f.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const c=f.useCallback(p=>{p.stopPropagation(),s()},[s]),l=f.useCallback(p=>{p.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?p=>D(p.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?p=>D(p.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($.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx($.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($.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function au({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:c,onRestoreView:l,onPermanentDelete:p,onEditView:x,onCloneView:y,onCopyLink:g,onDeleteView:v,onPromoteToGlobal:S,isReadOnly:k,isAdmin:b=!1}){const m=pt(),[z,h]=f.useState(!1),[B,T]=f.useState(!1),[w,P]=f.useState({top:0,left:0}),[O,M]=f.useState(null),[q,K]=f.useState(null),R=f.useRef(null),u=f.useRef(null),A=e.find(I=>I.id===r),F=A==null?void 0:A.isDefault,d=(I,ee)=>I.name.localeCompare(ee.name),oe=e.filter(I=>I.scope==="global"&&!I.isDeleted).sort(d),G=e.filter(I=>I.scope!=="global"&&!I.isDeleted).sort(d),te=e.filter(I=>I.isFavorite&&!I.isDeleted).sort(d),xe=e.filter(I=>I.isDeleted);f.useEffect(()=>{if(z&&u.current){const I=u.current.getBoundingClientRect();P({top:I.bottom+window.scrollY+8,left:I.right+window.scrollX-320})}},[z]),f.useEffect(()=>{const I=ee=>{R.current&&!R.current.contains(ee.target)&&u.current&&!u.current.contains(ee.target)&&h(!1)};return z&&document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[z]);const H=I=>{if(n&&I!==r){M(I),h(!1);return}i(I),h(!1)},Q=()=>{O&&(i(O),M(null))},le=()=>{M(null)},ce=(I,ee=!1)=>{const fe=I.scope==="global",se=!k&&(!fe||b),ke=b&&!fe;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===I.id?D(m.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===I.id?D(m.palette.primary.main,.12):m.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>H(I.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===I.id&&t.jsx($.Check,{sx:{fontSize:16,flexShrink:0}}),r!==I.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===I.id?m.palette.primary.dark:m.palette.text.primary,fontWeight:r===I.id?J=>J.typography.body2.fontWeight||500:400,fontSize:J=>J.typography.body2.fontSize||"0.875rem"},children:I.name}),ee&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:m.palette.text.secondary,backgroundColor:m.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[se&&c&&t.jsx(o.IconButton,{onClick:J=>{J.stopPropagation(),c(I.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:I.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx($.Star,{sx:{fontSize:16}})}),se&&a&&!I.isDefault&&t.jsx(o.IconButton,{onClick:J=>{J.stopPropagation(),a(I.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Set as default",children:t.jsx($.RadioButtonUnchecked,{sx:{fontSize:16}})}),(se||ke)&&(x||y||g||v||ke&&S)&&t.jsx(o.IconButton,{onClick:J=>{J.stopPropagation(),K({el:J.currentTarget,view:I})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"More actions",children:t.jsx($.MoreVert,{sx:{fontSize:16}})})]})]},I.id)},ie=I=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:m.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:m.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:I.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[l&&t.jsx(o.IconButton,{onClick:ee=>{ee.stopPropagation(),l(I.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Restore view",children:t.jsx($.Undo,{sx:{fontSize:16,color:"success.main"}})}),p&&t.jsx(o.IconButton,{onClick:ee=>{ee.stopPropagation(),p(I.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Delete permanently",children:t.jsx($.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},I.id),Z=n||!F,ue=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:u,onClick:()=>h(!z),variant:"outlined",size:"small",endIcon:t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:Z?"warning.main":"text.primary",borderColor:Z?"warning.main":"divider",bgcolor:Z?D(m.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:Z?"warning.dark":"primary.main",bgcolor:Z?D(m.palette.warning.main,.2):D(m.palette.text.primary,.06),color:Z?"warning.dark":"text.primary"}},title:`View: ${(A==null?void 0:A.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(A==null?void 0:A.name)||"Default View"}),ue&&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"}})]}),z&&vs.createPortal(t.jsxs(o.Box,{ref:R,sx:{position:"fixed",width:"320px",backgroundColor:m.palette.background.paper,border:`1px solid ${m.palette.divider}`,borderRadius:1,boxShadow:m.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:w.top,left:w.left},children:[oe.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:I=>I.typography.caption.fontSize||"caption.fontSize",fontWeight:I=>I.typography.caption.fontWeight||600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),oe.map(I=>ce(I,I.isDefault))]}),te.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.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:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx($.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),te.map(I=>ce(I))]})]}),G.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:I=>I.typography.caption.fontSize||"caption.fontSize",fontWeight:I=>I.typography.caption.fontWeight||600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),G.map(I=>ce(I))]})]}),xe.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>T(!B),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",xe.length,")"]}),t.jsx($.ChevronRight,{sx:{fontSize:16}})]}),B&&t.jsx(o.Box,{sx:{backgroundColor:m.palette.action.hover},children:xe.map(I=>ie(I))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),h(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:m.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},children:[t.jsx($.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!q,anchorEl:(q==null?void 0:q.el)||null,onClose:()=>K(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[x&&t.jsxs(o.MenuItem,{onClick:()=>{q&&x(q.view.id),K(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Edit,{sx:{fontSize:18}}),"Edit"]}),g&&t.jsxs(o.MenuItem,{onClick:()=>{q&&g(q.view.id),K(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Link,{sx:{fontSize:18}}),"Copy Link"]}),y&&t.jsxs(o.MenuItem,{onClick:()=>{q&&y(q.view.id),K(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),S&&b&&(q==null?void 0:q.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{q&&S(q.view.id),K(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Language,{sx:{fontSize:18}}),"Promote to Global"]}),v&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{q&&v(q.view.id),K(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx($.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:O!==null,onClose:le,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:$o(m)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx($.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:le,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:Q,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function lu({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:c=!1,position:l,onSortAscending:p,onSortDescending:x,onRemoveSort:y,onFilter:g,onClearFilter:v,onGroupByColumn:S,onHideColumn:k,onManageColumns:b,onResetLayout:m,onClose:z}){const h=pt(),B=h.palette,T=f.useRef(null);f.useEffect(()=>{if(!T.current)return;const K=T.current,R=K.getBoundingClientRect(),u=window.innerWidth,A=window.innerHeight;R.right>u-8&&(K.style.left=`${u-R.width-8}px`),R.bottom>A-8&&(K.style.top=`${A-R.height-8}px`)},[l]),f.useEffect(()=>{const K=u=>{T.current&&!T.current.contains(u.target)&&z()},R=u=>{u.key==="Escape"&&z()};return document.addEventListener("mousedown",K),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",R)}},[z]);const w=f.useCallback(K=>()=>{K(),z()},[z]),P=(n==null?void 0:n.direction)==="asc",O=(n==null?void 0:n.direction)==="desc",M=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",q=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return vs.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:$o(h),overflow:"hidden",boxShadow:`0 4px 20px ${D(B.common.black,.12)}, 0 1px 4px ${D(B.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:K=>K.typography.body2.fontSize||"0.8125rem",fontWeight:K=>K.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 (${M})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:w(()=>p(e)),sx:{p:.625,borderRadius:"6px",color:P?"primary.main":"text.secondary",bgcolor:P?D(B.primary.main,.1):"transparent","&:hover":{bgcolor:D(B.primary.main,.08),color:"primary.main"}},children:t.jsx($.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${q})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:w(()=>x(e)),sx:{p:.625,borderRadius:"6px",color:O?"primary.main":"text.secondary",bgcolor:O?D(B.primary.main,.1):"transparent","&:hover":{bgcolor:D(B.primary.main,.08),color:"primary.main"}},children:t.jsx($.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:w(()=>y(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:D(B.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx($.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:w(()=>g(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.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:w(()=>v(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:D(B.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($.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:w(()=>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($.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:w(()=>k(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($.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:w(b),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:D(B.primary.main,.08),color:"primary.main"}},children:t.jsx($.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:w(b),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&c&&m&&t.jsxs(o.MenuItem,{onClick:w(m),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:D(B.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($.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const cu=176,us="COLUMN_HEADER",du=f.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:c=!1,isGrouped:l=!1,hasModifications:p=!1,width:x,onColumnClick:y,onMoveColumn:g,onColumnDragEnd:v,onResizeStart:S,onSortAscending:k,onSortDescending:b,onRemoveSort:m,onOpenFilterForColumn:z,onClearFiltersForColumn:h,onGroupByColumn:B,onHideColumn:T,onManageColumns:w,onResetLayout:P}){const M=pt().urmTable,q=f.useRef(null),[K,R]=f.useState(!1),[u,A]=f.useState({x:0,y:0}),[{handlerId:F,isOver:d},oe]=rr.useDrop({accept:us,collect(Z){return{handlerId:Z.getHandlerId(),isOver:Z.isOver()}},hover(Z,ue){var We;if(!q.current)return;const I=Z.index,ee=n;if(I===ee)return;const fe=(We=q.current)==null?void 0:We.getBoundingClientRect(),se=(fe.right-fe.left)/2,ke=ue.getClientOffset(),J=((ke==null?void 0:ke.x)??0)-fe.left;I<ee&&J<se||I>ee&&J>se||(g(I,ee),Z.index=ee)}}),[{isDragging:G},te]=rr.useDrag({type:us,item:()=>({index:n,columnName:r.name}),collect:Z=>({isDragging:Z.isDragging()}),end:()=>{v==null||v()}});te(oe(q));const xe=f.useCallback(Z=>{Z.preventDefault(),Z.stopPropagation(),A({x:Z.clientX,y:Z.clientY}),R(!0)},[]),H=f.useCallback(()=>R(!1),[]),Q=f.useCallback(()=>{l||y(r.name)},[y,r.name,l]),le=f.useCallback(Z=>{Z.stopPropagation(),z(r.name)},[z,r.name]),ce=f.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx($.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx($.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]),ie=f.useCallback(()=>s?t.jsx($.FilterList,{onClick:le,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,le]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:q,"data-handler-id":F,"data-column-index":n,onClick:Q,onContextMenu:xe,sx:{position:"sticky",top:0,zIndex:5,textAlign:(M==null?void 0:M.cellAlignH)??"left",verticalAlign:(M==null?void 0:M.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(M==null?void 0:M.headerColor)??"text.secondary",opacity:G?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:d?Z=>D(Z.palette.primary.main,.08):(M==null?void 0:M.headerBg)??"action.hover",boxShadow:Z=>`0 1px 0 ${D(Z.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(M==null?void 0:M.rowDivider)??"1px solid",borderRight:M==null?void 0:M.colDivider,borderColor:"divider",py:0,px:l?0:(M==null?void 0:M.cellPaddingX)??2,"&:hover":{bgcolor:Z=>D(Z.palette.primary.main,.1),color:"text.primary"},width:l?"32px":x?`${x}px`:`${cu}px`,minWidth:l?"32px":void 0,maxWidth:l?"32px":void 0},children:[!l&&t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[ut(r.name),ce(),ie()]}),!l&&t.jsx(o.Box,{draggable:!1,onDragStart:Z=>Z.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:Z=>{Z.preventDefault(),Z.stopPropagation(),S(Z,r.name)},onClick:Z=>Z.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"}})]}),K&&t.jsx(lu,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:c,hasModifications:p,position:u,onSortAscending:k,onSortDescending:b,onRemoveSort:m,onFilter:z,onClearFilter:h,onGroupByColumn:B,onHideColumn:T,onManageColumns:w,onResetLayout:P,onClose:H})]})}),uu={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 rn(e,r){const n=uu[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:D(i.main,e.palette.mode==="dark"?.24:.12),color:e.palette.mode==="dark"?i.light:i.dark}}function pu(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 hu={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"}};function fu(e,r){const n=hu[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function jt(e){return D(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function mu(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=>rn(n,r).bg,color:n=>rn(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function xu(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 mu(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=pu(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 gu(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 yu({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:c,onOpenRowMenu:l,onToggleSelection:p,hideCheckbox:x}){const[y,g]=f.useState(!1),{primaryCol:v,idCol:S,bodyColumns:k}=f.useMemo(()=>gu(n),[n]),b=v?e[v.name]:null,m=S?e[S.name]:null,z=y||i;return t.jsxs(o.Box,{onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!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,w,P,O;const B=(O=(P=(w=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:w.styleOverrides)==null?void 0:P.root)==null?void 0:O.border;return i?"2px solid":B&&B!=="none"?B:"1px solid"},borderColor:i?h=>at(h).main:h=>{var T,w,P,O;const B=(O=(P=(w=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:w.styleOverrides)==null?void 0:P.root)==null?void 0:O.border;return B&&B!=="none"?"inherit":D(h.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:h=>{var T,w,P,O;const B=(O=(P=(w=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:w.styleOverrides)==null?void 0:P.root)==null?void 0:O.borderRadius;return B!==void 0?typeof B=="number"?`${B}px`:B:`${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 ${D(at(h).main,.15)}, 0 2px 8px ${D(h.palette.common.black,.08)}`:y?h=>{var T,w,P,O;const B=(O=(P=(w=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:w.styleOverrides)==null?void 0:P.root)==null?void 0:O.boxShadow;return B&&B!=="none"?B:ge(h,"cardHover")}:h=>{var T,w,P,O;const B=(O=(P=(w=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:w.styleOverrides)==null?void 0:P.root)==null?void 0:O.boxShadow;return B&&B!=="none"?B:ge(h,"cardRest")},transform:y&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:h=>D(at(h).main,.03)}},children:[t.jsxs(o.Box,{sx:h=>{var O,M,q,K;const B=((q=(M=(O=h.components)==null?void 0:O.MuiCardHeader)==null?void 0:M.styleOverrides)==null?void 0:q.root)||{},T=(B.backgroundColor&&B.backgroundColor!=="transparent"?B.backgroundColor:void 0)??((K=h.tokens)==null?void 0:K.cardHdrHex)??"transparent",w=B.borderBottom&&B.borderBottom!=="none"?B.borderBottom:void 0,P=B.boxShadow&&B.boxShadow!=="none"?B.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:T,borderBottom:w,boxShadow:P,display:"flex",alignItems:"center",gap:.5}},children:[!x&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:h=>h.stopPropagation(),onChange:()=>p(e),sx:{p:.25,opacity:z?1:0,transition:"opacity 0.15s ease"}}),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:b!=null&&b!==""?String(b):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:h=>{var w,P,O;const B=((O=(P=(w=h.components)==null?void 0:w.MuiCardHeader)==null?void 0:P.styleOverrides)==null?void 0:O.root)||{};return B.borderBottom&&B.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:[k.map(h=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:B=>B.typography.body2.fontWeight||500,fontSize:B=>B.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:ut(h.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[h.name]??""),children:xu(h,e[h.name])})]},h.name)),k.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=>D(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:m?.85:0,userSelect:"none"},children:m?String(m):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:z?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=>D(h.palette.text.primary,.08)}},children:t.jsx($.MoreVert,{sx:{fontSize:17}})})})})]})]})}function bu({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=>ge(s,"flatHover"),"&:hover":{bgcolor:s=>D(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx($.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx($.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:Ha(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=>D(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])=>zs(a)).filter(Boolean).join(" • ")})]})}function vu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:c,onCardDoubleClick:l,onCardContextMenu:p,onOpenRowMenu:x,onToggleSelection:y,hideSelectionCheckboxes:g}){const v=f.useMemo(()=>{const S=new Set;return i.forEach(k=>{const b=k==null?void 0:k.__urm_row_id__;b!==void 0&&S.add(b)}),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=>cs(S).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:S=>cs(S).cardGap,alignContent:"start"},children:e.map((S,k)=>s&&S.isGroupHeader?t.jsx(bu,{row:S,grouping:n,onToggleCollapse:a||(()=>{})},`group-${S.groupKey}`):t.jsx(yu,{row:S,rowIndex:k,visibleColumns:r,isSelected:v.has(S==null?void 0:S.__urm_row_id__),onCardClick:c,onCardDoubleClick:l,onCardContextMenu:p,onOpenRowMenu:x,onToggleSelection:y,hideCheckbox:g},`card-${k}`))})})}const ps=[10,15,25,50,100];function Su(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 Cu({currentPage:e,pageSize:r,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:a}){const l=pt().palette,p=Math.ceil(n/r),[x,y]=f.useState(String(e)),[g,v]=f.useState(null),[S,k]=f.useState(!1),b=f.useRef(null);f.useEffect(()=>{S||(y(String(e)),v(null))},[e,S]);const m=f.useCallback(()=>{const A=Su(x,p);if(A){v(A);return}const F=parseInt(x.trim(),10);v(null),k(!1),F!==e&&s(F)},[x,p,e,s]),z=f.useCallback(A=>{var F;A.key==="Enter"?(A.preventDefault(),m()):A.key==="Escape"&&(y(String(e)),v(null),k(!1),(F=b.current)==null||F.blur())},[m,e]),h=f.useCallback(()=>{y(String(e)),v(null),k(!1)},[e]),B=f.useCallback(()=>{k(!0),v(null),setTimeout(()=>{var A;return(A=b.current)==null?void 0:A.select()},0)},[]);if(n<=Math.min(...ps))return null;const T=()=>{y(String(e)),v(null),k(!1)},w=()=>{T(),s(1)},P=()=>{T(),e>1&&s(e-1)},O=()=>{T(),e<p&&s(e+1)},M=()=>{T(),s(p)},q=(e-1)*r+1,K=Math.min(e*r,n),R=`${Math.max(2,String(p).length+.5)}ch`,u={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:A=>A.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:A=>A.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:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:A=>a(Number(A.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:ps.map(A=>t.jsx(o.MenuItem,{value:A,sx:{fontSize:"0.8125rem"},children:A},A))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[q,"–",K," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[g&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:D(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${D(l.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:D(l.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:A=>A.typography.caption.fontSize||"0.6875rem",fontWeight:A=>A.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:g})}),t.jsx(o.InputBase,{inputRef:b,value:x,onChange:A=>{y(A.target.value),g&&v(null)},onKeyDown:z,onFocus:B,onBlur:h,inputProps:{"aria-label":`Page number, 1 to ${p}`,style:{textAlign:"center",padding:"2px 0",width:R,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:g?"error.main":"text.primary",border:"1px solid",borderColor:g?"error.main":S?"primary.main":"divider",borderRadius:"4px",bgcolor:g?D(l.error.main,.04):S?D(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:g?"error.main":"text.secondary"},"&:focus-within":{boxShadow:g?`0 0 0 2px ${D(l.error.main,.2)}`:`0 0 0 2px ${D(l.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",p]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:w,disabled:e===1,size:"small",title:"First page",sx:u,children:t.jsx($.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:P,disabled:e===1,size:"small",title:"Previous page",sx:u,children:t.jsx($.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:O,disabled:e===p,size:"small",title:"Next page",sx:u,children:t.jsx($.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:M,disabled:e===p,size:"small",title:"Last page",sx:u,children:t.jsx($.LastPage,{sx:{fontSize:20}})})]})]})]})}function ju(){return t.jsx(o.Chip,{icon:t.jsx($.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 Qs="urm_hint_seen_";function wu(e){try{return localStorage.getItem(Qs+e)==="true"}catch{return!1}}function ku(e){try{localStorage.setItem(Qs+e,"true")}catch{}}const Zs={"& .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 oi(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 ea({row:e,schema:r}){const i=pt().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:ut(l.name),value:oi(e[l.name],l.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:Zs},l.name)),c.map(l=>{const p=oi(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:ut(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:D(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:p?"text.primary":"text.disabled",fontStyle:p?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:p||"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 zu({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=pt(),c=a.palette;if(!n)return null;const l=i.filter(x=>x.name in n).length,p=de(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:tt(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...p.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,...p.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:D(c.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:D(c.text.primary,.015)},children:t.jsx(ea,{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 Tu({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=pt(),c=de(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:tt(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=>D(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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($.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(ea,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>D(l.palette.error.main,.1),border:l=>`1px solid ${D(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($.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=>ge(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>ge(l,"hoverButton")},"&:active":{boxShadow:l=>ge(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Bu({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var z;const c=pt(),l=c.palette,[p,x]=f.useState({});if(f.useEffect(()=>{e&&i&&x({...i})},[e,i]),!i)return null;const y=s.filter(h=>h.name in i),g=y.filter(h=>h.type!=="object"&&h.type!=="array"),v=y.filter(h=>h.type==="object"||h.type==="array"),S=(h,B)=>{x(T=>({...T,[h]:B}))},k=()=>{const h={...p};y.forEach(B=>{const T=p[B.name];if(B.type==="number"){const w=Number(T);h[B.name]=isNaN(w)?i[B.name]:w}else B.type==="boolean"&&(h[B.name]=!!T)}),n(h),r()},b=y.length,m=de(c);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:tt(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...m.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,...m.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:D(((z=l.warning)==null?void 0:z.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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," · ",b," ",b===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($.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:D(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[g.map(h=>{const B=p[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:ut(h.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!B,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:B?"Enabled":"Disabled"})]})]},h.name):t.jsx(o.TextField,{label:ut(h.name),value:B??"",onChange:T=>S(h.name,T.target.value),type:h.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:Zs},h.name)}),v.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:v.map(h=>{const B=oi(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:ut(h.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:D(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($.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:D(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:B?"text.primary":"text.disabled",fontStyle:B?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:B||"No value"})]},h.name)})}),y.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx($.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:k,variant:"contained",startIcon:t.jsx($.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:h=>`${h.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Iu=176,Eu=170,Du=40,$u=32;function ta(e){return e.type==="date"?180:Iu}function _u(e,r){return r!=null&&r!==Eu&&r!==ta(e)}function Ou(e,r,n,i){return f.useMemo(()=>{const s=e.map(v=>i!=null&&i.has(v.name)?{name:v.name,width:$u,explicit:!0}:{name:v.name,width:r[v.name]??ta(v),explicit:_u(v,r[v.name])}),a={};s.forEach(v=>{a[v.name]=v.width});const c=s.reduce((v,S)=>v+S.width,0),p=Math.max(0,n-Du)-c;if(p<=0)return{widths:a,fillerWidth:0};const x=s.filter(v=>!v.explicit);if(x.length===0)return{widths:a,fillerWidth:p};const y=x.reduce((v,S)=>v+S.width,0)||1;let g=0;return x.forEach((v,S)=>{const b=S===x.length-1?v.width+p-g:Math.round(v.width+p*v.width/y);a[v.name]=b,g+=b-v.width}),{widths:a,fillerWidth:0}},[e,r,n,i])}const hs=176,Mu=Wt(),Wu={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Au(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=>rn(n,r).bg,color:n=>rn(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Ru(e){const r=e.toLowerCase().trim(),n=Wu[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Pu(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 Nu(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 Au(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Ru(s);if(e.type==="date"){const l=e.dateFormat??"iso",p=_a(r,l,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:p})}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(p=>typeof p=="object"?JSON.stringify(p):String(p)).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 Pu(s,i)}function Lu({schema:e,data:r,sortStack:n=[],filters:i=Mu,views:s=[],activeViewId:a="",isDirty:c=!1,isExporting:l=!1,columnVisibility:p={},columnOrder:x=[],columnWidths:y={},grouping:g=null,classTokens:v={},onSort:S,onSortAscending:k,onSortDescending:b,onOpenFilters:m,onOpenSort:z,onOpenFilterForColumn:h,onSelectView:B,onCreateView:T,onUpdateCurrentView:w,onSaveAsNewView:P,onDiscardChanges:O,onToggleDefault:M,onToggleFavorite:q,onRestoreView:K,onPermanentDelete:R,onEditView:u,onCloneView:A,onCopyLink:F,onDeleteView:d,onPromoteToGlobal:oe,isAdmin:G=!1,onExport:te,onOpenColumns:xe,onUpdateColumnWidth:H,onUpdateColumnOrder:Q,onUpdateColumnVisibility:le,onClearFiltersForColumn:ce,onResetLayout:ie,onOpenGroup:Z,onGroupByColumn:ue,onToggleGroupCollapse:I,onExpandAllGroups:ee,onCollapseAllGroups:fe,onOpenAuditHistory:se,onOpenScheduledReports:ke,searchQuery:J,highlightQuery:We="",searchHistory:kt=[],onAddToSearchHistory:ht,onToggleSearchFavourite:Wr,onDeleteSearchHistory:At,selectedRowIds:it=new Set,onSearchChange:Yt,onToggleRowSelection:Je,onToggleAllRows:zt,onRangeSelection:xr,onClearSelection:gt,onExportSelected:nr,currentPage:lo=1,pageSize:Rt=15,totalRowsBeforePagination:co=r.length,onPageChange:yt,onPageSizeChange:gr,isReadOnly:Ke=!1,userRole:Pt,reportName:Tt,onEditRow:Xe,onDuplicateRow:Bt,onDeleteRow:rt,showDevPanel:yr=!1,onOpenDevConfig:Ar,rowActions:br,hideDefaultRowActions:He,hideToolbarActions:Ce,customSettingsActions:vr,viewOptions:Sr,defaultViewMode:qt,bulkActions:Jt,hideSelectionCheckboxes:Rr,rowClickBehavior:It="select",openModalOn:Qe,onRowClick:ir,onRowRightClick:Et}){var Ao;const pe=pt().urmTable,[je,Pr]=f.useState(null),[Nr,Nt]=f.useState(0),[V,Dt]=f.useState(0),[ne,st]=f.useState(null),sr=((Ao=_r().dates)==null?void 0:Ao.displayFormat)??null,[Cr,ar]=f.useState(null),[jr,Lt]=f.useState(null),[Ft,ot]=f.useState(null),[we,lt]=f.useState(!1),[U,Ue]=f.useState(!1),[Ee,wr]=f.useState(null),[po,Fr]=f.useState(!1),[ho,Kt]=f.useState(null),[Vr,Hr]=f.useState(null),[ye,Ge]=f.useState(null),[kr,ct]=f.useState(null),Xt=f.useRef(null),$t=f.useCallback(()=>{Xt.current&&(clearTimeout(Xt.current),Xt.current=null)},[]),zr=f.useCallback(()=>{$t(),Xt.current=setTimeout(()=>ct(null),200)},[$t]);f.useEffect(()=>$t,[$t]);const[me,be]=f.useState(null),Ye=f.useMemo(()=>Sr??["list","grid"],[Sr]),[Ze,_t]=f.useState(()=>qt??Ye[0]??"list"),[fo,lr]=f.useState(!1),[Ur,jn]=f.useState(()=>!wu("toolbar_search")),Gr=f.useRef(null),mo=f.useRef(null),[wn,_o]=f.useState(0);f.useLayoutEffect(()=>{const C=Gr.current;if(!C)return;_o(C.clientWidth);const N=new ResizeObserver(re=>{_o(re[0].contentRect.width)});return N.observe(C),()=>N.disconnect()},[]);const Yr=f.useCallback(()=>{ku("toolbar_search"),jn(!1)},[]);f.useEffect(()=>{if(!Ur)return;const C=setTimeout(Yr,2e3);return()=>clearTimeout(C)},[Ur,Yr]);const Oo=f.useMemo(()=>{const C=ne??x;return C.length>0?C.map(N=>e.find(re=>re.name===N)).filter(N=>N!==void 0):e},[ne,x,e]),qr=f.useMemo(()=>Oo.filter(C=>p[C.name]!==!1),[Oo,p]),Jr=f.useMemo(()=>new Set(((g==null?void 0:g.levels)??[]).map(C=>C.column)),[g]),xo=!!(g!=null&&g.enabled&&(g!=null&&g.levels)&&g.levels.length>0),Kr=f.useMemo(()=>{if(!xo)return qr;const C=((g==null?void 0:g.levels)??[]).map(re=>e.find(ve=>ve.name===re.column)).filter(re=>re!==void 0),N=qr.filter(re=>!Jr.has(re.name));return[...C,...N]},[qr,xo,Jr,g,e]),{widths:Xr}=Ou(Kr,y,wn,xo?Jr:void 0),cr=f.useMemo(()=>e.filter(C=>p[C.name]===!1).length,[e,p]),Mo=f.useMemo(()=>e.map(C=>C.name),[e]),Tr=f.useMemo(()=>x.length===0?!1:JSON.stringify(x)!==JSON.stringify(Mo),[x,Mo]),kn=f.useCallback((C,N)=>{C.preventDefault(),C.stopPropagation(),Pr(N),Nt(C.clientX),Dt(y[N]||150)},[y]);f.useEffect(()=>{if(!je)return;const C=re=>{const ve=re.clientX-Nr,Ae=Math.max(100,Math.min(600,V+ve));H==null||H(je,Ae)},N=()=>{Pr(null)};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",N),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",N)}},[je,Nr,V,H]);const zn=f.useCallback(C=>C==null?"-":typeof C=="object"?JSON.stringify(C):typeof C=="boolean"?C?"true":"false":String(C),[]);f.useCallback(C=>{const N=n.find(re=>re.column===C);return N?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[N.direction==="asc"?t.jsx($.ArrowUpward,{sx:{fontSize:14}}):t.jsx($.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]),f.useCallback(C=>Xn(i,C)?t.jsx(o.IconButton,{size:"small",onClick:re=>{re.stopPropagation(),h==null||h(C)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx($.FilterList,{sx:{fontSize:14}})}):null,[i,h]);const Tn=f.useCallback(C=>{S&&S(C)},[S]),Bn=f.useCallback((C,N)=>{st(re=>{const Ae=[...re??(x.length>0?x:e.map(et=>et.name))],[nt]=Ae.splice(C,1);return Ae.splice(N,0,nt),Ae})},[x,e]),In=f.useCallback(()=>{ne&&Q&&Q(ne),st(null)},[ne,Q]),En=f.useCallback(C=>{if(!S)return;const N=n.find(re=>re.column===C);(!N||N.direction!=="asc")&&S(C)},[S,n]),Dn=f.useCallback(C=>{if(!S)return;const N=n.find(re=>re.column===C);N?N.direction==="asc"&&S(C):(S(C),setTimeout(()=>S(C),0))},[S,n]),$n=f.useCallback(C=>{if(!S)return;const N=n.find(re=>re.column===C);N&&(N.direction==="asc"?(S(C),setTimeout(()=>S(C),0)):N.direction==="desc"&&S(C))},[S,n]),_n=f.useCallback(C=>{le&&le(C,!1)},[le]),Qr=!!(g!=null&&g.enabled&&(g!=null&&g.levels)&&g.levels.length>0),Qt=f.useMemo(()=>Ct(i),[i]),On=n.length>0||Qt>0||((g==null?void 0:g.enabled)??!1)||Object.values(p).some(C=>C===!1),Mn=(lo-1)*Rt,Me=r,dt=f.useMemo(()=>{const C=new Set;return it.forEach(N=>{const re=N==null?void 0:N.__urm_row_id__;re!==void 0&&C.add(re)}),C},[it]);f.useEffect(()=>{const C=N=>{!zt||!gt||N.target instanceof HTMLInputElement||N.target instanceof HTMLTextAreaElement||((N.ctrlKey||N.metaKey)&&N.key==="a"&&(N.preventDefault(),zt(!0,Me)),N.key==="Escape"&&(N.preventDefault(),gt()))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[zt,gt,Me]);const go=f.useCallback((C,N)=>{ir==null||ir(Me[C],C,N),(It==="activate"||It==="both")&&(ot(Me[C]),lt(!0)),It!=="activate"&&Je&&(N.shiftKey&&Cr!==null?(N.preventDefault(),xr&&xr(Cr,C,Me)):(Je(Me[C]),ar(C)))},[Je,Cr,xr,Me,ir,It,ot,lt]),Wo=f.useMemo(()=>Me.length>0&&dt.size>0&&Me.every(C=>dt.has(C==null?void 0:C.__urm_row_id__)),[Me,dt]),Wn=!Wo&&Me.some(C=>dt.has(C==null?void 0:C.__urm_row_id__)),Ot=!!(Je&&zt&&!Rr),Br=f.useMemo(()=>!(g!=null&&g.enabled)||!(g!=null&&g.levels)?new Set:new Set(g.levels.map(C=>C.column)),[g]),Zt=f.useMemo(()=>Kr,[Kr]),dr=f.useMemo(()=>{const C=new Map;if(!(g!=null&&g.enabled)||!Me)return C;let N=[];for(const re of Me)if(re.__isGroupHeader||re.isGroupHeader){const ve=re.groupLevel??0;N[ve]=re.groupKey,N=N.slice(0,ve+1),C.has(re.groupKey)||C.set(re.groupKey,[])}else if(re.__urm_is_grouped_data_row__)for(const ve of N)ve&&C.has(ve)&&C.get(ve).push(re);return C},[g,Me]),An=f.useCallback(C=>{const N=C.groupLevel,re=N===0?v.groupRowLevel0||"urm-group-level-0":N===1?v.groupRowLevel1||"urm-group-level-1":v.groupRowLevel2||"urm-group-level-2",ve=N===0?_e=>_e.palette.mode==="dark"?D(_e.palette.action.hover,.12):"#f1f5f9":_e=>_e.palette.mode==="dark"?D(_e.palette.action.hover,.06):"#f8fafc",Ae=String(C.groupValue??"(empty)"),nt=`${C.rowCount} ${C.rowCount===1?"item":"items"}`,et=dr.get(C.groupKey)||[],he=et.filter(_e=>dt.has(_e==null?void 0:_e.__urm_row_id__)).length,Vt=et.length>0&&he===et.length,er=he>0&&he<et.length;return t.jsxs(o.TableRow,{onClick:()=>I==null?void 0:I(C.groupKey),className:`urm-group-header-row urm-group-level-${N} ${re} ${v.groupRow||""}`,sx:{bgcolor:ve,"&:hover":{bgcolor:_e=>D(_e.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[Ot&&t.jsx(o.TableCell,{padding:"checkbox",onClick:_e=>_e.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Vt,indeterminate:er,onChange:()=>{if(!Je)return;const _e=!Vt;et.forEach(ur=>{const Rn=dt.has(ur==null?void 0:ur.__urm_row_id__);_e!==Rn&&Je(ur)})}})}),t.jsxs(o.TableCell,{colSpan:Zt.length-Br.size+(!Ot&&Br.size===0?1:0),className:`urm-group-cell ${v.groupCellFirst||""} ${v.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 ${v.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${v.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:C.isCollapsed?t.jsx($.ChevronRight,{sx:{fontSize:18}}):t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",className:`urm-group-title ${v.groupTitle||""}`,sx:{fontWeight:N===0?600:500,fontSize:N===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Ae}),!!C.__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:_e=>D(_e.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 ${v.groupBadge||""} ${v.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:_e=>D(_e.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:nt}),Object.keys(C.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${v.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(C.aggregates).map(([_e,ur])=>zs(ur)).filter(Boolean).join(" • "),")"]})]})]})]},C.groupKey)},[Br,Zt,Ot,g,e,I,v,pe,dr,dt,Je]),Ir=f.useCallback((C,N)=>{const re=dt.has(C==null?void 0:C.__urm_row_id__),ve=jr===N,Ae=we&&(C==null?void 0:C.__urm_row_id__)===(Ft==null?void 0:Ft.__urm_row_id__),nt=!!(C!=null&&C.__urm_is_grouped_data_row__),et=nt?C.__urm_group_level__??(g==null?void 0:g.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":N,className:nt?`urm-data-row-grouped ${v.dataRowGrouped||""}`:"",onMouseEnter:()=>Lt(N),onMouseLeave:()=>Lt(null),onClick:he=>{he.target.closest("[data-row-action-btn]")||go(N,he)},onDoubleClick:()=>{Qe!=null&&Qe.includes("doubleClick")&&(ot(C),lt(!0))},onContextMenu:he=>{he.preventDefault(),he.stopPropagation(),Et==null||Et(C,N,he),ct(null),Ge({mouseX:he.clientX,mouseY:he.clientY,row:C,rowIndex:N}),Qe!=null&&Qe.includes("rightClick")&&(ot(C),lt(!0))},sx:{cursor:"pointer",bgcolor:re?he=>at(he).bg:Ae?he=>D(he.palette.info.main,.12):pe!=null&&pe.striped&&N%2===1?pe.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:re?he=>at(he).hoverBg:Ae?he=>D(he.palette.info.main,.2):he=>`var(--highlight-hover-row, ${D(at(he).main,.04)})`},borderBottom:(pe==null?void 0:pe.rowDivider)??"1px solid",borderColor:"divider"},children:[Ot&&t.jsx(o.TableCell,{padding:"checkbox",onClick:he=>he.stopPropagation(),sx:{borderBottom:(pe==null?void 0:pe.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(pe==null?void 0:pe.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:re,onChange:()=>Je==null?void 0:Je(C)})}),Zt.map((he,Vt)=>{const er=Vt===0,_e=Br.has(he.name);return t.jsxs(o.TableCell,{className:nt&&er?`urm-data-cell-grouped ${v.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(pe==null?void 0:pe.rowPaddingY)??"6px",px:_e?0:(pe==null?void 0:pe.cellPaddingX)??2,position:"relative",textAlign:(pe==null?void 0:pe.cellAlignH)??"left",verticalAlign:(pe==null?void 0:pe.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(pe==null?void 0:pe.rowDivider)??"1px solid",borderRight:pe==null?void 0:pe.colDivider,borderColor:"divider",width:void 0,minWidth:y[he.name]?`${y[he.name]}px`:`${he.type==="date"?Math.max(hs,180):hs}px`},children:[nt&&er&&et>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),!_e&&t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${v.itemTitle||""}`,children:Nu(he,C[he.name],sr,We)})})]},he.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:ve?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:he=>{he.stopPropagation(),he.preventDefault(),ct(null),Ge({anchorEl:he.currentTarget,row:C,rowIndex:N})},sx:{color:"text.secondary",opacity:ve?1:0,transition:"opacity 0.12s ease",pointerEvents:ve?"auto":"none","&:hover":{bgcolor:he=>D(he.palette.text.primary,.08),color:"text.primary"}},children:t.jsx($.MoreVert,{sx:{fontSize:18}})})})})]},N)},[it,Mn,jr,go,Kr,y,We,zn,Xe,Bt,rt,Je,Ot,ot,lt,Ft,we,Ge,Qr,Jr,Et,Qe]);return t.jsxs(rr.DndProvider,{backend:ni.HTML5Backend,children:[t.jsxs(o.Box,{sx:C=>{var nt,et,he;const N=((he=(et=(nt=C.components)==null?void 0:nt.MuiCard)==null?void 0:et.styleOverrides)==null?void 0:he.root)||{},re=N.border&&N.border!=="none"?N.border:"1px solid",ve=N.borderRadius!==void 0?typeof N.borderRadius=="number"?`${N.borderRadius}px`:N.borderRadius:`${C.shape.borderRadius}px`,Ae=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:ge(C,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:re,borderColor:re!=="none"?"divider":void 0,borderRadius:ve,boxShadow:Ae,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:C=>{var nt,et,he,Vt,er;const N=((he=(et=(nt=C.components)==null?void 0:nt.MuiCardHeader)==null?void 0:et.styleOverrides)==null?void 0:he.root)||{},re=(N.backgroundColor&&N.backgroundColor!=="transparent"?N.backgroundColor:void 0)??((Vt=C.tokens)==null?void 0:Vt.cardHdrHex)??((er=C.urmTable)==null?void 0:er.headerBg)??C.palette.background.paper,ve=N.borderBottom&&N.borderBottom!=="none"?N.borderBottom:"1px solid",Ae=N.boxShadow&&N.boxShadow!=="none"?N.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:re,borderBottom:ve,borderColor:ve!=="none"?"divider":void 0,boxShadow:Ae,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Ke&&t.jsx(ju,{}),Yt&&ht&&Wr&&At&&!(Ce!=null&&Ce.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:C=>C.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(su,{value:J||"",onChange:C=>{Ur&&Yr(),Yt(C)},searchHistory:kt,onAddToHistory:ht,onToggleFavourite:Wr,onDeleteHistory:At,disabled:Ke})})}),t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>lr(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:C=>D(C.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.InfoOutlined,{sx:{fontSize:20}})})}),B&&T&&w&&s.length>0&&t.jsx(au,{views:s||[],activeViewId:a||"",isDirty:c,onSelectView:B,onCreateView:T,onToggleDefault:M,onToggleFavorite:q,onRestoreView:K,onPermanentDelete:R,onEditView:u,onCloneView:A,onCopyLink:F,onDeleteView:d,onPromoteToGlobal:oe,isAdmin:G,isReadOnly:Ke}),c&&!Ke&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[w&&t.jsx(o.Button,{onClick:w,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:C=>`var(--urm-btn-save-current-bg, ${C.palette.primary.main})`,color:C=>`var(--urm-btn-save-current-color, ${C.palette.primary.contrastText})`,textTransform:"none",boxShadow:C=>ge(C,"restButton"),"&:hover":{bgcolor:C=>`var(--urm-btn-save-current-hover-bg, ${C.palette.primary.dark})`,boxShadow:C=>ge(C,"hoverButton")}},children:"Save current view"}),P&&t.jsx(o.Button,{onClick:P,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:C=>`var(--urm-btn-save-new-border, ${C.palette.primary.main})`,color:C=>`var(--urm-btn-save-new-color, ${C.palette.primary.main})`,bgcolor:C=>`var(--urm-btn-save-new-bg, ${C.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:C=>`var(--urm-btn-save-new-hover-border, ${C.palette.primary.dark})`,bgcolor:C=>`var(--urm-btn-save-new-hover-bg, ${D(C.palette.primary.main,.08)})`}},children:"Save new view"}),O&&t.jsx(o.Button,{onClick:O,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:C=>`var(--urm-btn-discard-bg, ${D(C.palette.text.primary,.12)})`,color:C=>`var(--urm-btn-discard-color, ${C.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:C=>`var(--urm-btn-discard-hover-bg, ${D(C.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),yr&&Ar&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:Ar,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:C=>D(C.palette.text.secondary,.3),"&:hover":{bgcolor:C=>D(C.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx($.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!Ke&&z&&!(Ce!=null&&Ce.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:z,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?C=>jt(C):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?C=>D(C.palette.primary.main,.2):C=>D(C.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx($.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})]})}),!Ke&&m&&!(Ce!=null&&Ce.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:m,size:"small",sx:{position:"relative",color:Qt>0?"primary.main":"text.secondary",bgcolor:Qt>0?C=>jt(C):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Qt>0?C=>D(C.palette.primary.main,.2):C=>D(C.palette.text.primary,.06),color:Qt>0?"primary.main":"text.primary"}},children:[t.jsx($.FilterList,{sx:{fontSize:20}}),Qt>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:Qt})]})}),!Ke&&xe&&!(Ce!=null&&Ce.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:xe,size:"small",sx:{position:"relative",color:cr>0||Tr?"primary.main":"text.secondary",bgcolor:cr>0||Tr?C=>jt(C):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:cr>0||Tr?C=>D(C.palette.primary.main,.2):C=>D(C.palette.text.primary,.06),color:cr>0||Tr?"primary.main":"text.primary"}},children:[t.jsx($.ViewColumn,{sx:{fontSize:20}}),cr>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:cr})]})}),Qr&&(ee||fe)&&(()=>{var re;const C=(((re=g==null?void 0:g.collapsedGroups)==null?void 0:re.length)??0)>0,N=C?ee:fe;return N?t.jsx(o.Tooltip,{title:C?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:N,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:ve=>D(ve.palette.text.primary,.06),color:"text.primary"}},children:C?t.jsx($.UnfoldMore,{sx:{fontSize:20}}):t.jsx($.UnfoldLess,{sx:{fontSize:20}})})}):null})(),Ye.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),Ye.map(C=>{const N=Ze===C,re=C==="list"?t.jsx($.TableRows,{sx:{fontSize:20}}):t.jsx($.GridView,{sx:{fontSize:20}}),ve=C==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:ve,children:t.jsx(o.IconButton,{size:"small",onClick:()=>_t(C),sx:{borderRadius:1,color:N?"primary.main":"text.secondary",bgcolor:N?Ae=>jt(Ae):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:N?Ae=>D(Ae.palette.primary.main,.2):Ae=>D(Ae.palette.text.primary,.06),color:N?"primary.main":"text.primary"}},children:re})},C)})]}),!(Ce!=null&&Ce.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:C=>be(C.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:C=>D(C.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!me,anchorEl:me,onClose:()=>be(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:[te&&!(Ce!=null&&Ce.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{te(),be(null)},disabled:l,sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Ke&&Z&&!(Ce!=null&&Ce.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Z(),be(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),se&&!(Ce!=null&&Ce.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{se(),be(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),ke&&!(Ce!=null&&Ce.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ke(),be(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]}),vr==null?void 0:vr.map(C=>t.jsxs(o.MenuItem,{dense:!0,disabled:C.disabled,onClick:()=>{C.onClick(),be(null)},sx:{py:1,px:2,gap:1.5},children:[C.icon,t.jsx(o.Typography,{variant:"body2",children:C.label})]},C.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Jt&&Jt.length>0&&dt.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:C=>at(C).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:C=>C.typography.body2.fontWeight||600,mr:1},children:[dt.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>gt==null?void 0:gt(),children:"Clear"}),Jt.map(C=>{var re,ve;const N=Array.from(it);return(re=C.hidden)!=null&&re.call(C,N)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:C.icon,disabled:(ve=C.disabled)==null?void 0:ve.call(C,N),onClick:()=>C.onClick(N),children:C.label},C.key)})]}),Ze!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(vu,{data:Me,visibleColumns:qr,grouping:g,selectedRowIds:it,isGrouped:!!Qr,onToggleGroupCollapse:I,onCardClick:(C,N)=>go(C,N),onCardDoubleClick:C=>{Qe!=null&&Qe.includes("doubleClick")&&(ot(C),lt(!0))},onCardContextMenu:(C,N,re)=>{Et==null||Et(C,N,re),ct(null),Ge({mouseX:re.clientX,mouseY:re.clientY,row:C,rowIndex:N}),Qe!=null&&Qe.includes("rightClick")&&(ot(C),lt(!0))},onOpenRowMenu:(C,N,re)=>Ge({anchorEl:re,row:C,rowIndex:N}),onToggleSelection:C=>Je==null?void 0:Je(C),hideSelectionCheckboxes:Rr})}),Ze==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Gr,onScroll:C=>{mo.current&&(mo.current.scrollLeft=C.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((C,N)=>C+N,0)}px`},children:[t.jsxs("colgroup",{children:[Ot&&t.jsx("col",{style:{width:"40px"}}),Zt.map(C=>t.jsx("col",{style:{width:`${Xr[C.name]}px`}},C.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(pe==null?void 0:pe.headerBg)??"action.hover",borderBottom:(pe==null?void 0:pe.rowDivider)??"1px solid",borderColor:"divider"},children:[Ot&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(pe==null?void 0:pe.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(pe==null?void 0:pe.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Wo,indeterminate:Wn,onChange:C=>zt==null?void 0:zt(C.target.checked,Me)})}),Zt.map((C,N)=>{const re=Br.has(C.name);return t.jsx(du,{column:C,index:N,isGrouped:re,sortRule:n.find(ve=>ve.column===C.name),hasFilters:Xn(i,C.name),isInSortStack:n.some(ve=>ve.column===C.name),isReadOnly:Ke,hasModifications:On,width:re?32:y[C.name],onColumnClick:Tn,onMoveColumn:Bn,onColumnDragEnd:In,onResizeStart:kn,onSortAscending:k||En,onSortDescending:b||Dn,onRemoveSort:$n,onOpenFilterForColumn:h||(()=>{}),onClearFiltersForColumn:ce||(()=>{}),onGroupByColumn:ue,onHideColumn:_n,onManageColumns:xe||(()=>{}),onResetLayout:ie},C.name)})]})})]})}),t.jsx(o.Box,{ref:mo,onScroll:C=>{Gr.current&&(Gr.current.scrollLeft=C.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:C=>D(C.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:C=>D(C.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Xr).reduce((C,N)=>C+N,0)}px`},children:[t.jsxs("colgroup",{children:[Ot&&t.jsx("col",{style:{width:"40px"}}),Zt.map(C=>t.jsx("col",{style:{width:`${Xr[C.name]}px`}},C.name))]}),t.jsx(o.TableBody,{children:Me.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:Zt.length+(Ot?1:0),align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Qr?Me.map((C,N)=>C.isGroupHeader?An(C):Ir(C,N)):Me.map((C,N)=>Ir(C,N))})]})})]}),yt&&gr&&t.jsx(Cu,{currentPage:lo,pageSize:Rt,totalRows:co,totalFields:e.length,onPageChange:yt,onPageSizeChange:gr}),!(yt&&gr)&&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 ",Me.length," ",Me.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!ye,onClose:()=>{Ge(null),ct(null)},anchorEl:(ye==null?void 0:ye.anchorEl)||null,anchorReference:ye!=null&&ye.anchorEl?"anchorEl":"anchorPosition",anchorPosition:ye&&!ye.anchorEl?{top:ye.mouseY,left:ye.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:ye!=null&&ye.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(He!=null&&He.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ye&&(ot(ye.row),lt(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(He!=null&&He.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ye&&(Kt(ye.row),Hr(ye.rowIndex),Fr(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(He!=null&&He.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ye&&(Bt==null||Bt(ye.rowIndex,ye.row)),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),ye&&(br==null?void 0:br.map(C=>{var N,re;return(N=C.hidden)!=null&&N.call(C,ye.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(re=C.disabled)==null?void 0:re.call(C,ye.row),onClick:()=>{C.onClick(ye.row,ye.rowIndex),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[C.icon,t.jsx(o.Typography,{variant:"body2",children:C.label})]},C.key)})),dt.size>0&&nr&&!(He!=null&&He.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:C=>{$t(),ct(C.currentTarget)},onMouseLeave:zr,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($.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",dt.size,")"]})]}),t.jsx($.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!kr,anchorEl:kr,placement:"right-start",transition:!0,sx:{zIndex:C=>C.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:C})=>t.jsx(o.Grow,{...C,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:$t,onMouseLeave:zr,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:()=>{nr("csv"),ct(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{nr("excel"),ct(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{nr("json"),ct(null),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx($.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]})]})})})})]}),!(He!=null&&He.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ye&&(wr(ye.row),Ue(!0)),Ge(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx($.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(zu,{open:we,onClose:()=>{lt(!1),ot(null)},row:Ft,schema:e,reportName:Tt}),t.jsx(Bu,{open:po,onClose:()=>{Fr(!1),Kt(null),Hr(null)},onSave:C=>{Vr!==null&&(Xe==null||Xe(Vr,C))},row:ho,schema:e,reportName:Tt}),t.jsx(Tu,{open:U,onClose:()=>{Ue(!1),wr(null)},onConfirm:()=>{Ee!==null&&(rt==null||rt(Ee))},row:Ee,schema:e}),t.jsx(Ks,{isOpen:fo,onClose:()=>lr(!1)})]})}function Or({content:e,isDev:r=!1}){const[n,i]=f.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=>D(s.palette.primary.main,.08)}},children:t.jsx($.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=>D(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=>D(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>D(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"],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."}},Kn=40;function Fu({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 Vu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(p=>p.name===e.column),c=f.useMemo(()=>{const p=a?en(a.type):[],x=i.filter.allowedOperators;return x.length>0?p.filter(y=>x.includes(y.value)):p},[a,i]),l=Dl(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:p=>{var g;const x=r.find(v=>v.name===p.target.value),y=x?en(x.type):[];s({column:p.target.value,operator:((g=y[0])==null?void 0:g.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(p=>t.jsx(o.MenuItem,{value:p.name,sx:{fontSize:"0.875rem"},children:ut(p.name)},p.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:p=>s({operator:p.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:c.map(p=>t.jsx(o.MenuItem,{value:p.value,sx:{fontSize:"0.875rem"},children:p.label},p.value))})}),l&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:p=>s({value:p.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:p=>s({value:(a==null?void 0:a.type)==="number"?Number(p.target.value):p.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function ra({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}){const p=c>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((x,y)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:Kn,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[y<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),y>0&&t.jsx(Fu,{operator:e.operator,onSelect:g=>l(v=>ai(v,e.id,g))}),y>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:Kn/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:y>0?1:0},children:qe(x)?t.jsx(Hu,{group:x,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:c,onChange:l}):t.jsx(Vu,{condition:x,schema:n,availableColumns:i,devConfig:s,onUpdate:g=>l(v=>si(v,x.id,g))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>l(g=>li(g,x.id)),sx:{mt:y>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx($.Close,{sx:{fontSize:16}})})]},x.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${Kn}px`},children:[t.jsx(o.Button,{size:"small",disabled:p||i.length===0,onClick:()=>l(x=>{var y,g,v;return ao(x,e.id,{id:so(),column:((y=i[0])==null?void 0:y.name)??"",operator:((v=en(((g=i[0])==null?void 0:g.type)??"string")[0])==null?void 0:v.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:p,onClick:()=>l(x=>ao(x,e.id,Wt())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Hu(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>D(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>D(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(ra,{...e})})}function Uu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s}){const[a,c]=f.useState(r??Wt()),l=_r(),p=f.useMemo(()=>e.filter(m=>m.type!=="mixed"&&m.type!=="null"&&m.type!=="array"&&m.type!=="object"),[e]);f.useEffect(()=>{var z;const m=r??Wt();if(s&&m.children.length===0){const h=e.find(B=>B.name===s);if(h){c(ao(m,m.id,{id:so(),column:s,operator:((z=en(h.type)[0])==null?void 0:z.value)??"equals"}));return}}c(m)},[r,s,e]);const x=Ct(a),y=l.filter.maxConditions,g=f.useCallback(m=>{c(z=>m(z))},[]),v=f.useMemo(()=>JSON.stringify(a)!==JSON.stringify(r??Wt()),[a,r]),S=f.useCallback(()=>{n(a),i()},[a,n,i]),k=f.useCallback(()=>{c(r??Wt()),i()},[r,i]),b=f.useCallback(()=>{n(Wt()),i()},[n,i]);return t.jsx(o.Box,{onClick:k,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:m=>D(m.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:m=>m.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:m=>m.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:m=>tt(m),bgcolor:"background.paper",outline:"none",boxShadow:m=>de(m).paper.boxShadow,border:m=>de(m).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:m=>de(m).header.backgroundColor,borderBottom:m=>de(m).header.borderBottom,boxShadow:m=>de(m).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:m=>m.typography.h6.fontSize||"1.125rem",fontWeight:m=>m.typography.h6.fontWeight||500,color:m=>m.typography.h6.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(Or,{content:Mr.filter,isDev:process.env.NODE_ENV==="development"})]}),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($.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:m=>D(m.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:m=>D(m.palette.text.primary,.3)}}},children:[x===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:m=>m.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${ut(s)}"`:"","."]}),t.jsx(ra,{group:a,depth:0,schema:e,availableColumns:p,devConfig:l,maxConditions:y,totalConditions:x,onChange:g}),x>=y&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:m=>m.typography.caption.fontSize||"0.75rem",fontWeight:m=>m.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",y," 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:b,disabled:x===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:k,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:m=>`${m.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:S,disabled:!v,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:m=>`${m.shape.borderRadius}px`,boxShadow:m=>ge(m,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const fs="SORT_RULE";function Gu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=f.useRef(null),[{handlerId:c},l]=rr.useDrop({accept:fs,collect(y){return{handlerId:y.getHandlerId()}},hover(y,g){var h;if(!a.current)return;const v=y.index,S=r;if(v===S)return;const k=(h=a.current)==null?void 0:h.getBoundingClientRect(),b=(k.bottom-k.top)/2,m=g.getClientOffset(),z=((m==null?void 0:m.y)??0)-k.top;v<S&&z<b||v>S&&z>b||(s(v,S),y.index=S)}}),[{isDragging:p},x]=rr.useDrag({type:fs,item:()=>({index:r}),collect:y=>({isDragging:y.isDragging()})});return x(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:p?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:y=>ge(y,"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:y=>`0 1px 2px 0 ${D(y.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:y=>y.typography.body2.fontSize||"0.875rem",fontWeight:y=>y.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:y=>n(r,y.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:y=>jt(y),"&:hover":{bgcolor:y=>D(y.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:y=>jt(y),"&:hover":{bgcolor:y=>D(y.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:y=>D(y.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]})}function Yu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i}){const[s,a]=f.useState(""),[c,l]=f.useState([]);f.useEffect(()=>{l([...r])},[r]);const p=f.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r),[c,r]),x=_r(),y=f.useCallback(h=>{if(!h||c.length>=x.sort.maxLevels)return;const B={column:h,direction:"asc",priority:c.length+1};l([...c,B]),a(""),setTimeout(()=>{var T;return(T=document.activeElement)==null?void 0:T.blur()},0)},[c,x.sort.maxLevels]),g=f.useCallback(h=>{const T=c.filter((w,P)=>P!==h).map((w,P)=>({...w,priority:P+1}));l(T)},[c]),v=f.useCallback((h,B)=>{const T=[...c];T[h]={...T[h],direction:B},l(T)},[c]),S=f.useCallback((h,B)=>{const T=[...c],[w]=T.splice(h,1);T.splice(B,0,w);const P=T.map((O,M)=>({...O,priority:M+1}));l(P)},[c]),k=f.useCallback(()=>{n([]),i()},[n,i]),b=f.useCallback(()=>{n(c),i()},[c,n,i]),m=f.useCallback(()=>{l([...r]),a(""),i()},[r,i]),z=e.filter(h=>!c.some(B=>B.column===h.name));return t.jsx(rr.DndProvider,{backend:ni.HTML5Backend,children:t.jsx(o.Box,{onClick:m,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:h=>D(h.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:h=>h.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:h=>h.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:h=>tt(h),bgcolor:"background.paper",outline:"none",boxShadow:h=>de(h).paper.boxShadow,border:h=>de(h).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:h=>de(h).header.backgroundColor,borderBottom:h=>de(h).header.borderBottom,boxShadow:h=>de(h).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:h=>h.typography.h6.fontSize||"1.125rem",fontWeight:h=>h.typography.h6.fontWeight||500,color:h=>h.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(Or,{content:Mr.sort,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:m,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:h=>D(h.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:h=>D(h.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:h=>h.typography.caption.fontSize||"0.6875rem",fontWeight:h=>h.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:c.length>=x.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:s,onChange:h=>y(h.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:z.map(h=>t.jsx(o.MenuItem,{value:h.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:B=>jt(B),"&:hover":{bgcolor:B=>D(B.palette.primary.main,.2)}}},children:ut(h.name)},h.name))})]}),c.length>=x.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:h=>h.typography.caption.fontSize||"0.75rem",fontWeight:h=>h.typography.caption.fontWeight||500},children:["Maximum ",x.sort.maxLevels," sort levels allowed"]})]}),c.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:h=>h.typography.caption.fontSize||"0.6875rem",fontWeight:h=>h.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",c.length,"/",x.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:k,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:c.map((h,B)=>t.jsx(Gu,{rule:h,index:B,onToggleDirection:v,onRemove:g,onMove:S},`${h.column}-${B}`))})]})]}),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:m,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:h=>`${h.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:!p||c.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:h=>`${h.shape.borderRadius}px`,boxShadow:h=>ge(h,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:h=>ge(h,"hoverButton")},"&:active":{boxShadow:h=>ge(h,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const Ho=50;function ms({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:p=10}){const[x,y]=f.useState(s),[g,v]=f.useState(!1),[S,k]=f.useState(a),[b,m]=f.useState(c),z=()=>{if(!x.trim()){v(!0);return}if(x.trim().length>Ho){v(!0);return}r(x.trim(),S.trim(),b),n()},h=T=>{T.key==="Enter"&&!T.shiftKey?z():T.key==="Escape"&&n()},B=()=>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:tt(T),...de(T).paper})},children:[t.jsxs(o.DialogTitle,{sx:T=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...de(T).header}),children:[B(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx($.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 ",p," 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<=Ho&&y(T.target.value),g&&T.target.value.trim()&&v(!1)},onKeyDown:h,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:Ho},error:g&&!x.trim(),helperText:g&&!x.trim()?"View name is required":`${x.length} / ${Ho}`}),t.jsx(o.TextField,{label:"Description (optional)",value:S,onChange:T=>k(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:[Ct(e.filters)," filter",Ct(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",Ya(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:b,onChange:T=>m(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:z,variant:"contained",disabled:l&&!i,startIcon:t.jsx($.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=>ge(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>ge(T,"hoverButton")},"&:active":{boxShadow:T=>ge(T,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function qu({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:tt(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($.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($.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=>ge(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ge(i,"hoverButton")},"&:active":{boxShadow:i=>ge(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const Yo=100,qo=600,xs="COLUMN";function Ju({column:e,index:r,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:a,moveColumn:c}){const l=f.useRef(null),[p,x]=f.useState(i.toString());f.useEffect(()=>{x(i.toString())},[i]);const[{handlerId:y},g]=rr.useDrop({accept:xs,collect(h){return{handlerId:h.getHandlerId()}},hover(h,B){var K;if(!l.current)return;const T=h.index,w=r;if(T===w)return;const P=(K=l.current)==null?void 0:K.getBoundingClientRect(),O=(P.bottom-P.top)/2,M=B.getClientOffset(),q=((M==null?void 0:M.y)??0)-P.top;T<w&&q<O||T>w&&q>O||(c(T,w),h.index=w)}}),[{isDragging:v},S]=rr.useDrag({type:xs,item:()=>({index:r}),collect:h=>({isDragging:h.isDragging()})});S(g(l));const k=()=>{const h=parseInt(p);if(isNaN(h)){x(i.toString()),a(e.name,i);return}const B=Math.max(Yo,Math.min(qo,h));x(B.toString()),a(e.name,B)},b=h=>{if(h===""||/^\d+$/.test(h)){x(h);const B=parseInt(h);if(!isNaN(B)&&B>=Yo){const T=Math.min(qo,B);a(e.name,T)}}},m=h=>{h.key==="Enter"&&(h.preventDefault(),k(),h.target.blur())},z=h=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[h]||"text.secondary";return t.jsxs(o.TableRow,{ref:l,"data-handler-id":y,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($.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||400,fontSize:h=>h.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:ut(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:`${z(e.type)}15`,color:z(e.type),border:`1px solid ${z(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:p,onChange:h=>b(h.target.value),onBlur:k,onKeyDown:m,placeholder:"150",size:"small",inputProps:{min:Yo,max:qo,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:h=>h.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:()=>s(e.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"}},children:n?t.jsx($.Visibility,{sx:{fontSize:20}}):t.jsx($.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?h=>D(h.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Ku({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:c,onUpdateColumnOrder:l,onUpdateColumnWidth:p,onResetLayout:x,onClose:y}){const[g,v]=f.useState(!1),[S,k]=f.useState(n),[b,m]=f.useState(i),[z,h]=f.useState("all");f.useEffect(()=>{k(n)},[n]),f.useEffect(()=>{m(i)},[i]);const B=(u,A)=>{m(F=>({...F,[u]:A})),p==null||p(u,A)},T=(u,A)=>{const F=[...S],[d]=F.splice(u,1);F.splice(A,0,d),k(F),l(F)},w=()=>{x(),v(!1)},O=S.map(u=>e.find(A=>A.name===u)).filter(u=>u!==void 0).filter(u=>{const A=r[u.name]??!0;return z==="active"?A:z==="hidden"?!A:!0}),M=Object.values(r).filter(u=>u).length,q=e.length,K=s.find(u=>u.id===a),R=f.useMemo(()=>{if(!K)return!1;const u=K.snapshot,A=u.columnVisibility??{},F=JSON.stringify(r)!==JSON.stringify(A),d=u.columnOrder??[],oe=n??[],G=JSON.stringify(oe)!==JSON.stringify(d)&&!(oe.length===0&&d.length===0),te=u.columnWidths??{},xe=JSON.stringify(b)!==JSON.stringify(te);return F||G||xe},[K,r,n,b]);return t.jsx(rr.DndProvider,{backend:ni.HTML5Backend,children:t.jsx(o.Box,{onClick:y,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:u=>D(u.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:u=>u.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:u=>u.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:u=>tt(u),bgcolor:"background.paper",outline:"none",boxShadow:u=>de(u).paper.boxShadow,border:u=>de(u).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:u=>de(u).header.backgroundColor,borderBottom:u=>de(u).header.borderBottom,boxShadow:u=>de(u).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:u=>u.typography.h6.fontSize||"1.125rem",fontWeight:u=>u.typography.h6.fontWeight||500,color:u=>u.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx(Or,{content:Mr.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:y,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:z,onChange:(u,A)=>h(A),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:u=>at(u).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:u=>at(u).hoverBg},"&:hover":{color:"text.primary",bgcolor:u=>at(u).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:u=>at(u).hoverBg},"&:hover":{color:"text.primary",bgcolor:u=>at(u).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:u=>at(u).hoverBg},"&:hover":{color:"text.primary",bgcolor:u=>at(u).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:u=>D(u.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:u=>D(u.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: ${Yo}px, max: ${qo}px)`,arrow:!0,placement:"top",children:t.jsx($.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:O.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:u=>u.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):O.map((u,A)=>t.jsx(Ju,{column:u,index:A,isVisible:r[u.name]??!0,width:b[u.name]||170,onToggleVisibility:c,onWidthChange:B,moveColumn:T},u.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:u=>u.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[M," of ",q," 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:()=>v(!0),disabled:!R,variant:"outlined",startIcon:t.jsx($.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:u=>`${u.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),g&&t.jsx(o.Box,{onClick:()=>v(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:u=>D(u.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:u=>u.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:u=>u.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:u=>$o(u),bgcolor:"background.paper",boxShadow:u=>de(u).paper.boxShadow,border:u=>de(u).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:()=>v(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:u=>`${u.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:w,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:u=>`${u.shape.borderRadius}px`,boxShadow:u=>ge(u,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:u=>ge(u,"hoverButton")},"&:active":{boxShadow:u=>ge(u,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function Xu({schema:e,grouping:r,onApply:n,onClose:i}){var P;const[s,a]=f.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[c,l]=f.useState(""),[p,x]=f.useState(null),y=f.useMemo(()=>Na(e),[e]),g=f.useMemo(()=>y.filter(O=>!s.levels.some((M,q)=>M.column===O.name&&q!==p)),[y,s.levels,p]),v=_r(),S=s.levels.length<v.grouping.maxLevels&&g.length>0,k=f.useCallback(O=>{!S||!O||(a({...s,levels:[...s.levels,{column:O}],enabled:!0}),l(""),setTimeout(()=>{var M;return(M=document.activeElement)==null?void 0:M.blur()},0))},[S,s]),b=f.useCallback(O=>{const M=s.levels.filter((q,K)=>K!==O);if(M.length===0){n(null),i();return}a({...s,levels:M,enabled:M.length>0})},[s,n,i]),m=f.useCallback(O=>{x(O),l(s.levels[O].column)},[s.levels]),z=f.useCallback(()=>{if(p===null||!c)return;const O=[...s.levels];O[p]={column:c},a({...s,levels:O}),x(null),l("")},[p,c,s]),h=f.useCallback(()=>{x(null),l("")},[]),B=f.useCallback((O,M)=>{const q=M==="up"?O-1:O+1;if(q<0||q>=s.levels.length)return;const K=[...s.levels],[R]=K.splice(O,1);K.splice(q,0,R),a({...s,levels:K})},[s]),T=f.useCallback(()=>{n(null),i()},[n,i]),w=f.useCallback(()=>{s.levels.length===0?n(null):n({...s,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[s,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:O=>D(O.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:O=>O.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:O=>O.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:O=>tt(O),bgcolor:"background.paper",outline:"none",boxShadow:O=>de(O).paper.boxShadow,border:O=>de(O).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:O=>de(O).header.backgroundColor,borderBottom:O=>de(O).header.borderBottom,boxShadow:O=>de(O).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:O=>O.typography.h6.fontSize||"1.125rem",fontWeight:O=>O.typography.h6.fontWeight||500,color:O=>O.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(Or,{content:Mr.grouping,isDev:process.env.NODE_ENV==="development"})]}),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($.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:O=>D(O.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:O=>D(O.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[p===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:O=>O.typography.caption.fontSize||"0.6875rem",fontWeight:O=>O.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:c,onChange:O=>k(O.target.value),disabled:!S,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..."}),g.map(O=>t.jsxs(o.MenuItem,{value:O.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:M=>jt(M),"&:hover":{bgcolor:M=>D(M.palette.primary.main,.2)}}},children:[ut(O.name)," (",O.type.toUpperCase(),")"]},O.name))]})}),s.levels.length>=v.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:O=>O.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),y.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:O=>O.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),p!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:O=>`1px solid ${D(O.palette.warning.main,.5)}`,bgcolor:O=>D(O.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:O=>O.typography.body2.fontWeight||500,mb:1.5,fontSize:O=>O.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",p+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:c,onChange:O=>l(O.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:s.levels[p].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:O=>jt(O)}},children:[s.levels[p].column," (",(P=e.find(O=>O.name===s.levels[p].column))==null?void 0:P.type.toUpperCase(),")"]}),g.filter(O=>O.name!==s.levels[p].column).map(O=>t.jsxs(o.MenuItem,{value:O.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:M=>jt(M)}},children:[ut(O.name)," (",O.type.toUpperCase(),")"]},O.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:z,disabled:!c,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:O=>ge(O,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:h,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),s.levels.length>0&&p===null&&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:O=>O.typography.caption.fontSize||"0.6875rem",fontWeight:O=>O.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:T,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:s.levels.map((O,M)=>{const q=e.find(K=>K.name===O.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:K=>ge(K,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${M+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:K=>`0 1px 2px 0 ${D(K.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:K=>K.typography.body2.fontWeight||500,fontSize:K=>K.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:O.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:K=>K.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:q==null?void 0:q.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>B(M,"up"),disabled:M===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx($.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>B(M,"down"),disabled:M===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx($.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>m(M),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx($.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>b(M),sx:{color:"text.secondary","&:hover":{bgcolor:K=>D(K.palette.error.main,.08),color:"error.main"}},children:t.jsx($.Delete,{sx:{fontSize:18}})})]})]},M)})})]})]})}),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:O=>`${O.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:w,variant:"contained",disabled:s.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:O=>`${O.shape.borderRadius}px`,boxShadow:O=>ge(O,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:O=>ge(O,"hoverButton")},"&:active":{boxShadow:O=>ge(O,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function Qu({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($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx($.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($.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx($.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const gs=[{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 Zu(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 ep(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function tp({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=pt(),s=i.palette,[a,c]=f.useState("1h"),[l,p]=f.useState(!1),x=[...e].sort((k,b)=>new Date(b.timestamp).getTime()-new Date(k.timestamp).getTime()),y=gs.find(k=>k.key===a),g=Zu(e,y.ms),v=()=>p(!0),S=()=>{n&&(n(ep(e,y.ms)),p(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:D(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:k=>k.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:tt(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:k=>k.typography.body1.fontSize||"0.9375rem",fontWeight:k=>k.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx(Or,{content:Mr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:k=>k.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[x.length," event",x.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:k=>c(k.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:D(s.text.primary,.3)}},children:gs.map(k=>t.jsx(o.MenuItem,{value:k.key,sx:{fontSize:"0.8125rem"},children:k.label},k.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx($.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:v,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:D(s.error.main,.5),"&:hover":{bgcolor:D(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:17}})})]})]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:D(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:D(s.text.primary,.14),borderRadius:3}},children:x.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx($.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:k=>k.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:k=>k.typography.body2.fontWeight||500},children:"No audit events yet"}),t.jsx(o.Typography,{sx:{fontSize:k=>k.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:x.map(k=>{const b=fu(i,k.feature),{summary:m,detail:z}=al(k);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:D(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:dl(k.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:D(b,.1),color:b,border:`1px solid ${D(b,.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:m}),z&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:z}),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($.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:ul(k.timestamp)})]}),k.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx($.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:k.user})]})]})]})]},k.id)})})})]})}),t.jsxs(o.Dialog,{open:l,onClose:()=>p(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:$o(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:D(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:k=>k.typography.body1.fontSize||"0.9375rem",fontWeight:k=>k.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:k=>k.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:[g," audit record",g!==1?"s":""]})," ",y.key==="all"?"from all time":`from the ${y.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:()=>p(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:S,variant:"contained",color:"error",startIcon:t.jsx($.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",g," Record",g!==1?"s":""]})]})]})]})}function rp({onSave:e,onClose:r}){const[n,i]=f.useState(""),[s,a]=f.useState(""),[c,l]=f.useState(""),[p,x]=f.useState([]),[y,g]=f.useState(""),[v,S]=f.useState(""),k=w=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w),b=()=>{const w=c.trim();if(w){if(!k(w)){S("Please enter a valid email address");return}if(p.includes(w)){S("This email is already added");return}x([...p,w]),l(""),S("")}},m=w=>{x(p.filter(P=>P!==w))},z=w=>{w.key==="Enter"&&(w.preventDefault(),b())},h=()=>{if(!n.trim()){g("Preset name is required");return}e(n.trim(),s.trim(),p.length>0?p:void 0)},B=w=>{i(w),y&&g("")},T=w=>{l(w),v&&S("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:w=>D(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:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:w=>tt(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:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:w=>de(w).header.backgroundColor,borderBottom:w=>de(w).header.borderBottom,boxShadow:w=>de(w).header.boxShadow,flexShrink:0},children:[t.jsx(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:"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($.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:w=>D(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>D(w.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($.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:w=>`1px solid ${D(w.palette.primary.main,.3)}`,bgcolor:w=>jt(w),"& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:w=>w.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:w=>w.typography.caption.fontSize||"0.6875rem",fontWeight:w=>w.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:w=>B(w.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!y,helperText:y,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:w=>w.typography.caption.fontSize||"0.6875rem",fontWeight:w=>w.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:w=>a(w.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:w=>w.typography.caption.fontSize||"0.6875rem",fontWeight:w=>w.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:w=>T(w.target.value),onKeyPress:z,placeholder:"Enter email address",error:!!v,helperText:v,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx($.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:b,variant:"outlined",startIcon:t.jsx($.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:w=>`${w.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),p.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:p.map(w=>t.jsx(o.Chip,{label:w,onDelete:()=>m(w),deleteIcon:t.jsx($.Delete,{sx:{fontSize:16}}),sx:{bgcolor:P=>jt(P),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},w))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:p.length>0?`An email with the shareable link will be sent to ${p.length} recipient${p.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),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:w=>`${w.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($.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:w=>`${w.shape.borderRadius}px`,boxShadow:w=>ge(w,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:w=>ge(w,"hoverButton")},"&:active":{boxShadow:w=>ge(w,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function op({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx($.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($.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>D(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 np({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=>D(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=>tt(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($.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=>D(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($.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=>ge(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($.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=>D(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=>ge(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>ge(c,"hoverButton")},"&:active":{boxShadow:c=>ge(c,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const oa={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},ip=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],sp=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function ap(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=sp.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(p=>ip.some(x=>x.test(p))).length/c.length>.6),(s||a)&&n.push(i.name)}return n}function Cn(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(x=>String(x[c]??"")).filter(x=>x.length>0);if(l.length===0)return 5;const p=l.reduce((x,y)=>x+y.length,0);return Math.ceil(p/l.length)+1}).reduce((c,l)=>c+l,0)+1;return r.reduce((c,l)=>c+l.length+1,0)+s*e.length}function lp(e,r){const n=Cn(e,r);return Math.ceil(n*3.5)}function cp(e,r){const n=Cn(e,r);return Math.ceil(n*.7)}function dp(e,r){const n=Cn(e,r);return Math.ceil(n*2)}function up(e,r,n){switch(e){case"csv":return Cn(r,n);case"excel":return cp(r,n);case"json":return lp(r,n);case"pdf":return dp(r,n)}}function ys(e,r){return Math.ceil(e/r)}function pp(e,r,n,i,s=oa){const a=[],c=up(e,r,n),l=r.length;if(l>s.maxRowsHard){const y=ys(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 ${y} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:y,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const y=ys(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 ${y} smaller export${y>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:y,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${ko(c)} exceeds the ${ko(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 ${ko(c)}`,detail:`This exceeds the recommended ${ko(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),e!=="excel"){const y=ap(i.filter(g=>n.includes(g.name)),r);if(y.length>0){const g=y.length>s.maxImageColumns;a.push({type:"image_columns",severity:g?"error":"warning",message:`Image column${y.length>1?"s":""} detected: ${y.map(v=>`"${v.replace(/_/g," ")}"`).join(", ")}`,detail:g?`Exporting ${y.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:y.length,limit:s.maxImageColumns})}}const p=a.some(y=>y.severity==="error"),x=a.some(y=>y.severity==="warning");return{violations:a,hasBlockingViolation:p,hasWarning:x,estimatedBytes:c}}function ko(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function hp({violation:e}){const n=pt().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=D(i?n.error.main:n.warning.main,.06),c=i?D(n.error.main,.25):D(n.warning.main,.3),l=i?$.ErrorOutline:$.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:p=>p.typography.body2.fontSize||"0.8125rem",fontWeight:p=>p.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:p=>p.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($.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:p=>p.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:p=>p.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function fp({format:e}){const r=pt(),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:D(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 bs({checked:e}){const r=pt();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 mp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:c=[],allRows:l=[],processedRows:p=[],initialFormat:x,initialScope:y="visible",initialColumnScope:g="visible",classTokens:v={},onExport:S,onClose:k}){const b=pt(),m=b.palette,z=_r(),h=f.useMemo(()=>{var le,ce,ie,Z,ue;const G=((ie=(ce=(le=b.components)==null?void 0:le.MuiCard)==null?void 0:ce.styleOverrides)==null?void 0:ie.root)||{},te=G.border&&G.border!=="none"?G.border:(Z=b.tokens)!=null&&Z.cardBodyBorder&&b.tokens.cardBodyBorder!=="none"?b.tokens.cardBodyBorder:m.divider,xe=G.borderRadius!==void 0?typeof G.borderRadius=="number"?`${G.borderRadius}px`:G.borderRadius:`${b.shape.borderRadius}px`,H=G.boxShadow&&G.boxShadow!=="none"?G.boxShadow:((ue=b.tokens)==null?void 0:ue.cardBodyShadow)||ge(b,"menu"),Q=at(b);return{sectionBorder:`var(--urm-export-section-border, ${te})`,sectionTitleColor:`var(--urm-export-section-title-color, ${m.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${m.background.paper})`,cardBg:`var(--urm-export-card-bg, ${m.background.paper})`,cardBorder:`var(--urm-export-card-border, ${te})`,cardRadius:xe,cardShadow:H,cardHoverBg:`var(--urm-export-card-hover-bg, ${m.mode==="dark"?D(m.common.white,.08):D(m.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${D(Q.main,m.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${Q.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${m.mode==="dark"?m.primary.light:m.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${m.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${m.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${m.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${b.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${b.spacing(1.5)})`}},[m,b]),B=x||z.export.allowedFormats[0]||"csv",[T,w]=f.useState(B),[P,O]=f.useState(y),[M,q]=f.useState(g),K=P==="visible"?r:e,R=M==="visible"?i:s,u=f.useMemo(()=>P==="visible"?p.length>0?p:new Array(r):l.length>0?l:new Array(e),[P,r,e,p,l]),A=f.useMemo(()=>M==="all"?a.map(G=>G.name):a.map(G=>G.name).slice(0,i),[M,a,i]),F=f.useMemo(()=>pp(T,u,A,a,oa),[T,u,A,a]),d=()=>{F.hasBlockingViolation||(S({format:T,scope:P,columnScope:M}),k())},oe={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:k,className:`urm-export-backdrop ${v.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:D(m.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:b.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:G=>G.stopPropagation(),elevation:0,className:`urm-export-paper ${v.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:tt(b),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 ${v.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:G=>de(G).header.backgroundColor,borderBottom:G=>de(G).header.borderBottom,boxShadow:G=>de(G).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${v.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:m.text.primary},children:"Export Report"}),t.jsx(Or,{content:Mr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:k,size:"small",className:`urm-export-close ${v.modalCloseButton||""}`,sx:{color:m.text.secondary,borderRadius:"50%","&:hover":{bgcolor:m.action.hover,color:m.text.primary}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${v.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:D(m.text.primary,.15),borderRadius:3}},children:[F.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:F.violations.map((G,te)=>t.jsx(hp,{violation:G},te))}),t.jsxs(o.Box,{className:`urm-export-section ${v.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 ${v.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:z.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:z.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:z.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:z.export.allowedFormats.includes("pdf")}].filter(G=>G.allowed).map(G=>{const te=T===G.id;return t.jsxs(o.Box,{onClick:()=>w(G.id),className:`urm-export-format-card ${te?v.formatCardSelected||"":v.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:h.cardRadius,border:te?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:te?void 0:h.cardShadow,bgcolor:te?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:te?h.cardSelectedBorder:D(m.text.primary,.25),bgcolor:te?h.cardSelectedBg:h.cardHoverBg}},children:[te&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:h.cardSelectedBorder,color:m.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${D(m.primary.main,.3)}`},children:t.jsx($.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(fp,{format:G.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:te?h.cardSelectedColor:m.text.primary},children:G.title}),t.jsx(o.Tooltip,{title:G.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:xe=>xe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:13}})})})]})]},G.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.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 ${v.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($.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx($.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(G=>{const te=P===G.value;return t.jsxs(o.Box,{onClick:()=>O(G.value),className:`urm-export-row-card ${te?v.rowCardSelected||"":v.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:te?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:te?void 0:h.cardShadow,bgcolor:te?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:te?h.cardSelectedBorder:D(m.text.primary,.25),bgcolor:te?h.cardSelectedBg:h.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(bs,{checked:te}),t.jsx(o.Box,{sx:{color:te?h.cardSelectedColor:m.text.secondary,display:"flex"},children:G.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:te?h.cardSelectedColor:m.text.primary},children:G.label})]}),t.jsx(o.Tooltip,{title:G.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:xe=>xe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:16}})})})]},G.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.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 ${v.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($.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx($.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(G=>{const te=M===G.value;return t.jsxs(o.Box,{onClick:()=>q(G.value),className:`urm-export-column-card ${te?v.columnCardSelected||"":v.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:te?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:te?void 0:h.cardShadow,bgcolor:te?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:te?h.cardSelectedBorder:D(m.text.primary,.25),bgcolor:te?h.cardSelectedBg:h.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(bs,{checked:te}),t.jsx(o.Box,{sx:{color:te?h.cardSelectedColor:m.text.secondary,display:"flex"},children:G.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:te?h.cardSelectedColor:m.text.primary},children:G.label})]}),t.jsx(o.Tooltip,{title:G.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:xe=>xe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx($.InfoOutlined,{sx:{fontSize:16}})})})]},G.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${v.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 ${v.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($.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Format",value:oe[T]},{icon:t.jsx($.FormatListNumberedOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Rows to Export",value:K.toLocaleString()},{icon:t.jsx($.SwapVertOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Columns to Export",value:String(R)},{icon:t.jsx($.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Estimated File Size",value:`~${ko(F.estimatedBytes)}`,highlight:F.hasBlockingViolation?"error.main":F.hasWarning?"warning.main":void 0}].map(({icon:G,label:te,value:xe,highlight:H})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${v.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[G,t.jsx(o.Typography,{className:`urm-export-summary-label ${v.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:m.text.secondary,fontWeight:500},children:te})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${v.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:H??m.text.primary},children:xe})]},te))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${v.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[F.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx($.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:G=>G.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:G=>G.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:k,variant:"outlined",className:`urm-export-cancel-btn ${v.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:m.text.primary,borderColor:h.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:h.cardHoverBg,borderColor:D(m.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:d,disabled:F.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${v.downloadButton||""}`,startIcon:t.jsx($.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 ${D(m.primary.main,.25)}`,"&:hover":{bgcolor:h.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:D(m.primary.main,.4),color:h.primaryBtnColor}},children:["Download ",oe[T]]})]})]})})}function xp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx($.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 gp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=5e3}){f.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($.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx($.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx($.InfoOutlined,{sx:{fontSize:20}})}}})(),c=Cl(e);return t.jsx(o.Box,{sx:{position:"fixed",top: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($.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 yp extends f.Component{constructor(n){super(n);ji(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){Gt.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=>D(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($.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=>D(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($.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function bp({feature:e}){const[r,n]=f.useState(!0);return f.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($.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx($.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function Uo({children:e,feature:r,onError:n}){return t.jsx(yp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(bp,{feature:r}),children:e})}const vp=[{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"}],Sp=[{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"}];function So({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},children:e})}function Cp({open:e,onClose:r,config:n,onApply:i}){const[s,a]=f.useState(0),[c,l]=f.useState(n),p=()=>l(n),x=()=>l(ft),y=()=>{i(c),r()},g={sort:m=>l(z=>({...z,sort:{...z.sort,...m}})),filter:m=>l(z=>({...z,filter:{...z.filter,...m}})),columns:m=>l(z=>({...z,columns:{...z.columns,...m}})),grouping:m=>l(z=>({...z,grouping:{...z.grouping,...m}})),export:m=>l(z=>({...z,export:{...z.export,...m}}))},v=m=>{const z=c.filter.allowedOperators,h=z.includes(m)?z.filter(B=>B!==m):[...z,m];h.length!==0&&g.filter({allowedOperators:h})},S=m=>{const z=c.export.allowedFormats,h=z.includes(m)?z.filter(B=>B!==m):[...z,m];h.length!==0&&g.export({allowedFormats:h})},k=[{label:"Sort",icon:t.jsx($.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:t.jsx($.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:t.jsx($.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:t.jsx($.Layers,{sx:{fontSize:17}})},{label:"Export",icon:t.jsx($.Download,{sx:{fontSize:17}})}],b=m=>JSON.stringify(c[m])===JSON.stringify(ft[m]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:p},PaperProps:{sx:{borderRadius:m=>tt(m),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:m=>`0 8px 32px ${D(m.palette.common.black,.2)}`}},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:"8px",bgcolor:m=>D(m.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem"},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($.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:t.jsx(o.Tabs,{value:s,onChange:(m,z)=>a(z),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:k.map((m,z)=>t.jsx(o.Tab,{label:m.label,icon:m.icon,iconPosition:"start"},z))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[t.jsxs(So,{active:s===0,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!b("sort")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),t.jsx(o.Slider,{value:c.sort.maxLevels,onChange:(m,z)=>g.sort({maxLevels:z}),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(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",t.jsx("strong",{children:"5"}),"."]})]}),t.jsxs(So,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!b("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),t.jsx(o.Slider,{value:c.filter.maxConditions,onChange:(m,z)=>g.filter({maxConditions:z}),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.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter type dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(m=>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:"0.6875rem",display:"block",mb:.5},children:m}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:vp.filter(z=>z.group===m).map(z=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(z.value),onChange:()=>v(z.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:z.label}),sx:{mr:1.5}},z.value))})]},m))]})]}),t.jsxs(So,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!b("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),t.jsx(o.Slider,{value:c.columns.maxVisible,onChange:(m,z)=>g.columns({maxVisible:z}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),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:(m,z)=>g.columns({minColumnWidth:z}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}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:(m,z)=>g.columns({maxColumnWidth:z}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]})]})]})]}),t.jsxs(So,{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.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!b("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(m=>t.jsxs(o.Box,{onClick:()=>g.grouping({maxLevels:m}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===m?"primary.main":"divider",bgcolor:c.grouping.maxLevels===m?z=>D(z.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:z=>D(z.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===m?"primary.main":"text.secondary"},children:m}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][m-1]})]},m))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowNested,onChange:m=>g.grouping({allowNested:m.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:m=>g.grouping({allowCollapse:m.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),t.jsx(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),t.jsx(So,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!b("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog and the bulk export action. At least one must remain checked."}),t.jsx(o.FormGroup,{sx:{gap:1},children:Sp.map(m=>t.jsxs(o.Box,{onClick:()=>S(m.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:c.export.allowedFormats.includes(m.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(m.value)?z=>D(z.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(m.value),onChange:()=>S(m.value),onClick:z=>z.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:m.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:m.desc})]})]},m.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:m=>D(m.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx($.RestartAlt,{sx:{fontSize:18}}),onClick:x,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:m=>D(m.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:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),t.jsx(o.Button,{onClick:y,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const jp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],wp={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 Jo(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 p=n??1,x=l.getDay();let y=p-x;return y<0&&(y+=7),y===0&&l<=s&&(y=7),l.setDate(l.getDate()+y),l.toISOString()}if(e==="monthly"){const p=Math.min(i??1,28);return l.setDate(p),l<=s&&(l.setMonth(l.getMonth()+1),l.setDate(p)),l.toISOString()}return l.toISOString()}function kp(e){const r=na(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${jp[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${wp[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function na(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function zp(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 Tp(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=na(`${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 ia(e){return`urm_schedules_${e}`}function sa(e){try{const r=localStorage.getItem(ia(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 aa(e,r){try{localStorage.setItem(ia(e),JSON.stringify(r))}catch{}}const Bp=[{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"}],Ip=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,la={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",email:""},Dr={"& .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 Ep({initial:e=la,isEditing:r=!1,onSave:n,onBack:i}){const[s,a]=f.useState(e),[c,l]=f.useState(!1),[p,x]=f.useState(!1),y=(S,k)=>a(b=>({...b,[S]:k})),g=s.email.trim().length>0&&!Ip.test(s.email.trim()),v=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!g;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=>D(S.palette.text.primary,.06)}},children:t.jsx($.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=>{y("name",S.target.value),c&&S.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:Dr}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Dr,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:S=>y("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:Dr,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:S=>y("dayOfWeek",Number(S.target.value)),children:Bp.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=>y("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:Dr}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:S=>y("time",S.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:Dr}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Dr,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:S=>y("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=>y("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.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:S=>y("email",S.target.value),onBlur:()=>x(!0),placeholder:"user@company.com",error:p&&g,helperText:p&&g?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx($.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:Dr}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[t.jsx($.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{lineHeight:1.5},children:"Opens your device's email app when the schedule fires. Requires a default mail app (e.g. Outlook, Mail) on this device."})]})]}),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=>D(S.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>v&&n(s),disabled:!v,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Dp({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:$o(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=>D(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.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 $p({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=>D(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=>D(l.palette.success.main,.1):l=>D(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:kp(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=>D(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=>D(l.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx($.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>D(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: ",zp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Tp(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=>D(l.palette.primary.main,.08)}},children:t.jsx($.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=>D(l.palette.warning.main,.08):l=>D(l.palette.success.main,.08)}},children:c?t.jsx($.Pause,{sx:{fontSize:15}}):t.jsx($.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=>D(l.palette.primary.main,.08)}},children:t.jsx($.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=>D(l.palette.error.main,.08)}},children:t.jsx($.Delete,{sx:{fontSize:15}})})})]})]})]})}function _p({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,schedulerConfig:a}){const l=((a==null?void 0:a.mode)??"local")==="api",[p,x]=f.useState([]),y=l?(a==null?void 0:a.schedules)??[]:p,[g,v]=f.useState({type:"list"}),[S,k]=f.useState(0),[b,m]=f.useState(null);f.useEffect(()=>{e&&(l||x(sa(n)),v({type:"list"}))},[e,n,l]),f.useEffect(()=>{if(!e)return;const R=setInterval(()=>k(u=>u+1),3e4);return()=>clearInterval(R)},[e]);const z=f.useCallback(R=>{x(R),aa(n,R)},[n]),h=R=>{var F;const u=Jo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth),A={id:`sched-${Date.now()}`,reportId:n,name:R.name.trim(),frequency:R.frequency,dayOfWeek:R.frequency==="weekly"?R.dayOfWeek:void 0,dayOfMonth:R.frequency==="monthly"?R.dayOfMonth:void 0,time:R.time,format:R.format,scope:R.scope,email:R.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:u,runCount:0};l?(F=a==null?void 0:a.onScheduleCreate)==null||F.call(a,A):z([...y,A]),v({type:"list"})},B=R=>{var d;if(g.type!=="edit")return;const u=g.schedule,A=Jo(R.frequency,R.time,R.dayOfWeek,R.dayOfMonth),F={...u,name:R.name.trim(),frequency:R.frequency,dayOfWeek:R.frequency==="weekly"?R.dayOfWeek:void 0,dayOfMonth:R.frequency==="monthly"?R.dayOfMonth:void 0,time:R.time,format:R.format,scope:R.scope,email:R.email.trim()||void 0,nextRunAt:A};l?(d=a==null?void 0:a.onScheduleUpdate)==null||d.call(a,F):z(y.map(oe=>oe.id===u.id?F:oe)),v({type:"list"})},T=R=>{var oe;const u=y.find(G=>G.id===R);if(!u)return;const A=!u.isActive,F=A?Jo(u.frequency,u.time,u.dayOfWeek,u.dayOfMonth):u.nextRunAt,d={...u,isActive:A,nextRunAt:F};l?(oe=a==null?void 0:a.onScheduleToggle)==null||oe.call(a,R,A):z(y.map(G=>G.id===R?d:G))},w=R=>{if(s(R),!l){const u=new Date().toISOString();z(y.map(A=>A.id===R.id?{...A,lastRunAt:u,runCount:A.runCount+1}:A))}},P=R=>{const u=y.find(A=>A.id===R)??null;m(u)},O=()=>{var R;b&&(l?(R=a==null?void 0:a.onScheduleDelete)==null||R.call(a,b.id):z(y.filter(u=>u.id!==b.id)),m(null))},M=R=>({name:R.name,frequency:R.frequency,dayOfWeek:R.dayOfWeek??1,dayOfMonth:R.dayOfMonth??1,time:R.time,format:R.format,scope:R.scope,email:R.email??""}),q=g.type!=="list",K=y.filter(R=>R.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:q,PaperProps:{sx:R=>({borderRadius:tt(R),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...de(R).paper})},children:[t.jsxs(o.DialogTitle,{sx:R=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...de(R).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:R=>D(R.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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:R=>R.typography.h6.fontWeight||600,fontSize:R=>R.typography.subtitle2.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx(Or,{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:R=>D(R.palette.text.primary,.06)}},children:t.jsx($.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[q&&t.jsx(Ep,{initial:g.type==="edit"?M(g.schedule):la,isEditing:g.type==="edit",onSave:g.type==="edit"?B:h,onBack:()=>v({type:"list"})}),g.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:y.length===0?"No schedules yet":`${K} of ${y.length} active`}),t.jsx(o.Button,{startIcon:t.jsx($.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>v({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),y.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx($.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:R=>R.typography.body2.fontWeight||500,fontSize:R=>R.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:y.map(R=>t.jsx($p,{schedule:R,tick:S,onToggle:T,onRunNow:w,onEdit:u=>v({type:"edit",schedule:u}),onDelete:P},R.id))})]})]}),g.type==="list"&&t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:R=>D(R.palette.warning.main,.06),border:"1px solid",borderColor:R=>D(R.palette.warning.main,.2)},children:[t.jsx($.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:R=>D(R.palette.text.primary,.06)}},children:"Close"})]})]}),b&&t.jsx(Dp,{scheduleName:b.name,onConfirm:O,onCancel:()=>m(null)})]})}const Op=6e4;function Mp({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:p,sortStack:x,onFired:y,schedulerConfig:g}){const v=(g==null?void 0:g.mode)??"local",S=f.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:p,sortStack:x,onFired:y,schedulerConfig:g,schedulerMode:v});f.useEffect(()=>{S.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:p,sortStack:x,onFired:y,schedulerConfig:g,schedulerMode:v}});const k=f.useCallback(b=>{var R,u,A,F,d;const{reportName:m,uploadedData:z,processedData:h,schema:B,activeView:T,columnVisibility:w,columnOrder:P,filters:O,sortStack:M,schedulerConfig:q,schedulerMode:K}=S.current;try{const oe=b.scope==="all"?z:h;if(K==="api"){const xe=(P.length>0?P:B.map(Q=>Q.name)).filter(Q=>w[Q]!==!1),H={schedule:b,triggeredAt:new Date().toISOString(),rows:oe,columns:xe,format:b.format,reportName:m};(R=q==null?void 0:q.onScheduleFire)==null||R.call(q,H),(A=(u=S.current).onFired)==null||A.call(u,b);return}const G=Ko(oe,B,O,M,T,w,P),te=`${b.name}_scheduled`;switch(b.format){case"csv":Xo(G,te,{scope:b.scope});break;case"excel":Qo(G,te,{scope:b.scope});break;case"json":Zo(G,te,{scope:b.scope});break;case"pdf":ui(G,te,{scope:b.scope});break}if(q!=null&&q.onScheduleFire){const xe=(P.length>0?P:B.map(H=>H.name)).filter(H=>w[H]!==!1);q.onScheduleFire({schedule:b,triggeredAt:new Date().toISOString(),rows:oe,columns:xe,format:b.format,reportName:m})}if(b.email){const xe=encodeURIComponent(`Scheduled Report: ${b.name}`),H=encodeURIComponent(`Your scheduled report "${b.name}" has been generated.
192
192
 
193
193
  Report: ${m}
194
194
  Format: ${b.format.toUpperCase()}
195
195
  Generated: ${new Date().toLocaleString()}
196
196
 
197
- The file has been downloaded to your device.`);window.open(`mailto:${b.email}?subject=${xe}&body=${V}`,"_blank")}(d=(F=S.current).onFired)==null||d.call(F,b)}catch(ne){Lt.error("urm:scheduler",`Export failed for schedule: ${b.name}`,ne)}},[]);f.useEffect(()=>{if(!e)return;const b=()=>{const{reportId:z,schedulerMode:h,schedulerConfig:B}=S.current;if(!z)return;const T=h==="api"?(B==null?void 0:B.schedules)??[]:ia(z),j=new Date;let P=!1;const _=T.map(M=>{if(!M.isActive)return M;if(new Date(M.nextRunAt)<=j){k(M);const q=Xo(M.frequency,M.time,M.dayOfWeek,M.dayOfMonth,j);return P=!0,{...M,lastRunAt:j.toISOString(),nextRunAt:q,runCount:M.runCount+1}}return M});P&&h==="local"&&sa(z,_)};b();const m=setInterval(b,_p);return()=>clearInterval(m)},[e,k])}function la({reportEngine:e}){var Ge,wr,st,Jt,It,kr;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:c,isDirty:l,currentTableState:p,showFilterPanel:x,setShowFilterPanel:y,filterFocusColumn:g,handleReplaceFilters:v,handleOpenFilterForColumn:S,handleCloseFilterPanel:k,handleClearFiltersForColumn:b,showSortPanel:m,setShowSortPanel:z,handleSort:h,handleUpdateSortStack:B,handleSortAscending:T,handleSortDescending:j,showCreateViewModal:P,setShowCreateViewModal:_,showEditViewModal:M,setShowEditViewModal:G,showDeleteConfirmation:q,setShowDeleteConfirmation:R,editingView:u,deletingView:A,handleSelectView:F,handleCreateView:d,handleUpdateCurrentView:ne,handleSaveAsNewView:U,handleRevertChanges:re,handleToggleDefault:xe,handleToggleFavorite:V,handleSoftDelete:X,handleRestoreView:ae,handlePermanentDelete:le,handleEditView:ie,handleCloneView:Q,handleCopyViewLink:de,handleSaveEditView:I,handleConfirmDelete:te,handlePromoteToGlobal:he,showManageColumns:se,setShowManageColumns:ze,handleUpdateColumnVisibility:Y,handleUpdateColumnOrder:We,handleUpdateColumnWidth:kt,handleResetColumnLayout:dt,showGroupPanel:Or,setShowGroupPanel:Ot,handleGroup:ot,handleToggleGroupCollapse:Ft,handleExpandAllGroups:qe,handleCollapseAllGroups:zt,searchQuery:fr,debouncedSearchQuery:xt,searchHistory:tr,handleSearchChange:so,handleAddToSearchHistory:rr,handleToggleSearchFavourite:ao,handleDeleteSearchHistory:Tt,selectedRowIds:mr,handleToggleRowSelection:Je,handleToggleAllRows:Mt,handleRangeSelection:Vt,handleClearSelection:tt,handleUpdateSelectionAfterDelete:Qe,currentPage:Wt,pageSize:lo,paginationTotalRows:Mr,handlePageChange:xr,handlePageSizeChange:Ve,isExporting:ke,showExportModal:or,setShowExportModal:At,showDirtyExportWarning:gr,handleExport:yr,handleExportWithConfig:Ht,handleExportSelected:nr,handleExportAnyway:Ze,handleSaveAndExport:ir,handleCancelExport:gt,showAuditHistory:Wr,setShowAuditHistory:ee,showCreatePreset:br,setShowCreatePreset:Ar,showManagePresets:Bt,setShowManagePresets:H,activePreset:ut,handleCreatePreset:we,handleClearActivePreset:Ke,handleOpenPresetById:sr,handleDeletePresetById:vr,isViewerRole:co,userRole:Ut,featureLimitWarning:Sr,setFeatureLimitWarning:Gt,reportError:ar,setReportError:Yt,handleError:be,updateReport:yt,showSnack:Z,config:pe,scheduler:ye}=e,[Cr,jr]=f.useState(!1);Op({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)||((Ge=c==null?void 0:c.snapshot)==null?void 0:Ge.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((wr=c==null?void 0:c.snapshot)==null?void 0:wr.columnOrder)||[],filters:Le(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:me=>{Z(`Scheduled export "${me.name}" completed`,"success")},schedulerConfig:ye});const uo=f.useCallback((me,Se)=>{if(!(r!=null&&r.uploadedData))return;const Ne=[...r.uploadedData];Ne[me]=Se,yt(r.id,{uploadedData:Ne})},[r,yt]),Rr=f.useCallback(me=>{if(!(r!=null&&r.uploadedData))return;const Se=r.uploadedData.indexOf(me);if(Se===-1)return;const Ne=r.uploadedData.filter((nt,Et)=>Et!==Se);yt(r.id,{uploadedData:Ne}),Qe(me)},[r,yt,Qe]),po=f.useCallback((me,Se)=>{if(!(r!=null&&r.uploadedData))return;const Ne=r.uploadedData.indexOf(Se),nt=Ne!==-1?Ne+1:me+1,Et=[...r.uploadedData];Et.splice(nt,0,{...Se}),yt(r.id,{uploadedData:Et})},[r,yt]),qt=Dr(),{handleDevConfigChange:Pr}=cn(),[Nr,ve]=f.useState(!1);return f.useEffect(()=>{const me=Se=>{Se.ctrlKey&&Se.shiftKey&&Se.key==="D"&&(Se.preventDefault(),ve(!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:[Sr&&t.jsx(mp,{warning:Sr,onDismiss:()=>Gt(null)}),ar&&t.jsx(xp,{error:ar,onDismiss:()=>Yt(null)}),gr&&t.jsx(Xu,{onExportAnyway:Ze,onSaveAndExport:ir,onCancel:gt}),t.jsx(Nu,{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:j,onOpenFilters:()=>y(!0),onOpenSort:()=>z(!0),onOpenFilterForColumn:S,onSelectView:F,onCreateView:()=>_(!0),onUpdateCurrentView:ne,onSaveAsNewView:U,onDiscardChanges:re,onToggleDefault:xe,onToggleFavorite:V,onRestoreView:ae,onPermanentDelete:le,onEditView:ie,onCloneView:Q,onCopyLink:de,onDeleteView:X,onPromoteToGlobal:he,isAdmin:((st=qt.views)==null?void 0:st.isAdmin)??!1,onExport:yr,onOpenColumns:()=>ze(!0),onUpdateColumnWidth:kt,onUpdateColumnOrder:We,onUpdateColumnVisibility:Y,onClearFiltersForColumn:b,onResetLayout:dt,onOpenGroup:()=>Ot(!0),onGroupByColumn:(Jt=pe==null?void 0:pe.hideToolbarActions)!=null&&Jt.includes("grouping")?void 0:me=>{ot({enabled:!0,levels:[{column:me}],collapsedGroups:[]})},onToggleGroupCollapse:Ft,onExpandAllGroups:qe,onCollapseAllGroups:zt,onOpenAuditHistory:()=>ee(!0),onOpenScheduledReports:()=>jr(!0),searchQuery:fr,highlightQuery:xt,searchHistory:tr,onAddToSearchHistory:rr,onToggleSearchFavourite:ao,onDeleteSearchHistory:Tt,selectedRowIds:mr,onSearchChange:so,onToggleRowSelection:Je,onToggleAllRows:Mt,onRangeSelection:Vt,onClearSelection:tt,onExportSelected:nr,currentPage:Wt,pageSize:lo,onPageChange:xr,onPageSizeChange:Ve,totalRowsBeforePagination:Mr,isReadOnly:co,userRole:Ut,reportName:r.name,onEditRow:uo,onDeleteRow:Rr,onDuplicateRow:po,rowActions:pe==null?void 0:pe.rowActions,hideDefaultRowActions:pe==null?void 0:pe.hideDefaultRowActions,hideToolbarActions:pe==null?void 0:pe.hideToolbarActions,customSettingsActions:pe==null?void 0:pe.customSettingsActions,viewOptions:pe==null?void 0:pe.viewOptions,defaultViewMode:pe==null?void 0:pe.defaultViewMode,bulkActions:pe==null?void 0:pe.bulkActions,hideSelectionCheckboxes:pe==null?void 0:pe.hideSelectionCheckboxes,rowClickBehavior:pe==null?void 0:pe.rowClickBehavior,openModalOn:pe==null?void 0:pe.openModalOn,onRowClick:pe==null?void 0:pe.onRowClick,onRowRightClick:pe==null?void 0:pe.onRowRightClick,showDevPanel:qt.display.showDevPanel,onOpenDevConfig:()=>ve(!0)})]}),x&&t.jsx(Yo,{feature:"Filters",onError:me=>{const Se=ur("ui","filters",me);be(Se)},children:t.jsx(Hu,{schema:r.schema,filters:r.filters,onReplaceFilters:v,onClose:k,focusColumn:g})}),m&&t.jsx(Yo,{feature:"Sorting",onError:me=>{const Se=ur("ui","sorting",me);be(Se)},children:t.jsx(Gu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:B,onClose:()=>z(!1)})}),P&&p&&(()=>{var Ne;const me=(r.views??[]).filter(nt=>!nt.isDeleted).length,Se=((Ne=qt.views)==null?void 0:Ne.maxViews)??10;return t.jsx(fs,{currentSnapshot:p,onSave:d,onClose:()=>_(!1),atViewLimit:me>=Se,maxViews:Se})})(),M&&u&&t.jsx(fs,{currentSnapshot:u.snapshot,onSave:I,onClose:()=>{G(!1)},isEditMode:!0,initialName:u.name,initialDescription:u.description,initialIsDefault:u.isDefault}),q&&A&&t.jsx(Yu,{viewName:A.name,onConfirm:te,onCancel:()=>{R(!1)}}),se&&c&&t.jsx(Ju,{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:Y,onUpdateColumnOrder:We,onUpdateColumnWidth:kt,onResetLayout:dt,onClose:()=>ze(!1)}),Or&&t.jsx(Yo,{feature:"Grouping",onError:me=>{const Se=ur("ui","grouping",me);be(Se)},children:t.jsx(Ku,{schema:r.schema,grouping:r.grouping||null,onApply:ot,onClose:()=>Ot(!1)})}),Wr&&t.jsx(ep,{auditHistory:r.auditHistory||[],onClose:()=>ee(!1)}),br&&t.jsx(tp,{onSave:we,onClose:()=>Ar(!1)}),Bt&&t.jsx(op,{presets:r.presets||[],reportId:r.id,onOpenPreset:sr,onDeletePreset:vr,onClose:()=>H(!1)}),ut&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(rp,{presetName:ut.name,onClear:Ke})}),or&&t.jsx(Yo,{feature:"Export",onError:me=>{const Se=ur("ui","export",me);be(Se)},children:t.jsx(fp,{totalRows:(s==null?void 0:s.totalRows)||((It=r.uploadedData)==null?void 0:It.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((kr=a==null?void 0:a.columnEngine)==null?void 0:kr.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:Ht,onClose:()=>{At(!1)}})}),r&&t.jsx($p,{open:Cr,onClose:()=>jr(!1),reportId:r.id,reportName:r.name,schedulerConfig:ye,onRunNow:me=>{var Et;const Se=(ye==null?void 0:ye.mode)??"local",Ne=me.scope==="all"?r.uploadedData||[]:i||[],nt=Qo(Ne,r.schema||[],Le(r.filters),r.sortStack||[],c,r.columnVisibility,r.columnOrder);if(Se==="api"){const zr=(r.columnOrder||[]).filter(Lr=>(r.columnVisibility??{})[Lr]!==!1);(Et=ye==null?void 0:ye.onScheduleFire)==null||Et.call(ye,{schedule:me,triggeredAt:new Date().toISOString(),rows:Ne,columns:zr,format:me.format,reportName:r.name})}else me.format==="csv"&&Zo(nt,me.name),me.format==="excel"&&en(nt,me.name),me.format==="json"&&tn(nt,me.name),me.format==="pdf"&&ui(nt,me.name);Z(`"${me.name}" exported successfully`,"success")}}),t.jsx(Sp,{open:Nr,onClose:()=>ve(!1),config:qt,onApply:Pr})]})}const Mp={error:"err",warning:"warn",info:"info",success:"suc"};function ca({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var B,T,j,P;const a=o.useTheme(),c=a.tokens,l=(c==null?void 0:c.notifPosition)??"top-right",p=(c==null?void 0:c.notifStyle)??"toast",x=(c==null?void 0:c.notifAccent)??"severity",y=(c==null?void 0:c.notifAutoDismiss)??!0,g=(c==null?void 0:c.toastW)??252,v=l.startsWith("top")?"top":"bottom",S=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",k=Mp[n],b=((B=c==null?void 0:c.status)==null?void 0:B[`${k}Soft`])??a.palette[n].light,m=((T=c==null?void 0:c.status)==null?void 0:T[`${k}Txt`])??a.palette[n].dark,z=x==="primary"?a.palette.primary.main:x==="mono"?a.palette.text.secondary:m,h=p==="toast"?(c==null?void 0:c.toastBg)??a.palette.background.paper:b;return t.jsx(o.Snackbar,{open:e,autoHideDuration:y?s??(c!=null&&c.autoDismissSec?c.autoDismissSec*1e3:2e3):void 0,onClose:(_,M)=>{M!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:v,horizontal:S},children:t.jsx(o.Alert,{severity:n,icon:p==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((j=c==null?void 0:c.status)==null?void 0:j[`${k}Soft`])??a.palette[n].light,color:((P=c==null?void 0:c.status)==null?void 0:P[`${k}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:[y&&(c==null?void 0:c.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:E(z,.14),color:z,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($.Close,{sx:{fontSize:16}})})]}),sx:{width:g,alignItems:"flex-start",bgcolor:h,color:m,boxShadow:p==="inline"?"none":(c==null?void 0:c.cardShadow)??3,border:p==="inline"?"1px solid":p==="toast"?(c==null?void 0:c.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:p==="banner"?`4px solid ${z}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:z}},children:t.jsxs(o.Box,{children:[p==="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 da({hasExternalData:e=!1}){const r=cn(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:p,setActiveReportId:x,createReport:y,handleFileUpload:g,handleUploadError:v,handleRetry:S,handleConfirm:k,snack:b,handleSnackClose:m,snackDurationMs:z}=r,h=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Hl,{onCreateReport:()=>p(!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:h?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(Ks,{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(la,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(ou,{schema:s.schema,onConfirm:k,hasConflicts:c}):s.uploadError?t.jsx(nu,{error:s.uploadError,onRetry:S}):t.jsx(ru,{onFileUpload:g,onError:v,isUploading:a==="uploading"})})}):null}),!e&&t.jsx(tu,{isOpen:l,onClose:()=>p(!1),onCreate:y}),t.jsx(ca,{open:b.open,message:b.message,severity:b.severity,onClose:m,autoHideDurationMs:z})]})}function Wp({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c=!0,config:l}={}){return t.jsx(pi,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c,config:l,children:t.jsx(da,{hasExternalData:!!(e||r)})})}function ua(){const e=cn(),{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(la,{reportEngine:e}):t.jsx(Ks,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(ca,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Ap({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(pi,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(ua,{})})}exports.URMBuilder=Wp;exports.URMBuilderRaw=da;exports.URMProvider=pi;exports.URMViewer=Ap;exports.URMViewerRaw=ua;exports.useURMContext=cn;
197
+ The file has been downloaded to your device.`);window.open(`mailto:${b.email}?subject=${xe}&body=${H}`,"_blank")}(d=(F=S.current).onFired)==null||d.call(F,b)}catch(oe){Gt.error("urm:scheduler",`Export failed for schedule: ${b.name}`,oe)}},[]);f.useEffect(()=>{if(!e)return;const b=()=>{const{reportId:z,schedulerMode:h,schedulerConfig:B}=S.current;if(!z)return;const T=h==="api"?(B==null?void 0:B.schedules)??[]:sa(z),w=new Date;let P=!1;const O=T.map(M=>{if(!M.isActive)return M;if(new Date(M.nextRunAt)<=w){k(M);const K=Jo(M.frequency,M.time,M.dayOfWeek,M.dayOfMonth,w);return P=!0,{...M,lastRunAt:w.toISOString(),nextRunAt:K,runCount:M.runCount+1}}return M});P&&h==="local"&&aa(z,O)};b();const m=setInterval(b,Op);return()=>clearInterval(m)},[e,k])}function ca({reportEngine:e}){var Ge,kr,ct,Xt,$t,zr;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:c,isDirty:l,currentTableState:p,showFilterPanel:x,setShowFilterPanel:y,filterFocusColumn:g,handleReplaceFilters:v,handleOpenFilterForColumn:S,handleCloseFilterPanel:k,handleClearFiltersForColumn:b,showSortPanel:m,setShowSortPanel:z,handleSort:h,handleUpdateSortStack:B,handleSortAscending:T,handleSortDescending:w,showCreateViewModal:P,setShowCreateViewModal:O,showEditViewModal:M,setShowEditViewModal:q,showDeleteConfirmation:K,setShowDeleteConfirmation:R,editingView:u,deletingView:A,handleSelectView:F,handleCreateView:d,handleUpdateCurrentView:oe,handleSaveAsNewView:G,handleRevertChanges:te,handleToggleDefault:xe,handleToggleFavorite:H,handleSoftDelete:Q,handleRestoreView:le,handlePermanentDelete:ce,handleEditView:ie,handleCloneView:Z,handleCopyViewLink:ue,handleSaveEditView:I,handleConfirmDelete:ee,handlePromoteToGlobal:fe,showManageColumns:se,setShowManageColumns:ke,handleUpdateColumnVisibility:J,handleUpdateColumnOrder:We,handleUpdateColumnWidth:kt,handleResetColumnLayout:ht,showGroupPanel:Wr,setShowGroupPanel:At,handleGroup:it,handleToggleGroupCollapse:Yt,handleExpandAllGroups:Je,handleCollapseAllGroups:zt,searchQuery:xr,debouncedSearchQuery:gt,searchHistory:nr,handleSearchChange:lo,handleAddToSearchHistory:Rt,handleToggleSearchFavourite:co,handleDeleteSearchHistory:yt,selectedRowIds:gr,handleToggleRowSelection:Ke,handleToggleAllRows:Pt,handleRangeSelection:Tt,handleClearSelection:Xe,handleUpdateSelectionAfterDelete:Bt,currentPage:rt,pageSize:yr,paginationTotalRows:Ar,handlePageChange:br,handlePageSizeChange:He,isExporting:Ce,showExportModal:vr,setShowExportModal:Sr,showDirtyExportWarning:qt,handleExport:Jt,handleExportWithConfig:Rr,handleExportSelected:It,handleExportAnyway:Qe,handleSaveAndExport:ir,handleCancelExport:Et,showAuditHistory:uo,setShowAuditHistory:pe,showCreatePreset:je,setShowCreatePreset:Pr,showManagePresets:Nr,setShowManagePresets:Nt,activePreset:V,handleCreatePreset:Dt,handleClearActivePreset:ne,handleOpenPresetById:st,handleDeletePresetById:Lr,isViewerRole:sr,userRole:Cr,featureLimitWarning:ar,setFeatureLimitWarning:jr,reportError:Lt,setReportError:Ft,handleError:ot,updateReport:we,showSnack:lt,config:U,scheduler:Ue}=e,[Ee,wr]=f.useState(!1);Mp({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)||((Ge=c==null?void 0:c.snapshot)==null?void 0:Ge.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((kr=c==null?void 0:c.snapshot)==null?void 0:kr.columnOrder)||[],filters:Ne(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:me=>{lt(`Scheduled export "${me.name}" completed`,"success")},schedulerConfig:Ue});const po=f.useCallback((me,be)=>{if(!(r!=null&&r.uploadedData))return;const Ye=[...r.uploadedData];Ye[me]=be,we(r.id,{uploadedData:Ye})},[r,we]),Fr=f.useCallback(me=>{if(!(r!=null&&r.uploadedData))return;const be=r.uploadedData.indexOf(me);if(be===-1)return;const Ye=r.uploadedData.filter((Ze,_t)=>_t!==be);we(r.id,{uploadedData:Ye}),Bt(me)},[r,we,Bt]),ho=f.useCallback((me,be)=>{if(!(r!=null&&r.uploadedData))return;const Ye=r.uploadedData.indexOf(be),Ze=Ye!==-1?Ye+1:me+1,_t=[...r.uploadedData];_t.splice(Ze,0,{...be}),we(r.id,{uploadedData:_t})},[r,we]),Kt=_r(),{handleDevConfigChange:Vr}=an(),[Hr,ye]=f.useState(!1);return f.useEffect(()=>{const me=be=>{be.ctrlKey&&be.shiftKey&&be.key==="D"&&(be.preventDefault(),ye(!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:[ar&&t.jsx(xp,{warning:ar,onDismiss:()=>jr(null)}),Lt&&t.jsx(gp,{error:Lt,onDismiss:()=>Ft(null)}),qt&&t.jsx(Qu,{onExportAnyway:Qe,onSaveAndExport:ir,onCancel:Et}),t.jsx(Lu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:l,isExporting:Ce,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:w,onOpenFilters:()=>y(!0),onOpenSort:()=>z(!0),onOpenFilterForColumn:S,onSelectView:F,onCreateView:()=>O(!0),onUpdateCurrentView:oe,onSaveAsNewView:G,onDiscardChanges:te,onToggleDefault:xe,onToggleFavorite:H,onRestoreView:le,onPermanentDelete:ce,onEditView:ie,onCloneView:Z,onCopyLink:ue,onDeleteView:Q,onPromoteToGlobal:fe,isAdmin:((ct=Kt.views)==null?void 0:ct.isAdmin)??!1,onExport:Jt,onOpenColumns:()=>ke(!0),onUpdateColumnWidth:kt,onUpdateColumnOrder:We,onUpdateColumnVisibility:J,onClearFiltersForColumn:b,onResetLayout:ht,onOpenGroup:()=>At(!0),onGroupByColumn:(Xt=U==null?void 0:U.hideToolbarActions)!=null&&Xt.includes("grouping")?void 0:me=>{it({enabled:!0,levels:[{column:me}],collapsedGroups:[]})},onToggleGroupCollapse:Yt,onExpandAllGroups:Je,onCollapseAllGroups:zt,onOpenAuditHistory:()=>pe(!0),onOpenScheduledReports:()=>wr(!0),searchQuery:xr,highlightQuery:gt,searchHistory:nr,onAddToSearchHistory:Rt,onToggleSearchFavourite:co,onDeleteSearchHistory:yt,selectedRowIds:gr,onSearchChange:lo,onToggleRowSelection:Ke,onToggleAllRows:Pt,onRangeSelection:Tt,onClearSelection:Xe,onExportSelected:It,currentPage:rt,pageSize:yr,onPageChange:br,onPageSizeChange:He,totalRowsBeforePagination:Ar,isReadOnly:sr,userRole:Cr,reportName:r.name,onEditRow:po,onDeleteRow:Fr,onDuplicateRow:ho,rowActions:U==null?void 0:U.rowActions,hideDefaultRowActions:U==null?void 0:U.hideDefaultRowActions,hideToolbarActions:U==null?void 0:U.hideToolbarActions,customSettingsActions:U==null?void 0:U.customSettingsActions,viewOptions:U==null?void 0:U.viewOptions,defaultViewMode:U==null?void 0:U.defaultViewMode,bulkActions:U==null?void 0:U.bulkActions,hideSelectionCheckboxes:U==null?void 0:U.hideSelectionCheckboxes,rowClickBehavior:U==null?void 0:U.rowClickBehavior,openModalOn:U==null?void 0:U.openModalOn,onRowClick:U==null?void 0:U.onRowClick,onRowRightClick:U==null?void 0:U.onRowRightClick,showDevPanel:Kt.display.showDevPanel,onOpenDevConfig:()=>ye(!0)})]}),x&&t.jsx(Uo,{feature:"Filters",onError:me=>{const be=hr("ui","filters",me);ot(be)},children:t.jsx(Uu,{schema:r.schema,filters:r.filters,onReplaceFilters:v,onClose:k,focusColumn:g})}),m&&t.jsx(Uo,{feature:"Sorting",onError:me=>{const be=hr("ui","sorting",me);ot(be)},children:t.jsx(Yu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:B,onClose:()=>z(!1)})}),P&&p&&(()=>{var Ye;const me=(r.views??[]).filter(Ze=>!Ze.isDeleted).length,be=((Ye=Kt.views)==null?void 0:Ye.maxViews)??10;return t.jsx(ms,{currentSnapshot:p,onSave:d,onClose:()=>O(!1),atViewLimit:me>=be,maxViews:be})})(),M&&u&&t.jsx(ms,{currentSnapshot:u.snapshot,onSave:I,onClose:()=>{q(!1)},isEditMode:!0,initialName:u.name,initialDescription:u.description,initialIsDefault:u.isDefault}),K&&A&&t.jsx(qu,{viewName:A.name,onConfirm:ee,onCancel:()=>{R(!1)}}),se&&c&&t.jsx(Ku,{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:J,onUpdateColumnOrder:We,onUpdateColumnWidth:kt,onResetLayout:ht,onClose:()=>ke(!1)}),Wr&&t.jsx(Uo,{feature:"Grouping",onError:me=>{const be=hr("ui","grouping",me);ot(be)},children:t.jsx(Xu,{schema:r.schema,grouping:r.grouping||null,onApply:it,onClose:()=>At(!1)})}),uo&&t.jsx(tp,{auditHistory:r.auditHistory||[],onClose:()=>pe(!1)}),je&&t.jsx(rp,{onSave:Dt,onClose:()=>Pr(!1)}),Nr&&t.jsx(np,{presets:r.presets||[],reportId:r.id,onOpenPreset:st,onDeletePreset:Lr,onClose:()=>Nt(!1)}),V&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(op,{presetName:V.name,onClear:ne})}),vr&&t.jsx(Uo,{feature:"Export",onError:me=>{const be=hr("ui","export",me);ot(be)},children:t.jsx(mp,{totalRows:(s==null?void 0:s.totalRows)||(($t=r.uploadedData)==null?void 0:$t.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((zr=a==null?void 0:a.columnEngine)==null?void 0:zr.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:Rr,onClose:()=>{Sr(!1)}})}),r&&t.jsx(_p,{open:Ee,onClose:()=>wr(!1),reportId:r.id,reportName:r.name,schedulerConfig:Ue,onRunNow:me=>{var _t;const be=(Ue==null?void 0:Ue.mode)??"local",Ye=me.scope==="all"?r.uploadedData||[]:i||[],Ze=Ko(Ye,r.schema||[],Ne(r.filters),r.sortStack||[],c,r.columnVisibility,r.columnOrder);if(be==="api"){const fo=(r.columnOrder||[]).filter(lr=>(r.columnVisibility??{})[lr]!==!1);(_t=Ue==null?void 0:Ue.onScheduleFire)==null||_t.call(Ue,{schedule:me,triggeredAt:new Date().toISOString(),rows:Ye,columns:fo,format:me.format,reportName:r.name})}else me.format==="csv"&&Xo(Ze,me.name),me.format==="excel"&&Qo(Ze,me.name),me.format==="json"&&Zo(Ze,me.name),me.format==="pdf"&&ui(Ze,me.name);lt(`"${me.name}" exported successfully`,"success")}}),t.jsx(Cp,{open:Hr,onClose:()=>ye(!1),config:Kt,onApply:Vr})]})}const Wp={error:"err",warning:"warn",info:"info",success:"suc"};function da({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var B,T,w,P;const a=o.useTheme(),c=a.tokens,l=(c==null?void 0:c.notifPosition)??"top-right",p=(c==null?void 0:c.notifStyle)??"toast",x=(c==null?void 0:c.notifAccent)??"severity",y=(c==null?void 0:c.notifAutoDismiss)??!0,g=(c==null?void 0:c.toastW)??252,v=l.startsWith("top")?"top":"bottom",S=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",k=Wp[n],b=((B=c==null?void 0:c.status)==null?void 0:B[`${k}Soft`])??a.palette[n].light,m=((T=c==null?void 0:c.status)==null?void 0:T[`${k}Txt`])??a.palette[n].dark,z=x==="primary"?a.palette.primary.main:x==="mono"?a.palette.text.secondary:m,h=p==="toast"?(c==null?void 0:c.toastBg)??a.palette.background.paper:b;return t.jsx(o.Snackbar,{open:e,autoHideDuration:y?s??(c!=null&&c.autoDismissSec?c.autoDismissSec*1e3:2e3):void 0,onClose:(O,M)=>{M!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:v,horizontal:S},children:t.jsx(o.Alert,{severity:n,icon:p==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((w=c==null?void 0:c.status)==null?void 0:w[`${k}Soft`])??a.palette[n].light,color:((P=c==null?void 0:c.status)==null?void 0:P[`${k}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:[y&&(c==null?void 0:c.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:D(z,.14),color:z,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($.Close,{sx:{fontSize:16}})})]}),sx:{width:g,alignItems:"flex-start",bgcolor:h,color:m,boxShadow:p==="inline"?"none":(c==null?void 0:c.cardShadow)??3,border:p==="inline"?"1px solid":p==="toast"?(c==null?void 0:c.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:p==="banner"?`4px solid ${z}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:z}},children:t.jsxs(o.Box,{children:[p==="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 ua({hasExternalData:e=!1}){const r=an(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:p,setActiveReportId:x,createReport:y,handleFileUpload:g,handleUploadError:v,handleRetry:S,handleConfirm:k,snack:b,handleSnackClose:m,snackDurationMs:z}=r,h=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Ul,{onCreateReport:()=>p(!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:h?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(Xs,{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(ca,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(nu,{schema:s.schema,onConfirm:k,hasConflicts:c}):s.uploadError?t.jsx(iu,{error:s.uploadError,onRetry:S}):t.jsx(ou,{onFileUpload:g,onError:v,isUploading:a==="uploading"})})}):null}),!e&&t.jsx(ru,{isOpen:l,onClose:()=>p(!1),onCreate:y}),t.jsx(da,{open:b.open,message:b.message,severity:b.severity,onClose:m,autoHideDurationMs:z})]})}function Ap({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c=!0,config:l}={}){return t.jsx(pi,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c,config:l,children:t.jsx(ua,{hasExternalData:!!(e||r)})})}function pa(){const e=an(),{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(ca,{reportEngine:e}):t.jsx(Xs,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(da,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Rp({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(pi,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(pa,{})})}exports.URMBuilder=Ap;exports.URMBuilderRaw=ua;exports.URMProvider=pi;exports.URMViewer=Rp;exports.URMViewerRaw=pa;exports.useURMContext=an;