dts-universal-report-module 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +5475 -5334
- package/dist/index.js +29 -29
- 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 oo(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:js(r))}function yo(e){if(!Array.isArray(e)||e.length===0)return[];const r=oo(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 io(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Ye(e){return"children"in e}function _t(){return{id:io(),operator:"and",children:[]}}function Le(e){return e?Array.isArray(e)?{id:io(),operator:"and",children:e.map(r=>({...r,id:r.id??io()}))}: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 so(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Ye(i)?so(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(`
|
|
2
|
-
`)?`"${
|
|
3
|
-
`);
|
|
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 ji=(e,r,n)=>ha(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),h=require("react"),ma=require("xlsx"),$=require("@mui/icons-material"),o=require("@mui/material"),Ss=require("react-dom"),fa=require("@emotion/react"),nr=require("react-dnd"),ai=require("react-dnd-html5-backend");function Cs(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 ln=Cs(h),Fo=Cs(ma),mt={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}},ws="urm_dev_config";function xa(){try{const e=localStorage.getItem(ws);if(!e)return mt;const r=JSON.parse(e),n={sort:{...mt.sort,...r.sort},filter:{...mt.filter,...r.filter},columns:{...mt.columns,...r.columns},grouping:{...mt.grouping,...r.grouping},export:{...mt.export,...r.export},views:{...mt.views,...r.views},dates:{...mt.dates,...r.dates},display:{...mt.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return mt}}function ga(e){try{localStorage.setItem(ws,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 js=h.createContext(mt);function $r(){return h.useContext(js)}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,wa=41024448e5,ja=978307200,ka=4102444800;function za(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=Ca&&e<=wa?"timestamp_ms":Number.isInteger(e)&&e>=ja&&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 ki=["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),g=Math.floor(l/365);let f;return s<60?f="just now":a<60?f=`${a} minute${a!==1?"s":""}`:c<24?f=`${c} hour${c!==1?"s":""}`:l<7?f=`${l} day${l!==1?"s":""}`:p<5?f=`${p} week${p!==1?"s":""}`:x<12?f=`${x} month${x!==1?"s":""}`:f=`${g} year${g!==1?"s":""}`,s<60?f:i?`${f} ago`:`in ${f}`}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`${ki[i]} ${Ue(s)}, ${n}`;case"DD MMM YYYY":return`${Ue(s)} ${ki[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 ks(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,ks(c,a,n+1)):i[a]=c}return i}function oo(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:ks(r))}function go(e){if(!Array.isArray(e)||e.length===0)return[];const r=oo(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,g=l.size>1&&!l.has("null");let f="mixed";if(l.size===1)f=Array.from(l)[0];else if(l.size===2&&l.has("null")){const v=Array.from(l).filter(S=>S!=="null");v.length===1&&(f=v[0])}i.push({name:c,type:f,required:x,hasConflict:g})});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 zi(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 at(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 Ti(e){return e==null}function Ma(e){return(r,n,i)=>{const s=Ti(r),a=Ti(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(g=>g.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=li(e,n.levels,r);return zs(i,n.collapsedGroups||[])}function li(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,c=new Map;e.forEach(x=>{const g=x[a],f=g==null?"(empty)":String(g);c.has(f)||c.set(f,[]),c.get(f).push(x)});const l=[];return Array.from(c.keys()).sort().forEach(x=>{const g=c.get(x),f=`${a}:${x}`,v=i?`${i}|${f}`:f,S=Na(g,n),B=s<r.length-1?li(g,r,n,v,s+1):g,b={key:v,level:s,column:a,value:x,rowCount:g.length,aggregates:S,children:B};l.push(b)}),l}function zs(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&&zs(s.children,r,n,i+1)}else n.push({...s,__urm_row_id__:s.__urm_row_id__,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function Bi(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=li(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 Ts(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Va(e,r,n){const i=r?at(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function io(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function qe(e){return"children"in e}function $t(){return{id:io(),operator:"and",children:[]}}function Ne(e){return e?Array.isArray(e)?{id:io(),operator:"and",children:e.map(r=>({...r,id:r.id??io()}))}:e:$t()}function jt(e){return e?qe(e)?e.children.reduce((r,n)=>r+jt(n),0):1:0}function Ko(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=Ko(n,r);if(i)return i}}}function so(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>qe(i)?so(i,r,n):i)}}function ci(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!qe(i)?{...i,...n}:qe(i)?ci(i,r,n):i)}}function di(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>qe(i)?di(i,r,n):i)}}function ui(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>qe(i)?ui(i,r):i).filter(i=>!qe(i)||i.children.length>0);return{...e,children:n}}function ei(e,r){return e?qe(e)?e.children.some(n=>ei(n,r)):e.column===r:!1}function Bs(e,r){const n=e.children.filter(i=>qe(i)||i.column!==r).map(i=>qe(i)?Bs(i,r):i).filter(i=>!qe(i)||i.children.length>0);return{...e,children:n}}function Is(e){return e?qe(e)?e.children.flatMap(Is):[e]:[]}function Bo(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(Bo)}}function So(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 pi(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 Vn(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=[],g={};n.forEach(S=>{p[S.name]=!0,x.push(S.name),g[S.name]=170});const v=pi(s||x,c||null,l||x);return{filters:Ne(e),sortStack:r||[],columnVisibility:i||p,columnOrder:v,columnWidths:a||g,grouping:c||null}}function Ua(e,r){const n=S=>{if(S==null)return S;if(Array.isArray(S))return S.map(B=>n(B));if(typeof S=="object"){const B={};return Object.keys(S).sort().forEach(b=>{B[b]=n(S[b])}),B}return S},i=S=>JSON.stringify(n(S));if(i(Bo(e.filters))!==i(Bo(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=pi(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 f=e.columnWidths??{},v=r.columnWidths??{};return i(f)!==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,y,w;const n=[],i=JSON.stringify(Bo(e.filters)),s=JSON.stringify(Bo(r.filters));if(i!==s){const m=jt(e.filters),j=jt(r.filters);m>j?n.push({category:"filters",label:"Filters Added",description:`${m-j} new filter${m-j>1?"s":""} added`}):m<j?n.push({category:"filters",label:"Filters Removed",description:`${j-m} filter${j-m>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 m=e.sortStack.length,j=r.sortStack.length;m>j?n.push({category:"sorting",label:"Sorting Added",description:`${m-j} new sort rule${m-j>1?"s":""} added`}):m<j?n.push({category:"sorting",label:"Sorting Removed",description:`${j-m} sort rule${j-m>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 m=Object.values(e.columnVisibility).filter(I=>I).length,j=Object.values(r.columnVisibility).filter(I=>I).length;m>j?n.push({category:"visibility",label:"Columns Shown",description:`${m-j} column${m-j>1?"s":""} made visible`}):m<j?n.push({category:"visibility",label:"Columns Hidden",description:`${j-m} column${j-m>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const x=JSON.stringify(e.columnOrder),g=JSON.stringify(r.columnOrder);x!==g&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const f=JSON.stringify(e.columnWidths),v=JSON.stringify(r.columnWidths);if(f!==v){const m=Object.keys(e.columnWidths).filter(j=>e.columnWidths[j]!==r.columnWidths[j]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${m} column width${m>1?"s":""} modified`})}const S=JSON.stringify(e.grouping),B=JSON.stringify(r.grouping);if(S!==B){const m=(b=e.grouping)==null?void 0:b.enabled,j=(y=r.grouping)==null?void 0:y.enabled;if(m&&!j){const I=((w=e.grouping)==null?void 0:w.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${I} grouping level${I>1?"s":""} added`})}else!m&&j?n.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):n.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return n}function Ii(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Ei(e){return`[${e}]`}const Vt={warn(e,r,...n){Ii()&&console.warn(Ei(e),r,...n)},error(e,r,...n){Ii()&&console.error(Ei(e),r,...n)}},Es="urm_report_";function qa(e,r){try{const n=`${Es}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Vt.error("urm:persistence","Failed to save report state",n)}}function Ja(e){try{const r=`${Es}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Vt.error("urm:persistence","Failed to load report state",r),null}}function Eo(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=Eo(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 cn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function dn(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 en(e,r,n,i,s,a,c){let l,p;a?(l={...a},p=c||r.map(g=>g.name)):s?(l={...s.snapshot.columnVisibility},p=c||[...s.snapshot.columnOrder]):(l={},p=[],r.forEach(g=>{l[g.name]=!0,p.push(g.name)}));const x=Object.entries(l).filter(([g,f])=>!f).map(([g,f])=>g);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 tn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(f=>e.columnVisibility[f]);let l;if(a&&a.enabled){const f=a.collapsedGroups??[],v=Eo(i,f);l=cn(v)}else l=i;const p=c.join(","),x=l.map(f=>c.map(v=>{const S=f[v];if(S==null)return"";const B=String(S);return B.includes(",")||B.includes('"')||B.includes(`
|
|
2
|
+
`)?`"${B.replace(/"/g,'""')}"`:B}).join(",")),g=[p,...x].join(`
|
|
3
|
+
`);hi(g,dn(r,"csv"),"text/csv;charset=utf-8;")}function rn(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(f=>e.columnVisibility[f]);let l;if(a&&a.enabled){const f=a.collapsedGroups??[],v=Eo(i,f);l=cn(v)}else l=i;const p=[c,...l.map(f=>c.map(v=>f[v]??""))],x=Fo.utils.aoa_to_sheet(p),g=Fo.utils.book_new();Fo.utils.book_append_sheet(g,x,"Data"),Fo.writeFile(g,dn(r,"xlsx"))}function on(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:c,hiddenColumns:l,columnOrder:p,grouping:x}=e,g=p.filter(B=>e.columnVisibility[B]);let f;if(x&&x.enabled){const B=x.collapsedGroups??[],b=Eo(i,B);f=cn(b)}else f=i;f=f.map(B=>{const b={};return g.forEach(y=>{b[y]=B[y]}),b});const v={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(c==null?void 0:c.name)||"Default View",filters:Is(s).map(B=>({field:B.column,operator:B.operator,value:B.value})),sortStack:a.map(B=>({field:B.column,direction:B.direction,priority:B.priority})),grouping:x||{},hiddenColumns:l,columnOrder:p,exportConfig:n||{scope:"visible"}},data:f},S=JSON.stringify(v,null,2);hi(S,dn(r,"json"),"application/json;charset=utf-8;")}function hi(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 mi(e,r="export",n){var b;const{data:i,columnOrder:s,grouping:a}=e,c=s.filter(y=>e.columnVisibility[y]);let l;if(a&&a.enabled){const y=a.collapsedGroups??[],w=Eo(i,y);l=cn(w)}else l=i;const p=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),x=c.map(y=>`<th>${Vo(y)}</th>`).join(""),g=l.map((y,w)=>{const m=c.map(j=>{const I=y[j],k=I==null?"":String(I);return`<td>${Vo(k)}</td>`}).join("");return`<tr class="${w%2===0?"even":"odd"}">${m}</tr>`}).join(""),f=`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8" />
|
|
7
|
-
<title>${
|
|
7
|
+
<title>${Vo(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">${
|
|
85
|
+
<div class="report-title">${Vo(r)}</div>
|
|
86
86
|
<div class="report-meta">
|
|
87
87
|
${l.length.toLocaleString()} row${l.length!==1?"s":""}<br/>
|
|
88
88
|
Generated ${p}
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
</div>
|
|
91
91
|
<table>
|
|
92
92
|
<thead><tr>${x}</tr></thead>
|
|
93
|
-
<tbody>${
|
|
93
|
+
<tbody>${g}</tbody>
|
|
94
94
|
</table>
|
|
95
95
|
<div class="report-footer">Universal Report Module — PDF Export</div>
|
|
96
96
|
<script>
|
|
@@ -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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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).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(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:w}=_l({data:B,searchQuery:c,schema:n,visibleColumns:m.visibleColumns,mode:l}),P=Pl({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 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,w]=f.useState(""),[P,O]=f.useState(!1),[M,Y]=f.useState(!1),[J,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),[ne,U]=f.useState("idle"),[re,ge]=f.useState(!1),[V,X]=f.useState(!1),[ce,de]=f.useState(!1),[ie,Q]=f.useState(!1),[pe,I]=f.useState(!1),[te,fe]=f.useState(void 0),[ae,ze]=f.useState(null),[q,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,ao]=f.useState({enabled:!1,levels:[],collapsedGroups:[]}),[rr,lo]=f.useState(""),[Tt,mr]=f.useState(""),[Je,Mt]=f.useState(new Set),[Vt,Qe]=f.useState(1),[Ze,Wt]=f.useState(15),[co,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,et]=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((j,E)=>{h(W=>W.map(_=>_.id===j?{..._,...E}:_))},[]),ut=f.useCallback(j=>{if(!d)return;gt(j);const E=Oi(d.id,$t,j,d.auditHistory||[]);H(d.id,{auditHistory:E}),u(j.message,"error"),j.recoverable&&Wr.current&&setTimeout(()=>{jl(d,Wr.current,H),u("Previous state restored","success")},100)},[d,H]),se=f.useCallback((j,E,W,_)=>{if(!d)return;const G=Is(d.id,$t,j,E,W,_),K=d.auditHistory||[],le=Es(K,G);setTimeout(()=>{H(d.id,{auditHistory:le})},0)},[d,H]);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}})(),H(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,H]),f.useEffect(()=>{if(i&&n&&!M&&z.length===0){const j=oo(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:wi(yo(j),S.hiddenColumns),permissions:{owner:$t,editors:[],viewers:[]}};h([E]),w(E.id),Y(!0),U("confirmed")}},[i,n,M,z.length,r,p,x]),f.useEffect(()=>{b!=="server"||!M||!T||H(T,{uploadedData:oo(i||[])})},[i,b,M,T]),f.useEffect(()=>{b==="server"&&((a==null?void 0:a.page)!==void 0&&Qe(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 j=!1,E=null;const W=async()=>{try{U("uploading");let _;if(s.type==="api"){const K=await fetch(s.url,{headers:s.headers||{}});if(!K.ok)throw new Error(`HTTP ${K.status}: ${K.statusText}`);_=await K.json()}else _=await s.fetch();if(j)return;if(!Array.isArray(_))throw new Error("Data source must return an array of objects");const G=yo(_);if(M)h(K=>K.map(le=>le.id===T?{...le,uploadedData:oo(_)}:le)),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:oo(_),schema:wi(yo(oo(_)),S.hiddenColumns),permissions:{owner:$t,editors:[],viewers:[]}};h([K]),w(K.id),Y(!0),U("confirmed")}}catch(_){j||(U("error"),d&&H(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 Ke=(Po=d==null?void 0:d.views)==null?void 0:Po.find(j=>j.id===d.activeViewId),sr=f.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(j=>Fl(j,S.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);f.useEffect(()=>{Mt(j=>{if(j.size===0)return j;const E=new Set(sr.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})},[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:Ze,currentPage:Vt}}),{data:uo=[],searchedData:Ut=[],groupedData:Sr=[],sortedData:Gt=[],metrics:ar={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Yt=!1,paginationEngine:ve}=vr||{},yt=b==="server"?(a==null?void 0:a.totalRows)??0:ar.searchedRows,Z=((yi=vr.viewEngine)==null?void 0:yi.activeView)||Ke,he=((bi=vr.viewEngine)==null?void 0:bi.isDirty)||!1;f.useEffect(()=>{if(!(!Z||!d)&&!d.columnOrder){const j=Z.snapshot.columnOrder,E=Co(j,Z.snapshot.grouping);H(d.id,{columnOrder:E})}},[d==null?void 0:d.activeViewId]);const be=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||!be||!he?[]:Ya(be,Z.snapshot),[Z,be,he]),jr=f.useCallback((j,E,W)=>{const _={id:`report-${Date.now()}`,name:j,description:E,schemaLocked:!1,permissions:{owner:$t,editors:[],viewers:[]}};if(W&&Array.isArray(W)&&W.length>0){const G=yo(W),K=Nn(G);_.uploadedData=W,_.schema=G,_.schemaLocked=!0,_.views=[K],_.activeViewId=K.id,_.sortStack=K.snapshot.sortStack,_.filters=K.snapshot.filters,_.columnVisibility=K.snapshot.columnVisibility,_.columnOrder=K.snapshot.columnOrder,_.columnWidths=K.snapshot.columnWidths,_.grouping=K.snapshot.grouping}h(G=>[...G,_]),w(_.id),O(!1),U("confirmed")},[]),po=f.useCallback(j=>{d&&(U("uploading"),setTimeout(()=>{const E=yo(j);H(d.id,{uploadedData:j,schema:E,uploadError:void 0}),U("preview")},500))},[d,H]),Rr=f.useCallback(j=>{d&&(H(d.id,{uploadError:j}),U("idle"))},[d,H]),ho=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(j=>{if(!d)return;if(!bt("edit_sorting",ee)){u(vt("edit_sorting"),"error");return}const E=d.sortStack??[],W=E.find(_=>_.column===j);if(W){const _=Aa(W.direction);if(_===null){const G=E.filter(K=>K.column!==j).map((K,le)=>({...K,priority:le+1}));se("sorting","sort_level_removed",W,null),H(d.id,{sortStack:G.length>0?G:void 0})}else{const G=_,K=E.map(le=>le.column===j?{...le,direction:G}:le);se("sorting","sort_reordered",{column:j,direction:W.direction},{column:j,direction:G}),H(d.id,{sortStack:K})}}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};se("sorting","sort_level_added",null,_),H(d.id,{sortStack:[...E,_]})}},[d,ee,H,se]),Nr=f.useCallback(j=>{if(!d)return;const E=d.sortStack??[],W=j.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:_,invalidColumns:G}=Ds(j,d.schema);G.length>0&&u(`Removed invalid sort columns: ${G.join(", ")}`),Bt();try{se("sorting",W,E,_.length>0?_:null),H(d.id,{sortStack:_.length>0?_:void 0})}catch(K){const le=ur("processing","sorting",K);ut(le)}}else se("sorting",W,E,j.length>0?j:null),H(d.id,{sortStack:j.length>0?j:void 0})},[d,H,Bt,ut,se]),Se=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(G=>G.column===j?{...G,direction:"asc"}:G);se("sorting","sort_reordered",{column:j,direction:W.direction},{column:j,direction:"asc"}),H(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};se("sorting","sort_level_added",null,_),H(d.id,{sortStack:[...E,_]})}},[d,H,se]),Ge=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(G=>G.column===j?{...G,direction:"desc"}:G);se("sorting","sort_reordered",{column:j,direction:W.direction},{column:j,direction:"desc"}),H(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};se("sorting","sort_level_added",null,_),H(d.id,{sortStack:[...E,_]})}},[d,H,se]),wr=f.useCallback((j,E)=>{var _;if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const W=(_=d.schema)==null?void 0:_.find(G=>G.name===E.column);if(W&&E.value!==void 0){const G=wl(W.type,E.operator,E.value);if(!G.isValid){u(G.errorMessage||"Invalid filter value","error");return}}Bt();try{const G=Le(d.filters),K={...E,id:io()},le=so(G,j,K);se("filters","filter_added",null,K),H(d.id,{filters:le})}catch(G){const K=ur("processing","filters",G);ut(K)}},[d,ee,H,Bt,ut,se]),st=f.useCallback(j=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const E=Le(d.filters),W=so(E,j,_t());se("filters","filter_added",null,"a condition group"),H(d.id,{filters:W})},[d,ee,H,se]),Jt=f.useCallback((j,E)=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const W=Le(d.filters),_=qo(W,j),G=si(W,j,E),K=qo(G,j);se("filters","filter_updated",_,K),H(d.id,{filters:G})},[d,ee,H,se]),It=f.useCallback((j,E)=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const W=Le(d.filters),_=ai(W,j,E);se("filters","filter_updated",null,`group operator changed to ${E.toUpperCase()}`),H(d.id,{filters:_})},[d,ee,H,se]),kr=f.useCallback(j=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const E=Le(d.filters),W=qo(E,j),_=li(E,j);se("filters","filter_removed",W,null),H(d.id,{filters:_})},[d,ee,H,se]),xe=f.useCallback(()=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const j=Le(d.filters);se("filters","filter_cleared",{count:Ct(j)},null),H(d.id,{filters:_t()})},[d,ee,H,se]),Ce=f.useCallback(j=>{if(!d)return;if(!bt("edit_filters",ee)){u(vt("edit_filters"),"error");return}const E=Le(d.filters);se("filters","filter_cleared",{count:Ct(E)},{count:Ct(j)}),H(d.id,{filters:j})},[d,ee,H,se]),Ne=f.useCallback(j=>{var G;if(!d)return;const E=(G=d.views)==null?void 0:G.find(K=>K.id===j);if(!E)return;const W=E.snapshot.columnOrder,_=Co(W,E.snapshot.grouping);se("views","view_switched",{previousViewId:d.activeViewId},{viewId:j,name:E.name}),H(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}),Mt(new Set)},[d,H,se]),nt=f.useCallback((j,E,W)=>{var He;if(!(d!=null&&d.schema)||!be)return;const _=d.views??[],G=_.filter(Pn=>!Pn.isDeleted).length,K=((He=B.views)==null?void 0:He.maxViews)??10;if(G>=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 le={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:$t,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...be}},we=W?_.map(Pn=>({...Pn,isDefault:!1})):_;se("views","view_created",null,{viewId:le.id,name:j,isDefault:W}),H(d.id,{views:[...we,le],activeViewId:le.id}),u(`"${j}" view created`,"success")},[d,be,H,se]),Et=f.useCallback(j=>{var le;if(!(d!=null&&d.views))return;const E=d.views.find(we=>we.id===j);if(!E)return;const W=d.views,_=W.filter(we=>!we.isDeleted).length,G=((le=B.views)==null?void 0:le.maxViews)??10;if(_>=G){u(`View limit reached — you can have at most ${G} saved views. Delete an existing view to create a new one.`,"error");return}const K={...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:$t,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...E.snapshot}};H(d.id,{views:[...W,K]}),u(`"${K.name}" created`,"success")},[d,B,H]),zr=f.useCallback(()=>{var E;if(!Z||!be||!d)return;const j=(E=d.views)==null?void 0:E.map(W=>W.id===Z.id?{...W,snapshot:{...be}}:W);H(d.id,{views:j}),u(`"${Z.name}" view updated`,"success")},[Z,be,d,H]),Lr=f.useCallback(j=>{var _;if(!Z||!be||!d)return;const E=j??be.columnWidths,W=(_=d.views)==null?void 0:_.map(G=>G.id===Z.id?{...G,snapshot:{...G.snapshot,columnVisibility:be.columnVisibility,columnOrder:be.columnOrder,columnWidths:E},updatedAt:Date.now()}:G);H(d.id,{views:W,columnWidths:E}),u(`Column configuration saved to "${Z.name}"`,"success")},[Z,be,d,H]),Fr=f.useCallback(j=>{var K,le;if(!be||!d||!Z)return;const E=j??be.columnWidths,W={...Z,snapshot:{...Z.snapshot,columnVisibility:be.columnVisibility,columnOrder:be.columnOrder,columnWidths:E},updatedAt:Date.now()},_=(K=d.views)==null?void 0:K.map(we=>we.id===Z.id?W:{...we,snapshot:{...we.snapshot,columnVisibility:be.columnVisibility,columnOrder:be.columnOrder,columnWidths:E},updatedAt:Date.now()});H(d.id,{views:_,columnWidths:E});const G=(((le=d.views)==null?void 0:le.length)||0)-1;u(`Column configuration saved to current view and ${G} other view${G===1?"":"s"}`,"success")},[be,d,Z,H]),kn=f.useCallback(()=>{de(!0)},[]),Vr=f.useCallback(()=>{if(!Z||!d)return;const j=Z.snapshot.columnOrder,E=Co(j,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:E,columnWidths:{...Z.snapshot.columnWidths},grouping:Z.snapshot.grouping}),u("Changes reverted to last saved state","success")},[Z,d,H]),fo=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.map(_=>({..._,isDefault:_.id===j}));H(d.id,{views:E});const W=d.views.find(_=>_.id===j);W&&u(`"${W.name}" set as default view`,"success")},[d,H]),zn=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.map(_=>_.id===j?{..._,isFavorite:!_.isFavorite,updatedAt:Date.now()}:_);H(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,H]),_o=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.find(He=>He.id===j),W=d.views.filter(He=>!He.isDeleted||He.id===j);if((E==null?void 0:E.isDefault)&&W.filter(He=>He.isDefault).length===1){u("Cannot delete the last default view","error");return}const G=d.views.map(He=>He.id===j?{...He,isDeleted:!0,updatedAt:Date.now()}:He),K=d.activeViewId===j,le=G.find(He=>He.isDefault&&!He.isDeleted);H(d.id,{views:G,activeViewId:K&&le?le.id:d.activeViewId,filters:K&&le?le.snapshot.filters:d.filters,sortStack:K&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack});const we=d.views.find(He=>He.id===j);we&&u(`"${we.name}" moved to Recently Deleted`,"info")},[d,H]),Hr=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.map(_=>_.id===j?{..._,isDeleted:!1,updatedAt:Date.now()}:_);H(d.id,{views:E});const W=d.views.find(_=>_.id===j);W&&u(`"${W.name}" restored`,"success")},[d,H]),Oo=f.useCallback(j=>{if(!(d!=null&&d.views))return;const E=d.views.find(we=>we.id===j),W=d.views.filter(we=>!we.isDeleted||we.id===j);if((E==null?void 0:E.isDefault)&&W.filter(we=>we.isDefault).length===1){u("Cannot delete the last default view","error");return}const G=d.views.filter(we=>we.id!==j),K=d.activeViewId===j,le=G.find(we=>we.isDefault&&!we.isDeleted);H(d.id,{views:G,activeViewId:K&&le?le.id:d.activeViewId,filters:K&&le?le.snapshot.filters:d.filters,sortStack:K&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack}),E&&u(`"${E.name}" permanently deleted`,"success")},[d,H]),Ur=f.useCallback(j=>{ze(j),Q(!0)},[]),Gr=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 yl(W);u(_?"Link copied to clipboard":"Failed to copy link",_?"success":"error")},[d]),mo=f.useCallback((j,E)=>{if(!ae||!(d!=null&&d.views))return;const W=d.views.map(_=>_.id===ae?{..._,name:j,description:E||void 0}:_);H(d.id,{views:W}),ze(null)},[ae,d,H]),Yr=f.useCallback(j=>{We(j),I(!0)},[]),qr=f.useCallback(()=>{if(!q||!(d!=null&&d.views))return;const j=d.views.find(G=>G.id===q),E=d.views.filter(G=>G.id!==q),W=d.activeViewId===q,_=E.find(G=>G.isDefault);se("views","view_deleted",{viewId:q,name:j==null?void 0:j.name},null),H(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)},[q,d,H,se]),lr=f.useCallback(j=>{var G;if(!(d!=null&&d.views))return;if(!(((G=B.views)==null?void 0:G.isAdmin)??!1)){u("Only administrators can promote views to Global.","error");return}const W=d.views.find(K=>K.id===j);if(!W)return;if(W.scope==="global"){u(`"${W.name}" is already a Global View.`,"info");return}const _=d.views.map(K=>K.id===j?{...K,scope:"global",isDefault:!0,updatedAt:Date.now()}:K.scope==="global"&&K.isDefault?{...K,isDefault:!1}:K);H(d.id,{views:_}),u(`"${W.name}" promoted to Global View and set as default.`,"success")},[d,B,H]),xo=f.useRef(!0);f.useEffect(()=>{var j;if(xo.current){xo.current=!1;return}if(b==="server"){Qe(1),(j=a==null?void 0:a.onPaginationChange)==null||j.call(a,1,Ze);return}ve!=null&&ve.resetPage?ve.resetPage():Qe(1)},[d==null?void 0:d.filters,Tt,d==null?void 0:d.activeViewId,d==null?void 0:d.grouping]);const Jr=f.useCallback(j=>{var E;if(b==="server"){Qe(j),(E=a==null?void 0:a.onPaginationChange)==null||E.call(a,j,Ze);return}ve!=null&&ve.goToPage&&ve.goToPage(j),Qe(j)},[b,a,Ze,ve]),Tn=f.useCallback(j=>{var _;const E=(Vt-1)*Ze,W=Math.floor(E/j)+1;if(b==="server"){Wt(j),Qe(W),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,W,j);return}Wt(j),Qe(W),ve==null||ve.goToPage(W)},[Vt,Ze,b,a,ve]),Bn=f.useCallback((j,E)=>{if(!d)return;if(!bt("edit_columns",ee)){u(vt("edit_columns"),"error");return}const _={...d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{},[j]:E};se("columns",E?"column_shown":"column_hidden",{columnName:j,visible:!E},{columnName:j,visible:E}),H(d.id,{columnVisibility:_})},[d,Z,ee,H,se]),In=f.useCallback(j=>{if(d){if(!bt("edit_columns",ee)){u(vt("edit_columns"),"error");return}se("columns","column_reordered",d.columnOrder,j),H(d.id,{columnOrder:j})}},[d,ee,H,se]),En=f.useCallback((j,E)=>{if(!d)return;if(!bt("edit_columns",ee)){u(vt("edit_columns"),"error");return}const W=d.columnWidths||(Z==null?void 0:Z.snapshot.columnWidths)||{},_={...W,[j]:E};se("columns","column_resized",{columnName:j,width:W[j]},{columnName:j,width:E}),H(d.id,{columnWidths:_})},[d,Z,ee,H,se]),Dn=f.useCallback(j=>{if(!d)return;const E=Le(d.filters),W=zs(E,j);H(d.id,{filters:W})},[d,H]),$n=f.useCallback(()=>{if(!Z||!(d!=null&&d.schema))return;const j={},E=[],W={};d.schema.forEach(_=>{j[_.name]=!0,E.push(_.name),W[_.name]=170}),H(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")},[Z,d,H]);f.useEffect(()=>{const j=setTimeout(()=>mr(rr),300);return()=>clearTimeout(j)},[rr]),f.useEffect(()=>{var j;m==="server"&&((j=c==null?void 0:c.onSearchChange)==null||j.call(c,Tt))},[Tt,m,c]);const _n=f.useCallback(j=>{lo(j),Qe(1)},[]),On=f.useCallback(j=>{if(!j.trim()||!d)return;const E=d.searchHistory||[],W=Xa(E,j);H(d.id,{searchHistory:W})},[d,H]),Mn=f.useCallback(j=>{if(!d)return;const E=d.searchHistory||[],W=Qa(E,j);H(d.id,{searchHistory:W})},[d,H]),Kr=f.useCallback(j=>{if(!d)return;const E=d.searchHistory||[],W=Za(E,j);H(d.id,{searchHistory:W})},[d,H]);f.useEffect(()=>{if(!S.onSelectionChange)return;const j=Array.from(Je);S.onSelectionChange(j,j.map(E=>E==null?void 0:E.__urm_row_id__))},[Je,S.onSelectionChange]);const Kt=f.useCallback(j=>{const E=j==null?void 0:j.__urm_row_id__;Mt(W=>{const _=new Set(W);if(E!==void 0){const G=Array.from(_).find(K=>(K==null?void 0:K.__urm_row_id__)===E);G!==void 0?_.delete(G):_.add(j)}else{const G=JSON.stringify(j),K=Array.from(_).find(le=>JSON.stringify(le)===G);K!==void 0?_.delete(K):_.add(j)}return _})},[]),Wn=f.useCallback((j,E)=>{Mt(W=>{const _=new Set(W);for(const G of E)j?_.add(G):_.delete(G);return _})},[]),An=f.useCallback((j,E,W)=>{Mt(_=>{const G=new Set(_),K=Math.min(j,E),le=Math.max(j,E);for(let we=K;we<=le;we++)W[we]!==void 0&&G.add(W[we]);return G})},[]),Me=f.useCallback(()=>{Mt(new Set)},[]),at=f.useCallback(j=>{const E=j==null?void 0:j.__urm_row_id__;Mt(W=>{const _=new Set(W);if(E!==void 0){const G=Array.from(_).find(K=>(K==null?void 0:K.__urm_row_id__)===E);G!==void 0&&_.delete(G)}else _.delete(j);return _})},[]),go=f.useCallback(j=>{var E,W;if(d){if(!bt("edit_columns",ee)){u(vt("edit_columns"),"error");return}if(j&&d.schema){const{validGrouping:_,invalidColumns:G}=$s(j,d.schema);G.length>0&&u(`Removed invalid grouping columns: ${G.join(", ")}`,"warning"),Bt();try{const K=d.grouping;_===null?se("grouping","group_cleared",K,null):K?se("grouping","group_reordered",K,_):se("grouping","group_level_added",null,_);const le=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[],we=Co(le,_),He=_.levels.length>0?{..._,collapsedGroups:zi(Gt,d.schema,_)}:_;H(d.id,{grouping:He,columnOrder:we}),Qe(1),ve==null||ve.resetPage(),b==="server"&&((E=a==null?void 0:a.onPaginationChange)==null||E.call(a,1,Ze)),JSON.stringify(we)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,we),xt(!1)}catch(K){const le=ur("processing","grouping",K);ut(le)}}else{const _=d.grouping;se("grouping","group_cleared",_,null);const G=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[];H(d.id,{grouping:j,columnOrder:G}),Qe(1),ve==null||ve.resetPage(),b==="server"&&((W=a==null?void 0:a.onPaginationChange)==null||W.call(a,1,Ze)),JSON.stringify(G)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,G),xt(!1)}}},[d,Z,ee,H,Bt,ut,se,Gt]),Mo=f.useCallback(j=>{if(!d)return;const E=d.grouping;if(!E)return;const W=Fa(E,j);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 j=zi(Gt,d.schema,d.grouping);H(d.id,{grouping:{...d.grouping,collapsedGroups:j}})},[d,Gt,H]),Tr=f.useCallback(()=>{Ht(!0)},[]),pt=f.useCallback(j=>{d!=null&&d.schema&&(dt(!0),setTimeout(()=>{try{let E;j.scope==="visible"?E=Ut:E=d.uploadedData||[];let W;j.columnScope==="all"?(W={},(d.schema??[]).forEach(we=>{W[we.name]=!0})):W=d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{};const _=d.columnOrder||(Z==null?void 0:Z.snapshot.columnOrder),G=Qo(E,d.schema,Le(d.filters),d.sortStack??[],Z,W,_),K=d.name;let le;switch(j.format){case"csv":Zo(G,K,j),le="export_csv";break;case"excel":en(G,K,j),le="export_excel";break;case"json":tn(G,K,j),le="export_json";break;case"pdf":ui(G,K,j),le="export_pdf";break}se("export",le,null,{format:j.format,scope:j.scope,columnScope:j.columnScope,rowCount:E.length,viewName:(Z==null?void 0:Z.name)||"Default View"}),u(`Export completed successfully (${j.format.toUpperCase()})`,"success")}catch(E){const W=zl(E,{onRetry:()=>pt(j)});u(`Export failed: ${W.message}. Click Export to retry.`,"error");const _=Oi(d.id,$t,W,d.auditHistory||[]);H(d.id,{auditHistory:_}),Lt.error("urm:report-engine","Export failed",E)}finally{dt(!1)}},500))},[d,Z,Ut,H,se]),Wo=f.useCallback(j=>{if(d!=null&&d.schema){if(he&&Z&&!Z.isDefault){Ft(j.format),Ot(!0),Ht(!1);return}pt(j),Ht(!1)}},[d,Z,he,pt]),Xr=f.useCallback(j=>{pt({format:j,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(j=>{!(d!=null&&d.schema)||Je.size===0||(dt(!0),setTimeout(()=>{try{const E=Array.from(Je),W=Qo(E,d.schema,Le(d.filters),d.sortStack??[],Z),_=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(j){case"csv":Zo(W,_);break;case"excel":en(W,_);break;case"json":tn(W,_);break}u(`Exported ${E.length} selected rows`,"info")}catch(E){u("Export failed. Please try again.","error"),Lt.error("urm:report-engine","Bulk export failed",E)}finally{dt(!1)}},500))},[d,Z,Je,Sr]),oe=f.useCallback((j,E)=>{if(d)try{const W=pl(d),_=hl(j,E,$t,W),G=fl(d.presets,_);H(d.id,{presets:G}),se("presets","preset_created",null,{presetId:_.id,name:_.name}),Ve(!1),u(`Preset "${j}" saved successfully`,"success")}catch(W){u(W instanceof Error?W.message:"Failed to create preset","error")}},[d,H,se]),je=f.useCallback(()=>{gr(null),u("Exited preset view","info")},[]),Ae=f.useCallback(()=>{or(!0)},[]),rt=f.useCallback((j,E)=>{if(!d)return;const W=ml(d.presets,j);H(d.id,{presets:W}),se("presets","preset_deleted",{presetId:j,name:E},null),At===j&&gr(null),u(`Preset "${E}" deleted`,"success")},[d,At,H,se]);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 Xe=f.useRef(!1);f.useEffect(()=>{var E;if(!g||Xe.current||!d||d.id!==y)return;const j=(E=d.views)==null?void 0:E.find(W=>W.id===g&&!W.isDeleted);j&&Ne(j.id),Xe.current=!0},[g,y,d,Ne]),f.useEffect(()=>{if(!d)return;const j=xl();if(j&&d.presets&&d.schemaLocked&&d.schema){const E=_i(d.presets,j);if(E){const{sanitizedConfig:W,warnings:_}=kl(E.config,d.schema);_.length>0&&_.forEach(K=>u(K,"warning"));const G=gl(W);H(d.id,G),gr(j),se("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 me=At?_i(d==null?void 0:d.presets,At):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):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 j=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(j&&j.views.length>0){const E=j.views.find(W=>W.id===j.activeViewId);if(E)H(d.id,{views:j.views,activeViewId:j.activeViewId,filters:Le(E.snapshot.filters),sortStack:E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0});else{const W=j.views.find(_=>_.isDefault)||Nn(d.schema);H(d.id,{views:j.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(j=>{var _;const E=Le(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),ge(!0)},[d,B,u]),Xt=f.useCallback(()=>{ge(!1),fe(void 0)},[]),_e=(vi=d==null?void 0:d.views)==null?void 0:vi.find(j=>j.id===ae),cr=(Si=d==null?void 0:d.views)==null?void 0:Si.find(j=>j.id===q);return{reports:z,activeReport:d,activeReportId:T,setActiveReportId:w,isModalOpen:P,setIsModalOpen:O,createReport:jr,updateReport:H,uploadState:ne,handleFileUpload:po,handleUploadError:Rr,handleRetry:ho,handleConfirm:qt,paginatedData:uo,processedData:Ut,displayData:Sr,tableMetrics:ar,isGrouped:Yt,tableEngine:vr,activeView:Z,isDirty:he,currentTableState:be,viewChanges:Cr,filters:d==null?void 0:d.filters,showFilterPanel:re,setShowFilterPanel:ge,filterFocusColumn:te,handleAddCondition:wr,handleAddGroup:st,handleUpdateCondition:Jt,handleSetGroupOperator:It,handleRemoveFilterNode:kr,handleClearAllFilters:xe,handleReplaceFilters:Ce,handleOpenFilterForColumn:Rt,handleCloseFilterPanel:Xt,handleClearFiltersForColumn:Dn,sortStack:d==null?void 0:d.sortStack,showSortPanel:V,setShowSortPanel:X,handleSort:Pr,handleUpdateSortStack:Nr,handleSortAscending:Se,handleSortDescending:Ge,views:d==null?void 0:d.views,showCreateViewModal:ce,setShowCreateViewModal:de,showEditViewModal:ie,setShowEditViewModal:Q,showDeleteConfirmation:pe,setShowDeleteConfirmation:I,editingView:_e,deletingView:cr,editingViewId:ae,deletingViewId:q,handleSelectView:Ne,handleCreateView:nt,handleCloneView:Et,handleUpdateCurrentView:zr,handleSaveColumnConfigToCurrentView:Lr,handleSaveColumnConfigToAllViews:Fr,handleSaveAsNewView:kn,handleRevertChanges:Vr,handleToggleDefault:fo,handleToggleFavorite:zn,handleSoftDelete:_o,handleRestoreView:Hr,handlePermanentDelete:Oo,handleEditView:Ur,handleCopyViewLink:Gr,handleSaveEditView:mo,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:go,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:Ze,paginationEngine:ve,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:co,setShowAuditHistory:Mr,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:xr,setShowCreatePreset:Ve,showManagePresets:ke,setShowManagePresets:or,activePreset:me,activePresetId:At,handleOpenManagePresets:Ae,handleCreatePreset:oe,handleClearActivePreset:je,handleDeletePresetById:rt,userRole:ee,isViewerRole:br,currentUserId:$t,featureLimitWarning:nr,setFeatureLimitWarning:et,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:J,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,w]=f.useState(()=>xa()),P=(()=>{const J=ya(T,S,!!S);return{...J,display:{...J.display,showDevPanel:k||J.display.showDevPanel}}})(),O=f.useCallback(Y=>{w(Y),ga(Y)},[]),M={...B,activeDevConfig:P,handleDevConfigChange:O};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 y=document.createElement("iframe");y.style.position="fixed",y.style.right="0",y.style.bottom="0",y.style.width="0",y.style.height="0",y.style.border="0",document.body.appendChild(y);const w=((b=y.contentWindow)==null?void 0:b.document)||y.contentDocument;if(w){w.open(),w.write(f),w.close(),setTimeout(()=>{var m,j;try{(m=y.contentWindow)==null||m.focus(),(j=y.contentWindow)==null||j.print()}catch{}setTimeout(()=>{document.body.removeChild(y)},3e3)},300);return}}catch{}const v=new Blob([f],{type:"text/html;charset=utf-8;"}),S=URL.createObjectURL(v);window.open(S,"_blank")||hi(f,dn(r,"html"),"text/html;charset=utf-8;")}function Vo(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Di=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>Di&&(s=[...s].sort((c,l)=>c.isFavourite&&!l.isFavourite?-1:!c.isFavourite&&l.isFavourite?1:l.lastUsed-c.lastUsed).slice(0,Di)),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 St(e,r){return tl[r].includes(e)}function Ct(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 _i=1e3;function ti(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Ft(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return ti(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=Ft(e.column),n=nl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function Hn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":il(e):"a filter"}function $i(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${Ft(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: ${Hn(i)}`};case"filter_removed":return{summary:`Filter removed: ${Hn(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 "${Ft(p.column)}"`,detail:`Previously filtered "${Ft(l.column)}"`}:{summary:`Filter updated: ${Hn(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?Ft(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?Ft(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?Ft(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: "${Ft(l)}"`:"Column hidden"}}case"column_shown":{const l=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:l?`Column shown: "${Ft(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: "${Ft(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",g=(i==null?void 0:i.viewName)??"",f=typeof p=="number"?` (${p.toLocaleString()} rows)`:"";return{summary:`Exported as ${l}${f}`,detail:g?`${ti(x)} · View: "${g}"`:ti(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"row_edited":{const l=(i==null?void 0:i.id)??(n==null?void 0:n.id)??"",p=(i==null?void 0:i.label)??(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:p?`Row edited: "${p}"`:"Row edited"}}case"row_deleted":{const l=(n==null?void 0:n.id)??"",p=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:p?`Row deleted: "${p}"`:"Row deleted"}}case"row_duplicated":{const l=(n==null?void 0:n.id)??"",p=(n==null?void 0:n.label)??(l?`#${l}`:"");return{summary:p?`Row duplicated: "${p}"`:"Row duplicated"}}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 ko(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 zo(e,r){const n=[r,...e];return n.length>_i?n.slice(0,_i):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",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",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",rows:"Rows",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 Oi=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=pi(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 hl(e,r,n,i){return{id:ul(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function ml(e,r){const n=e||[];if(n.length>=Oi)throw new Error(`Maximum of ${Oi} presets reached. Please delete old presets first.`);return[...n,r]}function fl(e,r){return(e||[]).filter(i=>i.id!==r)}function Mi(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=So(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 yl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Vt.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){Vt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Vt.error("urm:presets","Fallback copy method failed",r),!1}}function bl(e,r){return{totalRows:e.length,totalColumns:r.length}}function mr(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"&&Vt.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 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 jl(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(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}=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 mr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Wi(e,r,n,i){const s=ko(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return zo(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).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 ri(e,r,n){var s;if(qe(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>ri(e,a,n)):r.children.some(a=>ri(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=>ri(i,r,n))}function nn(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:h.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:h.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:h.useMemo(()=>!r||r.length===0?e:Wa(e,n,r),[e,r,n])}}function Ml({data:e,grouping:r,schema:n}){const i=h.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=h.useMemo(()=>n.filter(l=>r[l]!==!1),[n,r]),s=h.useMemo(()=>Object.entries(r).filter(([l,p])=>!p).map(([l,p])=>l),[r]),a=h.useMemo(()=>n.map(l=>e.find(x=>x.name===l)||{name:l,type:"string"}),[n,e]),c=h.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=h.useMemo(()=>e.find(x=>x.id===r),[e,r]),s=h.useMemo(()=>i?Ua(n,i.snapshot):!1,[i,n]),a=h.useMemo(()=>e.find(x=>x.isDefault),[e]),c=h.useMemo(()=>e.filter(x=>!x.isDefault&&!x.isDeleted),[e]),l=h.useMemo(()=>e.filter(x=>x.isFavorite&&!x.isDeleted),[e]),p=h.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 f=r-1;f>=0;f--){const v=e[f];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 g=[];for(let f=0;f<=l;f++)p[f]&&g.push({...p[f],__urm_is_continuation_header__:!0});return[...g,...i]}function Pl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=h.useState(i),c=e.length,l=Math.max(1,Math.ceil(c/n));h.useEffect(()=>{s>l&&a(l)},[s,l]);const p=h.useMemo(()=>{if(!r)return e;const S=(s-1)*n,B=S+n;return Rl(e,S,B)},[e,r,s,n]),x=h.useCallback(S=>{const B=Math.max(1,Math.min(S,l));a(B)},[l]),g=h.useCallback(()=>{s<l&&a(S=>Math.min(S+1,l))},[l]),f=h.useCallback(()=>{s>1&&a(S=>Math.max(S-1,1))},[]),v=h.useCallback(()=>{a(1)},[]);return{paginatedData:p,currentPage:s,totalPages:l,pageSize:n,totalRows:c,goToPage:x,nextPage:g,prevPage:f,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:g,views:f,activeViewId:v,pagination:S}=e,B=h.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:p,columnOrder:x,columnWidths:g}),[i,s,a,p,x,g]),b=Al({views:f,activeViewId:v,currentState:B}),y=Wl({schema:n,columnVisibility:p,columnOrder:x}),{filteredData:w}=Dl({data:r,filters:i,schema:n}),{sortedData:m}=Ol({data:w,sortStack:s,schema:n}),{groupedData:j,isGrouped:I}=Ml({data:m,grouping:a,schema:n}),{searchedData:k}=$l({data:j,searchQuery:c,schema:n,visibleColumns:y.visibleColumns,mode:l}),P=Pl({data:k,enabled:(S==null?void 0:S.enabled)||!1,pageSize:(S==null?void 0:S.pageSize)||100,initialPage:(S==null?void 0:S.currentPage)||1}),J=S!=null&&S.enabled?P.paginatedData:k,T=h.useMemo(()=>({totalRows:r.length,filteredRows:w.length,sortedRows:m.length,groupedRows:I?j.length:m.length,searchedRows:k.length,visibleRows:J.length,hiddenColumns:y.hiddenCount,activeFilters:jt(i),activeSorts:s.length,isGrouped:I}),[r.length,w.length,m.length,j.length,k.length,J.length,y.hiddenCount,i,s.length,I]);return{data:J,filteredData:w,sortedData:m,groupedData:j,searchedData:k,viewEngine:b,columnEngine:y,paginationEngine:P,metrics:T,isGrouped:I,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 ct,Lo,Si,Ci,wi;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:c,scheduler:l,reportName:p,reportId:x,sharedReportId:g,sharedViewId:f,viewPersistence:v,config:S={}}=e,B=(v==null?void 0:v.mode)??"local",b=(a==null?void 0:a.mode)??"client",y=(c==null?void 0:c.mode)??"client",[w,m]=h.useState([]),j=$r(),[I,k]=h.useState(""),[P,J]=h.useState(!1),[T,F]=h.useState(!1),[K,M]=h.useState({message:"",severity:"info",open:!1}),u=(z,D="info")=>{M({message:z,severity:D,open:!0})},A=()=>M(z=>({...z,open:!1})),L=S.notifDurationMs??2e3,d=w.find(z=>z.id===I),[ne,U]=h.useState("idle"),[re,ge]=h.useState(!1),[V,X]=h.useState(!1),[ce,de]=h.useState(!1),[ie,Q]=h.useState(!1),[pe,E]=h.useState(!1),[te,fe]=h.useState(void 0),[ae,Te]=h.useState(null),[Y,Ae]=h.useState(null),[Tt,ut]=h.useState(!1),[Wr,Ot]=h.useState(!1),[nt,Ht]=h.useState(null),[Je,Bt]=h.useState(!1),[gr,gt]=h.useState(!1),[sr,ao]=h.useState({enabled:!1,levels:[],collapsedGroups:[]}),[ar,lo]=h.useState(""),[It,yr]=h.useState(""),[Ke,Mt]=h.useState(new Set),[Ut,Qe]=h.useState(1),[Ze,Wt]=h.useState(15),[co,Ar]=h.useState(!1),[br,Fe]=h.useState(!1),[ze,lr]=h.useState(!1),[At,vr]=h.useState(null),[Sr,Gt]=h.useState(!1),[cr,et]=h.useState(null),[dr,yt]=h.useState(null),Rr=h.useRef(null),ee=h.useMemo(()=>d?rl(d.permissions,_t):"owner",[d]),Cr=ol(ee),Pr=h.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]),Et=h.useCallback(()=>{d&&(Rr.current=Cl(d))},[d]),H=h.useCallback((z,D)=>{m(W=>W.map(O=>O.id===z?{...O,...D}:O))},[]),pt=h.useCallback(z=>{if(!d)return;yt(z);const D=Wi(d.id,_t,z,d.auditHistory||[]);H(d.id,{auditHistory:D}),u(z.message,"error"),z.recoverable&&Rr.current&&setTimeout(()=>{wl(d,Rr.current,H),u("Previous state restored","success")},100)},[d,H]),se=h.useCallback((z,D,W,O)=>{if(!d)return;const G=ko(d.id,_t,z,D,W,O),q=d.auditHistory||[],le=zo(q,G);setTimeout(()=>{H(d.id,{auditHistory:le})},0)},[d,H]);h.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const z=Vn(d.schema);(()=>{try{const D=localStorage.getItem("urm_dev_config");return D?JSON.parse(D):null}catch{return null}})(),H(d.id,{views:[z],activeViewId:z.id,filters:z.snapshot.filters,sortStack:z.snapshot.sortStack,columnVisibility:z.snapshot.columnVisibility,columnOrder:z.snapshot.columnOrder,columnWidths:z.snapshot.columnWidths,grouping:z.snapshot.grouping})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,H]),h.useEffect(()=>{if(i&&n&&!T&&w.length===0){const z=oo(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:z,schema:zi(go(z),S.hiddenColumns),permissions:{owner:_t,editors:[],viewers:[]}};m([D]),k(D.id),F(!0),U("confirmed")}},[i,n,T,w.length,r,p,x]),h.useEffect(()=>{b!=="server"||!T||!I||H(I,{uploadedData:oo(i||[])})},[i,b,T,I]),h.useEffect(()=>{b==="server"&&((a==null?void 0:a.page)!==void 0&&Qe(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]),h.useEffect(()=>{if(!s||T)return;let z=!1,D=null;const W=async()=>{try{U("uploading");let O;if(s.type==="api"){const q=await fetch(s.url,{headers:s.headers||{}});if(!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);O=await q.json()}else O=await s.fetch();if(z)return;if(!Array.isArray(O))throw new Error("Data source must return an array of objects");const G=go(O);if(T)m(q=>q.map(le=>le.id===I?{...le,uploadedData:oo(O)}:le)),U("confirmed");else{const q={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:oo(O),schema:zi(go(oo(O)),S.hiddenColumns),permissions:{owner:_t,editors:[],viewers:[]}};m([q]),k(q.id),F(!0),U("confirmed")}}catch(O){z||(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)),()=>{z=!0,D&&clearInterval(D)}},[s,p,r,x]);const Xe=(ct=d==null?void 0:d.views)==null?void 0:ct.find(z=>z.id===d.activeViewId),ur=h.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(z=>Fl(z,S.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);h.useEffect(()=>{Mt(z=>{if(z.size===0)return z;const D=new Set(ur.map(O=>O==null?void 0:O.__urm_row_id__)),W=new Set(Array.from(z).filter(O=>D.has(O==null?void 0:O.__urm_row_id__)));return W.size===z.size?z:W})},[ur]);const wr=Nl({rawData:ur,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:It||"",searchMode:y,columnVisibility:(d==null?void 0:d.columnVisibility)||(Xe==null?void 0:Xe.snapshot.columnVisibility)||{},columnOrder:(d==null?void 0:d.columnOrder)||(Xe==null?void 0:Xe.snapshot.columnOrder)||[],columnWidths:(d==null?void 0:d.columnWidths)||(Xe==null?void 0:Xe.snapshot.columnWidths)||{},views:(d==null?void 0:d.views)||[],activeViewId:(d==null?void 0:d.activeViewId)||"",pagination:{enabled:b==="client",pageSize:Ze,currentPage:Ut}}),{data:uo=[],searchedData:Yt=[],groupedData:jr=[],sortedData:qt=[],metrics:pr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Jt=!1,paginationEngine:Ce}=wr||{},bt=b==="server"?(a==null?void 0:a.totalRows)??0:pr.searchedRows,Z=((Lo=wr.viewEngine)==null?void 0:Lo.activeView)||Xe,he=((Si=wr.viewEngine)==null?void 0:Si.isDirty)||!1;h.useEffect(()=>{if(!(!Z||!d)&&!d.columnOrder){const z=Z.snapshot.columnOrder,D=So(z,Z.snapshot.grouping);H(d.id,{columnOrder:D})}},[d==null?void 0:d.activeViewId]);const Se=h.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]),kr=h.useMemo(()=>!Z||!Se||!he?[]:Ya(Se,Z.snapshot),[Z,Se,he]),zr=h.useCallback((z,D,W)=>{const O={id:`report-${Date.now()}`,name:z,description:D,schemaLocked:!1,permissions:{owner:_t,editors:[],viewers:[]}};if(W&&Array.isArray(W)&&W.length>0){const G=go(W),q=Vn(G);O.uploadedData=W,O.schema=G,O.schemaLocked=!0,O.views=[q],O.activeViewId=q.id,O.sortStack=q.snapshot.sortStack,O.filters=q.snapshot.filters,O.columnVisibility=q.snapshot.columnVisibility,O.columnOrder=q.snapshot.columnOrder,O.columnWidths=q.snapshot.columnWidths,O.grouping=q.snapshot.grouping}m(G=>[...G,O]),k(O.id),J(!1),U("confirmed")},[]),po=h.useCallback(z=>{d&&(U("uploading"),setTimeout(()=>{const D=go(z);H(d.id,{uploadedData:z,schema:D,uploadError:void 0}),U("preview")},500))},[d,H]),Nr=h.useCallback(z=>{d&&(H(d.id,{uploadError:z}),U("idle"))},[d,H]),ho=h.useCallback(()=>{d&&(H(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),U("idle"))},[d,H]),Kt=h.useCallback(()=>{d&&(H(d.id,{schemaLocked:!0}),U("confirmed"))},[d,H]),Lr=h.useCallback(z=>{if(!d)return;if(!St("edit_sorting",ee)){u(Ct("edit_sorting"),"error");return}const D=d.sortStack??[],W=D.find(O=>O.column===z);if(W){const O=Aa(W.direction);if(O===null){const G=D.filter(q=>q.column!==z).map((q,le)=>({...q,priority:le+1}));se("sorting","sort_level_removed",W,null),H(d.id,{sortStack:G.length>0?G:void 0})}else{const G=O,q=D.map(le=>le.column===z?{...le,direction:G}:le);se("sorting","sort_reordered",{column:z,direction:W.direction},{column:z,direction:G}),H(d.id,{sortStack:q})}}else{if(D.length>=j.sort.maxLevels){u(`Sort limit reached — maximum ${j.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:z,direction:"asc",priority:D.length+1};se("sorting","sort_level_added",null,O),H(d.id,{sortStack:[...D,O]})}},[d,ee,H,se]),Fr=h.useCallback(z=>{if(!d)return;const D=d.sortStack??[],W=z.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:O,invalidColumns:G}=Ds(z,d.schema);G.length>0&&u(`Removed invalid sort columns: ${G.join(", ")}`),Et();try{se("sorting",W,D,O.length>0?O:null),H(d.id,{sortStack:O.length>0?O:void 0})}catch(q){const le=mr("processing","sorting",q);pt(le)}}else se("sorting",W,D,z.length>0?z:null),H(d.id,{sortStack:z.length>0?z:void 0})},[d,H,Et,pt,se]),be=h.useCallback(z=>{if(!d)return;const D=d.sortStack??[],W=D.find(O=>O.column===z);if(!(W&&W.direction==="asc"))if(W){const O=D.map(G=>G.column===z?{...G,direction:"asc"}:G);se("sorting","sort_reordered",{column:z,direction:W.direction},{column:z,direction:"asc"}),H(d.id,{sortStack:O})}else{if(D.length>=j.sort.maxLevels){u(`Sort limit reached — maximum ${j.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:z,direction:"asc",priority:D.length+1};se("sorting","sort_level_added",null,O),H(d.id,{sortStack:[...D,O]})}},[d,H,se]),Ge=h.useCallback(z=>{if(!d)return;const D=d.sortStack??[],W=D.find(O=>O.column===z);if(!(W&&W.direction==="desc"))if(W){const O=D.map(G=>G.column===z?{...G,direction:"desc"}:G);se("sorting","sort_reordered",{column:z,direction:W.direction},{column:z,direction:"desc"}),H(d.id,{sortStack:O})}else{if(D.length>=j.sort.maxLevels){u(`Sort limit reached — maximum ${j.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:z,direction:"desc",priority:D.length+1};se("sorting","sort_level_added",null,O),H(d.id,{sortStack:[...D,O]})}},[d,H,se]),Tr=h.useCallback((z,D)=>{var O;if(!d)return;if(!St("edit_filters",ee)){u(Ct("edit_filters"),"error");return}const W=(O=d.schema)==null?void 0:O.find(G=>G.name===D.column);if(W&&D.value!==void 0){const G=jl(W.type,D.operator,D.value);if(!G.isValid){u(G.errorMessage||"Invalid filter value","error");return}}Et();try{const G=Ne(d.filters),q={...D,id:io()},le=so(G,z,q);se("filters","filter_added",null,q),H(d.id,{filters:le})}catch(G){const q=mr("processing","filters",G);pt(q)}},[d,ee,H,Et,pt,se]),lt=h.useCallback(z=>{if(!d)return;if(!St("edit_filters",ee)){u(Ct("edit_filters"),"error");return}const D=Ne(d.filters),W=so(D,z,$t());se("filters","filter_added",null,"a condition group"),H(d.id,{filters:W})},[d,ee,H,se]),Xt=h.useCallback((z,D)=>{if(!d)return;if(!St("edit_filters",ee)){u(Ct("edit_filters"),"error");return}const W=Ne(d.filters),O=Ko(W,z),G=ci(W,z,D),q=Ko(G,z);se("filters","filter_updated",O,q),H(d.id,{filters:G})},[d,ee,H,se]),Dt=h.useCallback((z,D)=>{if(!d)return;if(!St("edit_filters",ee)){u(Ct("edit_filters"),"error");return}const W=Ne(d.filters),O=di(W,z,D);se("filters","filter_updated",null,`group operator changed to ${D.toUpperCase()}`),H(d.id,{filters:O})},[d,ee,H,se]),Br=h.useCallback(z=>{if(!d)return;if(!St("edit_filters",ee)){u(Ct("edit_filters"),"error");return}const D=Ne(d.filters),W=Ko(D,z),O=ui(D,z);se("filters","filter_removed",W,null),H(d.id,{filters:O})},[d,ee,H,se]),xe=h.useCallback(()=>{if(!d)return;if(!St("edit_filters",ee)){u(Ct("edit_filters"),"error");return}const z=Ne(d.filters);se("filters","filter_cleared",{count:jt(z)},null),H(d.id,{filters:$t()})},[d,ee,H,se]),ve=h.useCallback(z=>{if(!d)return;if(!St("edit_filters",ee)){u(Ct("edit_filters"),"error");return}const D=Ne(d.filters);se("filters","filter_cleared",{count:jt(D)},{count:jt(z)}),H(d.id,{filters:z})},[d,ee,H,se]),Ve=h.useCallback(z=>{var G;if(!d)return;const D=(G=d.views)==null?void 0:G.find(q=>q.id===z);if(!D)return;const W=D.snapshot.columnOrder,O=So(W,D.snapshot.grouping);se("views","view_switched",{previousViewId:d.activeViewId},{viewId:z,name:D.name}),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:z}),Mt(new Set)},[d,H,se]),Ye=h.useCallback((z,D,W)=>{var He;if(!(d!=null&&d.schema)||!Se)return;const O=d.views??[],G=O.filter(Fn=>!Fn.isDeleted).length,q=((He=j.views)==null?void 0:He.maxViews)??10;if(G>=q){u(`View limit reached — you can have at most ${q} saved views. Delete an existing view to create a new one.`,"error");return}const le={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:z,description:D||void 0,isDefault:W,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:_t,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Se}},we=W?O.map(Fn=>({...Fn,isDefault:!1})):O;se("views","view_created",null,{viewId:le.id,name:z,isDefault:W}),H(d.id,{views:[...we,le],activeViewId:le.id}),u(`"${z}" view created`,"success")},[d,Se,H,se]),ht=h.useCallback(z=>{var le;if(!(d!=null&&d.views))return;const D=d.views.find(we=>we.id===z);if(!D)return;const W=d.views,O=W.filter(we=>!we.isDeleted).length,G=((le=j.views)==null?void 0:le.maxViews)??10;if(O>=G){u(`View limit reached — you can have at most ${G} saved views. Delete an existing view to create a new one.`,"error");return}const q={...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,q]}),u(`"${q.name}" created`,"success")},[d,j,H]),vt=h.useCallback(()=>{var D;if(!Z||!Se||!d)return;const z=(D=d.views)==null?void 0:D.map(W=>W.id===Z.id?{...W,snapshot:{...Se}}:W);H(d.id,{views:z}),u(`"${Z.name}" view updated`,"success")},[Z,Se,d,H]),Rt=h.useCallback(z=>{var O;if(!Z||!Se||!d)return;const D=z??Se.columnWidths,W=(O=d.views)==null?void 0:O.map(G=>G.id===Z.id?{...G,snapshot:{...G.snapshot,columnVisibility:Se.columnVisibility,columnOrder:Se.columnOrder,columnWidths:D},updatedAt:Date.now()}:G);H(d.id,{views:W,columnWidths:D}),u(`Column configuration saved to "${Z.name}"`,"success")},[Z,Se,d,H]),Vr=h.useCallback(z=>{var q,le;if(!Se||!d||!Z)return;const D=z??Se.columnWidths,W={...Z,snapshot:{...Z.snapshot,columnVisibility:Se.columnVisibility,columnOrder:Se.columnOrder,columnWidths:D},updatedAt:Date.now()},O=(q=d.views)==null?void 0:q.map(we=>we.id===Z.id?W:{...we,snapshot:{...we.snapshot,columnVisibility:Se.columnVisibility,columnOrder:Se.columnOrder,columnWidths:D},updatedAt:Date.now()});H(d.id,{views:O,columnWidths:D});const G=(((le=d.views)==null?void 0:le.length)||0)-1;u(`Column configuration saved to current view and ${G} other view${G===1?"":"s"}`,"success")},[Se,d,Z,H]),Tn=h.useCallback(()=>{de(!0)},[]),Hr=h.useCallback(()=>{if(!Z||!d)return;const z=Z.snapshot.columnOrder,D=So(z,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]),mo=h.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.map(O=>({...O,isDefault:O.id===z}));H(d.id,{views:D});const W=d.views.find(O=>O.id===z);W&&u(`"${W.name}" set as default view`,"success")},[d,H]),Bn=h.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.map(O=>O.id===z?{...O,isFavorite:!O.isFavorite,updatedAt:Date.now()}:O);H(d.id,{views:D});const W=d.views.find(O=>O.id===z);W&&!W.isFavorite?u(`"${W.name}" added to favorites`,"success"):W&&u(`"${W.name}" removed from favorites`,"info")},[d,H]),Oo=h.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.find(He=>He.id===z),W=d.views.filter(He=>!He.isDeleted||He.id===z);if((D==null?void 0:D.isDefault)&&W.filter(He=>He.isDefault).length===1){u("Cannot delete the last default view","error");return}const G=d.views.map(He=>He.id===z?{...He,isDeleted:!0,updatedAt:Date.now()}:He),q=d.activeViewId===z,le=G.find(He=>He.isDefault&&!He.isDeleted);H(d.id,{views:G,activeViewId:q&&le?le.id:d.activeViewId,filters:q&&le?le.snapshot.filters:d.filters,sortStack:q&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack});const we=d.views.find(He=>He.id===z);we&&u(`"${we.name}" moved to Recently Deleted`,"info")},[d,H]),Ur=h.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.map(O=>O.id===z?{...O,isDeleted:!1,updatedAt:Date.now()}:O);H(d.id,{views:D});const W=d.views.find(O=>O.id===z);W&&u(`"${W.name}" restored`,"success")},[d,H]),Mo=h.useCallback(z=>{if(!(d!=null&&d.views))return;const D=d.views.find(we=>we.id===z),W=d.views.filter(we=>!we.isDeleted||we.id===z);if((D==null?void 0:D.isDefault)&&W.filter(we=>we.isDefault).length===1){u("Cannot delete the last default view","error");return}const G=d.views.filter(we=>we.id!==z),q=d.activeViewId===z,le=G.find(we=>we.isDefault&&!we.isDeleted);H(d.id,{views:G,activeViewId:q&&le?le.id:d.activeViewId,filters:q&&le?le.snapshot.filters:d.filters,sortStack:q&&le?le.snapshot.sortStack.length>0?le.snapshot.sortStack:void 0:d.sortStack}),D&&u(`"${D.name}" permanently deleted`,"success")},[d,H]),Gr=h.useCallback(z=>{Te(z),Q(!0)},[]),fo=h.useCallback(async z=>{if(!d)return;const D=new URLSearchParams(window.location.search);D.set("reportId",d.id),D.set("view",z);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]),Wo=h.useCallback((z,D)=>{if(!ae||!(d!=null&&d.views))return;const W=d.views.map(O=>O.id===ae?{...O,name:z,description:D||void 0}:O);H(d.id,{views:W}),Te(null)},[ae,d,H]),Yr=h.useCallback(z=>{Ae(z),E(!0)},[]),qr=h.useCallback(()=>{if(!Y||!(d!=null&&d.views))return;const z=d.views.find(G=>G.id===Y),D=d.views.filter(G=>G.id!==Y),W=d.activeViewId===Y,O=D.find(G=>G.isDefault);se("views","view_deleted",{viewId:Y,name:z==null?void 0:z.name},null),H(d.id,{views:D,activeViewId:W&&O?O.id:d.activeViewId,filters:W&&O?O.snapshot.filters:d.filters,sortStack:W&&O?O.snapshot.sortStack.length>0?O.snapshot.sortStack:void 0:d.sortStack}),Ae(null),E(!1)},[Y,d,H,se]),Jr=h.useCallback(z=>{var G;if(!(d!=null&&d.views))return;if(!(((G=j.views)==null?void 0:G.isAdmin)??!1)){u("Only administrators can promote views to Global.","error");return}const W=d.views.find(q=>q.id===z);if(!W)return;if(W.scope==="global"){u(`"${W.name}" is already a Global View.`,"info");return}const O=d.views.map(q=>q.id===z?{...q,scope:"global",isDefault:!0,updatedAt:Date.now()}:q.scope==="global"&&q.isDefault?{...q,isDefault:!1}:q);H(d.id,{views:O}),u(`"${W.name}" promoted to Global View and set as default.`,"success")},[d,j,H]),Qt=h.useRef(!0);h.useEffect(()=>{var z;if(Qt.current){Qt.current=!1;return}if(b==="server"){Qe(1),(z=a==null?void 0:a.onPaginationChange)==null||z.call(a,1,Ze);return}Ce!=null&&Ce.resetPage?Ce.resetPage():Qe(1)},[d==null?void 0:d.filters,It,d==null?void 0:d.activeViewId,d==null?void 0:d.grouping]);const Ao=h.useCallback(z=>{var D;if(b==="server"){Qe(z),(D=a==null?void 0:a.onPaginationChange)==null||D.call(a,z,Ze);return}Ce!=null&&Ce.goToPage&&Ce.goToPage(z),Qe(z)},[b,a,Ze,Ce]),Kr=h.useCallback(z=>{var O;const D=(Ut-1)*Ze,W=Math.floor(D/z)+1;if(b==="server"){Wt(z),Qe(W),(O=a==null?void 0:a.onPaginationChange)==null||O.call(a,W,z);return}Wt(z),Qe(W),Ce==null||Ce.goToPage(W)},[Ut,Ze,b,a,Ce]),In=h.useCallback((z,D)=>{if(!d)return;if(!St("edit_columns",ee)){u(Ct("edit_columns"),"error");return}const O={...d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{},[z]:D};se("columns",D?"column_shown":"column_hidden",{columnName:z,visible:!D},{columnName:z,visible:D}),H(d.id,{columnVisibility:O})},[d,Z,ee,H,se]),En=h.useCallback(z=>{if(d){if(!St("edit_columns",ee)){u(Ct("edit_columns"),"error");return}se("columns","column_reordered",d.columnOrder,z),H(d.id,{columnOrder:z})}},[d,ee,H,se]),Dn=h.useCallback((z,D)=>{if(!d)return;if(!St("edit_columns",ee)){u(Ct("edit_columns"),"error");return}const W=d.columnWidths||(Z==null?void 0:Z.snapshot.columnWidths)||{},O={...W,[z]:D};se("columns","column_resized",{columnName:z,width:W[z]},{columnName:z,width:D}),H(d.id,{columnWidths:O})},[d,Z,ee,H,se]),_n=h.useCallback(z=>{if(!d)return;const D=Ne(d.filters),W=Bs(D,z);H(d.id,{filters:W})},[d,H]),$n=h.useCallback(()=>{if(!Z||!(d!=null&&d.schema))return;const z={},D=[],W={};d.schema.forEach(O=>{z[O.name]=!0,D.push(O.name),W[O.name]=170}),H(d.id,{columnVisibility:z,columnOrder:D,columnWidths:W,filters:void 0,sortStack:void 0}),u("Reset to default layout - all filters and sorts cleared","success")},[Z,d,H]);h.useEffect(()=>{const z=setTimeout(()=>yr(ar),300);return()=>clearTimeout(z)},[ar]),h.useEffect(()=>{var z;y==="server"&&((z=c==null?void 0:c.onSearchChange)==null||z.call(c,It))},[It,y,c]);const On=h.useCallback(z=>{lo(z),Qe(1)},[]),Mn=h.useCallback(z=>{if(!z.trim()||!d)return;const D=d.searchHistory||[],W=Xa(D,z);H(d.id,{searchHistory:W})},[d,H]),Wn=h.useCallback(z=>{if(!d)return;const D=d.searchHistory||[],W=Qa(D,z);H(d.id,{searchHistory:W})},[d,H]),An=h.useCallback(z=>{if(!d)return;const D=d.searchHistory||[],W=Za(D,z);H(d.id,{searchHistory:W})},[d,H]);h.useEffect(()=>{if(!S.onSelectionChange)return;const z=Array.from(Ke);S.onSelectionChange(z,z.map(D=>D==null?void 0:D.__urm_row_id__))},[Ke,S.onSelectionChange]);const Xr=h.useCallback(z=>{const D=z==null?void 0:z.__urm_row_id__;Mt(W=>{const O=new Set(W);if(D!==void 0){const G=Array.from(O).find(q=>(q==null?void 0:q.__urm_row_id__)===D);G!==void 0?O.delete(G):O.add(z)}else{const G=JSON.stringify(z),q=Array.from(O).find(le=>JSON.stringify(le)===G);q!==void 0?O.delete(q):O.add(z)}return O})},[]),Zt=h.useCallback((z,D)=>{Mt(W=>{const O=new Set(W);for(const G of D)z?O.add(G):O.delete(G);return O})},[]),Rn=h.useCallback((z,D,W)=>{Mt(O=>{const G=new Set(O),q=Math.min(z,D),le=Math.max(z,D);for(let we=q;we<=le;we++)W[we]!==void 0&&G.add(W[we]);return G})},[]),Pn=h.useCallback(()=>{Mt(new Set)},[]),We=h.useCallback(z=>{const D=z==null?void 0:z.__urm_row_id__;Mt(W=>{const O=new Set(W);if(D!==void 0){const G=Array.from(O).find(q=>(q==null?void 0:q.__urm_row_id__)===D);G!==void 0&&O.delete(G)}else O.delete(z);return O})},[]),it=h.useCallback(z=>{var D,W;if(d){if(!St("edit_columns",ee)){u(Ct("edit_columns"),"error");return}if(z&&d.schema){const{validGrouping:O,invalidColumns:G}=_s(z,d.schema);G.length>0&&u(`Removed invalid grouping columns: ${G.join(", ")}`,"warning"),Et();try{const q=d.grouping;O===null?se("grouping","group_cleared",q,null):q?se("grouping","group_reordered",q,O):se("grouping","group_level_added",null,O);const le=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[],we=So(le,O),He=O.levels.length>0?{...O,collapsedGroups:Bi(qt,d.schema,O)}:O;H(d.id,{grouping:He,columnOrder:we}),Qe(1),Ce==null||Ce.resetPage(),b==="server"&&((D=a==null?void 0:a.onPaginationChange)==null||D.call(a,1,Ze)),JSON.stringify(we)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,we),gt(!1)}catch(q){const le=mr("processing","grouping",q);pt(le)}}else{const O=d.grouping;se("grouping","group_cleared",O,null);const G=(Z==null?void 0:Z.snapshot.columnOrder)||d.columnOrder||[];H(d.id,{grouping:z,columnOrder:G}),Qe(1),Ce==null||Ce.resetPage(),b==="server"&&((W=a==null?void 0:a.onPaginationChange)==null||W.call(a,1,Ze)),JSON.stringify(G)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,G),gt(!1)}}},[d,Z,ee,H,Et,pt,se,qt]),xo=h.useCallback(z=>{if(!d)return;const D=d.grouping;if(!D)return;const W=Fa(D,z);H(d.id,{grouping:W})},[d,H]),Ro=h.useCallback(()=>{d!=null&&d.grouping&&H(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,H]),Nn=h.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema)return;const z=Bi(qt,d.schema,d.grouping);H(d.id,{grouping:{...d.grouping,collapsedGroups:z}})},[d,qt,H]),er=h.useCallback(()=>{Gt(!0)},[]),Pt=h.useCallback(z=>{d!=null&&d.schema&&(ut(!0),setTimeout(()=>{try{let D;z.scope==="visible"?D=Yt:D=d.uploadedData||[];let W;z.columnScope==="all"?(W={},(d.schema??[]).forEach(we=>{W[we.name]=!0})):W=d.columnVisibility||(Z==null?void 0:Z.snapshot.columnVisibility)||{};const O=d.columnOrder||(Z==null?void 0:Z.snapshot.columnOrder),G=en(D,d.schema,Ne(d.filters),d.sortStack??[],Z,W,O),q=d.name;let le;switch(z.format){case"csv":tn(G,q,z),le="export_csv";break;case"excel":rn(G,q,z),le="export_excel";break;case"json":on(G,q,z),le="export_json";break;case"pdf":mi(G,q,z),le="export_pdf";break}se("export",le,null,{format:z.format,scope:z.scope,columnScope:z.columnScope,rowCount:D.length,viewName:(Z==null?void 0:Z.name)||"Default View"}),u(`Export completed successfully (${z.format.toUpperCase()})`,"success")}catch(D){const W=zl(D,{onRetry:()=>Pt(z)});u(`Export failed: ${W.message}. Click Export to retry.`,"error");const O=Wi(d.id,_t,W,d.auditHistory||[]);H(d.id,{auditHistory:O}),Vt.error("urm:report-engine","Export failed",D)}finally{ut(!1)}},500))},[d,Z,Yt,H,se]),tr=h.useCallback(z=>{if(d!=null&&d.schema){if(he&&Z&&!Z.isDefault){Ht(z.format),Ot(!0),Gt(!1);return}Pt(z),Gt(!1)}},[d,Z,he,Pt]),Ir=h.useCallback(z=>{Pt({format:z,scope:"visible",columnScope:"visible"})},[Pt]),Ln=h.useCallback(()=>{nt&&Ir(nt),Ot(!1),Ht(null)},[nt,Ir]),Po=h.useCallback(()=>{vt(),nt&&Ir(nt),Ot(!1),Ht(null)},[vt,nt,Ir]),No=h.useCallback(()=>{Ot(!1),Ht(null)},[]),C=h.useCallback(z=>{!(d!=null&&d.schema)||Ke.size===0||(ut(!0),setTimeout(()=>{try{const D=Array.from(Ke),W=en(D,d.schema,Ne(d.filters),d.sortStack??[],Z),O=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(z){case"csv":tn(W,O);break;case"excel":rn(W,O);break;case"json":on(W,O);break}u(`Exported ${D.length} selected rows`,"info")}catch(D){u("Export failed. Please try again.","error"),Vt.error("urm:report-engine","Bulk export failed",D)}finally{ut(!1)}},500))},[d,Z,Ke,jr]),R=h.useCallback((z,D)=>{if(d)try{const W=pl(d),O=hl(z,D,_t,W),G=ml(d.presets,O);H(d.id,{presets:G}),se("presets","preset_created",null,{presetId:O.id,name:O.name}),Fe(!1),u(`Preset "${z}" saved successfully`,"success")}catch(W){u(W instanceof Error?W.message:"Failed to create preset","error")}},[d,H,se]),oe=h.useCallback(()=>{vr(null),u("Exited preset view","info")},[]),je=h.useCallback(()=>{lr(!0)},[]),Oe=h.useCallback((z,D)=>{if(!d)return;const W=fl(d.presets,z);H(d.id,{presets:W}),se("presets","preset_deleted",{presetId:z,name:D},null),At===z&&vr(null),u(`Preset "${D}" deleted`,"success")},[d,At,H,se]);h.useEffect(()=>{if(!g||w.length===0)return;const z=w.find(D=>D.id===g);z&&z.id!==I&&k(z.id)},[g,w,I]);const tt=h.useRef(!1);h.useEffect(()=>{var D;if(!f||tt.current||!d||d.id!==g)return;const z=(D=d.views)==null?void 0:D.find(W=>W.id===f&&!W.isDeleted);z&&Ve(z.id),tt.current=!0},[f,g,d,Ve]),h.useEffect(()=>{if(!d)return;const z=xl();if(z&&d.presets&&d.schemaLocked&&d.schema){const D=Mi(d.presets,z);if(D){const{sanitizedConfig:W,warnings:O}=kl(D.config,d.schema);O.length>0&&O.forEach(q=>u(q,"warning"));const G=gl(W);H(d.id,G),vr(z),se("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 rt=At?Mi(d==null?void 0:d.presets,At):void 0;h.useEffect(()=>{var z;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&(B==="api"?(z=v==null?void 0:v.onViewsChange)==null||z.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,B]),h.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const z=B==="api"?v!=null&&v.views&&v.views.length>0?{views:v.views,activeViewId:v.activeViewId??v.views[0].id}:null:Ja(d.id);if(z&&z.views.length>0){const D=z.views.find(W=>W.id===z.activeViewId);if(D)H(d.id,{views:z.views,activeViewId:z.activeViewId,filters:Ne(D.snapshot.filters),sortStack:D.snapshot.sortStack.length>0?D.snapshot.sortStack:void 0});else{const W=z.views.find(O=>O.isDefault)||Vn(d.schema);H(d.id,{views:z.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,B,v]);const me=h.useCallback(z=>{var O;const D=Ne(d==null?void 0:d.filters),W=((O=j.filter)==null?void 0:O.maxConditions)??3;if(jt(D)>=W){u(`Filter limit reached — maximum ${W} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}fe(z),ge(!0)},[d,j,u]),Nt=h.useCallback(()=>{ge(!1),fe(void 0)},[]),rr=(Ci=d==null?void 0:d.views)==null?void 0:Ci.find(z=>z.id===ae),ke=(wi=d==null?void 0:d.views)==null?void 0:wi.find(z=>z.id===Y);return{reports:w,activeReport:d,activeReportId:I,setActiveReportId:k,isModalOpen:P,setIsModalOpen:J,createReport:zr,updateReport:H,uploadState:ne,handleFileUpload:po,handleUploadError:Nr,handleRetry:ho,handleConfirm:Kt,paginatedData:uo,processedData:Yt,displayData:jr,tableMetrics:pr,isGrouped:Jt,tableEngine:wr,activeView:Z,isDirty:he,currentTableState:Se,viewChanges:kr,filters:d==null?void 0:d.filters,showFilterPanel:re,setShowFilterPanel:ge,filterFocusColumn:te,handleAddCondition:Tr,handleAddGroup:lt,handleUpdateCondition:Xt,handleSetGroupOperator:Dt,handleRemoveFilterNode:Br,handleClearAllFilters:xe,handleReplaceFilters:ve,handleOpenFilterForColumn:me,handleCloseFilterPanel:Nt,handleClearFiltersForColumn:_n,sortStack:d==null?void 0:d.sortStack,showSortPanel:V,setShowSortPanel:X,handleSort:Lr,handleUpdateSortStack:Fr,handleSortAscending:be,handleSortDescending:Ge,views:d==null?void 0:d.views,showCreateViewModal:ce,setShowCreateViewModal:de,showEditViewModal:ie,setShowEditViewModal:Q,showDeleteConfirmation:pe,setShowDeleteConfirmation:E,editingView:rr,deletingView:ke,editingViewId:ae,deletingViewId:Y,handleSelectView:Ve,handleCreateView:Ye,handleCloneView:ht,handleUpdateCurrentView:vt,handleSaveColumnConfigToCurrentView:Rt,handleSaveColumnConfigToAllViews:Vr,handleSaveAsNewView:Tn,handleRevertChanges:Hr,handleToggleDefault:mo,handleToggleFavorite:Bn,handleSoftDelete:Oo,handleRestoreView:Ur,handlePermanentDelete:Mo,handleEditView:Gr,handleCopyViewLink:fo,handleSaveEditView:Wo,handleDeleteView:Yr,handleConfirmDelete:qr,handlePromoteToGlobal:Jr,showManageColumns:Je,setShowManageColumns:Bt,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:In,handleUpdateColumnOrder:En,handleUpdateColumnWidth:Dn,handleResetColumnLayout:$n,showGroupPanel:gr,setShowGroupPanel:gt,grouping:d==null?void 0:d.grouping,groupingState:sr,handleGroup:it,handleToggleGroupCollapse:xo,handleExpandAllGroups:Ro,handleCollapseAllGroups:Nn,searchQuery:ar,debouncedSearchQuery:It,searchHistory:el((d==null?void 0:d.searchHistory)||[]),handleSearchChange:On,handleAddToSearchHistory:Mn,handleToggleSearchFavourite:Wn,handleDeleteSearchHistory:An,selectedRowIds:Ke,handleToggleRowSelection:Xr,handleToggleAllRows:Zt,handleRangeSelection:Rn,handleClearSelection:Pn,handleUpdateSelectionAfterDelete:We,currentPage:Ut,pageSize:Ze,paginationEngine:Ce,paginationMode:b,paginationTotalRows:bt,handlePageChange:Ao,handlePageSizeChange:Kr,isExporting:Tt,showExportModal:Sr,setShowExportModal:Gt,showDirtyExportWarning:Wr,handleExport:er,handleExportWithConfig:tr,handleExportSelected:C,handleExportAnyway:Ln,handleSaveAndExport:Po,handleCancelExport:No,showAuditHistory:co,setShowAuditHistory:Ar,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:br,setShowCreatePreset:Fe,showManagePresets:ze,setShowManagePresets:lr,activePreset:rt,activePresetId:At,handleOpenManagePresets:je,handleCreatePreset:R,handleClearActivePreset:oe,handleDeletePresetById:Oe,userRole:ee,isViewerRole:Cr,currentUserId:_t,featureLimitWarning:cr,setFeatureLimitWarning:et,datasetMeta:Pr,reportError:dr,setReportError:yt,handleError:pt,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?Oa(d.schema):!1,snack:K,handleSnackClose:A,showSnack:u,snackDurationMs:L,config:S,scheduler:l}}const $s=h.createContext(void 0);function fi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:c,pagination:l,search:p,scheduler:x,mode:g="builder",autoLoad:f=!0,config:v,devConfig:S,showDevPanel:B=!1,sharedReportId:b,sharedViewId:y,viewPersistence:w}=e,j=Vl({mode:g,autoLoad:f,initialData:i||n,dataSource:c,pagination:l,search:p,scheduler:x,reportName:s,reportId:a,sharedReportId:b,sharedViewId:y,viewPersistence:w,config:v}),[I,k]=h.useState(()=>xa()),P=(()=>{const K=ya(I,S,!!S);return{...K,display:{...K.display,showDevPanel:B||K.display.showDevPanel}}})(),J=h.useCallback(F=>{k(F),ga(F)},[]),T={...j,activeDevConfig:P,handleDevConfigChange:J};return t.jsx(js.Provider,{value:P,children:t.jsx($s.Provider,{value:T,children:r})})}function un(){const e=h.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 g,f,v;const c=((v=(f=(g=a.components)==null?void 0:g.MuiCardHeader)==null?void 0:f.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 Ul="$$material";function Gl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ho={exports:{}},Uo={exports:{}},Be={};/** @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
|
|
112
|
+
*/var Ai;function Yl(){if(Ai)return Be;Ai=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,g=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,w=e?Symbol.for("react.responder"):60118,m=e?Symbol.for("react.scope"):60119;function j(k){if(typeof k=="object"&&k!==null){var P=k.$$typeof;switch(P){case r:switch(k=k.type,k){case p:case x:case i:case a:case s:case f:return k;default:switch(k=k&&k.$$typeof,k){case l:case g:case B:case S:case c:return k;default:return P}}case n:return P}}}function I(k){return j(k)===x}return Be.AsyncMode=p,Be.ConcurrentMode=x,Be.ContextConsumer=l,Be.ContextProvider=c,Be.Element=r,Be.ForwardRef=g,Be.Fragment=i,Be.Lazy=B,Be.Memo=S,Be.Portal=n,Be.Profiler=a,Be.StrictMode=s,Be.Suspense=f,Be.isAsyncMode=function(k){return I(k)||j(k)===p},Be.isConcurrentMode=I,Be.isContextConsumer=function(k){return j(k)===l},Be.isContextProvider=function(k){return j(k)===c},Be.isElement=function(k){return typeof k=="object"&&k!==null&&k.$$typeof===r},Be.isForwardRef=function(k){return j(k)===g},Be.isFragment=function(k){return j(k)===i},Be.isLazy=function(k){return j(k)===B},Be.isMemo=function(k){return j(k)===S},Be.isPortal=function(k){return j(k)===n},Be.isProfiler=function(k){return j(k)===a},Be.isStrictMode=function(k){return j(k)===s},Be.isSuspense=function(k){return j(k)===f},Be.isValidElementType=function(k){return typeof k=="string"||typeof k=="function"||k===i||k===x||k===a||k===s||k===f||k===v||typeof k=="object"&&k!==null&&(k.$$typeof===B||k.$$typeof===S||k.$$typeof===c||k.$$typeof===l||k.$$typeof===g||k.$$typeof===y||k.$$typeof===w||k.$$typeof===m||k.$$typeof===b)},Be.typeOf=j,Be}var Ie={};/** @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
|
|
119
|
+
*/var Ri;function ql(){return Ri||(Ri=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,g=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,w=e?Symbol.for("react.responder"):60118,m=e?Symbol.for("react.scope"):60119;function j(Y){return typeof Y=="string"||typeof Y=="function"||Y===i||Y===x||Y===a||Y===s||Y===f||Y===v||typeof Y=="object"&&Y!==null&&(Y.$$typeof===B||Y.$$typeof===S||Y.$$typeof===c||Y.$$typeof===l||Y.$$typeof===g||Y.$$typeof===y||Y.$$typeof===w||Y.$$typeof===m||Y.$$typeof===b)}function I(Y){if(typeof Y=="object"&&Y!==null){var Ae=Y.$$typeof;switch(Ae){case r:var Tt=Y.type;switch(Tt){case p:case x:case i:case a:case s:case f:return Tt;default:var ut=Tt&&Tt.$$typeof;switch(ut){case l:case g:case B:case S:case c:return ut;default:return Ae}}case n:return Ae}}}var k=p,P=x,J=l,T=c,F=r,K=g,M=i,u=B,A=S,L=n,d=a,ne=s,U=f,re=!1;function ge(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)||I(Y)===p}function V(Y){return I(Y)===x}function X(Y){return I(Y)===l}function ce(Y){return I(Y)===c}function de(Y){return typeof Y=="object"&&Y!==null&&Y.$$typeof===r}function ie(Y){return I(Y)===g}function Q(Y){return I(Y)===i}function pe(Y){return I(Y)===B}function E(Y){return I(Y)===S}function te(Y){return I(Y)===n}function fe(Y){return I(Y)===a}function ae(Y){return I(Y)===s}function Te(Y){return I(Y)===f}Ie.AsyncMode=k,Ie.ConcurrentMode=P,Ie.ContextConsumer=J,Ie.ContextProvider=T,Ie.Element=F,Ie.ForwardRef=K,Ie.Fragment=M,Ie.Lazy=u,Ie.Memo=A,Ie.Portal=L,Ie.Profiler=d,Ie.StrictMode=ne,Ie.Suspense=U,Ie.isAsyncMode=ge,Ie.isConcurrentMode=V,Ie.isContextConsumer=X,Ie.isContextProvider=ce,Ie.isElement=de,Ie.isForwardRef=ie,Ie.isFragment=Q,Ie.isLazy=pe,Ie.isMemo=E,Ie.isPortal=te,Ie.isProfiler=fe,Ie.isStrictMode=ae,Ie.isSuspense=Te,Ie.isValidElementType=j,Ie.typeOf=I})()),Ie}var Pi;function Os(){return Pi||(Pi=1,process.env.NODE_ENV==="production"?Uo.exports=Yl():Uo.exports=ql()),Uo.exports}/*
|
|
120
120
|
object-assign
|
|
121
121
|
(c) Sindre Sorhus
|
|
122
122
|
@license MIT
|
|
123
|
-
*/var
|
|
124
|
-
Valid keys: `+JSON.stringify(Object.keys(V),null," "));var
|
|
123
|
+
*/var Un,Ni;function Jl(){if(Ni)return Un;Ni=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(g){return c[g]});if(p.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(g){x[g]=g}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Un=s()?Object.assign:function(a,c){for(var l,p=i(a),x,g=1;g<arguments.length;g++){l=Object(arguments[g]);for(var f in l)r.call(l,f)&&(p[f]=l[f]);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},Un}var Gn,Li;function xi(){if(Li)return Gn;Li=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Gn=e,Gn}var Yn,Fi;function Ms(){return Fi||(Fi=1,Yn=Function.call.bind(Object.prototype.hasOwnProperty)),Yn}var qn,Vi;function Kl(){if(Vi)return qn;Vi=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=xi(),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 g in a)if(i(a,g)){var f;try{if(typeof a[g]!="function"){var v=Error((p||"React class")+": "+l+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}f=a[g](c,g,p,l,null,r)}catch(B){f=B}if(f&&!(f instanceof Error)&&e((p||"React class")+": type specification of "+l+" `"+g+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof f+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),f instanceof Error&&!(f.message in n)){n[f.message]=!0;var S=x?x():"";e("Failed "+l+" type: "+f.message+(S??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},qn=s,qn}var Jn,Hi;function Xl(){if(Hi)return Jn;Hi=1;var e=Os(),r=Jl(),n=xi(),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 Jn=function(l,p){var x=typeof Symbol=="function"&&Symbol.iterator,g="@@iterator";function f(V){var X=V&&(x&&V[x]||V[g]);if(typeof X=="function")return X}var v="<<anonymous>>",S={array:w("array"),bigint:w("bigint"),bool:w("boolean"),func:w("function"),number:w("number"),object:w("object"),string:w("string"),symbol:w("symbol"),any:m(),arrayOf:j,element:I(),elementType:k(),instanceOf:P,node:K(),objectOf:T,oneOf:J,oneOfType:F,shape:u,exact:A};function B(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 y(V){if(process.env.NODE_ENV!=="production")var X={},ce=0;function de(Q,pe,E,te,fe,ae,Te){if(te=te||v,ae=ae||E,Te!==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 Ae=te+":"+E;!X[Ae]&&ce<3&&(a("You are manually calling a React.PropTypes validation function for the `"+ae+"` 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[Ae]=!0,ce++)}}return pe[E]==null?Q?pe[E]===null?new b("The "+fe+" `"+ae+"` is marked as required "+("in `"+te+"`, but its value is `null`.")):new b("The "+fe+" `"+ae+"` is marked as required in "+("`"+te+"`, but its value is `undefined`.")):null:V(pe,E,te,fe,ae)}var ie=de.bind(null,!1);return ie.isRequired=de.bind(null,!0),ie}function w(V){function X(ce,de,ie,Q,pe,E){var te=ce[de],fe=ne(te);if(fe!==V){var ae=U(te);return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+ae+"` supplied to `"+ie+"`, expected ")+("`"+V+"`."),{expectedType:V})}return null}return y(X)}function m(){return y(c)}function j(V){function X(ce,de,ie,Q,pe){if(typeof V!="function")return new b("Property `"+pe+"` of component `"+ie+"` has invalid PropType notation inside arrayOf.");var E=ce[de];if(!Array.isArray(E)){var te=ne(E);return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+te+"` supplied to `"+ie+"`, expected an array."))}for(var fe=0;fe<E.length;fe++){var ae=V(E,fe,ie,Q,pe+"["+fe+"]",n);if(ae instanceof Error)return ae}return null}return y(X)}function I(){function V(X,ce,de,ie,Q){var pe=X[ce];if(!l(pe)){var E=ne(pe);return new b("Invalid "+ie+" `"+Q+"` of type "+("`"+E+"` supplied to `"+de+"`, expected a single ReactElement."))}return null}return y(V)}function k(){function V(X,ce,de,ie,Q){var pe=X[ce];if(!e.isValidElementType(pe)){var E=ne(pe);return new b("Invalid "+ie+" `"+Q+"` of type "+("`"+E+"` supplied to `"+de+"`, expected a single ReactElement type."))}return null}return y(V)}function P(V){function X(ce,de,ie,Q,pe){if(!(ce[de]instanceof V)){var E=V.name||v,te=ge(ce[de]);return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+te+"` supplied to `"+ie+"`, expected ")+("instance of `"+E+"`."))}return null}return y(X)}function J(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(ce,de,ie,Q,pe){for(var E=ce[de],te=0;te<V.length;te++)if(B(E,V[te]))return null;var fe=JSON.stringify(V,function(Te,Y){var Ae=U(Y);return Ae==="symbol"?String(Y):Y});return new b("Invalid "+Q+" `"+pe+"` of value `"+String(E)+"` "+("supplied to `"+ie+"`, expected one of "+fe+"."))}return y(X)}function T(V){function X(ce,de,ie,Q,pe){if(typeof V!="function")return new b("Property `"+pe+"` of component `"+ie+"` has invalid PropType notation inside objectOf.");var E=ce[de],te=ne(E);if(te!=="object")return new b("Invalid "+Q+" `"+pe+"` of type "+("`"+te+"` supplied to `"+ie+"`, expected an object."));for(var fe in E)if(i(E,fe)){var ae=V(E,fe,ie,Q,pe+"."+fe,n);if(ae instanceof Error)return ae}return null}return y(X)}function F(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 ce=V[X];if(typeof ce!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+re(ce)+" at index "+X+"."),c}function de(ie,Q,pe,E,te){for(var fe=[],ae=0;ae<V.length;ae++){var Te=V[ae],Y=Te(ie,Q,pe,E,te,n);if(Y==null)return null;Y.data&&i(Y.data,"expectedType")&&fe.push(Y.data.expectedType)}var Ae=fe.length>0?", expected one of type ["+fe.join(", ")+"]":"";return new b("Invalid "+E+" `"+te+"` supplied to "+("`"+pe+"`"+Ae+"."))}return y(de)}function K(){function V(X,ce,de,ie,Q){return L(X[ce])?null:new b("Invalid "+ie+" `"+Q+"` supplied to "+("`"+de+"`, expected a ReactNode."))}return y(V)}function M(V,X,ce,de,ie){return new b((V||"React class")+": "+X+" type `"+ce+"."+de+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+ie+"`.")}function u(V){function X(ce,de,ie,Q,pe){var E=ce[de],te=ne(E);if(te!=="object")return new b("Invalid "+Q+" `"+pe+"` of type `"+te+"` "+("supplied to `"+ie+"`, expected `object`."));for(var fe in V){var ae=V[fe];if(typeof ae!="function")return M(ie,Q,pe,fe,U(ae));var Te=ae(E,fe,ie,Q,pe+"."+fe,n);if(Te)return Te}return null}return y(X)}function A(V){function X(ce,de,ie,Q,pe){var E=ce[de],te=ne(E);if(te!=="object")return new b("Invalid "+Q+" `"+pe+"` of type `"+te+"` "+("supplied to `"+ie+"`, expected `object`."));var fe=r({},ce[de],V);for(var ae in fe){var Te=V[ae];if(i(V,ae)&&typeof Te!="function")return M(ie,Q,pe,ae,U(Te));if(!Te)return new b("Invalid "+Q+" `"+pe+"` key `"+ae+"` supplied to `"+ie+"`.\nBad object: "+JSON.stringify(ce[de],null," ")+`
|
|
124
|
+
Valid keys: `+JSON.stringify(Object.keys(V),null," "));var Y=Te(E,ae,ie,Q,pe+"."+ae,n);if(Y)return Y}return null}return y(X)}function L(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(L);if(V===null||l(V))return!0;var X=f(V);if(X){var ce=X.call(V),de;if(X!==V.entries){for(;!(de=ce.next()).done;)if(!L(de.value))return!1}else for(;!(de=ce.next()).done;){var ie=de.value;if(ie&&!L(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 ge(V){return!V.constructor||!V.constructor.name?v:V.constructor.name}return S.checkPropTypes=s,S.resetWarningCache=s.resetWarningCache,S.PropTypes=S,S},Jn}var Kn,Ui;function Ql(){if(Ui)return Kn;Ui=1;var e=xi();function r(){}function n(){}return n.resetWarningCache=r,Kn=function(){function i(c,l,p,x,g,f){if(f!==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},Kn}var Gi;function Zl(){if(Gi)return Ho.exports;if(Gi=1,process.env.NODE_ENV!=="production"){var e=Os(),r=!0;Ho.exports=Xl()(e.isElement,r)}else Ho.exports=Ql()();return Ho.exports}var ec=Zl();const yo=Gl(ec);var Go={exports:{}},_e={};/**
|
|
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 q=ze(I,ae,ie,Q,pe+".
|
|
|
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
|
|
132
|
+
*/var Yi;function tc(){if(Yi)return _e;Yi=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"),g=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),S=Symbol.for("react.client.reference");function B(b){if(typeof b=="object"&&b!==null){var y=b.$$typeof;switch(y){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 f:case g:return b;case a:return b;default:return y}}case r:return y}}}return _e.ContextConsumer=a,_e.ContextProvider=c,_e.Element=e,_e.ForwardRef=l,_e.Fragment=n,_e.Lazy=f,_e.Memo=g,_e.Portal=r,_e.Profiler=s,_e.StrictMode=i,_e.Suspense=p,_e.SuspenseList=x,_e.isContextConsumer=function(b){return B(b)===a},_e.isContextProvider=function(b){return B(b)===c},_e.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===e},_e.isForwardRef=function(b){return B(b)===l},_e.isFragment=function(b){return B(b)===n},_e.isLazy=function(b){return B(b)===f},_e.isMemo=function(b){return B(b)===g},_e.isPortal=function(b){return B(b)===r},_e.isProfiler=function(b){return B(b)===s},_e.isStrictMode=function(b){return B(b)===i},_e.isSuspense=function(b){return B(b)===p},_e.isSuspenseList=function(b){return B(b)===x},_e.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===f||b.$$typeof===g||b.$$typeof===c||b.$$typeof===a||b.$$typeof===l||b.$$typeof===S||b.getModuleId!==void 0)},_e.typeOf=B,_e}var $e={};/**
|
|
133
133
|
* @license React
|
|
134
134
|
* react-is.development.js
|
|
135
135
|
*
|
|
@@ -137,16 +137,16 @@ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var q=ze(I,ae,ie,Q,pe+".
|
|
|
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
|
|
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},
|
|
140
|
+
*/var qi;function rc(){return qi||(qi=1,process.env.NODE_ENV!=="production"&&(function(){function e(b){if(typeof b=="object"&&b!==null){var y=b.$$typeof;switch(y){case r:switch(b=b.type,b){case i:case a:case s:case x:case g:case S:return b;default:switch(b=b&&b.$$typeof,b){case l:case p:case v:case f:return b;case c:return b;default:return y}}case n:return y}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),B=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=f,$e.Portal=n,$e.Profiler=a,$e.StrictMode=s,$e.Suspense=x,$e.SuspenseList=g,$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)===f},$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)===g},$e.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===i||b===a||b===s||b===x||b===g||typeof b=="object"&&b!==null&&(b.$$typeof===v||b.$$typeof===f||b.$$typeof===l||b.$$typeof===c||b.$$typeof===p||b.$$typeof===B||b.getModuleId!==void 0)},$e.typeOf=e})()),$e}var Ji;function oc(){return Ji||(Ji=1,process.env.NODE_ENV==="production"?Go.exports=tc():Go.exports=rc()),Go.exports}var Ws=oc();function hr(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(ln.isValidElement(e)||Ws.isValidElementType(e)||!hr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=As(e[n])}),r}function xt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return hr(e)&&hr(r)&&Object.keys(r).forEach(s=>{ln.isValidElement(r[s])||Ws.isValidElementType(r[s])?i[s]=r[s]:hr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&hr(e[s])?i[s]=xt(e[s],r[s],n):n.clone?i[s]=hr(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 B=c.indexOf(S);return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n}) and (max-width:${(B!==-1&&typeof r[c[B]]=="number"?r[c[B]]:S)-i/100}${n})`}function g(v){return c.indexOf(v)+1<c.length?x(v,c[c.indexOf(v)+1]):l(v)}function f(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:g,not:f,unit:n,...s}}function Ki(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},xr=process.env.NODE_ENV!=="production"?yo.oneOfType([yo.number,yo.string,yo.object,yo.array]):{};function To(e,r){return r?xt(e,r,{clone:!1}):e}const pn={xs:0,sm:600,md:900,lg:1200,xl:1536},Xi={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${pn[e]}px)`},dc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:pn[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function ir(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||Xi;return r.reduce((c,l,p)=>(c[a.up(a.keys[p])]=n(r[p]),c),{})}if(typeof r=="object"){const a=i.breakpoints||Xi;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||pn).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 Qi(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.":_r(7));return e.charAt(0).toUpperCase()+e.slice(1)}function hn(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 sn(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=hn(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=hn(p,i)||{};return ir(c,l,f=>{let v=sn(x,s,f);return f===v&&typeof f=="string"&&(v=sn(x,s,`${r}${f==="default"?"":Rs(f)}`,f)),n===!1?v:{[n]:v}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:xr}:{},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"},mc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Zi={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},fc=pc(e=>{if(e.length>2)if(Zi[e])e=Zi[e];else return[e];const[r,n]=e.split(""),i=hc[r],s=mc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),mn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],fn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],xc=[...mn,...fn];function Do(e,r,n,i){const s=hn(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 no(e,r){return r==="grey"?r:e}const Nc=Fe({prop:"color",themeKey:"palette",transform:no}),Lc=Fe({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:no}),Fc=Fe({prop:"backgroundColor",themeKey:"palette",transform:no});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:no},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:no},backgroundColor:{themeKey:"palette",transform:no},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().`:
|
|
146
|
-
The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:
|
|
147
|
-
`))}return
|
|
148
|
-
The color object needs to have a \`main\` property or a \`${
|
|
149
|
-
\`color.main\` should be a string, but \`${JSON.stringify(
|
|
144
|
+
`)),()=>{})}function gi(e){return Do(e,"spacing",8,"spacing")}function _o(e,r){return typeof r=="string"||r==null?r:e(r)}function gc(e,r){return n=>e.reduce((i,s)=>(i[s]=_o(r,n),i),{})}function yc(e,r,n,i){if(!r.includes(n))return null;const s=fc(n),a=gc(s,i),c=e[n];return ir(e,c,a)}function Ps(e,r){const n=gi(e.theme);return Object.keys(e).map(i=>yc(e,r,i,n)).reduce(To,{})}function Re(e){return Ps(e,mn)}Re.propTypes=process.env.NODE_ENV!=="production"?mn.reduce((e,r)=>(e[r]=xr,e),{}):{};Re.filterProps=mn;function Pe(e){return Ps(e,fn)}Pe.propTypes=process.env.NODE_ENV!=="production"?fn.reduce((e,r)=>(e[r]=xr,e),{}):{};Pe.filterProps=fn;process.env.NODE_ENV!=="production"&&xc.reduce((e,r)=>(e[r]=xr,e),{});function Ns(e=8,r=gi({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 xn(...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]?To(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 wt(e){return typeof e!="number"?e:`${e}px solid`}function zt(e,r){return Le({prop:e,themeKey:"borders",transform:r})}const bc=zt("border",wt),vc=zt("borderTop",wt),Sc=zt("borderRight",wt),Cc=zt("borderBottom",wt),wc=zt("borderLeft",wt),jc=zt("borderColor"),kc=zt("borderTopColor"),zc=zt("borderRightColor"),Tc=zt("borderBottomColor"),Bc=zt("borderLeftColor"),Ic=zt("outline",wt),Ec=zt("outlineColor"),gn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Do(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:_o(r,i)});return ir(e,e.borderRadius,n)}return null};gn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:xr}:{};gn.filterProps=["borderRadius"];xn(bc,vc,Sc,Cc,wc,jc,kc,zc,Tc,Bc,gn,Ic,Ec);const yn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Do(e.theme,"spacing",8,"gap"),n=i=>({gap:_o(r,i)});return ir(e,e.gap,n)}return null};yn.propTypes=process.env.NODE_ENV!=="production"?{gap:xr}:{};yn.filterProps=["gap"];const bn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Do(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:_o(r,i)});return ir(e,e.columnGap,n)}return null};bn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:xr}:{};bn.filterProps=["columnGap"];const vn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Do(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:_o(r,i)});return ir(e,e.rowGap,n)}return null};vn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:xr}:{};vn.filterProps=["rowGap"];const Dc=Le({prop:"gridColumn"}),_c=Le({prop:"gridRow"}),$c=Le({prop:"gridAutoFlow"}),Oc=Le({prop:"gridAutoColumns"}),Mc=Le({prop:"gridAutoRows"}),Wc=Le({prop:"gridTemplateColumns"}),Ac=Le({prop:"gridTemplateRows"}),Rc=Le({prop:"gridTemplateAreas"}),Pc=Le({prop:"gridArea"});xn(yn,bn,vn,Dc,_c,$c,Oc,Mc,Wc,Ac,Rc,Pc);function no(e,r){return r==="grey"?r:e}const Nc=Le({prop:"color",themeKey:"palette",transform:no}),Lc=Le({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:no}),Fc=Le({prop:"backgroundColor",themeKey:"palette",transform:no});xn(Nc,Lc,Fc);function ft(e){return e<=1&&e!==0?`${e*100}%`:e}const Vc=Le({prop:"width",transform:ft}),yi=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])||pn[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 ir(e,e.maxWidth,r)}return null};yi.filterProps=["maxWidth"];const Hc=Le({prop:"minWidth",transform:ft}),Uc=Le({prop:"height",transform:ft}),Gc=Le({prop:"maxHeight",transform:ft}),Yc=Le({prop:"minHeight",transform:ft});Le({prop:"size",cssProperty:"width",transform:ft});Le({prop:"size",cssProperty:"height",transform:ft});const qc=Le({prop:"boxSizing"});xn(Vc,yi,Hc,Uc,Gc,Yc,qc);const Sn={border:{themeKey:"borders",transform:wt},borderTop:{themeKey:"borders",transform:wt},borderRight:{themeKey:"borders",transform:wt},borderBottom:{themeKey:"borders",transform:wt},borderLeft:{themeKey:"borders",transform:wt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:wt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:gn},color:{themeKey:"palette",transform:no},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:no},backgroundColor:{themeKey:"palette",transform:no},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:yn},rowGap:{style:vn},columnGap:{style:bn},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:yi},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:g,style:f}=l;if(i==null)return null;if(x==="typography"&&i==="inherit")return{[n]:i};const v=hn(s,x)||{};return f?f(c):ir(c,i,B=>{let b=sn(v,g,B);return B===b&&typeof B=="string"&&(b=sn(v,g,`${n}${B==="default"?"":Rs(B)}`,B)),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??Sn;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 g=uc(s.breakpoints),f=Object.keys(g);let v=g;return Object.keys(x).forEach(S=>{const B=Kc(x[S],s);if(B!=null)if(typeof B=="object")if(c[S])v=To(v,e(S,B,s,c));else{const b=ir({theme:s},B,y=>({[S]:y}));Jc(b,B)?v[S]=r({sx:B,theme:s,nested:!0}):v=To(v,b)}else v=To(v,e(S,B,s,c))}),!a&&s.modularCssLayers?{"@layer sx":Ki(s,Qi(f,v))}:Ki(s,Qi(f,v))}return Array.isArray(i)?i.map(l):l(i)}return r}const Cn=Xc();Cn.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=xt({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((g,f)=>xt(g,f),x),x.unstable_sxConfig={...Sn,...c==null?void 0:c.unstable_sxConfig},x.unstable_sx=function(f){return Cn({sx:f,theme:this})},x}function Zc(e){return Object.keys(e).length===0}function ed(e=null){const r=ln.useContext(fa.ThemeContext);return!r||Zc(r)?e:r}const td=Ls();function rd(e=td){return ed(e)}const es=e=>e,od=()=>{let e=es;return{configure(r){e=r},generate(r){return e(r)},reset(){e=es}}},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 bi(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 fr(e){if(e.type)return e;if(e.charAt(0)==="#")return fr(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().`:_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 cd=e=>{const r=fr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Co=(e,r)=>{try{return cd(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function wn(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=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,g=(x+n/30)%12)=>s-a*Math.max(Math.min(g-3,9-g,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])),wn({type:l,values:p})}function oi(e){e=fr(e);let r=e.type==="hsl"||e.type==="hsla"?fr(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 ts(e,r){const n=oi(e),i=oi(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function _(e,r){return e=fr(e),r=bi(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,wn(e)}function Er(e,r,n){try{return _(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function jn(e,r){if(e=fr(e),r=bi(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 wn(e)}function Ee(e,r,n){try{return jn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function kn(e,r){if(e=fr(e),r=bi(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 wn(e)}function De(e,r,n){try{return kn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function dd(e,r=.15){return oi(e)>.5?jn(e,r):kn(e,r)}function Yo(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 rs=(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 Xn(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 g=`--${n?`${n}-`:""}${l.join("-")}`,f=hd(l,p);Object.assign(s,{[g]:f}),rs(a,l,`var(${g})`,x),rs(c,l,`var(${g}, ${f})`,x)}},l=>l[0]==="vars"),{css:s,vars:a,varsWithDefaults:c}}function md(e,r={}){const{getSelector:n=w,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:c={},components:l,defaultColorScheme:p="light",...x}=e,{vars:g,css:f,varsWithDefaults:v}=Xn(x,r);let S=v;const B={},{[p]:b,...y}=c;if(Object.entries(y||{}).forEach(([I,k])=>{const{vars:P,css:J,varsWithDefaults:T}=Xn(k,r);S=xt(S,T),B[I]={css:J,vars:P}}),b){const{css:I,vars:k,varsWithDefaults:P}=Xn(b,r);S=xt(S,P),B[p]={css:I,vars:k}}function w(I,k){var J,T;let P=s;if(s==="class"&&(P=".%s"),s==="data"&&(P="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(P=`[${s}="%s"]`),I){if(P==="media")return e.defaultColorScheme===I?":root":{[`@media (prefers-color-scheme: ${((T=(J=c[I])==null?void 0:J.palette)==null?void 0:T.mode)||I})`]:{":root":k}};if(P)return e.defaultColorScheme===I?`:root, ${P.replace("%s",String(I))}`:P.replace("%s",String(I))}return":root"}return{vars:S,generateThemeVars:()=>{let I={...g};return Object.entries(B).forEach(([,{vars:k}])=>{I=xt(I,k)}),I},generateStyleSheets:()=>{var F,K;const I=[],k=e.defaultColorScheme||"light";function P(M,u){Object.keys(u).length&&I.push(typeof M=="string"?{[M]:{...u}}:M)}P(n(void 0,{...f}),f);const{[k]:J,...T}=B;if(J){const{css:M}=J,u=(K=(F=c[k])==null?void 0:F.palette)==null?void 0:K.mode,A=!i&&u?{colorScheme:u,...M}:{...M};P(n(k,{...A}),A)}return Object.entries(T).forEach(([M,{css:u}])=>{var d,ne;const A=(ne=(d=c[M])==null?void 0:d.palette)==null?void 0:ne.mode,L=!i&&A?{colorScheme:A,...u}:{...u};P(n(M,{...L}),L)}),a&&I.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)"}}),I}}}function fd(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 Io={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:Io.white,default:Io.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:Io.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:Io.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 ni=Us();function os(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=kn(e.main,s):r==="dark"&&(e.dark=jn(e.main,a)))}function ns(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 wd(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function vi(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),g=e.success||Sd(r),f=e.warning||Cd(r);function v(y){if(s)return wd(y);const w=ts(y,ni.text.primary)>=n?ni.text.primary:Hs.text.primary;if(process.env.NODE_ENV!=="production"){const m=ts(y,w);m<3&&console.error([`MUI: The contrast ratio of ${m}:1 for ${w} on ${y}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
|
|
147
|
+
`))}return w}const S=({color:y,name:w,mainShade:m=500,lightShade:j=300,darkShade:I=700})=>{if(y={...y},!y.main&&y[m]&&(y.main=y[m]),!y.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${w?` (${w})`:""} provided to augmentColor(color) is invalid.
|
|
148
|
+
The color object needs to have a \`main\` property or a \`${m}\` property.`:_r(11,w?` (${w})`:"",m));if(typeof y.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${w?` (${w})`:""} provided to augmentColor(color) is invalid.
|
|
149
|
+
\`color.main\` should be a string, but \`${JSON.stringify(y.main)}\` was provided instead.
|
|
150
150
|
|
|
151
151
|
Did you intend to use one of the following approaches?
|
|
152
152
|
|
|
@@ -158,17 +158,17 @@ const theme1 = createTheme({ palette: {
|
|
|
158
158
|
|
|
159
159
|
const theme2 = createTheme({ palette: {
|
|
160
160
|
primary: { main: green[500] },
|
|
161
|
-
} });`:
|
|
162
|
-
`)),Object.keys(x).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(x).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(
|
|
161
|
+
} });`:_r(12,w?` (${w})`:"",JSON.stringify(y.main)));return s?(ns(s,y,"light",j,i),ns(s,y,"dark",I,i)):(os(y,"light",j,i),os(y,"dark",I,i)),y.contrastText||(y.contrastText=v(y.main)),y};let B;return r==="light"?B=Vs():r==="dark"&&(B=Us()),process.env.NODE_ENV!=="production"&&(B||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),xt({common:{...Io},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:f,name:"warning"}),info:S({color:x,name:"info"}),success:S({color:g,name:"success"}),grey:xd,contrastThreshold:n,getContrastText:v,augmentColor:S,tonalOffset:i,...B},a)}function jd(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 is={textTransform:"uppercase"},ss='"Roboto", "Helvetica", "Arial", sans-serif';function Td(e,r){const{fontFamily:n=ss,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:c=500,fontWeightBold:l=700,htmlFontSize:p=16,allVariants:x,pxToRem:g,...f}=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=g||(y=>`${y/p*v}rem`),B=(y,w,m,j,I)=>({fontFamily:n,fontWeight:y,fontSize:S(w),lineHeight:m,...n===ss?{letterSpacing:`${zd(j/w)}em`}:{},...I,...x}),b={h1:B(s,96,1.167,-1.5),h2:B(s,60,1.2,-.5),h3:B(a,48,1.167,0),h4:B(a,34,1.235,.25),h5:B(a,24,1.334,0),h6:B(c,20,1.6,.15),subtitle1:B(a,16,1.75,.15),subtitle2:B(c,14,1.57,.1),body1:B(a,16,1.5,.15),body2:B(a,14,1.43,.15),button:B(c,14,1.75,.4,is),caption:B(a,12,1.66,.4),overline:B(a,12,2.66,1,is),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},f,{clone:!1})}const Bd=.2,Id=.14,Ed=.12;function Me(...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",Me(0,2,1,-1,0,1,1,0,0,1,3,0),Me(0,3,1,-2,0,2,2,0,0,1,5,0),Me(0,3,3,-2,0,3,4,0,0,1,8,0),Me(0,2,4,-1,0,4,5,0,0,1,10,0),Me(0,3,5,-1,0,5,8,0,0,1,14,0),Me(0,3,5,-1,0,6,10,0,0,1,18,0),Me(0,4,5,-2,0,7,10,1,0,2,16,1),Me(0,5,5,-3,0,8,10,1,0,3,14,2),Me(0,5,6,-3,0,9,12,1,0,3,16,2),Me(0,6,6,-3,0,10,14,1,0,4,18,3),Me(0,6,7,-4,0,11,15,1,0,4,20,3),Me(0,7,8,-4,0,12,17,2,0,5,22,4),Me(0,7,8,-4,0,13,19,2,0,5,24,4),Me(0,7,9,-4,0,14,21,2,0,5,26,4),Me(0,8,9,-5,0,15,22,2,0,6,28,5),Me(0,8,10,-5,0,16,24,2,0,6,30,5),Me(0,8,11,-5,0,17,26,2,0,6,32,5),Me(0,9,11,-5,0,18,28,2,0,7,34,6),Me(0,9,12,-6,0,19,29,2,0,7,36,6),Me(0,10,13,-6,0,20,31,3,0,8,38,7),Me(0,10,13,-6,0,21,33,3,0,8,40,7),Me(0,10,14,-6,0,22,35,3,0,8,42,7),Me(0,11,14,-7,0,23,36,3,0,9,44,8),Me(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 as(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 g=v=>typeof v=="string",f=v=>!Number.isNaN(parseFloat(v));!g(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!f(c)&&!g(c)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${c}.`),g(l)||console.error('MUI: Argument "easing" must be a string.'),!f(p)&&!g(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(g=>`${g} ${typeof c=="string"?c:as(c)} ${l} ${typeof p=="string"?p:as(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 hr(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]:hr(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
|
|
170
|
-
`))}m
|
|
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 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:{...wd(w.typography),...w.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 O={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Ud(P),enableContrastVars:c},{vars:M,generateThemeVars:Y,generateStyleSheets:J}=fd(P,O);return P.vars=M,Object.entries(P.colorSchemes[P.defaultColorScheme]).forEach(([R,u])=>{P[R]=u}),P.generateThemeVars=Y,P.generateStyleSheets=J,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 ${D(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 ye(e,r){return Zd(e,eu[r])}function tt(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, ${D(n,.08)})`,hoverBg:`var(--highlight-hover, ${D(n,.12)})`}}function ue(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||ye(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,w]=f.useState("json"),[P,O]=f.useState(""),[M,Y]=f.useState(""),[J,R]=f.useState(""),[u,A]=f.useState("idle"),[F,d]=f.useState(""),[ne,U]=f.useState(null),[re,ge]=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 fe=await I.text();let ae;try{ae=JSON.parse(fe)}catch{h("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ae)){h("JSON must be an array of objects");return}if(ae.length===0){h("No data rows found in JSON file");return}v(I),k(ae)}catch{h("Network error — please try again")}},X=I=>{I.preventDefault();const te=I.dataTransfer.files[0];te&&V(te)},ce=async()=>{if(P.trim()){A("loading"),d("");try{const I=await Qd(P.trim(),M.trim()||void 0,J.trim()||void 0);U(I.data),ge(I.data.length),A("ready")}catch(I){d((I==null?void 0:I.message)||"Connection failed"),A("error")}}},de=()=>{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(""),w("json"),O(""),Y(""),R(""),A("idle"),d(""),U(null),ge(0),r()},Q=i||S,pe=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",...ue(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",...ue(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:pe,helperText:pe?"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)=>{w(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, ${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: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=>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 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=>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=>Y(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:J,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:ce,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:[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=>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:de,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",...ue(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",...ue(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 ls(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})`:_(r,Rd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${ls(n)})`:kn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${ls(n)})`:jn(r,n)}})}function ii(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:c={},typography:l={},shape:p,colorSpace:x,...g}=e;if(e.vars&&e.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":_r(20));const f=vi({...a,colorSpace:x}),v=Ls(e);let S=xt(v,{mixins:kd(v.breakpoints,i),palette:f,shadows:Dd.slice(),typography:Td(f,l),transitions:Md(c),zIndex:{...Wd}});if(S=xt(S,g),S=r.reduce((B,b)=>xt(B,b),S),process.env.NODE_ENV!=="production"){const B=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],b=(y,w)=>{let m;for(m in y){const j=y[m];if(B.includes(m)&&Object.keys(j).length>0){if(process.env.NODE_ENV!=="production"){const I=sd("",m);console.error([`MUI: The \`${w}\` component increases the CSS specificity of the \`${m}\` internal state.`,"You can not override it like this: ",JSON.stringify(y,null,2),"",`Instead, you need to use the '&.${I}' syntax:`,JSON.stringify({root:{[`&.${I}`]:j}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
|
|
170
|
+
`))}y[m]={}}}};Object.keys(S.components).forEach(y=>{const w=S.components[y].styleOverrides;w&&y.startsWith("Mui")&&b(w,y)})}return S.unstable_sxConfig={...Sn,...g==null?void 0:g.unstable_sxConfig},S.unstable_sx=function(b){return Cn({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=vi({...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 N(e,r,n){!e[r]&&n&&(e[r]=n)}function wo(e){return typeof e!="string"||!e.startsWith("hsl")?e:Fs(e)}function or(e,r){`${r}Channel`in e||(e[`${r}Channel`]=Co(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 Lt=e=>{try{return e()}catch{}},qd=(e="mui")=>ud(e);function Qn(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}=ii({...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",...g}=e,f=Object.keys(n)[0],v=i||(n.light&&f!=="light"?"light":f),S=qd(a),{[v]:B,light:b,dark:y,...w}=n,m={...w};let j=B;if((v==="dark"&&!("dark"in n)||v==="light"&&!("light"in n))&&(j=!0),!j)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${v}\` option is either missing or invalid.`:_r(21,v));let I;c&&(I="oklch");const k=Qn(I,m,j,g,v);b&&!m.light&&Qn(I,m,b,void 0,"light"),y&&!m.dark&&Qn(I,m,y,void 0,"dark");let P={defaultColorScheme:v,...k,cssVarPrefix:a,colorSchemeSelector:p,rootSelector:x,getCssVar:S,colorSchemes:m,font:{...jd(k.typography),...k.font},spacing:Yd(g.spacing)};Object.keys(P.colorSchemes).forEach(M=>{const u=P.colorSchemes[M].palette,A=d=>{const ne=d.split("-"),U=ne[1],re=ne[2];return S(d,u[U][re])};u.mode==="light"&&(N(u.common,"background","#fff"),N(u.common,"onBackground","#000")),u.mode==="dark"&&(N(u.common,"background","#000"),N(u.common,"onBackground","#fff"));function L(d,ne,U){if(I){let re;return d===Er&&(re=`transparent ${((1-U)*100).toFixed(0)}%`),d===Ee&&(re=`#000 ${(U*100).toFixed(0)}%`),d===De&&(re=`#fff ${(U*100).toFixed(0)}%`),`color-mix(in ${I}, ${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"){N(u.Alert,"errorColor",L(Ee,u.error.light,.6)),N(u.Alert,"infoColor",L(Ee,u.info.light,.6)),N(u.Alert,"successColor",L(Ee,u.success.light,.6)),N(u.Alert,"warningColor",L(Ee,u.warning.light,.6)),N(u.Alert,"errorFilledBg",A("palette-error-main")),N(u.Alert,"infoFilledBg",A("palette-info-main")),N(u.Alert,"successFilledBg",A("palette-success-main")),N(u.Alert,"warningFilledBg",A("palette-warning-main")),N(u.Alert,"errorFilledColor",Lt(()=>u.getContrastText(u.error.main))),N(u.Alert,"infoFilledColor",Lt(()=>u.getContrastText(u.info.main))),N(u.Alert,"successFilledColor",Lt(()=>u.getContrastText(u.success.main))),N(u.Alert,"warningFilledColor",Lt(()=>u.getContrastText(u.warning.main))),N(u.Alert,"errorStandardBg",L(De,u.error.light,.9)),N(u.Alert,"infoStandardBg",L(De,u.info.light,.9)),N(u.Alert,"successStandardBg",L(De,u.success.light,.9)),N(u.Alert,"warningStandardBg",L(De,u.warning.light,.9)),N(u.Alert,"errorIconColor",A("palette-error-main")),N(u.Alert,"infoIconColor",A("palette-info-main")),N(u.Alert,"successIconColor",A("palette-success-main")),N(u.Alert,"warningIconColor",A("palette-warning-main")),N(u.AppBar,"defaultBg",A("palette-grey-100")),N(u.Avatar,"defaultBg",A("palette-grey-400")),N(u.Button,"inheritContainedBg",A("palette-grey-300")),N(u.Button,"inheritContainedHoverBg",A("palette-grey-A100")),N(u.Chip,"defaultBorder",A("palette-grey-400")),N(u.Chip,"defaultAvatarColor",A("palette-grey-700")),N(u.Chip,"defaultIconColor",A("palette-grey-700")),N(u.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),N(u.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),N(u.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),N(u.LinearProgress,"primaryBg",L(De,u.primary.main,.62)),N(u.LinearProgress,"secondaryBg",L(De,u.secondary.main,.62)),N(u.LinearProgress,"errorBg",L(De,u.error.main,.62)),N(u.LinearProgress,"infoBg",L(De,u.info.main,.62)),N(u.LinearProgress,"successBg",L(De,u.success.main,.62)),N(u.LinearProgress,"warningBg",L(De,u.warning.main,.62)),N(u.Skeleton,"bg",I?L(Er,u.text.primary,.11):`rgba(${A("palette-text-primaryChannel")} / 0.11)`),N(u.Slider,"primaryTrack",L(De,u.primary.main,.62)),N(u.Slider,"secondaryTrack",L(De,u.secondary.main,.62)),N(u.Slider,"errorTrack",L(De,u.error.main,.62)),N(u.Slider,"infoTrack",L(De,u.info.main,.62)),N(u.Slider,"successTrack",L(De,u.success.main,.62)),N(u.Slider,"warningTrack",L(De,u.warning.main,.62));const d=I?L(Ee,u.background.default,.6825):Yo(u.background.default,.8);N(u.SnackbarContent,"bg",d),N(u.SnackbarContent,"color",Lt(()=>I?ni.text.primary:u.getContrastText(d))),N(u.SpeedDialAction,"fabHoverBg",Yo(u.background.paper,.15)),N(u.StepConnector,"border",A("palette-grey-400")),N(u.StepContent,"border",A("palette-grey-400")),N(u.Switch,"defaultColor",A("palette-common-white")),N(u.Switch,"defaultDisabledColor",A("palette-grey-100")),N(u.Switch,"primaryDisabledColor",L(De,u.primary.main,.62)),N(u.Switch,"secondaryDisabledColor",L(De,u.secondary.main,.62)),N(u.Switch,"errorDisabledColor",L(De,u.error.main,.62)),N(u.Switch,"infoDisabledColor",L(De,u.info.main,.62)),N(u.Switch,"successDisabledColor",L(De,u.success.main,.62)),N(u.Switch,"warningDisabledColor",L(De,u.warning.main,.62)),N(u.TableCell,"border",L(De,L(Er,u.divider,1),.88)),N(u.Tooltip,"bg",L(Er,u.grey[700],.92))}if(u.mode==="dark"){N(u.Alert,"errorColor",L(De,u.error.light,.6)),N(u.Alert,"infoColor",L(De,u.info.light,.6)),N(u.Alert,"successColor",L(De,u.success.light,.6)),N(u.Alert,"warningColor",L(De,u.warning.light,.6)),N(u.Alert,"errorFilledBg",A("palette-error-dark")),N(u.Alert,"infoFilledBg",A("palette-info-dark")),N(u.Alert,"successFilledBg",A("palette-success-dark")),N(u.Alert,"warningFilledBg",A("palette-warning-dark")),N(u.Alert,"errorFilledColor",Lt(()=>u.getContrastText(u.error.dark))),N(u.Alert,"infoFilledColor",Lt(()=>u.getContrastText(u.info.dark))),N(u.Alert,"successFilledColor",Lt(()=>u.getContrastText(u.success.dark))),N(u.Alert,"warningFilledColor",Lt(()=>u.getContrastText(u.warning.dark))),N(u.Alert,"errorStandardBg",L(Ee,u.error.light,.9)),N(u.Alert,"infoStandardBg",L(Ee,u.info.light,.9)),N(u.Alert,"successStandardBg",L(Ee,u.success.light,.9)),N(u.Alert,"warningStandardBg",L(Ee,u.warning.light,.9)),N(u.Alert,"errorIconColor",A("palette-error-main")),N(u.Alert,"infoIconColor",A("palette-info-main")),N(u.Alert,"successIconColor",A("palette-success-main")),N(u.Alert,"warningIconColor",A("palette-warning-main")),N(u.AppBar,"defaultBg",A("palette-grey-900")),N(u.AppBar,"darkBg",A("palette-background-paper")),N(u.AppBar,"darkColor",A("palette-text-primary")),N(u.Avatar,"defaultBg",A("palette-grey-600")),N(u.Button,"inheritContainedBg",A("palette-grey-800")),N(u.Button,"inheritContainedHoverBg",A("palette-grey-700")),N(u.Chip,"defaultBorder",A("palette-grey-700")),N(u.Chip,"defaultAvatarColor",A("palette-grey-300")),N(u.Chip,"defaultIconColor",A("palette-grey-300")),N(u.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),N(u.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),N(u.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),N(u.LinearProgress,"primaryBg",L(Ee,u.primary.main,.5)),N(u.LinearProgress,"secondaryBg",L(Ee,u.secondary.main,.5)),N(u.LinearProgress,"errorBg",L(Ee,u.error.main,.5)),N(u.LinearProgress,"infoBg",L(Ee,u.info.main,.5)),N(u.LinearProgress,"successBg",L(Ee,u.success.main,.5)),N(u.LinearProgress,"warningBg",L(Ee,u.warning.main,.5)),N(u.Skeleton,"bg",I?L(Er,u.text.primary,.13):`rgba(${A("palette-text-primaryChannel")} / 0.13)`),N(u.Slider,"primaryTrack",L(Ee,u.primary.main,.5)),N(u.Slider,"secondaryTrack",L(Ee,u.secondary.main,.5)),N(u.Slider,"errorTrack",L(Ee,u.error.main,.5)),N(u.Slider,"infoTrack",L(Ee,u.info.main,.5)),N(u.Slider,"successTrack",L(Ee,u.success.main,.5)),N(u.Slider,"warningTrack",L(Ee,u.warning.main,.5));const d=I?L(De,u.background.default,.985):Yo(u.background.default,.98);N(u.SnackbarContent,"bg",d),N(u.SnackbarContent,"color",Lt(()=>I?Hs.text.primary:u.getContrastText(d))),N(u.SpeedDialAction,"fabHoverBg",Yo(u.background.paper,.15)),N(u.StepConnector,"border",A("palette-grey-600")),N(u.StepContent,"border",A("palette-grey-600")),N(u.Switch,"defaultColor",A("palette-grey-300")),N(u.Switch,"defaultDisabledColor",A("palette-grey-600")),N(u.Switch,"primaryDisabledColor",L(Ee,u.primary.main,.55)),N(u.Switch,"secondaryDisabledColor",L(Ee,u.secondary.main,.55)),N(u.Switch,"errorDisabledColor",L(Ee,u.error.main,.55)),N(u.Switch,"infoDisabledColor",L(Ee,u.info.main,.55)),N(u.Switch,"successDisabledColor",L(Ee,u.success.main,.55)),N(u.Switch,"warningDisabledColor",L(Ee,u.warning.main,.55)),N(u.TableCell,"border",L(Ee,L(Er,u.divider,1),.68)),N(u.Tooltip,"bg",L(Er,u.grey[700],.92))}or(u.background,"default"),or(u.background,"paper"),or(u.common,"background"),or(u.common,"onBackground"),or(u,"divider"),Object.keys(u).forEach(d=>{const ne=u[d];d!=="tonalOffset"&&ne&&typeof ne=="object"&&(ne.main&&N(u[d],"mainChannel",Co(wo(ne.main))),ne.light&&N(u[d],"lightChannel",Co(wo(ne.light))),ne.dark&&N(u[d],"darkChannel",Co(wo(ne.dark))),ne.contrastText&&N(u[d],"contrastTextChannel",Co(wo(ne.contrastText))),d==="text"&&(or(u[d],"primary"),or(u[d],"secondary")),d==="action"&&(ne.active&&or(u[d],"active"),ne.selected&&or(u[d],"selected")))})}),P=r.reduce((M,u)=>xt(M,u),P);const J={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:l,getSelector:Ud(P),enableContrastVars:c},{vars:T,generateThemeVars:F,generateStyleSheets:K}=md(P,J);return P.vars=T,Object.entries(P.colorSchemes[P.defaultColorScheme]).forEach(([M,u])=>{P[M]=u}),P.generateThemeVars=F,P.generateStyleSheets=K,P.generateSpacing=function(){return Ns(g.spacing,gi(this))},P.getColorSchemeSelector=fd(p),P.spacing=P.generateSpacing(),P.shouldSkipGeneratingVar=l,P.unstable_sxConfig={...Sn,...g==null?void 0:g.unstable_sxConfig},P.unstable_sx=function(u){return Cn({sx:u,theme:this})},P.toRuntimeSource=Gs,P}function cs(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:vi({...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 ii(e,...r);let g=n;"palette"in e||x[l]&&(x[l]!==!0?g=x[l].palette:l==="dark"&&(g={mode:"dark"}));const f=ii({...e,palette:g},...r);return f.defaultColorScheme=l,f.colorSchemes=x,f.palette.mode==="light"&&(f.colorSchemes.light={...x.light!==!0&&x.light,palette:f.palette},cs(f,"dark",x.dark)),f.palette.mode==="dark"&&(f.colorSchemes.dark={...x.dark!==!0&&x.dark,palette:f.palette},cs(f,"light",x.light)),f}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 dt(){const e=rd(Xd);return process.env.NODE_ENV!=="production"&&ln.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 g=["data","results","items","records"].find(f=>l[f]&&Array.isArray(l[f]));if(g)p=l[g];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.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 ye(e,r){return Zd(e,eu[r])}function ot(e){return`${Number(e.shape.borderRadius)*1.5}px`}function $o(e){return`${Number(e.shape.borderRadius)}px`}function ds(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 st(e){const r=e.tokens,n=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:n,bg:`var(--highlight-bg, ${_(n,.08)})`,hoverBg:`var(--highlight-hover, ${_(n,.12)})`}}function ue(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||ye(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]=h.useState(""),[l,p]=h.useState(!1),[x,g]=h.useState(""),[f,v]=h.useState(null),[S,B]=h.useState(null),[b,y]=h.useState(!1),[w,m]=h.useState(""),j=h.useRef(null),[I,k]=h.useState("json"),[P,J]=h.useState(""),[T,F]=h.useState(""),[K,M]=h.useState(""),[u,A]=h.useState("idle"),[L,d]=h.useState(""),[ne,U]=h.useState(null),[re,ge]=h.useState(0),V=async E=>{if(m(""),!E.name.endsWith(".json")){m("Only .json files are allowed");return}const te=10*1024*1024;if(E.size>te){m("File size exceeds 10MB limit");return}try{const fe=await E.text();let ae;try{ae=JSON.parse(fe)}catch{m("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ae)){m("JSON must be an array of objects");return}if(ae.length===0){m("No data rows found in JSON file");return}v(E),B(ae)}catch{m("Network error — please try again")}},X=E=>{E.preventDefault();const te=E.dataTransfer.files[0];te&&V(te)},ce=async()=>{if(P.trim()){A("loading"),d("");try{const E=await Qd(P.trim(),T.trim()||void 0,K.trim()||void 0);U(E.data),ge(E.data.length),A("ready")}catch(E){d((E==null?void 0:E.message)||"Connection failed"),A("error")}}},de=()=>{if(!a.trim()){p(!0);return}const E=I==="api"?ne:i||S;E&&(n(a.trim(),x.trim(),E),ie())},ie=()=>{c(""),p(!1),g(""),v(null),B(null),m(""),k("json"),J(""),F(""),M(""),A("idle"),d(""),U(null),ge(0),r()},Q=i||S,pe=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:E=>({borderRadius:ot(E),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...ue(E).paper})},children:[t.jsxs(o.DialogTitle,{sx:E=>({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",...ue(E).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:E=>{c(E.target.value),l&&E.target.value.trim()&&p(!1)},placeholder:"Enter report name",autoFocus:!0,error:pe,helperText:pe?"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:E=>g(E.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:I==="json"?0:1,onChange:(E,te)=>{k(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:E=>`var(--highlight-hover, ${_(E.palette.primary.main,.15)})`},"&:hover":{bgcolor:E=>`var(--highlight-hover, ${_(E.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:E=>`var(--highlight-hover, ${_(E.palette.primary.main,.15)})`},"&:hover":{bgcolor:E=>`var(--highlight-hover, ${_(E.palette.primary.main,.08)})`}}})]}),I==="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:E=>_(E.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:E=>_(E.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:()=>y(!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:E=>E.preventDefault(),onPaste:E=>E.preventDefault(),onClick:()=>{var E;return(E=j.current)==null?void 0:E.click()},sx:{position:"relative",border:"1.5px",borderStyle:S?"solid":"dashed",borderColor:S?"success.main":w?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:S?E=>_(E.palette.success.main,.04):w?E=>_(E.palette.error.main,.04):E=>_(E.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:S?E=>_(E.palette.success.main,.08):w?E=>_(E.palette.error.main,.08):E=>_(E.palette.primary.main,.08),borderColor:S?"success.dark":w?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:j,type:"file",accept:".json",sx:{display:"none"},onChange:E=>{var te;return((te=E.target.files)==null?void 0:te[0])&&V(E.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:E=>_(E.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:f==null?void 0:f.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:E=>_(E.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"}),w&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:E=>_(E.palette.error.main,.08),border:1,borderColor:E=>_(E.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:w})})]})]})]})}),I==="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:E=>{J(E.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:T,onChange:E=>F(E.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:E=>M(E.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:ce,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:E=>_(E.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:E=>_(E.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:E=>_(E.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:L})]})]})]})]})}),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:E=>`${E.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:E=>_(E.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:de,disabled:I==="json"&&!Q||I==="api"&&u!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:E=>`${E.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:()=>y(!1),maxWidth:"sm",PaperProps:{sx:E=>({borderRadius:3,width:560,maxHeight:"80vh",...ue(E).paper})},children:[t.jsxs(o.DialogTitle,{sx:E=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...ue(E).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>y(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx($.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:()=>
|
|
181
|
+
]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>y(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:E=>`${E.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:ot(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ue(n).paper})},children:[t.jsxs(o.DialogTitle,{sx:n=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(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=>ye(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>ye(n,"hoverButton")},"&:active":{boxShadow:n=>ye(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=>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(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=>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 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=>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 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=>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 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(Y){S.current&&!S.current.contains(Y.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 Y;r(M),i(M),p(!1),(Y=k.current)==null||Y.blur()},[r,i]),h=f.useCallback(M=>{v(-1),z(M)},[z]),B=f.useCallback(M=>{var Y;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),(Y=k.current)==null||Y.blur()):M.key==="ArrowDown"?(M.preventDefault(),n.length>0&&(l||p(!0),v(J=>J<n.length-1?J+1:J))):M.key==="ArrowUp"&&(M.preventDefault(),v(J=>J>0?J-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,Y)=>t.jsx(cs,{entry:M,isSelected:g===Y,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,Y)=>{const J=w.length+Y;return t.jsx(cs,{entry:M,isSelected:g===J,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=>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 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),[w,P]=f.useState({top:0,left:0}),[O,M]=f.useState(null),[Y,J]=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),ge=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=()=>{O&&(i(O),M(null))},ce=()=>{M(null)},de=(I,te=!1)=>{const fe=I.scope==="global",ae=!k&&(!fe||b),ze=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:()=>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?q=>q.typography.body2.fontWeight||500:400,fontSize:q=>q.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:[ae&&c&&t.jsx(o.IconButton,{onClick:q=>{q.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}})}),ae&&a&&!I.isDefault&&t.jsx(o.IconButton,{onClick:q=>{q.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}})}),(ae||ze)&&(x||y||g||v||ze&&S)&&t.jsx(o.IconButton,{onClick:q=>{q.stopPropagation(),J({el:q.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,pe=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?D(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?D(m.palette.warning.main,.2):D(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"}),pe&&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:w.top,left:w.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=>de(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=>de(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=>de(I))]})]}),ge.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 (",ge.length,")"]}),t.jsx($.ChevronRight,{sx:{fontSize:16}})]}),B&&t.jsx(o.Box,{sx:{backgroundColor:m.palette.action.hover},children:ge.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:!!Y,anchorEl:(Y==null?void 0:Y.el)||null,onClose:()=>J(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[x&&t.jsxs(o.MenuItem,{onClick:()=>{Y&&x(Y.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Edit,{sx:{fontSize:18}}),"Edit"]}),g&&t.jsxs(o.MenuItem,{onClick:()=>{Y&&g(Y.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Link,{sx:{fontSize:18}}),"Copy Link"]}),y&&t.jsxs(o.MenuItem,{onClick:()=>{Y&&y(Y.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),S&&b&&(Y==null?void 0:Y.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{Y&&S(Y.view.id),J(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:()=>{Y&&v(Y.view.id),J(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:ce,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:ce,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 J=T.current,R=J.getBoundingClientRect(),u=window.innerWidth,A=window.innerHeight;R.right>u-8&&(J.style.left=`${u-R.width-8}px`),R.bottom>A-8&&(J.style.top=`${A-R.height-8}px`)},[l]),f.useEffect(()=>{const J=u=>{T.current&&!T.current.contains(u.target)&&z()},R=u=>{u.key==="Escape"&&z()};return document.addEventListener("mousedown",J),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("keydown",R)}},[z]);const w=f.useCallback(J=>()=>{J(),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",Y=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return bs.createPortal(t.jsxs(o.Paper,{ref:T,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:h.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:$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:J=>J.typography.body2.fontSize||"0.8125rem",fontWeight:J=>J.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 (${Y})`,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 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:w,onResetLayout:P}){const M=ct().urmTable,Y=f.useRef(null),[J,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,pe){var We;if(!Y.current)return;const I=Q.index,te=n;if(I===te)return;const fe=(We=Y.current)==null?void 0:We.getBoundingClientRect(),ae=(fe.right-fe.left)/2,ze=pe.getClientOffset(),q=((ze==null?void 0:ze.x)??0)-fe.left;I<te&&q<ae||I>te&&q>ae||(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(Y));const ge=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]),ce=f.useCallback(Q=>{Q.stopPropagation(),z(r.name)},[z,r.name]),de=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:ce,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,ce]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:Y,"data-handler-id":F,"data-column-index":n,onClick:X,onContextMenu:ge,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=>D(Q.palette.primary.main,.08):(M==null?void 0:M.headerBg)??"action.hover",boxShadow:Q=>`0 1px 0 ${D(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=>D(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),de(),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"}})]}),J&&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:w,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:D(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 D(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,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=>it(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(it(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:ye(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:ye(h,"cardRest")},transform:y&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:h=>D(it(h).main,.03)}},children:[t.jsxs(o.Box,{sx:h=>{var O,M,Y,J;const B=((Y=(M=(O=h.components)==null?void 0:O.MuiCardHeader)==null?void 0:M.styleOverrides)==null?void 0:Y.root)||{},T=(B.backgroundColor&&B.backgroundColor!=="transparent"?B.backgroundColor:void 0)??((J=h.tokens)==null?void 0:J.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: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=>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 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=>ye(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: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=>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])=>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)},w=()=>{T(),s(1)},P=()=>{T(),e>1&&s(e-1)},O=()=>{T(),e<p&&s(e+1)},M=()=>{T(),s(p)},Y=(e-1)*r+1,J=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:[Y,"–",J," 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 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: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 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=ue(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(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=ue(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(Zs,{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=>ye(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>ye(l,"hoverButton")},"&:active":{boxShadow:l=>ye(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 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=ue(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: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: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 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:w,onSaveAsNewView:P,onDiscardChanges:O,onToggleDefault:M,onToggleFavorite:Y,onRestoreView:J,onPermanentDelete:R,onEditView:u,onCloneView:A,onCopyLink:F,onDeleteView:d,onPromoteToGlobal:ne,isAdmin:U=!1,onExport:re,onOpenColumns:ge,onUpdateColumnWidth:V,onUpdateColumnOrder:X,onUpdateColumnVisibility:ce,onClearFiltersForColumn:de,onResetLayout:ie,onOpenGroup:Q,onGroupByColumn:pe,onToggleGroupCollapse:I,onExpandAllGroups:te,onCollapseAllGroups:fe,onOpenAuditHistory:ae,onOpenScheduledReports:ze,searchQuery:q,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:ao=1,pageSize:rr=15,totalRowsBeforePagination:lo=r.length,onPageChange:Tt,onPageSizeChange:mr,isReadOnly:Je=!1,userRole:Mt,reportName:Vt,onEditRow:Qe,onDuplicateRow:Ze,onDeleteRow:Wt,showDevPanel:co=!1,onOpenDevConfig:Mr,rowActions:xr,hideDefaultRowActions:Ve,hideToolbarActions:ke,customSettingsActions:or,viewOptions:At,defaultViewMode:gr,bulkActions:yr,hideSelectionCheckboxes:Ht,rowClickBehavior:nr="select",openModalOn:et,onRowClick:ir,onRowRightClick:gt}){var Ro;const ee=ct().urmTable,[br,Ar]=f.useState(null),[Bt,H]=f.useState(0),[ut,se]=f.useState(0),[Ke,sr]=f.useState(null),uo=((Ro=Dr().dates)==null?void 0:Ro.displayFormat)??null,[Ut,Sr]=f.useState(null),[Gt,ar]=f.useState(null),[Yt,ve]=f.useState(null),[yt,Z]=f.useState(!1),[he,be]=f.useState(!1),[Cr,jr]=f.useState(null),[po,Rr]=f.useState(!1),[ho,qt]=f.useState(null),[Pr,Nr]=f.useState(null),[Se,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[xe,Ce]=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),fo=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]),mo=!!(g!=null&&g.enabled&&(g!=null&&g.levels)&&g.levels.length>0),Yr=f.useMemo(()=>{if(!mo)return Ur;const C=((g==null?void 0:g.levels)??[]).map(oe=>e.find(je=>je.name===oe.column)).filter(oe=>oe!==void 0),N=Ur.filter(oe=>!Gr.has(oe.name));return[...C,...N]},[Ur,mo,Gr,g,e]),{widths:qr}=_u(Yr,y,zn,mo?Gr:void 0),lr=f.useMemo(()=>e.filter(C=>p[C.name]===!1).length,[e,p]),xo=f.useMemo(()=>e.map(C=>C.name),[e]),Jr=f.useMemo(()=>x.length===0?!1:JSON.stringify(x)!==JSON.stringify(xo),[x,xo]),Tn=f.useCallback((C,N)=>{C.preventDefault(),C.stopPropagation(),Ar(N),H(C.clientX),se(y[N]||150)},[y]);f.useEffect(()=>{if(!br)return;const C=oe=>{const je=oe.clientX-Bt,Ae=Math.max(100,Math.min(600,ut+je));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=>{ce&&ce(C,!1)},[ce]),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=(ao-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 go=f.useCallback((C,N)=>{ir==null||ir(Me[C],C,N),(nr==="activate"||nr==="both")&&(ve(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,ve,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 je=oe.groupLevel??0;N[je]=oe.groupKey,N=N.slice(0,je+1),C.has(oe.groupKey)||C.set(oe.groupKey,[])}else if(oe.__urm_is_grouped_data_row__)for(const je of N)je&&C.has(je)&&C.get(je).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",je=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)"),rt=`${C.rowCount} ${C.rowCount===1?"item":"items"}`,Xe=Wo.get(C.groupKey)||[],me=Xe.filter(_e=>at.has(_e==null?void 0:_e.__urm_row_id__)).length,Rt=Xe.length>0&&me===Xe.length,Xt=me>0&&me<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:je,"&:hover":{bgcolor:_e=>D(_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=>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: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__),je=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:me=>{me.target.closest("[data-row-action-btn]")||go(N,me)},onDoubleClick:()=>{et!=null&&et.includes("doubleClick")&&(ve(C),Z(!0))},onContextMenu:me=>{me.preventDefault(),me.stopPropagation(),gt==null||gt(C,N,me),st(null),Ge({mouseX:me.clientX,mouseY:me.clientY,row:C,rowIndex:N}),et!=null&&et.includes("rightClick")&&(ve(C),Z(!0))},sx:{cursor:"pointer",bgcolor:oe?me=>it(me).bg:Ae?me=>D(me.palette.info.main,.12):ee!=null&&ee.striped&&N%2===1?ee.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:oe?me=>it(me).hoverBg:Ae?me=>D(me.palette.info.main,.2):me=>`var(--highlight-hover-row, ${D(it(me).main,.04)})`},borderBottom:(ee==null?void 0:ee.rowDivider)??"1px solid",borderColor:"divider"},children:[Dt&&t.jsx(o.TableCell,{padding:"checkbox",onClick:me=>me.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((me,Rt)=>{const Xt=Rt===0,_e=Tr.has(me.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[me.name]?`${y[me.name]}px`:`${me.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(me,C[me.name],uo,We)})})]},me.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:je?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:me=>{me.stopPropagation(),me.preventDefault(),st(null),Ge({anchorEl:me.currentTarget,row:C,rowIndex:N})},sx:{color:"text.secondary",opacity:je?1:0,transition:"opacity 0.12s ease",pointerEvents:je?"auto":"none","&:hover":{bgcolor:me=>D(me.palette.text.primary,.08),color:"text.primary"}},children:t.jsx($.MoreVert,{sx:{fontSize:18}})})})})]},N)},[ot,An,Gt,go,Yr,y,We,Bn,Qe,Ze,Wt,qe,Dt,ve,Z,Yt,yt,Ge,Kr,Gr,gt,et]);return t.jsxs(Zt.DndProvider,{backend:ni.HTML5Backend,children:[t.jsxs(o.Box,{sx:C=>{var rt,Xe,me;const N=((me=(Xe=(rt=C.components)==null?void 0:rt.MuiCard)==null?void 0:Xe.styleOverrides)==null?void 0:me.root)||{},oe=N.border&&N.border!=="none"?N.border:"1px solid",je=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:ye(C,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:oe,borderColor:oe!=="none"?"divider":void 0,borderRadius:je,boxShadow:Ae,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:C=>{var rt,Xe,me,Rt,Xt;const N=((me=(Xe=(rt=C.components)==null?void 0:rt.MuiCardHeader)==null?void 0:Xe.styleOverrides)==null?void 0:me.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,je=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:je,borderColor:je!=="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:q||"",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=>D(C.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.InfoOutlined,{sx:{fontSize:20}})})}),B&&T&&w&&s.length>0&&t.jsx(su,{views:s||[],activeViewId:a||"",isDirty:c,onSelectView:B,onCreateView:T,onToggleDefault:M,onToggleFavorite:Y,onRestoreView:J,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:[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=>ye(C,"restButton"),"&:hover":{bgcolor:C=>`var(--urm-btn-save-current-hover-bg, ${C.palette.primary.dark})`,boxShadow:C=>ye(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"})]}),co&&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=>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}}),!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=>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})]})}),!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=>D(C.palette.primary.main,.2):C=>D(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&&ge&&!(ke!=null&&ke.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:ge,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=>D(C.palette.primary.main,.2):C=>D(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||fe)&&(()=>{var oe;const C=(((oe=g==null?void 0:g.collapsedGroups)==null?void 0:oe.length)??0)>0,N=C?te: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:je=>D(je.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}}),je=C==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:je,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=>D(Ae.palette.primary.main,.2):Ae=>D(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=>Ce(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:!!xe,anchorEl:xe,onClose:()=>Ce(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(),Ce(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(),Ce(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"})]}),ae&&!(ke!=null&&ke.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ae(),Ce(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(),Ce(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(),Ce(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,je;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:(je=C.disabled)==null?void 0:je.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)=>go(C,N),onCardDoubleClick:C=>{et!=null&&et.includes("doubleClick")&&(ve(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}),et!=null&&et.includes("rightClick")&&(ve(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=>{fo.current&&(fo.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(je=>je.column===C.name),hasFilters:Xn(i,C.name),isInSortStack:n.some(je=>je.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:de||(()=>{}),onGroupByColumn:pe,onHideColumn:Mn,onManageColumns:ge||(()=>{}),onResetLayout:ie},C.name)})]})})]})}),t.jsx(o.Box,{ref:fo,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=>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(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:ao,pageSize:rr,totalRows:lo,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:!!Se,onClose:()=>{Ge(null),st(null)},anchorEl:(Se==null?void 0:Se.anchorEl)||null,anchorReference:Se!=null&&Se.anchorEl?"anchorEl":"anchorPosition",anchorPosition:Se&&!Se.anchorEl?{top:Se.mouseY,left:Se.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:Se!=null&&Se.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:()=>{Se&&(ve(Se.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:()=>{Se&&(qt(Se.row),Nr(Se.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:()=>{Se&&(Ze==null||Ze(Se.rowIndex,Se.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"})]}),Se&&(xr==null?void 0:xr.map(C=>{var N,oe;return(N=C.hidden)!=null&&N.call(C,Se.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(oe=C.disabled)==null?void 0:oe.call(C,Se.row),onClick:()=>{C.onClick(Se.row,Se.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:()=>{Se&&(jr(Se.row),be(!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),ve(null)},row:Yt,schema:e,reportName:Vt}),t.jsx(Tu,{open:po,onClose:()=>{Rr(!1),qt(null),Nr(null)},onSave:C=>{Pr!==null&&(Qe==null||Qe(Pr,C))},row:ho,schema:e,reportName:Vt}),t.jsx(zu,{open:he,onClose:()=>{be(!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=>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 _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 so(x,e.id,{id:io(),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=>so(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=>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(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(so(m,m.id,{id:io(),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=>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=>ue(m).paper.boxShadow,border:m=>ue(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=>ue(m).header.backgroundColor,borderBottom:m=>ue(m).header.borderBottom,boxShadow:m=>ue(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=>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 "${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=>ye(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=>ye(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 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((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(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=>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=>ue(h).paper.boxShadow,border:h=>ue(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=>ue(h).header.backgroundColor,borderBottom:h=>ue(h).header.borderBottom,boxShadow:h=>ue(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=>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: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=>ye(h,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:h=>ye(h,"hoverButton")},"&:active":{boxShadow:h=>ye(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:tt(T),...ue(T).paper})},children:[t.jsxs(o.DialogTitle,{sx:T=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(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=>ye(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>ye(T,"hoverButton")},"&:active":{boxShadow:T=>ye(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:tt(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...ue(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(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=>ye(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ye(i,"hoverButton")},"&:active":{boxShadow:i=>ye(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 J;if(!l.current)return;const T=h.index,w=r;if(T===w)return;const P=(J=l.current)==null?void 0:J.getBoundingClientRect(),O=(P.bottom-P.top)/2,M=B.getClientOffset(),Y=((M==null?void 0:M.y)??0)-P.top;T<w&&Y<O||T>w&&Y>O||(c(T,w),h.index=w)}}),[{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=>D(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)},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,Y=e.length,J=s.find(u=>u.id===a),R=f.useMemo(()=>{if(!J)return!1;const u=J.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??{},ge=JSON.stringify(b)!==JSON.stringify(re);return F||U||ge},[J,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=>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=>ue(u).paper.boxShadow,border:u=>ue(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=>ue(u).header.backgroundColor,borderBottom:u=>ue(u).header.borderBottom,boxShadow:u=>ue(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=>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: ${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: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(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 ",Y," 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=>ue(u).paper.boxShadow,border:u=>ue(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=>ye(u,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:u=>ye(u,"hoverButton")},"&:active":{boxShadow:u=>ye(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(O=>!s.levels.some((M,Y)=>M.column===O.name&&Y!==p)),[y,s.levels,p]),v=Dr(),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((Y,J)=>J!==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 Y=M==="up"?O-1:O+1;if(Y<0||Y>=s.levels.length)return;const J=[...s.levels],[R]=J.splice(O,1);J.splice(Y,0,R),a({...s,levels:J})},[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=>ue(O).paper.boxShadow,border:O=>ue(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=>ue(O).header.backgroundColor,borderBottom:O=>ue(O).header.borderBottom,boxShadow:O=>ue(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($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: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:[lt(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:[lt(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=>ye(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 Y=e.find(J=>J.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:J=>ye(J,"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:J=>`0 1px 2px 0 ${D(J.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:J=>J.typography.body2.fontWeight||500,fontSize:J=>J.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:O.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:J=>J.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:Y==null?void 0:Y.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:J=>D(J.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=>ye(O,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:O=>ye(O,"hoverButton")},"&:active":{boxShadow:O=>ye(O,"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: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",...ue(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,...ue(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:D(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: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=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:D(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: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: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),...ue(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 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=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=>ue(w).paper.boxShadow,border:w=>ue(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=>ue(w).header.backgroundColor,borderBottom:w=>ue(w).header.borderBottom,boxShadow:w=>ue(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=>ye(w,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:w=>ye(w,"hoverButton")},"&:active":{boxShadow:w=>ye(w,"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=>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 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=>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=>ue(c).paper.boxShadow,border:c=>ue(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=>ue(c).header.backgroundColor,borderBottom:c=>ue(c).header.borderBottom,boxShadow:c=>ue(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=>ye(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=>ye(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>ye(c,"hoverButton")},"&:active":{boxShadow:c=>ye(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=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 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: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 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 ce,de,ie,Q,pe;const U=((ie=(de=(ce=b.components)==null?void 0:ce.MuiCard)==null?void 0:de.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,ge=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:((pe=b.tokens)==null?void 0:pe.cardBodyShadow)||ye(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:ge,cardShadow:V,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(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,w]=f.useState(B),[P,O]=f.useState(y),[M,Y]=f.useState(g),J=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: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: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: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:U=>ue(U).header.backgroundColor,borderBottom:U=>ue(U).header.borderBottom,boxShadow:U=>ue(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: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((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:()=>w(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:D(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 ${D(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:ge=>ge.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:()=>O(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:D(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:ge=>ge.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:()=>Y(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:D(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:ge=>ge.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:J.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:ge,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:ge})]},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: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 ",ne[T]]})]})]})})}function mp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx($.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=3e4}){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",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx($.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=>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 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 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 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=>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: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(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: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=>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 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=>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: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=>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 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),...ue(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 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=>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: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=>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: ",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=>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(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))},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??""}),Y=g.type!=="list",J=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:Y,PaperProps:{sx:R=>({borderRadius:tt(R),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ue(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,...ue(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($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=>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:[Y&&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":`${J} 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: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(Ep,{scheduleName:b.name,onConfirm:O,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:w,columnOrder:P,filters:O,sortStack:M,schedulerConfig:Y,schedulerMode:J}=S.current;try{const ne=b.scope==="all"?z:h;if(J==="api"){const ge=(P.length>0?P:B.map(X=>X.name)).filter(X=>w[X]!==!1),V={schedule:b,triggeredAt:new Date().toISOString(),rows:ne,columns:ge,format:b.format,reportName:m};(R=Y==null?void 0:Y.onScheduleFire)==null||R.call(Y,V),(A=(u=S.current).onFired)==null||A.call(u,b);return}const U=Qo(ne,B,O,M,T,w,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(Y!=null&&Y.onScheduleFire){const ge=(P.length>0?P:B.map(V=>V.name)).filter(V=>w[V]!==!1);Y.onScheduleFire({schedule:b,triggeredAt:new Date().toISOString(),rows:ne,columns:ge,format:b.format,reportName:m})}if(b.email){const ge=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=>ye(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>ye(n,"hoverButton")},"&:active":{boxShadow:n=>ye(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function ru({onFileUpload:e,onError:r,isUploading:n}){const[i,s]=h.useState(!1),[a,c]=h.useState(""),[l,p]=h.useState(!1),x=h.useRef(null),g=async w=>{if(!w.name.endsWith(".json")){r("Only .json files are allowed");return}const m=10*1024*1024;if(w.size>m){r("File size exceeds 10MB limit");return}c(w.name);try{const j=await w.text();let I;try{I=JSON.parse(j)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(I)){r("JSON must be an array of objects");return}if(I.length===0){r("No data rows found in JSON file");return}e(I)}catch{r("Network error — please try again")}finally{c("")}},f=w=>{w.preventDefault(),s(!0)},v=w=>{w.preventDefault(),s(!1)},S=w=>{w.preventDefault(),s(!1);const m=w.dataTransfer.files[0];m&&g(m)},B=()=>{var w;(w=x.current)==null||w.click()},b=w=>{var j;const m=(j=w.target.files)==null?void 0:j[0];m&&g(m)},y=w=>{w.stopPropagation(),p(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:f,onDragLeave:v,onDrop:S,onPaste:w=>w.preventDefault(),onClick:B,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?w=>_(w.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[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:w=>w.typography.body2.fontWeight||500,fontSize:w=>w.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:w=>_(w.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:y,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=>_(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=>_(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>_(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.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=>_(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]=h.useState(!1),[x,g]=h.useState(!1),[f,v]=h.useState(-1),S=h.useRef(null),B=h.useRef(null);h.useEffect(()=>{function T(F){S.current&&!S.current.contains(F.target)&&(p(!1),g(!1))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const b=h.useCallback(()=>{g(!0),v(-1),n.length>0&&p(!0)},[n.length]),y=h.useCallback(T=>{r(T),v(-1)},[r]),w=h.useCallback(T=>{var F;r(T),i(T),p(!1),(F=B.current)==null||F.blur()},[r,i]),m=h.useCallback(T=>{v(-1),w(T)},[w]),j=h.useCallback(T=>{var F;T.key==="Enter"?f>=0&&f<n.length?(T.preventDefault(),m(n[f].query)):e.trim()&&w(e.trim()):T.key==="Escape"?(p(!1),v(-1),(F=B.current)==null||F.blur()):T.key==="ArrowDown"?(T.preventDefault(),n.length>0&&(l||p(!0),v(K=>K<n.length-1?K+1:K))):T.key==="ArrowUp"&&(T.preventDefault(),v(K=>K>0?K-1:-1))},[f,n,e,l,m,w]),I=h.useCallback(()=>{var T;r(""),(T=B.current)==null||T.focus()},[r]),k=h.useMemo(()=>n.filter(T=>T.isFavourite),[n]),P=h.useMemo(()=>n.filter(T=>!T.isFavourite),[n]),J=l&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:S,children:[t.jsx(o.TextField,{inputRef:B,size:"small",fullWidth:!0,value:e,onChange:T=>y(T.target.value),onFocus:b,onKeyDown:j,placeholder:"Search data...",disabled:c,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:T=>_(T.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:T=>_(T.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:I,edge:"end",sx:{mr:-.5},children:t.jsx($.Close,{sx:{fontSize:16}})})}):null}}),J&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[k.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:T=>T.typography.caption.fontWeight||600,fontSize:T=>T.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),k.map((T,F)=>t.jsx(us,{entry:T,isSelected:f===F,onClick:()=>m(T.query),onToggleFavourite:()=>s(T.query),onDelete:()=>a(T.query)},`fav-${T.query}`))]}),P.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[k.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:T=>T.typography.caption.fontWeight||600,fontSize:T=>T.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),P.map((T,F)=>{const K=k.length+F;return t.jsx(us,{entry:T,isSelected:f===K,onClick:()=>m(T.query),onToggleFavourite:()=>s(T.query),onDelete:()=>a(T.query)},`recent-${T.query}`)})]})]})]})}const us=h.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const c=h.useCallback(p=>{p.stopPropagation(),s()},[s]),l=h.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=>_(p.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?p=>_(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:g,onCopyLink:f,onDeleteView:v,onPromoteToGlobal:S,isReadOnly:B,isAdmin:b=!1}){const y=dt(),[w,m]=h.useState(!1),[j,I]=h.useState(!1),[k,P]=h.useState({top:0,left:0}),[J,T]=h.useState(null),[F,K]=h.useState(null),M=h.useRef(null),u=h.useRef(null),A=e.find(E=>E.id===r),L=A==null?void 0:A.isDefault,d=(E,te)=>E.name.localeCompare(te.name),ne=e.filter(E=>E.scope==="global"&&!E.isDeleted).sort(d),U=e.filter(E=>E.scope!=="global"&&!E.isDeleted).sort(d),re=e.filter(E=>E.isFavorite&&!E.isDeleted).sort(d),ge=e.filter(E=>E.isDeleted);h.useEffect(()=>{if(w&&u.current){const E=u.current.getBoundingClientRect();P({top:E.bottom+window.scrollY+8,left:E.right+window.scrollX-320})}},[w]),h.useEffect(()=>{const E=te=>{M.current&&!M.current.contains(te.target)&&u.current&&!u.current.contains(te.target)&&m(!1)};return w&&document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E)}},[w]);const V=E=>{if(n&&E!==r){T(E),m(!1);return}i(E),m(!1)},X=()=>{J&&(i(J),T(null))},ce=()=>{T(null)},de=(E,te=!1)=>{const fe=E.scope==="global",ae=!B&&(!fe||b),Te=b&&!fe;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===E.id?_(y.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===E.id?_(y.palette.primary.main,.12):y.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>V(E.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===E.id&&t.jsx($.Check,{sx:{fontSize:16,flexShrink:0}}),r!==E.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===E.id?y.palette.primary.dark:y.palette.text.primary,fontWeight:r===E.id?Y=>Y.typography.body2.fontWeight||500:400,fontSize:Y=>Y.typography.body2.fontSize||"0.875rem"},children:E.name}),te&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:y.palette.text.secondary,backgroundColor:y.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:[ae&&c&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),c(E.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:E.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx($.Star,{sx:{fontSize:16}})}),ae&&a&&!E.isDefault&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),a(E.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Set as default",children:t.jsx($.RadioButtonUnchecked,{sx:{fontSize:16}})}),(ae||Te)&&(x||g||f||v||Te&&S)&&t.jsx(o.IconButton,{onClick:Y=>{Y.stopPropagation(),K({el:Y.currentTarget,view:E})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"More actions",children:t.jsx($.MoreVert,{sx:{fontSize:16}})})]})]},E.id)},ie=E=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:y.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:y.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:E.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(E.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.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(E.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Delete permanently",children:t.jsx($.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},E.id),Q=n||!L,pe=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:u,onClick:()=>m(!w),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?_(y.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?_(y.palette.warning.main,.2):_(y.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"}),pe&&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"}})]}),w&&Ss.createPortal(t.jsxs(o.Box,{ref:M,sx:{position:"fixed",width:"320px",backgroundColor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:1,boxShadow:y.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:k.top,left:k.left},children:[ne.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:E=>E.typography.caption.fontSize||"caption.fontSize",fontWeight:E=>E.typography.caption.fontWeight||600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),ne.map(E=>de(E,E.isDefault))]}),re.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.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:y.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(E=>de(E))]})]}),U.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:E=>E.typography.caption.fontSize||"caption.fontSize",fontWeight:E=>E.typography.caption.fontWeight||600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),U.map(E=>de(E))]})]}),ge.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>I(!j),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",ge.length,")"]}),t.jsx($.ChevronRight,{sx:{fontSize:16}})]}),j&&t.jsx(o.Box,{sx:{backgroundColor:y.palette.action.hover},children:ge.map(E=>ie(E))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),m(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:y.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:y.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:!!F,anchorEl:(F==null?void 0:F.el)||null,onClose:()=>K(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[x&&t.jsxs(o.MenuItem,{onClick:()=>{F&&x(F.view.id),K(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Edit,{sx:{fontSize:18}}),"Edit"]}),f&&t.jsxs(o.MenuItem,{onClick:()=>{F&&f(F.view.id),K(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.Link,{sx:{fontSize:18}}),"Copy Link"]}),g&&t.jsxs(o.MenuItem,{onClick:()=>{F&&g(F.view.id),K(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx($.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),S&&b&&(F==null?void 0:F.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{F&&S(F.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:()=>{F&&v(F.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:J!==null,onClose:ce,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:$o(y)}},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:ce,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:g,onFilter:f,onClearFilter:v,onGroupByColumn:S,onHideColumn:B,onManageColumns:b,onResetLayout:y,onClose:w}){const m=dt(),j=m.palette,I=h.useRef(null);h.useEffect(()=>{if(!I.current)return;const K=I.current,M=K.getBoundingClientRect(),u=window.innerWidth,A=window.innerHeight;M.right>u-8&&(K.style.left=`${u-M.width-8}px`),M.bottom>A-8&&(K.style.top=`${A-M.height-8}px`)},[l]),h.useEffect(()=>{const K=u=>{I.current&&!I.current.contains(u.target)&&w()},M=u=>{u.key==="Escape"&&w()};return document.addEventListener("mousedown",K),document.addEventListener("keydown",M),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",M)}},[w]);const k=h.useCallback(K=>()=>{K(),w()},[w]),P=(n==null?void 0:n.direction)==="asc",J=(n==null?void 0:n.direction)==="desc",T=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",F=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Ss.createPortal(t.jsxs(o.Paper,{ref:I,elevation:0,sx:{position:"fixed",left:`${l.x}px`,top:`${l.y}px`,zIndex:m.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:$o(m),overflow:"hidden",boxShadow:`0 4px 20px ${_(j.common.black,.12)}, 0 1px 4px ${_(j.common.black,.06)}`},children:[!a&&t.jsxs(o.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(o.Typography,{sx:{fontSize: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 (${T})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:k(()=>p(e)),sx:{p:.625,borderRadius:"6px",color:P?"primary.main":"text.secondary",bgcolor:P?_(j.primary.main,.1):"transparent","&:hover":{bgcolor:_(j.primary.main,.08),color:"primary.main"}},children:t.jsx($.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${F})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:k(()=>x(e)),sx:{p:.625,borderRadius:"6px",color:J?"primary.main":"text.secondary",bgcolor:J?_(j.primary.main,.1):"transparent","&:hover":{bgcolor:_(j.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:k(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:_(j.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:k(()=>f(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:k(()=>v(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:_(j.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.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:k(()=>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:k(()=>B(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:k(b),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:_(j.primary.main,.08),color:"primary.main"}},children:t.jsx($.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:k(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&&y&&t.jsxs(o.MenuItem,{onClick:k(y),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:_(j.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx($.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,ps="COLUMN_HEADER",cu=h.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:c=!1,isGrouped:l=!1,hasModifications:p=!1,width:x,onColumnClick:g,onMoveColumn:f,onColumnDragEnd:v,onResizeStart:S,onSortAscending:B,onSortDescending:b,onRemoveSort:y,onOpenFilterForColumn:w,onClearFiltersForColumn:m,onGroupByColumn:j,onHideColumn:I,onManageColumns:k,onResetLayout:P}){const T=dt().urmTable,F=h.useRef(null),[K,M]=h.useState(!1),[u,A]=h.useState({x:0,y:0}),[{handlerId:L,isOver:d},ne]=nr.useDrop({accept:ps,collect(Q){return{handlerId:Q.getHandlerId(),isOver:Q.isOver()}},hover(Q,pe){var Ae;if(!F.current)return;const E=Q.index,te=n;if(E===te)return;const fe=(Ae=F.current)==null?void 0:Ae.getBoundingClientRect(),ae=(fe.right-fe.left)/2,Te=pe.getClientOffset(),Y=((Te==null?void 0:Te.x)??0)-fe.left;E<te&&Y<ae||E>te&&Y>ae||(f(E,te),Q.index=te)}}),[{isDragging:U},re]=nr.useDrag({type:ps,item:()=>({index:n,columnName:r.name}),collect:Q=>({isDragging:Q.isDragging()}),end:()=>{v==null||v()}});re(ne(F));const ge=h.useCallback(Q=>{Q.preventDefault(),Q.stopPropagation(),A({x:Q.clientX,y:Q.clientY}),M(!0)},[]),V=h.useCallback(()=>M(!1),[]),X=h.useCallback(()=>{l||g(r.name)},[g,r.name,l]),ce=h.useCallback(Q=>{Q.stopPropagation(),w(r.name)},[w,r.name]),de=h.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=h.useCallback(()=>s?t.jsx($.FilterList,{onClick:ce,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,ce]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:F,"data-handler-id":L,"data-column-index":n,onClick:X,onContextMenu:ge,sx:{position:"sticky",top:0,zIndex:5,textAlign:(T==null?void 0:T.cellAlignH)??"left",verticalAlign:(T==null?void 0:T.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(T==null?void 0:T.headerColor)??"text.secondary",opacity:U?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease, width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease",bgcolor:d?Q=>_(Q.palette.primary.main,.08):(T==null?void 0:T.headerBg)??"action.hover",boxShadow:Q=>`0 1px 0 ${_(Q.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(T==null?void 0:T.rowDivider)??"1px solid",borderRight:T==null?void 0:T.colDivider,borderColor:"divider",py:0,px:l?0:(T==null?void 0:T.cellPaddingX)??2,"&:hover":{bgcolor:Q=>_(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:[at(r.name),de(),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"}})]}),K&&t.jsx(au,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:c,hasModifications:p,position:u,onSortAscending:B,onSortDescending:b,onRemoveSort:y,onFilter:w,onClearFilter:m,onGroupByColumn:j,onHideColumn:I,onManageColumns:k,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 an(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:_(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 kt(e){return _(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=>an(n,r).bg,color:n=>an(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function fu(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=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[g,f]=h.useState(!1),{primaryCol:v,idCol:S,bodyColumns:B}=h.useMemo(()=>xu(n),[n]),b=v?e[v.name]:null,y=S?e[S.name]:null,w=g||i;return t.jsxs(o.Box,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:m=>s(r,m),onDoubleClick:m=>a(e,r,m),onContextMenu:m=>{m.preventDefault(),m.stopPropagation(),c(e,r,m)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:m=>{var I,k,P,J;const j=(J=(P=(k=(I=m.components)==null?void 0:I.MuiCard)==null?void 0:k.styleOverrides)==null?void 0:P.root)==null?void 0:J.border;return i?"2px solid":j&&j!=="none"?j:"1px solid"},borderColor:i?m=>st(m).main:m=>{var I,k,P,J;const j=(J=(P=(k=(I=m.components)==null?void 0:I.MuiCard)==null?void 0:k.styleOverrides)==null?void 0:P.root)==null?void 0:J.border;return j&&j!=="none"?"inherit":_(m.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:m=>{var I,k,P,J;const j=(J=(P=(k=(I=m.components)==null?void 0:I.MuiCard)==null?void 0:k.styleOverrides)==null?void 0:P.root)==null?void 0:J.borderRadius;return j!==void 0?typeof j=="number"?`${j}px`:j:`${m.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?m=>`0 0 0 3px ${_(st(m).main,.15)}, 0 2px 8px ${_(m.palette.common.black,.08)}`:g?m=>{var I,k,P,J;const j=(J=(P=(k=(I=m.components)==null?void 0:I.MuiCard)==null?void 0:k.styleOverrides)==null?void 0:P.root)==null?void 0:J.boxShadow;return j&&j!=="none"?j:ye(m,"cardHover")}:m=>{var I,k,P,J;const j=(J=(P=(k=(I=m.components)==null?void 0:I.MuiCard)==null?void 0:k.styleOverrides)==null?void 0:P.root)==null?void 0:J.boxShadow;return j&&j!=="none"?j:ye(m,"cardRest")},transform:g&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:m=>_(st(m).main,.03)}},children:[t.jsxs(o.Box,{sx:m=>{var J,T,F,K;const j=((F=(T=(J=m.components)==null?void 0:J.MuiCardHeader)==null?void 0:T.styleOverrides)==null?void 0:F.root)||{},I=(j.backgroundColor&&j.backgroundColor!=="transparent"?j.backgroundColor:void 0)??((K=m.tokens)==null?void 0:K.cardHdrHex)??"transparent",k=j.borderBottom&&j.borderBottom!=="none"?j.borderBottom:void 0,P=j.boxShadow&&j.boxShadow!=="none"?j.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:I,borderBottom:k,boxShadow:P,display:"flex",alignItems:"center",gap:.5}},children:[!x&&w&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:m=>m.stopPropagation(),onChange:()=>p(e),sx:{p:.25}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:m=>m.typography.body2.fontWeight||600,fontSize:m=>m.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:m=>{var k,P,J;const j=((J=(P=(k=m.components)==null?void 0:k.MuiCardHeader)==null?void 0:P.styleOverrides)==null?void 0:J.root)||{};return j.borderBottom&&j.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[B.map(m=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:j=>j.typography.body2.fontWeight||500,fontSize:j=>j.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:at(m.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[m.name]??""),children:fu(m,e[m.name])})]},m.name)),B.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:m=>_(m.palette.action.hover,.1),minHeight:40},children:[t.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:y?.85:0,userSelect:"none"},children:y?String(y):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:w?1:0,transition:"opacity 0.15s ease"},onClick:m=>m.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:m=>{m.stopPropagation(),l(e,r,m.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:m=>_(m.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=>ye(s,"flatHover"),"&:hover":{bgcolor:s=>_(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=>_(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])=>Ts(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:g,hideSelectionCheckboxes:f}){const v=h.useMemo(()=>{const S=new Set;return i.forEach(B=>{const b=B==null?void 0:B.__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=>ds(S).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:S=>ds(S).cardGap,alignContent:"start"},children:e.map((S,B)=>s&&S.isGroupHeader?t.jsx(yu,{row:S,grouping:n,onToggleCollapse:a||(()=>{})},`group-${S.groupKey}`):t.jsx(gu,{row:S,rowIndex:B,visibleColumns:r,isSelected:v.has(S==null?void 0:S.__urm_row_id__),onCardClick:c,onCardDoubleClick:l,onCardContextMenu:p,onOpenRowMenu:x,onToggleSelection:g,hideCheckbox:f},`card-${B}`))})})}const hs=[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=dt().palette,p=Math.ceil(n/r),[x,g]=h.useState(String(e)),[f,v]=h.useState(null),[S,B]=h.useState(!1),b=h.useRef(null);h.useEffect(()=>{S||(g(String(e)),v(null))},[e,S]);const y=h.useCallback(()=>{const A=vu(x,p);if(A){v(A);return}const L=parseInt(x.trim(),10);v(null),B(!1),L!==e&&s(L)},[x,p,e,s]),w=h.useCallback(A=>{var L;A.key==="Enter"?(A.preventDefault(),y()):A.key==="Escape"&&(g(String(e)),v(null),B(!1),(L=b.current)==null||L.blur())},[y,e]),m=h.useCallback(()=>{g(String(e)),v(null),B(!1)},[e]),j=h.useCallback(()=>{B(!0),v(null),setTimeout(()=>{var A;return(A=b.current)==null?void 0:A.select()},0)},[]);if(n<=Math.min(...hs))return null;const I=()=>{g(String(e)),v(null),B(!1)},k=()=>{I(),s(1)},P=()=>{I(),e>1&&s(e-1)},J=()=>{I(),e<p&&s(e+1)},T=()=>{I(),s(p)},F=(e-1)*r+1,K=Math.min(e*r,n),M=`${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:hs.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:[F,"–",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:[f&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:_(l.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${_(l.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:_(l.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:A=>A.typography.caption.fontSize||"0.6875rem",fontWeight:A=>A.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:f})}),t.jsx(o.InputBase,{inputRef:b,value:x,onChange:A=>{g(A.target.value),f&&v(null)},onKeyDown:w,onFocus:j,onBlur:m,inputProps:{"aria-label":`Page number, 1 to ${p}`,style:{textAlign:"center",padding:"2px 0",width:M,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:f?"error.main":"text.primary",border:"1px solid",borderColor:f?"error.main":S?"primary.main":"divider",borderRadius:"4px",bgcolor:f?_(l.error.main,.04):S?_(l.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:f?"error.main":"text.secondary"},"&:focus-within":{boxShadow:f?`0 0 0 2px ${_(l.error.main,.2)}`:`0 0 0 2px ${_(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:k,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:J,disabled:e===p,size:"small",title:"Next page",sx:u,children:t.jsx($.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:T,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 wu(e){try{return localStorage.getItem(Xs+e)==="true"}catch{return!1}}function ju(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 si(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=dt().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:at(l.name),value:si(e[l.name],l.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:Qs},l.name)),c.map(l=>{const p=si(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:at(l.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:_(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color: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=dt(),c=a.palette;if(!n)return null;const l=i.filter(x=>x.name in n).length,p=ue(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...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:_(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:_(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=dt(),c=ue(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(a),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",...c.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...c.header},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:l=>_(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx($.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=>_(l.palette.error.main,.1),border:l=>`1px solid ${_(l.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:l=>l.typography.body2.fontWeight||500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx($.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=>ye(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>ye(l,"hoverButton")},"&:active":{boxShadow:l=>ye(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Tu({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var w;const c=dt(),l=c.palette,[p,x]=h.useState({});if(h.useEffect(()=>{e&&i&&x({...i})},[e,i]),!i)return null;const g=s.filter(m=>m.name in i),f=g.filter(m=>m.type!=="object"&&m.type!=="array"),v=g.filter(m=>m.type==="object"||m.type==="array"),S=(m,j)=>{x(I=>({...I,[m]:j}))},B=()=>{const m={...p};g.forEach(j=>{const I=p[j.name];if(j.type==="number"){const k=Number(I);m[j.name]=isNaN(k)?i[j.name]:k}else j.type==="boolean"&&(m[j.name]=!!I)}),n(m),r()},b=g.length,y=ue(c);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:ot(c),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...y.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...y.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:_(((w=l.warning)==null?void 0:w.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:m=>m.typography.h6.fontSize||"1rem",fontWeight:m=>m.typography.h6.fontWeight||600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),a&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:m=>m.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:_(l.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[f.map(m=>{const j=p[m.name];return m.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:I=>I.typography.caption.fontWeight||500,fontSize:I=>I.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:at(m.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!j,onChange:I=>S(m.name,I.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:j?"Enabled":"Disabled"})]})]},m.name):t.jsx(o.TextField,{label:at(m.name),value:j??"",onChange:I=>S(m.name,I.target.value),type:m.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:Qs},m.name)}),v.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:v.map(m=>{const j=si(i[m.name],m.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:I=>I.typography.caption.fontSize||"0.75rem",fontWeight:I=>I.typography.caption.fontWeight||500,color:"text.secondary"},children:at(m.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:_(l.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(o.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx($.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:_(l.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:j?"text.primary":"text.disabled",fontStyle:j?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:j||"No value"})]},m.name)})}),g.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx($.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:m=>`${m.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,variant:"contained",startIcon:t.jsx($.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:m=>`${m.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 h.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 g=x.reduce((v,S)=>v+S.width,0)||1;let f=0;return x.forEach((v,S)=>{const b=S===x.length-1?v.width+p-f:Math.round(v.width+p*v.width/g);a[v.name]=b,f+=b-v.width}),{widths:a,fillerWidth:0}},[e,r,n,i])}const ms=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=>an(n,r).bg,color:n=>an(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:g={},grouping:f=null,classTokens:v={},onSort:S,onSortAscending:B,onSortDescending:b,onOpenFilters:y,onOpenSort:w,onOpenFilterForColumn:m,onSelectView:j,onCreateView:I,onUpdateCurrentView:k,onSaveAsNewView:P,onDiscardChanges:J,onToggleDefault:T,onToggleFavorite:F,onRestoreView:K,onPermanentDelete:M,onEditView:u,onCloneView:A,onCopyLink:L,onDeleteView:d,onPromoteToGlobal:ne,isAdmin:U=!1,onExport:re,onOpenColumns:ge,onUpdateColumnWidth:V,onUpdateColumnOrder:X,onUpdateColumnVisibility:ce,onClearFiltersForColumn:de,onResetLayout:ie,onOpenGroup:Q,onGroupByColumn:pe,onToggleGroupCollapse:E,onExpandAllGroups:te,onCollapseAllGroups:fe,onOpenAuditHistory:ae,onOpenScheduledReports:Te,searchQuery:Y,highlightQuery:Ae="",searchHistory:Tt=[],onAddToSearchHistory:ut,onToggleSearchFavourite:Wr,onDeleteSearchHistory:Ot,selectedRowIds:nt=new Set,onSearchChange:Ht,onToggleRowSelection:Je,onToggleAllRows:Bt,onRangeSelection:gr,onClearSelection:gt,onExportSelected:sr,currentPage:ao=1,pageSize:ar=15,totalRowsBeforePagination:lo=r.length,onPageChange:It,onPageSizeChange:yr,isReadOnly:Ke=!1,userRole:Mt,reportName:Ut,onEditRow:Qe,onDuplicateRow:Ze,onDeleteRow:Wt,showDevPanel:co=!1,onOpenDevConfig:Ar,rowActions:br,hideDefaultRowActions:Fe,hideToolbarActions:ze,customSettingsActions:lr,viewOptions:At,defaultViewMode:vr,bulkActions:Sr,hideSelectionCheckboxes:Gt,rowClickBehavior:cr="select",openModalOn:et,onRowClick:dr,onRowRightClick:yt}){var No;const ee=dt().urmTable,[Cr,Pr]=h.useState(null),[Et,H]=h.useState(0),[pt,se]=h.useState(0),[Xe,ur]=h.useState(null),uo=((No=$r().dates)==null?void 0:No.displayFormat)??null,[Yt,jr]=h.useState(null),[qt,pr]=h.useState(null),[Jt,Ce]=h.useState(null),[bt,Z]=h.useState(!1),[he,Se]=h.useState(!1),[kr,zr]=h.useState(null),[po,Nr]=h.useState(!1),[ho,Kt]=h.useState(null),[Lr,Fr]=h.useState(null),[be,Ge]=h.useState(null),[Tr,lt]=h.useState(null),Xt=h.useRef(null),Dt=h.useCallback(()=>{Xt.current&&(clearTimeout(Xt.current),Xt.current=null)},[]),Br=h.useCallback(()=>{Dt(),Xt.current=setTimeout(()=>lt(null),200)},[Dt]);h.useEffect(()=>Dt,[Dt]);const[xe,ve]=h.useState(null),Ve=h.useMemo(()=>At??["list","grid"],[At]),[Ye,ht]=h.useState(()=>vr??Ve[0]??"list"),[vt,Rt]=h.useState(!1),[Vr,Tn]=h.useState(()=>!wu("toolbar_search")),Hr=h.useRef(null),mo=h.useRef(null),[Bn,Oo]=h.useState(0);h.useLayoutEffect(()=>{const C=Hr.current;if(!C)return;Oo(C.clientWidth);const R=new ResizeObserver(oe=>{Oo(oe[0].contentRect.width)});return R.observe(C),()=>R.disconnect()},[]);const Ur=h.useCallback(()=>{ju("toolbar_search"),Tn(!1)},[]);h.useEffect(()=>{if(!Vr)return;const C=setTimeout(Ur,2e3);return()=>clearTimeout(C)},[Vr,Ur]);const Mo=h.useMemo(()=>{const C=Xe??x;return C.length>0?C.map(R=>e.find(oe=>oe.name===R)).filter(R=>R!==void 0):e},[Xe,x,e]),Gr=h.useMemo(()=>Mo.filter(C=>p[C.name]!==!1),[Mo,p]),fo=h.useMemo(()=>new Set(((f==null?void 0:f.levels)??[]).map(C=>C.column)),[f]),Wo=!!(f!=null&&f.enabled&&(f!=null&&f.levels)&&f.levels.length>0),Yr=h.useMemo(()=>{if(!Wo)return Gr;const C=((f==null?void 0:f.levels)??[]).map(oe=>e.find(je=>je.name===oe.column)).filter(oe=>oe!==void 0),R=Gr.filter(oe=>!fo.has(oe.name));return[...C,...R]},[Gr,Wo,fo,f,e]),qr=h.useMemo(()=>{const C=new Set;if(!(f!=null&&f.enabled)||!r)return C;for(const R of r)(R.isGroupHeader||R.__isGroupHeader)&&!R.isCollapsed&&R.groupColumn&&C.add(R.groupColumn);return C},[r,f]),{widths:Jr}=$u(Yr,g,Bn,qr),Qt=h.useMemo(()=>e.filter(C=>p[C.name]===!1).length,[e,p]),Ao=h.useMemo(()=>e.map(C=>C.name),[e]),Kr=h.useMemo(()=>x.length===0?!1:JSON.stringify(x)!==JSON.stringify(Ao),[x,Ao]),In=h.useCallback((C,R)=>{C.preventDefault(),C.stopPropagation(),Pr(R),H(C.clientX),se(g[R]||150)},[g]);h.useEffect(()=>{if(!Cr)return;const C=oe=>{const je=oe.clientX-Et,Oe=Math.max(100,Math.min(600,pt+je));V==null||V(Cr,Oe)},R=()=>{Pr(null)};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",R),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",R)}},[Cr,Et,pt,V]);const En=h.useCallback(C=>C==null?"-":typeof C=="object"?JSON.stringify(C):typeof C=="boolean"?C?"true":"false":String(C),[]);h.useCallback(C=>{const R=n.find(oe=>oe.column===C);return R?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[R.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:R.priority})]}):null},[n]),h.useCallback(C=>ei(i,C)?t.jsx(o.IconButton,{size:"small",onClick:oe=>{oe.stopPropagation(),m==null||m(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,m]);const Dn=h.useCallback(C=>{S&&S(C)},[S]),_n=h.useCallback((C,R)=>{ur(oe=>{const Oe=[...oe??(x.length>0?x:e.map(rt=>rt.name))],[tt]=Oe.splice(C,1);return Oe.splice(R,0,tt),Oe})},[x,e]),$n=h.useCallback(()=>{Xe&&X&&X(Xe),ur(null)},[Xe,X]),On=h.useCallback(C=>{if(!S)return;const R=n.find(oe=>oe.column===C);(!R||R.direction!=="asc")&&S(C)},[S,n]),Mn=h.useCallback(C=>{if(!S)return;const R=n.find(oe=>oe.column===C);R?R.direction==="asc"&&S(C):(S(C),setTimeout(()=>S(C),0))},[S,n]),Wn=h.useCallback(C=>{if(!S)return;const R=n.find(oe=>oe.column===C);R&&(R.direction==="asc"?(S(C),setTimeout(()=>S(C),0)):R.direction==="desc"&&S(C))},[S,n]),An=h.useCallback(C=>{ce&&ce(C,!1)},[ce]),Xr=!!(f!=null&&f.enabled&&(f!=null&&f.levels)&&f.levels.length>0),Zt=h.useMemo(()=>jt(i),[i]),Rn=n.length>0||Zt>0||((f==null?void 0:f.enabled)??!1)||Object.values(p).some(C=>C===!1),Pn=(ao-1)*ar,We=r,it=h.useMemo(()=>{const C=new Set;return nt.forEach(R=>{const oe=R==null?void 0:R.__urm_row_id__;oe!==void 0&&C.add(oe)}),C},[nt]);h.useEffect(()=>{const C=R=>{!Bt||!gt||R.target instanceof HTMLInputElement||R.target instanceof HTMLTextAreaElement||((R.ctrlKey||R.metaKey)&&R.key==="a"&&(R.preventDefault(),Bt(!0,We)),R.key==="Escape"&&(R.preventDefault(),gt()))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[Bt,gt,We]);const xo=h.useCallback((C,R)=>{dr==null||dr(We[C],C,R),(cr==="activate"||cr==="both")&&(Ce(We[C]),Z(!0)),cr!=="activate"&&Je&&(R.shiftKey&&Yt!==null?(R.preventDefault(),gr&&gr(Yt,C,We)):(Je(We[C]),jr(C)))},[Je,Yt,gr,We,dr,cr,Ce,Z]),Ro=h.useMemo(()=>We.length>0&&it.size>0&&We.every(C=>it.has(C==null?void 0:C.__urm_row_id__)),[We,it]),Nn=!Ro&&We.some(C=>it.has(C==null?void 0:C.__urm_row_id__)),er=!!(Je&&Bt&&!Gt),Pt=h.useMemo(()=>!(f!=null&&f.enabled)||!(f!=null&&f.levels)?new Set:new Set(f.levels.map(C=>C.column)),[f]),tr=h.useMemo(()=>Yr,[Yr]),Ir=h.useMemo(()=>{const C=new Map;if(!(f!=null&&f.enabled)||!We)return C;let R=[];for(const oe of We)if(oe.__isGroupHeader||oe.isGroupHeader){const je=oe.groupLevel??0;R[je]=oe.groupKey,R=R.slice(0,je+1),C.has(oe.groupKey)||C.set(oe.groupKey,[])}else if(oe.__urm_is_grouped_data_row__)for(const je of R)je&&C.has(je)&&C.get(je).push(oe);return C},[f,We]),Ln=h.useCallback(C=>{const R=C.groupLevel,oe=R===0?v.groupRowLevel0||"urm-group-level-0":R===1?v.groupRowLevel1||"urm-group-level-1":v.groupRowLevel2||"urm-group-level-2",je=R===0?ke=>ke.palette.mode==="dark"?_(ke.palette.action.hover,.12):"#f1f5f9":ke=>ke.palette.mode==="dark"?_(ke.palette.action.hover,.06):"#f8fafc",Oe=String(C.groupValue??"(empty)"),tt=`${C.rowCount} ${C.rowCount===1?"item":"items"}`,rt=Ir.get(C.groupKey)||[],me=rt.filter(ke=>it.has(ke==null?void 0:ke.__urm_row_id__)).length,Nt=rt.length>0&&me===rt.length,rr=me>0&&me<rt.length;return t.jsxs(o.TableRow,{onClick:()=>E==null?void 0:E(C.groupKey),className:`urm-group-header-row urm-group-level-${R} ${oe} ${v.groupRow||""}`,sx:{bgcolor:je,"&:hover":{bgcolor:ke=>_(ke.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[er&&t.jsx(o.TableCell,{padding:"checkbox",onClick:ke=>ke.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Nt,indeterminate:rr,onChange:()=>{if(!Je)return;const ke=!Nt;rt.forEach(ct=>{const Lo=it.has(ct==null?void 0:ct.__urm_row_id__);ke!==Lo&&Je(ct)})}})}),t.jsxs(o.TableCell,{colSpan:tr.length,className:`urm-group-cell ${v.groupCellFirst||""} ${v.groupCell||""}`,sx:{pl:`${R*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[R>0&&t.jsx(o.Box,{sx:{position:"absolute",left:`${R*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:"h5",className:`urm-group-title ${v.groupTitle||""}`,sx:{fontWeight:R===0?600:500,fontSize:R===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Oe}),!C.isCollapsed&&t.jsx(o.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:ke=>_(ke.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:ke=>_(ke.palette.primary.main,.2),ml:.5},children:at(C.groupColumn||"")}),!!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:ke=>_(ke.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:ke=>_(ke.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:tt}),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(([ke,ct])=>Ts(ct)).filter(Boolean).join(" • "),")"]})]})]})]},C.groupKey)},[Pt,tr,er,f,e,E,v,ee,Ir,it,Je]),Po=h.useCallback((C,R)=>{const oe=it.has(C==null?void 0:C.__urm_row_id__),je=qt===R,Oe=bt&&(C==null?void 0:C.__urm_row_id__)===(Jt==null?void 0:Jt.__urm_row_id__),tt=!!(C!=null&&C.__urm_is_grouped_data_row__),rt=tt?C.__urm_group_level__??(f==null?void 0:f.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":R,className:tt?`urm-data-row-grouped ${v.dataRowGrouped||""}`:"",onMouseEnter:()=>pr(R),onMouseLeave:()=>pr(null),onClick:me=>{me.target.closest("[data-row-action-btn]")||xo(R,me)},onDoubleClick:()=>{et!=null&&et.includes("doubleClick")&&(Ce(C),Z(!0))},onContextMenu:me=>{me.preventDefault(),me.stopPropagation(),yt==null||yt(C,R,me),lt(null),Ge({mouseX:me.clientX,mouseY:me.clientY,row:C,rowIndex:R}),et!=null&&et.includes("rightClick")&&(Ce(C),Z(!0))},sx:{cursor:"pointer",bgcolor:oe?me=>st(me).bg:Oe?me=>_(me.palette.info.main,.12):ee!=null&&ee.striped&&R%2===1?ee.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:oe?me=>st(me).hoverBg:Oe?me=>_(me.palette.info.main,.2):me=>`var(--highlight-hover-row, ${_(st(me).main,.04)})`},borderBottom:(ee==null?void 0:ee.rowDivider)??"1px solid",borderColor:"divider"},children:[er&&t.jsx(o.TableCell,{padding:"checkbox",onClick:me=>me.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:()=>Je==null?void 0:Je(C)})}),tr.map((me,Nt)=>{const rr=Nt===0,ke=Pt.has(me.name),ct=qr.has(me.name);return t.jsxs(o.TableCell,{className:tt&&rr?`urm-data-cell-grouped ${v.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(ee==null?void 0:ee.rowPaddingY)??"6px",px:ke&&ct?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:ke&&ct?"32px":void 0,minWidth:ke&&ct?"32px":g[me.name]?`${g[me.name]}px`:`${me.type==="date"?Math.max(ms,180):ms}px`,maxWidth:ke&&ct?"32px":void 0,transition:"all 0.3s ease-in-out"},children:[tt&&rr&&rt>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),!ke&&t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${v.itemTitle||""}`,children:Pu(me,C[me.name],uo,Ae)})})]},me.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:je?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:me=>{me.stopPropagation(),me.preventDefault(),lt(null),Ge({anchorEl:me.currentTarget,row:C,rowIndex:R})},sx:{color:"text.secondary",opacity:je?1:0,transition:"opacity 0.12s ease",pointerEvents:je?"auto":"none","&:hover":{bgcolor:me=>_(me.palette.text.primary,.08),color:"text.primary"}},children:t.jsx($.MoreVert,{sx:{fontSize:18}})})})})]},R)},[nt,Pn,qt,xo,Yr,g,Ae,En,Qe,Ze,Wt,Je,er,Ce,Z,Jt,bt,Ge,Xr,fo,yt,et,Pt,qr,it]);return t.jsxs(nr.DndProvider,{backend:ai.HTML5Backend,children:[t.jsxs(o.Box,{sx:C=>{var tt,rt,me;const R=((me=(rt=(tt=C.components)==null?void 0:tt.MuiCard)==null?void 0:rt.styleOverrides)==null?void 0:me.root)||{},oe=R.border&&R.border!=="none"?R.border:"1px solid",je=R.borderRadius!==void 0?typeof R.borderRadius=="number"?`${R.borderRadius}px`:R.borderRadius:`${C.shape.borderRadius}px`,Oe=R.boxShadow&&R.boxShadow!=="none"?R.boxShadow:ye(C,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:oe,borderColor:oe!=="none"?"divider":void 0,borderRadius:je,boxShadow:Oe,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:C=>{var tt,rt,me,Nt,rr;const R=((me=(rt=(tt=C.components)==null?void 0:tt.MuiCardHeader)==null?void 0:rt.styleOverrides)==null?void 0:me.root)||{},oe=(R.backgroundColor&&R.backgroundColor!=="transparent"?R.backgroundColor:void 0)??((Nt=C.tokens)==null?void 0:Nt.cardHdrHex)??((rr=C.urmTable)==null?void 0:rr.headerBg)??C.palette.background.paper,je=R.borderBottom&&R.borderBottom!=="none"?R.borderBottom:"1px solid",Oe=R.boxShadow&&R.boxShadow!=="none"?R.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:oe,borderBottom:je,borderColor:je!=="none"?"divider":void 0,boxShadow:Oe,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Ke&&t.jsx(Cu,{}),Ht&&ut&&Wr&&Ot&&!(ze!=null&&ze.includes("search"))&&t.jsx(o.Tooltip,{open:Vr,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:Ur},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=>{Vr&&Ur(),Ht(C)},searchHistory:Tt,onAddToHistory:ut,onToggleFavourite:Wr,onDeleteHistory:Ot,disabled:Ke})})}),t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>Rt(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:C=>_(C.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.InfoOutlined,{sx:{fontSize:20}})})}),j&&I&&k&&s.length>0&&t.jsx(su,{views:s||[],activeViewId:a||"",isDirty:c,onSelectView:j,onCreateView:I,onToggleDefault:T,onToggleFavorite:F,onRestoreView:K,onPermanentDelete:M,onEditView:u,onCloneView:A,onCopyLink:L,onDeleteView:d,onPromoteToGlobal:ne,isAdmin:U,isReadOnly:Ke}),c&&!Ke&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[k&&t.jsx(o.Button,{onClick:k,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=>ye(C,"restButton"),"&:hover":{bgcolor:C=>`var(--urm-btn-save-current-hover-bg, ${C.palette.primary.dark})`,boxShadow:C=>ye(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, ${_(C.palette.primary.main,.08)})`}},children:"Save new view"}),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-discard-bg, ${_(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, ${_(C.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),co&&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=>_(C.palette.text.secondary,.3),"&:hover":{bgcolor:C=>_(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&&w&&!(ze!=null&&ze.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:w,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?C=>kt(C):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?C=>_(C.palette.primary.main,.2):C=>_(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&&y&&!(ze!=null&&ze.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:y,size:"small",sx:{position:"relative",color:Zt>0?"primary.main":"text.secondary",bgcolor:Zt>0?C=>kt(C):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Zt>0?C=>_(C.palette.primary.main,.2):C=>_(C.palette.text.primary,.06),color:Zt>0?"primary.main":"text.primary"}},children:[t.jsx($.FilterList,{sx:{fontSize:20}}),Zt>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:Zt})]})}),!Ke&&ge&&!(ze!=null&&ze.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:ge,size:"small",sx:{position:"relative",color:Qt>0||Kr?"primary.main":"text.secondary",bgcolor:Qt>0||Kr?C=>kt(C):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Qt>0||Kr?C=>_(C.palette.primary.main,.2):C=>_(C.palette.text.primary,.06),color:Qt>0||Kr?"primary.main":"text.primary"}},children:[t.jsx($.ViewColumn,{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})]})}),Xr&&(te||fe)&&(()=>{var oe;const C=(((oe=f==null?void 0:f.collapsedGroups)==null?void 0:oe.length)??0)>0,R=C?te:fe;return R?t.jsx(o.Tooltip,{title:C?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:R,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:je=>_(je.palette.text.primary,.06),color:"text.primary"}},children:C?t.jsx($.UnfoldMore,{sx:{fontSize:20}}):t.jsx($.UnfoldLess,{sx:{fontSize:20}})})}):null})(),Ve.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),Ve.map(C=>{const R=Ye===C,oe=C==="list"?t.jsx($.TableRows,{sx:{fontSize:20}}):t.jsx($.GridView,{sx:{fontSize:20}}),je=C==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:je,children:t.jsx(o.IconButton,{size:"small",onClick:()=>ht(C),sx:{borderRadius:1,color:R?"primary.main":"text.secondary",bgcolor:R?Oe=>kt(Oe):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:R?Oe=>_(Oe.palette.primary.main,.2):Oe=>_(Oe.palette.text.primary,.06),color:R?"primary.main":"text.primary"}},children:oe})},C)})]}),!(ze!=null&&ze.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=>ve(C.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:C=>_(C.palette.text.primary,.06),color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!xe,anchorEl:xe,onClose:()=>ve(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&&!(ze!=null&&ze.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{re(),ve(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&&Q&&!(ze!=null&&ze.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Q(),ve(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"})]}),ae&&!(ze!=null&&ze.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ae(),ve(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"})]}),Te&&!(ze!=null&&ze.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Te(),ve(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"})]}),lr==null?void 0:lr.map(C=>t.jsxs(o.MenuItem,{dense:!0,disabled:C.disabled,onClick:()=>{C.onClick(),ve(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:[Sr&&Sr.length>0&&it.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:C=>st(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:[it.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>gt==null?void 0:gt(),children:"Clear"}),Sr.map(C=>{var oe,je;const R=Array.from(nt);return(oe=C.hidden)!=null&&oe.call(C,R)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:C.icon,disabled:(je=C.disabled)==null?void 0:je.call(C,R),onClick:()=>C.onClick(R),children:C.label},C.key)})]}),Ye!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(bu,{data:We,visibleColumns:Gr,grouping:f,selectedRowIds:nt,isGrouped:!!Xr,onToggleGroupCollapse:E,onCardClick:(C,R)=>xo(C,R),onCardDoubleClick:C=>{et!=null&&et.includes("doubleClick")&&(Ce(C),Z(!0))},onCardContextMenu:(C,R,oe)=>{yt==null||yt(C,R,oe),lt(null),Ge({mouseX:oe.clientX,mouseY:oe.clientY,row:C,rowIndex:R}),et!=null&&et.includes("rightClick")&&(Ce(C),Z(!0))},onOpenRowMenu:(C,R,oe)=>Ge({anchorEl:oe,row:C,rowIndex:R}),onToggleSelection:C=>Je==null?void 0:Je(C),hideSelectionCheckboxes:Gt})}),Ye==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Hr,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(Jr).reduce((C,R)=>C+R,0)}px`},children:[t.jsxs("colgroup",{children:[er&&t.jsx("col",{style:{width:"40px"}}),tr.map(C=>t.jsx("col",{style:{width:`${Jr[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:[er&&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:Ro,indeterminate:Nn,onChange:C=>Bt==null?void 0:Bt(C.target.checked,We)})}),tr.map((C,R)=>{const oe=Pt.has(C.name),je=qr.has(C.name);return t.jsx(cu,{column:C,index:R,isGrouped:oe&&je,sortRule:n.find(Oe=>Oe.column===C.name),hasFilters:ei(i,C.name),isInSortStack:n.some(Oe=>Oe.column===C.name),isReadOnly:Ke,hasModifications:Rn,width:oe&&je?32:g[C.name],onColumnClick:Dn,onMoveColumn:_n,onColumnDragEnd:$n,onResizeStart:In,onSortAscending:B||On,onSortDescending:b||Mn,onRemoveSort:Wn,onOpenFilterForColumn:m||(()=>{}),onClearFiltersForColumn:de||(()=>{}),onGroupByColumn:pe,onHideColumn:An,onManageColumns:ge||(()=>{}),onResetLayout:ie},C.name)})]})})]})}),t.jsx(o.Box,{ref:mo,onScroll:C=>{Hr.current&&(Hr.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=>_(C.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:C=>_(C.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Jr).reduce((C,R)=>C+R,0)}px`},children:[t.jsxs("colgroup",{children:[er&&t.jsx("col",{style:{width:"40px"}}),tr.map(C=>t.jsx("col",{style:{width:`${Jr[C.name]}px`}},C.name))]}),t.jsx(o.TableBody,{children:We.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:tr.length,align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Xr?We.map((C,R)=>C.isGroupHeader?Ln(C):Po(C,R)):We.map((C,R)=>Po(C,R))})]})})]}),It&&yr&&t.jsx(Su,{currentPage:ao,pageSize:ar,totalRows:lo,totalFields:e.length,onPageChange:It,onPageSizeChange:yr}),!(It&&yr)&&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 ",We.length," ",We.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!be,onClose:()=>{Ge(null),lt(null)},anchorEl:(be==null?void 0:be.anchorEl)||null,anchorReference:be!=null&&be.anchorEl?"anchorEl":"anchorPosition",anchorPosition:be&&!be.anchorEl?{top:be.mouseY,left:be.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:be!=null&&be.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(Fe!=null&&Fe.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{be&&(Ce(be.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"})]}),!(Fe!=null&&Fe.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{be&&(Kt(be.row),Fr(be.rowIndex),Nr(!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"})]}),!(Fe!=null&&Fe.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{be&&(Ze==null||Ze(be.rowIndex,be.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"})]}),be&&(br==null?void 0:br.map(C=>{var R,oe;return(R=C.hidden)!=null&&R.call(C,be.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(oe=C.disabled)==null?void 0:oe.call(C,be.row),onClick:()=>{C.onClick(be.row,be.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)})),it.size>0&&sr&&!(Fe!=null&&Fe.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:C=>{Dt(),lt(C.currentTarget)},onMouseLeave:Br,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 (",it.size,")"]})]}),t.jsx($.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!Tr,anchorEl:Tr,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:Dt,onMouseLeave:Br,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:()=>{sr("csv"),lt(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:()=>{sr("excel"),lt(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:()=>{sr("json"),lt(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"})]})]})})})})]}),!(Fe!=null&&Fe.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{be&&(zr(be.row),Se(!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:bt,onClose:()=>{Z(!1),Ce(null)},row:Jt,schema:e,reportName:Ut}),t.jsx(Tu,{open:po,onClose:()=>{Nr(!1),Kt(null),Fr(null)},onSave:C=>{Lr!==null&&(Qe==null||Qe(Lr,C))},row:ho,schema:e,reportName:Ut}),t.jsx(zu,{open:he,onClose:()=>{Se(!1),zr(null)},onConfirm:()=>{kr!==null&&(Wt==null||Wt(kr))},row:kr,schema:e}),t.jsx(Js,{isOpen:vt,onClose:()=>Rt(!1)})]})}function Or({content:e,isDev:r=!1}){const[n,i]=h.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${e.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>_(s.palette.primary.main,.08)}},children:t.jsx($.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(o.Popover,{open:!!n,anchorEl:n,onClose:()=>i(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{width:280,borderRadius:"10px",boxShadow:4,p:0,overflow:"hidden"}},children:[t.jsx(o.Box,{sx:{px:2,py:1.5,bgcolor:s=>_(s.palette.primary.main,.06)},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||600,color:"primary.main",fontSize:s=>s.typography.body2.fontSize||"0.875rem"},children:e.title})}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.8125rem",lineHeight:1.6},children:e.description}),e.tips&&e.tips.length>0&&t.jsx(o.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:e.tips.map((s,a)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},a))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>_(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>_(s.palette.warning.main,.2)},children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:s=>s.typography.caption.fontWeight||500,fontSize:s=>s.typography.caption.fontSize||"0.75rem",display:"block",mb:.25},children:"Dev note"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontSize:s=>s.typography.caption.fontSize||"0.75rem",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}const Mr={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],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."}},Zn=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=h.useMemo(()=>{const p=a?nn(a.type):[],x=i.filter.allowedOperators;return x.length>0?p.filter(g=>x.includes(g.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 f;const x=r.find(v=>v.name===p.target.value),g=x?nn(x.type):[];s({column:p.target.value,operator:((f=g[0])==null?void 0:f.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:at(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,g)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:Zn,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[g<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),g>0&&t.jsx(Lu,{operator:e.operator,onSelect:f=>l(v=>di(v,e.id,f))}),g>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:Zn/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:g>0?1:0},children:qe(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:f=>l(v=>ci(v,x.id,f))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>l(f=>ui(f,x.id)),sx:{mt:g>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:`${Zn}px`},children:[t.jsx(o.Button,{size:"small",disabled:p||i.length===0,onClick:()=>l(x=>{var g,f,v;return so(x,e.id,{id:io(),column:((g=i[0])==null?void 0:g.name)??"",operator:((v=nn(((f=i[0])==null?void 0:f.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=>so(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=>_(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>_(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(ta,{...e})})}function Hu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[c,l]=h.useState(r??$t()),p=$r(),x=h.useMemo(()=>e.filter(w=>w.type!=="mixed"&&w.type!=="null"&&w.type!=="array"&&w.type!=="object"),[e]);h.useEffect(()=>{var m;const w=r??$t();if(s&&w.children.length===0){const j=e.find(I=>I.name===s);if(j){l(so(w,w.id,{id:io(),column:s,operator:((m=nn(j.type)[0])==null?void 0:m.value)??"equals"}));return}}l(w)},[r,s,e]);const g=jt(c),f=p.filter.maxConditions,v=h.useCallback(w=>{l(m=>w(m))},[]),S=h.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r??$t()),[c,r]),B=h.useCallback(()=>{n(c),i()},[c,n,i]),b=h.useCallback(()=>{l(r??$t()),i()},[r,i]),y=h.useCallback(()=>{n($t()),i()},[n,i]);return t.jsx(o.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:w=>_(w.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:w=>w.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:w=>w.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:w=>ot(w),bgcolor:"background.paper",outline:"none",boxShadow:w=>ue(w).paper.boxShadow,border:w=>ue(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=>ue(w).header.backgroundColor,borderBottom:w=>ue(w).header.borderBottom,boxShadow:w=>ue(w).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:w=>w.typography.h6.fontSize||"1.125rem",fontWeight:w=>w.typography.h6.fontWeight||500,color:w=>w.typography.h6.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(Or,{content:Mr.filter,isDev:process.env.NODE_ENV==="development"}),a&&t.jsx(o.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:b,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:w=>_(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>_(w.palette.text.primary,.3)}}},children:[g===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:w=>w.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${at(s)}"`:"","."]}),t.jsx(ta,{group:c,depth:0,schema:e,availableColumns:x,devConfig:p,maxConditions:f,totalConditions:g,onChange:v}),g>=f&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:w=>w.typography.caption.fontSize||"0.75rem",fontWeight:w=>w.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",f," conditions allowed. Remove one to add another."]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",alignItems:"center",gap:1.5,justifyContent:"space-between",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:y,disabled:g===0,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"Clear all"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1.5},children:[t.jsx(o.Button,{onClick:b,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:w=>`${w.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:B,disabled:!S,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:w=>`${w.shape.borderRadius}px`,boxShadow:w=>ye(w,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const fs="SORT_RULE";function Uu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=h.useRef(null),[{handlerId:c},l]=nr.useDrop({accept:fs,collect(g){return{handlerId:g.getHandlerId()}},hover(g,f){var m;if(!a.current)return;const v=g.index,S=r;if(v===S)return;const B=(m=a.current)==null?void 0:m.getBoundingClientRect(),b=(B.bottom-B.top)/2,y=f.getClientOffset(),w=((y==null?void 0:y.y)??0)-B.top;v<S&&w<b||v>S&&w>b||(s(v,S),g.index=S)}}),[{isDragging:p},x]=nr.useDrag({type:fs,item:()=>({index:r}),collect:g=>({isDragging:g.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:g=>ye(g,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(o.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:g=>`0 1px 2px 0 ${_(g.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:g=>g.typography.body2.fontSize||"0.875rem",fontWeight:g=>g.typography.body2.fontWeight||400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:e.column}),t.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:t.jsxs(o.Select,{value:e.direction,onChange:g=>n(r,g.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"text.primary",fontWeight:400}},children:[t.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>kt(g),"&:hover":{bgcolor:g=>_(g.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>kt(g),"&:hover":{bgcolor:g=>_(g.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:g=>_(g.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx($.Close,{sx:{fontSize:18}})})]})}function Gu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i,onOpenDevConfig:s}){const[a,c]=h.useState(""),[l,p]=h.useState([]);h.useEffect(()=>{p([...r])},[r]);const x=h.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r),[l,r]),g=$r(),f=h.useCallback(j=>{if(!j||l.length>=g.sort.maxLevels)return;const I={column:j,direction:"asc",priority:l.length+1};p([...l,I]),c(""),setTimeout(()=>{var k;return(k=document.activeElement)==null?void 0:k.blur()},0)},[l,g.sort.maxLevels]),v=h.useCallback(j=>{const k=l.filter((P,J)=>J!==j).map((P,J)=>({...P,priority:J+1}));p(k)},[l]),S=h.useCallback((j,I)=>{const k=[...l];k[j]={...k[j],direction:I},p(k)},[l]),B=h.useCallback((j,I)=>{const k=[...l],[P]=k.splice(j,1);k.splice(I,0,P);const J=k.map((T,F)=>({...T,priority:F+1}));p(J)},[l]),b=h.useCallback(()=>{n([]),i()},[n,i]),y=h.useCallback(()=>{n(l),i()},[l,n,i]),w=h.useCallback(()=>{p([...r]),c(""),i()},[r,i]),m=e.filter(j=>!l.some(I=>I.column===j.name));return t.jsx(nr.DndProvider,{backend:ai.HTML5Backend,children:t.jsx(o.Box,{onClick:w,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:j=>_(j.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:j=>j.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:j=>j.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:j=>ot(j),bgcolor:"background.paper",outline:"none",boxShadow:j=>ue(j).paper.boxShadow,border:j=>ue(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=>ue(j).header.backgroundColor,borderBottom:j=>ue(j).header.borderBottom,boxShadow:j=>ue(j).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:j=>j.typography.h6.fontSize||"1.125rem",fontWeight:j=>j.typography.h6.fontWeight||500,color:j=>j.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(Or,{content:Mr.sort,isDev:process.env.NODE_ENV==="development"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:w,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:j=>_(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>_(j.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:l.length>=g.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:a,onChange:j=>f(j.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:m.map(j=>t.jsx(o.MenuItem,{value:j.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:I=>kt(I),"&:hover":{bgcolor:I=>_(I.palette.primary.main,.2)}}},children:at(j.name)},j.name))})]}),l.length>=g.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:j=>j.typography.caption.fontSize||"0.75rem",fontWeight:j=>j.typography.caption.fontWeight||500},children:["Maximum ",g.sort.maxLevels," sort levels allowed"]})]}),l.length>0&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Typography,{variant:"overline",sx:{fontSize:j=>j.typography.caption.fontSize||"0.6875rem",fontWeight:j=>j.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",g.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:b,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((j,I)=>t.jsx(Uu,{rule:j,index:I,onToggleDirection:S,onRemove:v,onMove:B},`${j.column}-${I}`))})]})]}),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:w,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:y,variant:"contained",disabled:!x||l.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,boxShadow:j=>ye(j,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:j=>ye(j,"hoverButton")},"&:active":{boxShadow:j=>ye(j,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const qo=50;function xs({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:c=!1,atViewLimit:l=!1,maxViews:p=10}){const[x,g]=h.useState(s),[f,v]=h.useState(!1),[S,B]=h.useState(a),[b,y]=h.useState(c),w=()=>{if(!x.trim()){v(!0);return}if(x.trim().length>qo){v(!0);return}r(x.trim(),S.trim(),b),n()},m=I=>{I.key==="Enter"&&!I.shiftKey?w():I.key==="Escape"&&n()},j=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:I=>({mt:8,borderRadius:ot(I),...ue(I).paper})},children:[t.jsxs(o.DialogTitle,{sx:I=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(I).header}),children:[j(),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:I=>{I.target.value.length<=qo&&g(I.target.value),f&&I.target.value.trim()&&v(!1)},onKeyDown:m,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:l&&!i,inputProps:{maxLength:qo},error:f&&!x.trim(),helperText:f&&!x.trim()?"View name is required":`${x.length} / ${qo}`}),t.jsx(o.TextField,{label:"Description (optional)",value:S,onChange:I=>B(I.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:I=>I.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:[jt(e.filters)," filter",jt(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:I=>y(I.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:I=>`${I.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: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:I=>`${I.shape.borderRadius}px`,boxShadow:I=>ye(I,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:I=>ye(I,"hoverButton")},"&:active":{boxShadow:I=>ye(I,"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:ot(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...ue(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,...ue(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=>ye(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ye(i,"hoverButton")},"&:active":{boxShadow:i=>ye(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const Xo=100,Qo=600,gs="COLUMN";function qu({column:e,index:r,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:a,moveColumn:c}){const l=h.useRef(null),[p,x]=h.useState(i.toString());h.useEffect(()=>{x(i.toString())},[i]);const[{handlerId:g},f]=nr.useDrop({accept:gs,collect(m){return{handlerId:m.getHandlerId()}},hover(m,j){var K;if(!l.current)return;const I=m.index,k=r;if(I===k)return;const P=(K=l.current)==null?void 0:K.getBoundingClientRect(),J=(P.bottom-P.top)/2,T=j.getClientOffset(),F=((T==null?void 0:T.y)??0)-P.top;I<k&&F<J||I>k&&F>J||(c(I,k),m.index=k)}}),[{isDragging:v},S]=nr.useDrag({type:gs,item:()=>({index:r}),collect:m=>({isDragging:m.isDragging()})});S(f(l));const B=()=>{const m=parseInt(p);if(isNaN(m)){x(i.toString()),a(e.name,i);return}const j=Math.max(Xo,Math.min(Qo,m));x(j.toString()),a(e.name,j)},b=m=>{if(m===""||/^\d+$/.test(m)){x(m);const j=parseInt(m);if(!isNaN(j)&&j>=Xo){const I=Math.min(Qo,j);a(e.name,I)}}},y=m=>{m.key==="Enter"&&(m.preventDefault(),B(),m.target.blur())},w=m=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[m]||"text.secondary";return t.jsxs(o.TableRow,{ref:l,"data-handler-id":g,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:m=>m.typography.body2.fontWeight||400,fontSize:m=>m.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:at(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:`${w(e.type)}15`,color:w(e.type),border:`1px solid ${w(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:m=>b(m.target.value),onBlur:B,onKeyDown:y,placeholder:"150",size:"small",inputProps:{min:Xo,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:m=>m.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?m=>_(m.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:g}){const[f,v]=h.useState(!1),[S,B]=h.useState(n),[b,y]=h.useState(i),[w,m]=h.useState("all");h.useEffect(()=>{B(n)},[n]),h.useEffect(()=>{y(i)},[i]);const j=(u,A)=>{y(L=>({...L,[u]:A})),p==null||p(u,A)},I=(u,A)=>{const L=[...S],[d]=L.splice(u,1);L.splice(A,0,d),B(L),l(L)},k=()=>{x(),v(!1)},J=S.map(u=>e.find(A=>A.name===u)).filter(u=>u!==void 0).filter(u=>{const A=r[u.name]??!0;return w==="active"?A:w==="hidden"?!A:!0}),T=Object.values(r).filter(u=>u).length,F=e.length,K=s.find(u=>u.id===a),M=h.useMemo(()=>{if(!K)return!1;const u=K.snapshot,A=u.columnVisibility??{},L=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??{},ge=JSON.stringify(b)!==JSON.stringify(re);return L||U||ge},[K,r,n,b]);return t.jsx(nr.DndProvider,{backend:ai.HTML5Backend,children:t.jsx(o.Box,{onClick:g,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:u=>_(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=>ot(u),bgcolor:"background.paper",outline:"none",boxShadow:u=>ue(u).paper.boxShadow,border:u=>ue(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=>ue(u).header.backgroundColor,borderBottom:u=>ue(u).header.borderBottom,boxShadow:u=>ue(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:g,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:w,onChange:(u,A)=>m(A),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:u=>st(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=>st(u).hoverBg},"&:hover":{color:"text.primary",bgcolor:u=>st(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=>st(u).hoverBg},"&:hover":{color:"text.primary",bgcolor:u=>st(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=>st(u).hoverBg},"&:hover":{color:"text.primary",bgcolor:u=>st(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=>_(u.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:u=>_(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: ${Xo}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:J.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"})})}):J.map((u,A)=>t.jsx(qu,{column:u,index:A,isVisible:r[u.name]??!0,width:b[u.name]||170,onToggleVisibility:c,onWidthChange:j,moveColumn:I},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:[T," of ",F," 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:!M,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"})}),f&&t.jsx(o.Box,{onClick:()=>v(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:u=>_(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=>ue(u).paper.boxShadow,border:u=>ue(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:k,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:u=>`${u.shape.borderRadius}px`,boxShadow:u=>ye(u,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:u=>ye(u,"hoverButton")},"&:active":{boxShadow:u=>ye(u,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function Ku({schema:e,grouping:r,onApply:n,onClose:i,onOpenDevConfig:s}){var J;const[a,c]=h.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,p]=h.useState(""),[x,g]=h.useState(null),f=h.useMemo(()=>Pa(e),[e]),v=h.useMemo(()=>f.filter(T=>!a.levels.some((F,K)=>F.column===T.name&&K!==x)),[f,a.levels,x]),S=$r(),B=a.levels.length<S.grouping.maxLevels&&v.length>0,b=h.useCallback(T=>{!B||!T||(c({...a,levels:[...a.levels,{column:T}],enabled:!0}),p(""),setTimeout(()=>{var F;return(F=document.activeElement)==null?void 0:F.blur()},0))},[B,a]),y=h.useCallback(T=>{const F=a.levels.filter((K,M)=>M!==T);if(F.length===0){n(null),i();return}c({...a,levels:F,enabled:F.length>0})},[a,n,i]),w=h.useCallback(T=>{g(T),p(a.levels[T].column)},[a.levels]),m=h.useCallback(()=>{if(x===null||!l)return;const T=[...a.levels];T[x]={column:l},c({...a,levels:T}),g(null),p("")},[x,l,a]),j=h.useCallback(()=>{g(null),p("")},[]),I=h.useCallback((T,F)=>{const K=F==="up"?T-1:T+1;if(K<0||K>=a.levels.length)return;const M=[...a.levels],[u]=M.splice(T,1);M.splice(K,0,u),c({...a,levels:M})},[a]),k=h.useCallback(()=>{n(null),i()},[n,i]),P=h.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:T=>_(T.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:T=>T.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:T=>T.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:T=>ot(T),bgcolor:"background.paper",outline:"none",boxShadow:T=>ue(T).paper.boxShadow,border:T=>ue(T).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:T=>ue(T).header.backgroundColor,borderBottom:T=>ue(T).header.borderBottom,boxShadow:T=>ue(T).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:T=>T.typography.h6.fontSize||"1.125rem",fontWeight:T=>T.typography.h6.fontWeight||500,color:T=>T.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"}),s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.Settings,{sx:{fontSize:18}})})]}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx($.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:T=>_(T.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:T=>_(T.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[x===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:T=>b(T.target.value),disabled:!B,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),v.map(T=>t.jsxs(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:F=>kt(F),"&:hover":{bgcolor:F=>_(F.palette.primary.main,.2)}}},children:[at(T.name)," (",T.type.toUpperCase(),")"]},T.name))]})}),a.levels.length>=S.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:T=>T.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),f.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:T=>T.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),x!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:T=>`1px solid ${_(T.palette.warning.main,.5)}`,bgcolor:T=>_(T.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:T=>T.typography.body2.fontWeight||500,mb:1.5,fontSize:T=>T.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",x+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:l,onChange:T=>p(T.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[x].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:T=>kt(T)}},children:[a.levels[x].column," (",(J=e.find(T=>T.name===a.levels[x].column))==null?void 0:J.type.toUpperCase(),")"]}),v.filter(T=>T.name!==a.levels[x].column).map(T=>t.jsxs(o.MenuItem,{value:T.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:F=>kt(F)}},children:[at(T.name)," (",T.type.toUpperCase(),")"]},T.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:m,disabled:!l,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:T=>ye(T,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:j,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),a.levels.length>0&&x===null&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:k,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((T,F)=>{const K=e.find(M=>M.name===T.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:M=>ye(M,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${F+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:M=>`0 1px 2px 0 ${_(M.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:M=>M.typography.body2.fontWeight||500,fontSize:M=>M.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:T.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:M=>M.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:K==null?void 0:K.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>I(F,"up"),disabled:F===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:()=>I(F,"down"),disabled:F===a.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:()=>w(F),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:()=>y(F),sx:{color:"text.secondary","&:hover":{bgcolor:M=>_(M.palette.error.main,.08),color:"error.main"}},children:t.jsx($.Delete,{sx:{fontSize:18}})})]})]},F)})})]})]})}),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:T=>`${T.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:P,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,boxShadow:T=>ye(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>ye(T,"hoverButton")},"&:active":{boxShadow:T=>ye(T,"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 ys=[{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=dt(),s=i.palette,[a,c]=h.useState("1h"),[l,p]=h.useState(!1),x=[...e].sort((B,b)=>new Date(b.timestamp).getTime()-new Date(B.timestamp).getTime()),g=ys.find(B=>B.key===a),f=Qu(e,g.ms),v=()=>p(!0),S=()=>{n&&(n(Zu(e,g.ms)),p(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:_(s.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:B=>B.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:ot(i),bgcolor:"background.paper",overflow:"hidden",...ue(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,...ue(i).header},children:[t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx(Or,{content:Mr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[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:B=>c(B.target.value),size:"small",variant:"outlined",sx:{fontSize:"0.75rem",height:30,minWidth:120,"& .MuiSelect-select":{py:.375,px:1,fontSize:"0.75rem"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:_(s.text.primary,.3)}},children:ys.map(B=>t.jsx(o.MenuItem,{value:B.key,sx:{fontSize:"0.8125rem"},children:B.label},B.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx($.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:v,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:_(s.error.main,.5),"&:hover":{bgcolor:_(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),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:_(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:_(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:B=>B.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:B=>B.typography.body2.fontWeight||500},children:"No audit events yet"}),t.jsx(o.Typography,{sx:{fontSize:B=>B.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(B=>{const b=hu(i,B.feature),{summary:y,detail:w}=sl(B);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:_(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:cl(B.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:_(b,.1),color:b,border:`1px solid ${_(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:y}),w&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:w}),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(B.timestamp)})]}),B.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:B.user})]})]})]})]},B.id)})})})]})}),t.jsxs(o.Dialog,{open:l,onClose:()=>p(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:$o(i),...ue(i).paper}},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:_(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:B=>B.typography.body1.fontSize||"0.9375rem",fontWeight:B=>B.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:B=>B.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[f," audit record",f!==1?"s":""]})," ",g.key==="all"?"from all time":`from the ${g.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 ",f," Record",f!==1?"s":""]})]})]})]})}function tp({onSave:e,onClose:r}){const[n,i]=h.useState(""),[s,a]=h.useState(""),[c,l]=h.useState(""),[p,x]=h.useState([]),[g,f]=h.useState(""),[v,S]=h.useState(""),B=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),b=()=>{const k=c.trim();if(k){if(!B(k)){S("Please enter a valid email address");return}if(p.includes(k)){S("This email is already added");return}x([...p,k]),l(""),S("")}},y=k=>{x(p.filter(P=>P!==k))},w=k=>{k.key==="Enter"&&(k.preventDefault(),b())},m=()=>{if(!n.trim()){f("Preset name is required");return}e(n.trim(),s.trim(),p.length>0?p:void 0)},j=k=>{i(k),g&&f("")},I=k=>{l(k),v&&S("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:k=>_(k.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:k=>k.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:k=>k.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:k=>ot(k),bgcolor:"background.paper",outline:"none",boxShadow:k=>ue(k).paper.boxShadow,border:k=>ue(k).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:k=>ue(k).header.backgroundColor,borderBottom:k=>ue(k).header.borderBottom,boxShadow:k=>ue(k).header.boxShadow,flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:k=>k.typography.h6.fontSize||"1.125rem",fontWeight:k=>k.typography.h6.fontWeight||500,color:k=>k.typography.h6.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"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:k=>_(k.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:k=>_(k.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:k=>`1px solid ${_(k.palette.primary.main,.3)}`,bgcolor:k=>kt(k),"& .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:k=>k.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:k=>k.typography.caption.fontSize||"0.6875rem",fontWeight:k=>k.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:k=>j(k.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!g,helperText:g,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:k=>k.typography.caption.fontSize||"0.6875rem",fontWeight:k=>k.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:k=>a(k.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:k=>k.typography.caption.fontSize||"0.6875rem",fontWeight:k=>k.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:k=>I(k.target.value),onKeyPress:w,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:k=>`${k.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(k=>t.jsx(o.Chip,{label:k,onDelete:()=>y(k),deleteIcon:t.jsx($.Delete,{sx:{fontSize:16}}),sx:{bgcolor:P=>kt(P),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},k))}),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:k=>`${k.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:m,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:k=>`${k.shape.borderRadius}px`,boxShadow:k=>ye(k,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:k=>ye(k,"hoverButton")},"&:active":{boxShadow:k=>ye(k,"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=>_(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=>_(c.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:c=>c.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:c=>c.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:c=>ot(c),bgcolor:"background.paper",outline:"none",boxShadow:c=>ue(c).paper.boxShadow,border:c=>ue(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=>ue(c).header.backgroundColor,borderBottom:c=>ue(c).header.borderBottom,boxShadow:c=>ue(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=>_(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=>ye(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=>_(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=>ye(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:c=>ye(c,"hoverButton")},"&:active":{boxShadow:c=>ye(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 zn(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,g)=>x+g.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=zn(e,r);return Math.ceil(n*3.5)}function lp(e,r){const n=zn(e,r);return Math.ceil(n*.7)}function cp(e,r){const n=zn(e,r);return Math.ceil(n*2)}function dp(e,r,n){switch(e){case"csv":return zn(r,n);case"excel":return lp(r,n);case"json":return ap(r,n);case"pdf":return cp(r,n)}}function bs(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 g=bs(l,s.maxRows);a.push({type:"row_count",severity:"error",message:`Export blocked: ${l.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${g} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:l,limit:s.maxRowsHard})}else if(l>s.maxRows){const g=bs(l,s.maxRows);a.push({type:"row_count",severity:"warning",message:`Large export: ${l.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${g} smaller export${g>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:l,limit:s.maxRows})}if(c>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${jo(c)} exceeds the ${jo(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 ${jo(c)}`,detail:`This exceeds the recommended ${jo(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:c,limit:s.maxFileSizeBytes}),e!=="excel"){const g=sp(i.filter(f=>n.includes(f.name)),r);if(g.length>0){const f=g.length>s.maxImageColumns;a.push({type:"image_columns",severity:f?"error":"warning",message:`Image column${g.length>1?"s":""} detected: ${g.map(v=>`"${v.replace(/_/g," ")}"`).join(", ")}`,detail:f?`Exporting ${g.length} image columns may produce a very large file. Consider hiding these columns before exporting.`:"Image URL columns are included in the export as plain text links — not embedded images.",value:g.length,limit:s.maxImageColumns})}}const p=a.some(g=>g.severity==="error"),x=a.some(g=>g.severity==="warning");return{violations:a,hasBlockingViolation:p,hasWarning:x,estimatedBytes:c}}function jo(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=dt().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=_(i?n.error.main:n.warning.main,.06),c=i?_(n.error.main,.25):_(n.warning.main,.3),l=i?$.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=dt(),n={csv:{color:r.palette.primary.main,bg:r.palette.primary.main,label:"CSV"},excel:{color:r.palette.success.main,bg:r.palette.success.main,label:"XLSX"},json:{color:r.palette.text.secondary,bg:r.palette.text.secondary,label:"JSON"},pdf:{color:r.palette.error.main,bg:r.palette.error.main,label:"PDF"}}[e];return t.jsxs(o.Box,{sx:{width:44,height:52,position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",mb:1},children:[t.jsxs("svg",{width:"38",height:"46",viewBox:"0 0 38 46",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M5 2C3.34315 2 2 3.34315 2 5V41C2 42.6569 3.34315 44 5 44H33C34.6569 44 36 42.6569 36 41V13L25 2H5Z",fill:r.palette.background.paper,stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M24 2V13H36",fill:_(r.palette.text.primary,.05),stroke:n.color,strokeWidth:"2.5",strokeLinejoin:"round"})]}),t.jsx(o.Box,{sx:{position:"absolute",bottom:8,left:3,right:3,bgcolor:n.bg,color:r.palette.primary.contrastText,fontSize:"0.625rem",fontWeight:800,py:.25,borderRadius:"3px",textAlign:"center",letterSpacing:"0.05em"},children:n.label})]})}function vs({checked:e}){const r=dt();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:g="visible",initialColumnScope:f="visible",classTokens:v={},onExport:S,onClose:B}){const b=dt(),y=b.palette,w=$r(),m=h.useMemo(()=>{var ce,de,ie,Q,pe;const U=((ie=(de=(ce=b.components)==null?void 0:ce.MuiCard)==null?void 0:de.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:y.divider,ge=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:((pe=b.tokens)==null?void 0:pe.cardBodyShadow)||ye(b,"menu"),X=st(b);return{sectionBorder:`var(--urm-export-section-border, ${re})`,sectionTitleColor:`var(--urm-export-section-title-color, ${y.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${y.background.paper})`,cardBg:`var(--urm-export-card-bg, ${y.background.paper})`,cardBorder:`var(--urm-export-card-border, ${re})`,cardRadius:ge,cardShadow:V,cardHoverBg:`var(--urm-export-card-hover-bg, ${y.mode==="dark"?_(y.common.white,.08):_(y.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${_(X.main,y.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${X.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${y.mode==="dark"?y.primary.light:y.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${y.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${y.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${y.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${b.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${b.spacing(1.5)})`}},[y,b]),j=x||w.export.allowedFormats[0]||"csv",[I,k]=h.useState(j),[P,J]=h.useState(g),[T,F]=h.useState(f),K=P==="visible"?r:e,M=T==="visible"?i:s,u=h.useMemo(()=>P==="visible"?p.length>0?p:new Array(r):l.length>0?l:new Array(e),[P,r,e,p,l]),A=h.useMemo(()=>T==="all"?a.map(U=>U.name):a.map(U=>U.name).slice(0,i),[T,a,i]),L=h.useMemo(()=>up(I,u,A,a,ra),[I,u,A,a]),d=()=>{L.hasBlockingViolation||(S({format:I,scope:P,columnScope:T}),B())},ne={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:B,className:`urm-export-backdrop ${v.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:_(y.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:ot(b),bgcolor:m.sectionTitleBg,overflow:"hidden",border:`1px solid ${m.cardBorder}`,boxShadow:m.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=>ue(U).header.backgroundColor,borderBottom:U=>ue(U).header.borderBottom,boxShadow:U=>ue(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:y.text.primary},children:"Export Report"}),t.jsx(Or,{content:Mr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:B,size:"small",className:`urm-export-close ${v.modalCloseButton||""}`,sx:{color:y.text.secondary,borderRadius:"50%","&:hover":{bgcolor:y.action.hover,color:y.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:m.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:_(y.text.primary,.15),borderRadius:3}},children:[L.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:L.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 ${m.sectionBorder}`,borderRadius:"12px",p:m.sectionPadding,pt:2.25,bgcolor:m.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:m.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:m.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:m.optionGap},children:[{id:"csv",title:"CSV",info:"Comma-separated values, compatible with Excel",allowed:w.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:w.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:w.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:w.export.allowedFormats.includes("pdf")}].filter(U=>U.allowed).map(U=>{const re=I===U.id;return t.jsxs(o.Box,{onClick:()=>k(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:m.cardRadius,border:re?`2px solid ${m.cardSelectedBorder}`:`1px solid ${m.cardBorder}`,boxShadow:re?void 0:m.cardShadow,bgcolor:re?m.cardSelectedBg:m.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?m.cardSelectedBorder:_(y.text.primary,.25),bgcolor:re?m.cardSelectedBg:m.cardHoverBg}},children:[re&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:m.cardSelectedBorder,color:y.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${_(y.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?m.cardSelectedColor:y.text.primary},children:U.title}),t.jsx(o.Tooltip,{title:U.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ge=>ge.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.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 ${m.sectionBorder}`,borderRadius:"12px",p:m.sectionPadding,pt:2.25,bgcolor:m.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:m.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:m.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:m.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:()=>J(U.value),className:`urm-export-row-card ${re?v.rowCardSelected||"":v.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:m.cardRadius,border:re?`2px solid ${m.cardSelectedBorder}`:`1px solid ${m.cardBorder}`,boxShadow:re?void 0:m.cardShadow,bgcolor:re?m.cardSelectedBg:m.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?m.cardSelectedBorder:_(y.text.primary,.25),bgcolor:re?m.cardSelectedBg:m.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(vs,{checked:re}),t.jsx(o.Box,{sx:{color:re?m.cardSelectedColor:y.text.secondary,display:"flex"},children:U.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?m.cardSelectedColor:y.text.primary},children:U.label})]}),t.jsx(o.Tooltip,{title:U.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ge=>ge.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.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 ${m.sectionBorder}`,borderRadius:"12px",p:m.sectionPadding,pt:2.25,bgcolor:m.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:m.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:m.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:m.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=T===U.value;return t.jsxs(o.Box,{onClick:()=>F(U.value),className:`urm-export-column-card ${re?v.columnCardSelected||"":v.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:m.cardRadius,border:re?`2px solid ${m.cardSelectedBorder}`:`1px solid ${m.cardBorder}`,boxShadow:re?void 0:m.cardShadow,bgcolor:re?m.cardSelectedBg:m.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?m.cardSelectedBorder:_(y.text.primary,.25),bgcolor:re?m.cardSelectedBg:m.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(vs,{checked:re}),t.jsx(o.Box,{sx:{color:re?m.cardSelectedColor:y.text.secondary,display:"flex"},children:U.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?m.cardSelectedColor:y.text.primary},children:U.label})]}),t.jsx(o.Tooltip,{title:U.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ge=>ge.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:y.text.secondary,"&:hover":{color:y.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 ${m.sectionBorder}`,borderRadius:"12px",p:m.sectionPadding,pt:2.25,bgcolor:m.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${v.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:m.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:m.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:y.text.secondary}}),label:"Format",value:ne[I]},{icon:t.jsx($.FormatListNumberedOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Rows to Export",value:K.toLocaleString()},{icon:t.jsx($.SwapVertOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Columns to Export",value:String(M)},{icon:t.jsx($.InsertDriveFileOutlined,{sx:{fontSize:18,color:y.text.secondary}}),label:"Estimated File Size",value:`~${jo(L.estimatedBytes)}`,highlight:L.hasBlockingViolation?"error.main":L.hasWarning?"warning.main":void 0}].map(({icon:U,label:re,value:ge,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:y.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??y.text.primary},children:ge})]},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:[L.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:B,variant:"outlined",className:`urm-export-cancel-btn ${v.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:y.text.primary,borderColor:m.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:m.cardHoverBg,borderColor:_(y.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:d,disabled:L.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${v.downloadButton||""}`,startIcon:t.jsx($.Download,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:m.primaryBtnBg,color:m.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${_(y.primary.main,.25)}`,"&:hover":{bgcolor:m.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:_(y.primary.main,.4),color:m.primaryBtnColor}},children:["Download ",ne[I]]})]})]})})}function fp({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx($.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=3e4}){h.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",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx($.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 h.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){Vt.error("urm:error-boundary","Caught unhandled component error",n,i),this.props.onError&&this.props.onError(n,i)}render(){var n,i;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(o.Paper,{sx:{bgcolor:s=>_(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx($.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:s=>s.typography.h6.fontWeight||600,fontSize:s=>s.typography.h6.fontSize||"1.25rem"},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((n=this.state.error)==null?void 0:n.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>_(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),t.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx($.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function yp({feature:e}){const[r,n]=h.useState(!0);return h.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 Jo({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]=h.useState(0),[c,l]=h.useState(n),p=()=>l(n),x=()=>l(mt),g=()=>{i(c),r()},f={sort:y=>l(w=>({...w,sort:{...w.sort,...y}})),filter:y=>l(w=>({...w,filter:{...w.filter,...y}})),columns:y=>l(w=>({...w,columns:{...w.columns,...y}})),grouping:y=>l(w=>({...w,grouping:{...w.grouping,...y}})),export:y=>l(w=>({...w,export:{...w.export,...y}}))},v=y=>{const w=c.filter.allowedOperators,m=w.includes(y)?w.filter(j=>j!==y):[...w,y];m.length!==0&&f.filter({allowedOperators:m})},S=y=>{const w=c.export.allowedFormats,m=w.includes(y)?w.filter(j=>j!==y):[...w,y];m.length!==0&&f.export({allowedFormats:m})},B=[{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=y=>JSON.stringify(c[y])===JSON.stringify(mt[y]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:p},PaperProps:{sx:{borderRadius:y=>ot(y),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:y=>`0 8px 32px ${_(y.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:y=>_(y.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:(y,w)=>a(w),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:B.map((y,w)=>t.jsx(o.Tab,{label:y.label,icon:y.icon,iconPosition:"start"},w))})}),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:(y,w)=>f.sort({maxLevels:w}),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:(y,w)=>f.filter({maxConditions:w}),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(y=>t.jsxs(o.Box,{sx:{mb:1.5},children:[t.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:y}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:bp.filter(w=>w.group===y).map(w=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:c.filter.allowedOperators.includes(w.value),onChange:()=>v(w.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:w.label}),sx:{mr:1.5}},w.value))})]},y))]})]}),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:(y,w)=>f.columns({maxVisible:w}),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:(y,w)=>f.columns({minColumnWidth:w}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}px`})]}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(o.Slider,{value:c.columns.maxColumnWidth,onChange:(y,w)=>f.columns({maxColumnWidth:w}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}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(y=>t.jsxs(o.Box,{onClick:()=>f.grouping({maxLevels:y}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:c.grouping.maxLevels===y?"primary.main":"divider",bgcolor:c.grouping.maxLevels===y?w=>_(w.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:w=>_(w.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:c.grouping.maxLevels===y?"primary.main":"text.secondary"},children:y}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][y-1]})]},y))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowNested,onChange:y=>f.grouping({allowNested:y.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:c.grouping.allowCollapse,onChange:y=>f.grouping({allowCollapse:y.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(y=>t.jsxs(o.Box,{onClick:()=>S(y.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(y.value)?"primary.main":"divider",bgcolor:c.export.allowedFormats.includes(y.value)?w=>_(w.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:c.export.allowedFormats.includes(y.value),onChange:()=>S(y.value),onClick:w=>w.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:y.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:y.desc})]})]},y.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:y=>_(y.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:y=>_(y.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),t.jsx(o.Button,{onClick:g,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const Cp=["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 Zo(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 g=p-x;return g<0&&(g+=7),g===0&&l<=s&&(g=7),l.setDate(l.getDate()+g),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 jp(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 ${wp[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:""},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 Ip({initial:e=aa,isEditing:r=!1,onSave:n,onBack:i}){const[s,a]=h.useState(e),[c,l]=h.useState(!1),[p,x]=h.useState(!1),g=(S,B)=>a(b=>({...b,[S]:B})),f=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)&&!f;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=>_(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=>{g("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=>g("frequency",S.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:Dr,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:S=>g("dayOfWeek",Number(S.target.value)),children: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=>g("dayOfMonth",Number(S.target.value)),inputProps:{min:1,max:28},error:s.dayOfMonth<1||s.dayOfMonth>28,helperText:s.dayOfMonth<1||s.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:Dr}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:S=>g("time",S.target.value),InputLabelProps:{shrink:!0},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=>g("format",S.target.value),children:[t.jsx(o.MenuItem,{value:"pdf",children:"PDF — Print-ready document"}),t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:S=>g("scope",S.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:S=>g("email",S.target.value),onBlur:()=>x(!0),placeholder:"user@company.com",error:p&&f,helperText:p&&f?"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=>_(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),...ue(i).paper})},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>_(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx($.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=>_(l.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:c?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:c?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:c?l=>_(l.palette.success.main,.1):l=>_(l.palette.text.primary,.06),color:c?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:jp(e)}),t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[t.jsx(o.Chip,{label:e.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:l=>_(l.palette.primary.main,.08),color:"primary.main"}}),t.jsx(o.Chip,{label:e.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:l=>_(l.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx($.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:l=>_(l.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[c&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",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=>_(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=>_(l.palette.warning.main,.08):l=>_(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=>_(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=>_(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]=h.useState([]),g=l?(a==null?void 0:a.schedules)??[]:p,[f,v]=h.useState({type:"list"}),[S,B]=h.useState(0),[b,y]=h.useState(null);h.useEffect(()=>{e&&(l||x(ia(n)),v({type:"list"}))},[e,n,l]),h.useEffect(()=>{if(!e)return;const M=setInterval(()=>B(u=>u+1),3e4);return()=>clearInterval(M)},[e]);const w=h.useCallback(M=>{x(M),sa(n,M)},[n]),m=M=>{var L;const u=Zo(M.frequency,M.time,M.dayOfWeek,M.dayOfMonth),A={id:`sched-${Date.now()}`,reportId:n,name:M.name.trim(),frequency:M.frequency,dayOfWeek:M.frequency==="weekly"?M.dayOfWeek:void 0,dayOfMonth:M.frequency==="monthly"?M.dayOfMonth:void 0,time:M.time,format:M.format,scope:M.scope,email:M.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:u,runCount:0};l?(L=a==null?void 0:a.onScheduleCreate)==null||L.call(a,A):w([...g,A]),v({type:"list"})},j=M=>{var d;if(f.type!=="edit")return;const u=f.schedule,A=Zo(M.frequency,M.time,M.dayOfWeek,M.dayOfMonth),L={...u,name:M.name.trim(),frequency:M.frequency,dayOfWeek:M.frequency==="weekly"?M.dayOfWeek:void 0,dayOfMonth:M.frequency==="monthly"?M.dayOfMonth:void 0,time:M.time,format:M.format,scope:M.scope,email:M.email.trim()||void 0,nextRunAt:A};l?(d=a==null?void 0:a.onScheduleUpdate)==null||d.call(a,L):w(g.map(ne=>ne.id===u.id?L:ne)),v({type:"list"})},I=M=>{var ne;const u=g.find(U=>U.id===M);if(!u)return;const A=!u.isActive,L=A?Zo(u.frequency,u.time,u.dayOfWeek,u.dayOfMonth):u.nextRunAt,d={...u,isActive:A,nextRunAt:L};l?(ne=a==null?void 0:a.onScheduleToggle)==null||ne.call(a,M,A):w(g.map(U=>U.id===M?d:U))},k=M=>{if(s(M),!l){const u=new Date().toISOString();w(g.map(A=>A.id===M.id?{...A,lastRunAt:u,runCount:A.runCount+1}:A))}},P=M=>{const u=g.find(A=>A.id===M)??null;y(u)},J=()=>{var M;b&&(l?(M=a==null?void 0:a.onScheduleDelete)==null||M.call(a,b.id):w(g.filter(u=>u.id!==b.id)),y(null))},T=M=>({name:M.name,frequency:M.frequency,dayOfWeek:M.dayOfWeek??1,dayOfMonth:M.dayOfMonth??1,time:M.time,format:M.format,scope:M.scope,email:M.email??""}),F=f.type!=="list",K=g.filter(M=>M.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:F,PaperProps:{sx:M=>({borderRadius:ot(M),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...ue(M).paper})},children:[t.jsxs(o.DialogTitle,{sx:M=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...ue(M).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:M=>_(M.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:M=>M.typography.h6.fontWeight||600,fontSize:M=>M.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:M=>_(M.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:[F&&t.jsx(Ip,{initial:f.type==="edit"?T(f.schedule):aa,isEditing:f.type==="edit",onSave:f.type==="edit"?j:m,onBack:()=>v({type:"list"})}),f.type==="list"&&t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:g.length===0?"No schedules yet":`${K} of ${g.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"})]}),g.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx($.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:M=>M.typography.body2.fontWeight||500,fontSize:M=>M.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:g.map(M=>t.jsx(Dp,{schedule:M,tick:S,onToggle:I,onRunNow:k,onEdit:u=>v({type:"edit",schedule:u}),onDelete:P},M.id))})]})]}),f.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:M=>_(M.palette.warning.main,.06),border:"1px solid",borderColor:M=>_(M.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:M=>_(M.palette.text.primary,.06)}},children:"Close"})]})]}),b&&t.jsx(Ep,{scheduleName:b.name,onConfirm:J,onCancel:()=>y(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:g,schedulerConfig:f}){const v=(f==null?void 0:f.mode)??"local",S=h.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:p,sortStack:x,onFired:g,schedulerConfig:f,schedulerMode:v});h.useEffect(()=>{S.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,columnVisibility:c,columnOrder:l,filters:p,sortStack:x,onFired:g,schedulerConfig:f,schedulerMode:v}});const B=h.useCallback(b=>{var M,u,A,L,d;const{reportName:y,uploadedData:w,processedData:m,schema:j,activeView:I,columnVisibility:k,columnOrder:P,filters:J,sortStack:T,schedulerConfig:F,schedulerMode:K}=S.current;try{const ne=b.scope==="all"?w:m;if(K==="api"){const ge=(P.length>0?P:j.map(X=>X.name)).filter(X=>k[X]!==!1),V={schedule:b,triggeredAt:new Date().toISOString(),rows:ne,columns:ge,format:b.format,reportName:y};(M=F==null?void 0:F.onScheduleFire)==null||M.call(F,V),(A=(u=S.current).onFired)==null||A.call(u,b);return}const U=en(ne,j,J,T,I,k,P),re=`${b.name}_scheduled`;switch(b.format){case"csv":tn(U,re,{scope:b.scope});break;case"excel":rn(U,re,{scope:b.scope});break;case"json":on(U,re,{scope:b.scope});break;case"pdf":mi(U,re,{scope:b.scope});break}if(F!=null&&F.onScheduleFire){const ge=(P.length>0?P:j.map(V=>V.name)).filter(V=>k[V]!==!1);F.onScheduleFire({schedule:b,triggeredAt:new Date().toISOString(),rows:ne,columns:ge,format:b.format,reportName:y})}if(b.email){const ge=encodeURIComponent(`Scheduled Report: ${b.name}`),V=encodeURIComponent(`Your scheduled report "${b.name}" has been generated.
|
|
192
192
|
|
|
193
|
-
Report: ${
|
|
193
|
+
Report: ${y}
|
|
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=${ge}&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),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 J=Xo(M.frequency,M.time,M.dayOfWeek,M.dayOfMonth,w);return P=!0,{...M,lastRunAt:w.toISOString(),nextRunAt:J,runCount:M.runCount+1}}return M});P&&h==="local"&&sa(z,O)};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:w,showCreateViewModal:P,setShowCreateViewModal:O,showEditViewModal:M,setShowEditViewModal:Y,showDeleteConfirmation:J,setShowDeleteConfirmation:R,editingView:u,deletingView:A,handleSelectView:F,handleCreateView:d,handleUpdateCurrentView:ne,handleSaveAsNewView:U,handleRevertChanges:re,handleToggleDefault:ge,handleToggleFavorite:V,handleSoftDelete:X,handleRestoreView:ce,handlePermanentDelete:de,handleEditView:ie,handleCloneView:Q,handleCopyViewLink:pe,handleSaveEditView:I,handleConfirmDelete:te,handlePromoteToGlobal:fe,showManageColumns:ae,setShowManageColumns:ze,handleUpdateColumnVisibility:q,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:ao,handleAddToSearchHistory:rr,handleToggleSearchFavourite:lo,handleDeleteSearchHistory:Tt,selectedRowIds:mr,handleToggleRowSelection:Je,handleToggleAllRows:Mt,handleRangeSelection:Vt,handleClearSelection:Qe,handleUpdateSelectionAfterDelete:Ze,currentPage:Wt,pageSize:co,paginationTotalRows:Mr,handlePageChange:xr,handlePageSizeChange:Ve,isExporting:ke,showExportModal:or,setShowExportModal:At,showDirtyExportWarning:gr,handleExport:yr,handleExportWithConfig:Ht,handleExportSelected:nr,handleExportAnyway:et,handleSaveAndExport:ir,handleCancelExport:gt,showAuditHistory:Wr,setShowAuditHistory:ee,showCreatePreset:br,setShowCreatePreset:Ar,showManagePresets:Bt,setShowManagePresets:H,activePreset:ut,handleCreatePreset:se,handleClearActivePreset:Ke,handleOpenPresetById:sr,handleDeletePresetById:vr,isViewerRole:uo,userRole:Ut,featureLimitWarning:Sr,setFeatureLimitWarning:Gt,reportError:ar,setReportError:Yt,handleError:ve,updateReport:yt,showSnack:Z,config:he,scheduler:be}=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:xe=>{Z(`Scheduled export "${xe.name}" completed`,"success")},schedulerConfig:be});const po=f.useCallback((xe,Ce)=>{if(!(r!=null&&r.uploadedData))return;const Ne=[...r.uploadedData];Ne[xe]=Ce,yt(r.id,{uploadedData:Ne})},[r,yt]),Rr=f.useCallback(xe=>{if(!(r!=null&&r.uploadedData))return;const Ce=r.uploadedData.indexOf(xe);if(Ce===-1)return;const Ne=r.uploadedData.filter((nt,Et)=>Et!==Ce);yt(r.id,{uploadedData:Ne}),Ze(xe)},[r,yt,Ze]),ho=f.useCallback((xe,Ce)=>{if(!(r!=null&&r.uploadedData))return;const Ne=r.uploadedData.indexOf(Ce),nt=Ne!==-1?Ne+1:xe+1,Et=[...r.uploadedData];Et.splice(nt,0,{...Ce}),yt(r.id,{uploadedData:Et})},[r,yt]),qt=Dr(),{handleDevConfigChange:Pr}=cn(),[Nr,Se]=f.useState(!1);return f.useEffect(()=>{const xe=Ce=>{Ce.ctrlKey&&Ce.shiftKey&&Ce.key==="D"&&(Ce.preventDefault(),Se(!0))};return document.addEventListener("keydown",xe),()=>document.removeEventListener("keydown",xe)},[]),!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:et,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:w,onOpenFilters:()=>y(!0),onOpenSort:()=>z(!0),onOpenFilterForColumn:S,onSelectView:F,onCreateView:()=>O(!0),onUpdateCurrentView:ne,onSaveAsNewView:U,onDiscardChanges:re,onToggleDefault:ge,onToggleFavorite:V,onRestoreView:ce,onPermanentDelete:de,onEditView:ie,onCloneView:Q,onCopyLink:pe,onDeleteView:X,onPromoteToGlobal:fe,isAdmin:((st=qt.views)==null?void 0:st.isAdmin)??!1,onExport:yr,onOpenColumns:()=>ze(!0),onUpdateColumnWidth:kt,onUpdateColumnOrder:We,onUpdateColumnVisibility:q,onClearFiltersForColumn:b,onResetLayout:dt,onOpenGroup:()=>Ot(!0),onGroupByColumn:(Jt=he==null?void 0:he.hideToolbarActions)!=null&&Jt.includes("grouping")?void 0:xe=>{ot({enabled:!0,levels:[{column:xe}],collapsedGroups:[]})},onToggleGroupCollapse:Ft,onExpandAllGroups:qe,onCollapseAllGroups:zt,onOpenAuditHistory:()=>ee(!0),onOpenScheduledReports:()=>jr(!0),searchQuery:fr,highlightQuery:xt,searchHistory:tr,onAddToSearchHistory:rr,onToggleSearchFavourite:lo,onDeleteSearchHistory:Tt,selectedRowIds:mr,onSearchChange:ao,onToggleRowSelection:Je,onToggleAllRows:Mt,onRangeSelection:Vt,onClearSelection:Qe,onExportSelected:nr,currentPage:Wt,pageSize:co,onPageChange:xr,onPageSizeChange:Ve,totalRowsBeforePagination:Mr,isReadOnly:uo,userRole:Ut,reportName:r.name,onEditRow:po,onDeleteRow:Rr,onDuplicateRow:ho,rowActions:he==null?void 0:he.rowActions,hideDefaultRowActions:he==null?void 0:he.hideDefaultRowActions,hideToolbarActions:he==null?void 0:he.hideToolbarActions,customSettingsActions:he==null?void 0:he.customSettingsActions,viewOptions:he==null?void 0:he.viewOptions,defaultViewMode:he==null?void 0:he.defaultViewMode,bulkActions:he==null?void 0:he.bulkActions,hideSelectionCheckboxes:he==null?void 0:he.hideSelectionCheckboxes,rowClickBehavior:he==null?void 0:he.rowClickBehavior,openModalOn:he==null?void 0:he.openModalOn,onRowClick:he==null?void 0:he.onRowClick,onRowRightClick:he==null?void 0:he.onRowRightClick,showDevPanel:qt.display.showDevPanel,onOpenDevConfig:()=>Se(!0)})]}),x&&t.jsx(Yo,{feature:"Filters",onError:xe=>{const Ce=ur("ui","filters",xe);ve(Ce)},children:t.jsx(Hu,{schema:r.schema,filters:r.filters,onReplaceFilters:v,onClose:k,focusColumn:g})}),m&&t.jsx(Yo,{feature:"Sorting",onError:xe=>{const Ce=ur("ui","sorting",xe);ve(Ce)},children:t.jsx(Gu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:B,onClose:()=>z(!1)})}),P&&p&&(()=>{var Ne;const xe=(r.views??[]).filter(nt=>!nt.isDeleted).length,Ce=((Ne=qt.views)==null?void 0:Ne.maxViews)??10;return t.jsx(fs,{currentSnapshot:p,onSave:d,onClose:()=>O(!1),atViewLimit:xe>=Ce,maxViews:Ce})})(),M&&u&&t.jsx(fs,{currentSnapshot:u.snapshot,onSave:I,onClose:()=>{Y(!1)},isEditMode:!0,initialName:u.name,initialDescription:u.description,initialIsDefault:u.isDefault}),J&&A&&t.jsx(Yu,{viewName:A.name,onConfirm:te,onCancel:()=>{R(!1)}}),ae&&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:q,onUpdateColumnOrder:We,onUpdateColumnWidth:kt,onResetLayout:dt,onClose:()=>ze(!1)}),Or&&t.jsx(Yo,{feature:"Grouping",onError:xe=>{const Ce=ur("ui","grouping",xe);ve(Ce)},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:se,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:xe=>{const Ce=ur("ui","export",xe);ve(Ce)},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:be,onRunNow:xe=>{var Et;const Ce=(be==null?void 0:be.mode)??"local",Ne=xe.scope==="all"?r.uploadedData||[]:i||[],nt=Qo(Ne,r.schema||[],Le(r.filters),r.sortStack||[],c,r.columnVisibility,r.columnOrder);if(Ce==="api"){const zr=(r.columnOrder||[]).filter(Lr=>(r.columnVisibility??{})[Lr]!==!1);(Et=be==null?void 0:be.onScheduleFire)==null||Et.call(be,{schedule:xe,triggeredAt:new Date().toISOString(),rows:Ne,columns:zr,format:xe.format,reportName:r.name})}else xe.format==="csv"&&Zo(nt,xe.name),xe.format==="excel"&&en(nt,xe.name),xe.format==="json"&&tn(nt,xe.name),xe.format==="pdf"&&ui(nt,xe.name);Z(`"${xe.name}" exported successfully`,"success")}}),t.jsx(Sp,{open:Nr,onClose:()=>Se(!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,w,P;const a=o.useTheme(),c=a.tokens,l=(c==null?void 0:c.notifPosition)??"bottom-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:3e4):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 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=${ge}&body=${V}`,"_blank")}(d=(L=S.current).onFired)==null||d.call(L,b)}catch(ne){Vt.error("urm:scheduler",`Export failed for schedule: ${b.name}`,ne)}},[]);h.useEffect(()=>{if(!e)return;const b=()=>{const{reportId:w,schedulerMode:m,schedulerConfig:j}=S.current;if(!w)return;const I=m==="api"?(j==null?void 0:j.schedules)??[]:ia(w),k=new Date;let P=!1;const J=I.map(T=>{if(!T.isActive)return T;if(new Date(T.nextRunAt)<=k){B(T);const K=Zo(T.frequency,T.time,T.dayOfWeek,T.dayOfMonth,k);return P=!0,{...T,lastRunAt:k.toISOString(),nextRunAt:K,runCount:T.runCount+1}}return T});P&&m==="local"&&sa(w,J)};b();const y=setInterval(b,$p);return()=>clearInterval(y)},[e,B])}function la({reportEngine:e}){var Ge,Tr,lt,Xt,Dt,Br;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:c,isDirty:l,currentTableState:p,showFilterPanel:x,setShowFilterPanel:g,filterFocusColumn:f,handleReplaceFilters:v,handleOpenFilterForColumn:S,handleCloseFilterPanel:B,handleClearFiltersForColumn:b,showSortPanel:y,setShowSortPanel:w,handleSort:m,handleUpdateSortStack:j,handleSortAscending:I,handleSortDescending:k,showCreateViewModal:P,setShowCreateViewModal:J,showEditViewModal:T,setShowEditViewModal:F,showDeleteConfirmation:K,setShowDeleteConfirmation:M,editingView:u,deletingView:A,handleSelectView:L,handleCreateView:d,handleUpdateCurrentView:ne,handleSaveAsNewView:U,handleRevertChanges:re,handleToggleDefault:ge,handleToggleFavorite:V,handleSoftDelete:X,handleRestoreView:ce,handlePermanentDelete:de,handleEditView:ie,handleCloneView:Q,handleCopyViewLink:pe,handleSaveEditView:E,handleConfirmDelete:te,handlePromoteToGlobal:fe,showManageColumns:ae,setShowManageColumns:Te,handleUpdateColumnVisibility:Y,handleUpdateColumnOrder:Ae,handleUpdateColumnWidth:Tt,handleResetColumnLayout:ut,showGroupPanel:Wr,setShowGroupPanel:Ot,handleGroup:nt,handleToggleGroupCollapse:Ht,handleExpandAllGroups:Je,handleCollapseAllGroups:Bt,searchQuery:gr,debouncedSearchQuery:gt,searchHistory:sr,handleSearchChange:ao,handleAddToSearchHistory:ar,handleToggleSearchFavourite:lo,handleDeleteSearchHistory:It,selectedRowIds:yr,handleToggleRowSelection:Ke,handleToggleAllRows:Mt,handleRangeSelection:Ut,handleClearSelection:Qe,handleUpdateSelectionAfterDelete:Ze,currentPage:Wt,pageSize:co,paginationTotalRows:Ar,handlePageChange:br,handlePageSizeChange:Fe,isExporting:ze,showExportModal:lr,setShowExportModal:At,showDirtyExportWarning:vr,handleExport:Sr,handleExportWithConfig:Gt,handleExportSelected:cr,handleExportAnyway:et,handleSaveAndExport:dr,handleCancelExport:yt,showAuditHistory:Rr,setShowAuditHistory:ee,showCreatePreset:Cr,setShowCreatePreset:Pr,showManagePresets:Et,setShowManagePresets:H,activePreset:pt,handleCreatePreset:se,handleClearActivePreset:Xe,handleOpenPresetById:ur,handleDeletePresetById:wr,isViewerRole:uo,userRole:Yt,featureLimitWarning:jr,setFeatureLimitWarning:qt,reportError:pr,setReportError:Jt,handleError:Ce,updateReport:bt,showSnack:Z,config:he,scheduler:Se}=e,[kr,zr]=h.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)||((Tr=c==null?void 0:c.snapshot)==null?void 0:Tr.columnOrder)||[],filters:Ne(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:xe=>{Z(`Scheduled export "${xe.name}" completed`,"success")},schedulerConfig:Se});const po=h.useCallback((xe,ve)=>{if(!(r!=null&&r.uploadedData))return;const Ve=r.uploadedData[xe],Ye=[...r.uploadedData];Ye[xe]=ve;const ht=ko(r.id,"user","rows","row_edited",Ve,ve),vt=zo(r.auditHistory||[],ht);bt(r.id,{uploadedData:Ye,auditHistory:vt})},[r,bt]),Nr=h.useCallback(xe=>{if(!(r!=null&&r.uploadedData))return;const ve=r.uploadedData.indexOf(xe);if(ve===-1)return;const Ve=r.uploadedData.filter((vt,Rt)=>Rt!==ve),Ye=ko(r.id,"user","rows","row_deleted",xe,null),ht=zo(r.auditHistory||[],Ye);bt(r.id,{uploadedData:Ve,auditHistory:ht}),Ze(xe)},[r,bt,Ze]),ho=h.useCallback((xe,ve)=>{if(!(r!=null&&r.uploadedData))return;const Ve=r.uploadedData.indexOf(ve),Ye=Ve!==-1?Ve+1:xe+1,ht=[...r.uploadedData];ht.splice(Ye,0,{...ve});const vt=ko(r.id,"user","rows","row_duplicated",ve,{...ve}),Rt=zo(r.auditHistory||[],vt);bt(r.id,{uploadedData:ht,auditHistory:Rt})},[r,bt]),Kt=$r(),{handleDevConfigChange:Lr}=un(),[Fr,be]=h.useState(!1);return h.useEffect(()=>{const xe=ve=>{ve.ctrlKey&&ve.shiftKey&&ve.key==="D"&&(ve.preventDefault(),be(!0))};return document.addEventListener("keydown",xe),()=>document.removeEventListener("keydown",xe)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[jr&&t.jsx(fp,{warning:jr,onDismiss:()=>qt(null)}),pr&&t.jsx(xp,{error:pr,onDismiss:()=>Jt(null)}),vr&&t.jsx(Xu,{onExportAnyway:et,onSaveAndExport:dr,onCancel:yt}),t.jsx(Nu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:l,isExporting:ze,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:m,onSortAscending:I,onSortDescending:k,onOpenFilters:()=>g(!0),onOpenSort:()=>w(!0),onOpenFilterForColumn:S,onSelectView:L,onCreateView:()=>J(!0),onUpdateCurrentView:ne,onSaveAsNewView:U,onDiscardChanges:re,onToggleDefault:ge,onToggleFavorite:V,onRestoreView:ce,onPermanentDelete:de,onEditView:ie,onCloneView:Q,onCopyLink:pe,onDeleteView:X,onPromoteToGlobal:fe,isAdmin:((lt=Kt.views)==null?void 0:lt.isAdmin)??!1,onExport:Sr,onOpenColumns:()=>Te(!0),onUpdateColumnWidth:Tt,onUpdateColumnOrder:Ae,onUpdateColumnVisibility:Y,onClearFiltersForColumn:b,onResetLayout:ut,onOpenGroup:()=>Ot(!0),onGroupByColumn:(Xt=he==null?void 0:he.hideToolbarActions)!=null&&Xt.includes("grouping")?void 0:xe=>{nt({enabled:!0,levels:[{column:xe}],collapsedGroups:[]})},onToggleGroupCollapse:Ht,onExpandAllGroups:Je,onCollapseAllGroups:Bt,onOpenAuditHistory:()=>ee(!0),onOpenScheduledReports:()=>zr(!0),searchQuery:gr,highlightQuery:gt,searchHistory:sr,onAddToSearchHistory:ar,onToggleSearchFavourite:lo,onDeleteSearchHistory:It,selectedRowIds:yr,onSearchChange:ao,onToggleRowSelection:Ke,onToggleAllRows:Mt,onRangeSelection:Ut,onClearSelection:Qe,onExportSelected:cr,currentPage:Wt,pageSize:co,onPageChange:br,onPageSizeChange:Fe,totalRowsBeforePagination:Ar,isReadOnly:uo,userRole:Yt,reportName:r.name,onEditRow:po,onDeleteRow:Nr,onDuplicateRow:ho,rowActions:he==null?void 0:he.rowActions,hideDefaultRowActions:he==null?void 0:he.hideDefaultRowActions,hideToolbarActions:he==null?void 0:he.hideToolbarActions,customSettingsActions:he==null?void 0:he.customSettingsActions,viewOptions:he==null?void 0:he.viewOptions,defaultViewMode:he==null?void 0:he.defaultViewMode,bulkActions:he==null?void 0:he.bulkActions,hideSelectionCheckboxes:he==null?void 0:he.hideSelectionCheckboxes,rowClickBehavior:he==null?void 0:he.rowClickBehavior,openModalOn:he==null?void 0:he.openModalOn,onRowClick:he==null?void 0:he.onRowClick,onRowRightClick:he==null?void 0:he.onRowRightClick,showDevPanel:Kt.display.showDevPanel,onOpenDevConfig:()=>be(!0)})]}),x&&t.jsx(Jo,{feature:"Filters",onError:xe=>{const ve=mr("ui","filters",xe);Ce(ve)},children:t.jsx(Hu,{schema:r.schema,filters:r.filters,onReplaceFilters:v,onClose:B,focusColumn:f,onOpenDevConfig:()=>be(!0)})}),y&&t.jsx(Jo,{feature:"Sorting",onError:xe=>{const ve=mr("ui","sorting",xe);Ce(ve)},children:t.jsx(Gu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:j,onClose:()=>w(!1),onOpenDevConfig:()=>be(!0)})}),P&&p&&(()=>{var Ve;const xe=(r.views??[]).filter(Ye=>!Ye.isDeleted).length,ve=((Ve=Kt.views)==null?void 0:Ve.maxViews)??10;return t.jsx(xs,{currentSnapshot:p,onSave:d,onClose:()=>J(!1),atViewLimit:xe>=ve,maxViews:ve})})(),T&&u&&t.jsx(xs,{currentSnapshot:u.snapshot,onSave:E,onClose:()=>{F(!1)},isEditMode:!0,initialName:u.name,initialDescription:u.description,initialIsDefault:u.isDefault}),K&&A&&t.jsx(Yu,{viewName:A.name,onConfirm:te,onCancel:()=>{M(!1)}}),ae&&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:Ae,onUpdateColumnWidth:Tt,onResetLayout:ut,onClose:()=>Te(!1)}),Wr&&t.jsx(Jo,{feature:"Grouping",onError:xe=>{const ve=mr("ui","grouping",xe);Ce(ve)},children:t.jsx(Ku,{schema:r.schema,grouping:r.grouping||null,onApply:nt,onClose:()=>Ot(!1),onOpenDevConfig:()=>be(!0)})}),Rr&&t.jsx(ep,{auditHistory:r.auditHistory||[],onClose:()=>ee(!1)}),Cr&&t.jsx(tp,{onSave:se,onClose:()=>Pr(!1)}),Et&&t.jsx(op,{presets:r.presets||[],reportId:r.id,onOpenPreset:ur,onDeletePreset:wr,onClose:()=>H(!1)}),pt&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(rp,{presetName:pt.name,onClear:Xe})}),lr&&t.jsx(Jo,{feature:"Export",onError:xe=>{const ve=mr("ui","export",xe);Ce(ve)},children:t.jsx(mp,{totalRows:(s==null?void 0:s.totalRows)||((Dt=r.uploadedData)==null?void 0:Dt.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((Br=a==null?void 0:a.columnEngine)==null?void 0:Br.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:Gt,onClose:()=>{At(!1)}})}),r&&t.jsx(_p,{open:kr,onClose:()=>zr(!1),reportId:r.id,reportName:r.name,schedulerConfig:Se,onRunNow:xe=>{var ht;const ve=(Se==null?void 0:Se.mode)??"local",Ve=xe.scope==="all"?r.uploadedData||[]:i||[],Ye=en(Ve,r.schema||[],Ne(r.filters),r.sortStack||[],c,r.columnVisibility,r.columnOrder);if(ve==="api"){const vt=(r.columnOrder||[]).filter(Rt=>(r.columnVisibility??{})[Rt]!==!1);(ht=Se==null?void 0:Se.onScheduleFire)==null||ht.call(Se,{schedule:xe,triggeredAt:new Date().toISOString(),rows:Ve,columns:vt,format:xe.format,reportName:r.name})}else xe.format==="csv"&&tn(Ye,xe.name),xe.format==="excel"&&rn(Ye,xe.name),xe.format==="json"&&on(Ye,xe.name),xe.format==="pdf"&&mi(Ye,xe.name);Z(`"${xe.name}" exported successfully`,"success")}}),t.jsx(Sp,{open:Fr,onClose:()=>be(!1),config:Kt,onApply:Lr})]})}const Mp={error:"err",warning:"warn",info:"info",success:"suc"};function ca({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var j,I,k,P;const a=o.useTheme(),c=a.tokens,l=(c==null?void 0:c.notifPosition)??"bottom-right",p=(c==null?void 0:c.notifStyle)??"toast",x=(c==null?void 0:c.notifAccent)??"severity",g=(c==null?void 0:c.notifAutoDismiss)??!0,f=(c==null?void 0:c.toastW)??252,v=l.startsWith("top")?"top":"bottom",S=l.endsWith("center")?"center":l.endsWith("left")?"left":"right",B=Mp[n],b=((j=c==null?void 0:c.status)==null?void 0:j[`${B}Soft`])??a.palette[n].light,y=((I=c==null?void 0:c.status)==null?void 0:I[`${B}Txt`])??a.palette[n].dark,w=x==="primary"?a.palette.primary.main:x==="mono"?a.palette.text.secondary:y,m=p==="toast"?(c==null?void 0:c.toastBg)??a.palette.background.paper:b;return t.jsx(o.Snackbar,{open:e,autoHideDuration:g?s??(c!=null&&c.autoDismissSec?c.autoDismissSec*1e3:3e4):void 0,onClose:(J,T)=>{T!=="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:((k=c==null?void 0:c.status)==null?void 0:k[`${B}Soft`])??a.palette[n].light,color:((P=c==null?void 0:c.status)==null?void 0:P[`${B}Txt`])??a.palette[n].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:n==="error"||n==="warning"?"!":n==="success"?"✓":"i"}):void 0,action:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[g&&(c==null?void 0:c.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:_(w,.14),color:w,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:f,alignItems:"flex-start",bgcolor:m,color:y,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 ${w}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:w}},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=un(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:c,isModalOpen:l,setIsModalOpen:p,setActiveReportId:x,createReport:g,handleFileUpload:f,handleUploadError:v,handleRetry:S,handleConfirm:B,snack:b,handleSnackClose:y,snackDurationMs:w}=r,m=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:m?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:B,hasConflicts:c}):s.uploadError?t.jsx(nu,{error:s.uploadError,onRetry:S}):t.jsx(ru,{onFileUpload:f,onError:v,isUploading:a==="uploading"})})}):null}),!e&&t.jsx(tu,{isOpen:l,onClose:()=>p(!1),onCreate:g}),t.jsx(ca,{open:b.open,message:b.message,severity:b.severity,onClose:y,autoHideDurationMs:w})]})}function Wp({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:c=!0,config:l}={}){return t.jsx(fi,{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=un(),{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(fi,{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=fi;exports.URMViewer=Ap;exports.URMViewerRaw=ua;exports.useURMContext=un;
|